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:
parent
8cb10ca246
commit
f6b679e831
@ -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 ) );
|
||||
|
@ -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( ) )
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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() );
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user