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