[Libreoffice-commits] .: Branch 'libreoffice-3-5' - sw/source vcl/source

Cédric Bosdonnat cbosdo at kemper.freedesktop.org
Fri Dec 16 08:37:09 PST 2011


 sw/source/core/layout/paintfrm.cxx     |    4 ++++
 sw/source/ui/docvw/HeaderFooterWin.cxx |   20 ++++++++------------
 sw/source/ui/docvw/PageBreakWin.cxx    |   16 ++++++++++------
 vcl/source/control/menubtn.cxx         |    2 ++
 vcl/source/window/floatwin.cxx         |    8 ++------
 5 files changed, 26 insertions(+), 24 deletions(-)

New commits:
commit 588857a86bcbc85e21b70ca95a9ab0c0b782a996
Author: Cédric Bosdonnat <cedric.bosdonnat at free.fr>
Date:   Thu Dec 15 12:02:29 2011 +0100

    fdo#43790: RTL PopupMenu position fixes
    
    Fixed the Writer PageBreak and Header/Footer indicator position. It also
    fixed the popup menu position in RTL UI for all PopupButton instances.

diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx
index ec104f5..c33da28 100755
--- a/sw/source/core/layout/paintfrm.cxx
+++ b/sw/source/core/layout/paintfrm.cxx
@@ -3470,6 +3470,8 @@ void SwPageFrm::PaintDecorators( ) const
                  !pGlobalShell->IsPreView() &&
                  pGlobalShell->IsShowHeaderFooterSeparator( ) )
             {
+                bool bRtl = Application::GetSettings().GetLayoutRTL();
+
                 // Header
                 const SwFrm* pHeaderFrm = Lower();
                 if ( !pHeaderFrm->IsHeaderFrm() )
@@ -3477,6 +3479,8 @@ void SwPageFrm::PaintDecorators( ) const
 
                 const SwRect& rVisArea = pGlobalShell->VisArea();
                 long nXOff = std::min( aBodyRect.Right(), rVisArea.Right() );
+                if ( bRtl )
+                    nXOff = std::max( aBodyRect.Left(), rVisArea.Left() );
 
                 long nHeaderYOff = aBodyRect.Top();
                 Point nOutputOff = rEditWin.LogicToPixel( Point( nXOff, nHeaderYOff ) );
diff --git a/sw/source/ui/docvw/HeaderFooterWin.cxx b/sw/source/ui/docvw/HeaderFooterWin.cxx
index d3ce419..64e75e4 100644
--- a/sw/source/ui/docvw/HeaderFooterWin.cxx
+++ b/sw/source/ui/docvw/HeaderFooterWin.cxx
@@ -223,6 +223,11 @@ void SwHeaderFooterWin::SetOffset( Point aOffset, long nXLineStart, long nXLineE
     Point aBoxPos( aOffset.X() - aBoxSize.Width() - BOX_DISTANCE,
                    aOffset.Y() - nYFooterOff );
 
+    if ( Application::GetSettings().GetLayoutRTL() )
+    {
+        aBoxPos.setX( aOffset.X() + BOX_DISTANCE );
+    }
+
     // Set the position & Size of the window
     SetPosSizePixel( aBoxPos, aBoxSize );
 
@@ -284,8 +289,6 @@ void SwHeaderFooterWin::Paint( const Rectangle& )
     aSeq[1] = Primitive2DReference( new PolygonHairlinePrimitive2D(
             aPolygon, aLineColor ) );
 
-    bool bRtl = Application::GetSettings().GetLayoutRTL();
-
     // Create the text primitive
     B2DVector aFontSize;
     FontAttribute aFontAttr = getFontAttributeFromVclFont(
@@ -296,11 +299,7 @@ void SwHeaderFooterWin::Paint( const Rectangle& )
 
     FontMetric aFontMetric = GetFontMetric( GetFont() );
     double nTextOffsetY = aFontMetric.GetHeight() - aFontMetric.GetDescent() + TEXT_PADDING;
-    double nTextOffsetX = TEXT_PADDING;
-    if ( bRtl )
-        nTextOffsetX = aRect.GetWidth( ) - aTextRect.GetWidth() - TEXT_PADDING;
-
-    Point aTextPos( nTextOffsetX, nTextOffsetY );
+    Point aTextPos( TEXT_PADDING, nTextOffsetY );
 
     basegfx::B2DHomMatrix aTextMatrix( createScaleTranslateB2DHomMatrix(
                 aFontSize.getX(), aFontSize.getY(),
@@ -317,11 +316,8 @@ void SwHeaderFooterWin::Paint( const Rectangle& )
     // Create the 'plus' or 'arrow' primitive if not readonly
     if ( !m_bReadonly )
     {
-        double aSignPosX = aRect.Right() - BUTTON_WIDTH;
-        if ( bRtl )
-            aSignPosX = aRect.Left();
-        B2DRectangle aSignArea( B2DPoint( aSignPosX, 0.0 ),
-                                B2DSize( aSignPosX + BUTTON_WIDTH, aRect.getHeight() ) );
+        B2DRectangle aSignArea( B2DPoint( aRect.Right() - BUTTON_WIDTH, 0.0 ),
+                                B2DSize( aRect.Right(), aRect.getHeight() ) );
 
         B2DPolygon aSign;
         if ( IsEmptyHeaderFooter( ) )
diff --git a/sw/source/ui/docvw/PageBreakWin.cxx b/sw/source/ui/docvw/PageBreakWin.cxx
index 2194bd9..9279c00 100644
--- a/sw/source/ui/docvw/PageBreakWin.cxx
+++ b/sw/source/ui/docvw/PageBreakWin.cxx
@@ -68,7 +68,7 @@ using namespace drawinglayer::primitive2d;
 
 namespace
 {
-    B2DPolygon lcl_CreatePolygon( B2DRectangle aBounds, bool bShowOnRight )
+    B2DPolygon lcl_CreatePolygon( B2DRectangle aBounds, bool bMirror )
     {
         B2DPolygon aRetval;
         const double nRadius = 1;
@@ -144,7 +144,7 @@ namespace
 
         aRetval.setClosed( true );
 
-        if ( bShowOnRight )
+        if ( bMirror )
         {
             B2DHomMatrix bRotMatrix = createRotateAroundPoint(
                     aBounds.getCenterX(), aBounds.getCenterY(), M_PI );
@@ -233,11 +233,13 @@ void SwPageBreakWin::Paint( const Rectangle& )
     }
 
     bool bShowOnRight = ShowOnRight( );
+    bool bRtl = Application::GetSettings().GetLayoutRTL();
 
     Primitive2DSequence aSeq( 3 );
     B2DRectangle aBRect( double( aRect.Left() ), double( aRect.Top( ) ),
            double( aRect.Right() ), double( aRect.Bottom( ) ) );
-    B2DPolygon aPolygon = lcl_CreatePolygon( aBRect, bShowOnRight );
+    bool bMirror = ( bShowOnRight && !bRtl ) || ( !bShowOnRight && bRtl );
+    B2DPolygon aPolygon = lcl_CreatePolygon( aBRect, bMirror );
 
     // Create the polygon primitives
     aSeq[0] = Primitive2DReference( new PolyPolygonColorPrimitive2D(
@@ -248,7 +250,7 @@ void SwPageBreakWin::Paint( const Rectangle& )
     // Create the primitive for the image
     Image aImg( SW_RES( IMG_PAGE_BREAK ) );
     double nImgOfstX = 3.0;
-    if ( bShowOnRight )
+    if ( bMirror )
         nImgOfstX = aRect.Right() - aImg.GetSizePixel().Width() - 3.0;
     aSeq[2] = Primitive2DReference( new DiscreteBitmapPrimitive2D(
             aImg.GetBitmapEx(), B2DPoint( nImgOfstX, 1.0 ) ) );
@@ -259,7 +261,7 @@ void SwPageBreakWin::Paint( const Rectangle& )
         double nTop = double( aRect.getHeight() ) / 2.0;
         double nBottom = nTop + 4.0;
         double nLeft = aRect.getWidth( ) - ARROW_WIDTH - 6.0;
-        if ( bShowOnRight )
+        if ( bMirror )
             nLeft = ARROW_WIDTH - 2.0;
         double nRight = nLeft + 8.0;
 
@@ -403,7 +405,9 @@ bool SwPageBreakWin::ShowOnRight( )
     if ( bBookMode )
         bOnRight = GetPageFrame()->SidebarPosition( ) == sw::sidebarwindows::SIDEBAR_RIGHT;
 
-    // TODO Handle the RTL case
+    // Handle the RTL case
+    if ( !bBookMode && Application::GetSettings().GetLayoutRTL() )
+        bOnRight = !bOnRight;
 
     return bOnRight;
 }
diff --git a/vcl/source/control/menubtn.cxx b/vcl/source/control/menubtn.cxx
index 2fa3a07..3350d14 100644
--- a/vcl/source/control/menubtn.cxx
+++ b/vcl/source/control/menubtn.cxx
@@ -33,6 +33,7 @@
 #include <vcl/menu.hxx>
 #include <vcl/timer.hxx>
 #include <vcl/menubtn.hxx>
+#include <vcl/svapp.hxx>
 
 
 
@@ -62,6 +63,7 @@ void MenuButton::ImplInit( Window* pParent, WinBits nStyle )
         nStyle |= WB_TABSTOP;
 
     PushButton::ImplInit( pParent, nStyle );
+    EnableRTL( Application::GetSettings().GetLayoutRTL() );
 }
 
 // -----------------------------------------------------------------------
diff --git a/vcl/source/window/floatwin.cxx b/vcl/source/window/floatwin.cxx
index 894021e..d4e1b1f 100644
--- a/vcl/source/window/floatwin.cxx
+++ b/vcl/source/window/floatwin.cxx
@@ -424,11 +424,6 @@ Point FloatingWindow::ImplCalcPos( Window* pWindow,
                 {
                     if( devRectRTL.Right()-aSize.Width()+1 < aScreenRect.Left() )
                         aPos.X() -= aScreenRect.Left() - devRectRTL.Right() + aSize.Width() - 1;
-                    else if( aPos.X() + aSize.Width() > aScreenRect.Right() )
-                    {
-                        aPos.X() -= aSize.Width()-2; // popup to left instead
-                        aPos.Y() -= 2;
-                    }
                 }
                 else if ( aPos.X()+aSize.Width() > aScreenRect.Right() )
                 {
@@ -688,7 +683,8 @@ void FloatingWindow::StartPopupMode( const Rectangle& rRect, sal_uLong nFlags )
 
     // compute window position according to flags and arrangement
     sal_uInt16 nArrangeIndex;
-    SetPosPixel( ImplCalcPos( this, rRect, nFlags, nArrangeIndex ) );
+    Point aPos = ImplCalcPos( this, rRect, nFlags, nArrangeIndex );
+    SetPosPixel( aPos );
 
     // set data and display window
     // convert maFloatRect to absolute device coordinates


More information about the Libreoffice-commits mailing list