From 6d9b321745e617daed8a407b97ee4c1c4a24eaa6 Mon Sep 17 00:00:00 2001 From: Niklas Nebel Date: Wed, 6 Oct 2010 17:08:15 +0200 Subject: ooo33gsl10: #i114944# handle AutoFilter button position on RTL sheets --- sc/source/ui/cctrl/dpcontrol.cxx | 22 +++++++++++++++++++--- sc/source/ui/inc/dpcontrol.hxx | 4 +++- sc/source/ui/view/gridwin2.cxx | 17 ++++++++++++++--- sc/source/ui/view/gridwin4.cxx | 13 +++++-------- sc/source/ui/view/output2.cxx | 22 +++++++--------------- 5 files changed, 48 insertions(+), 30 deletions(-) (limited to 'sc') diff --git a/sc/source/ui/cctrl/dpcontrol.cxx b/sc/source/ui/cctrl/dpcontrol.cxx index 82c276d98f2c..b90a51ed6bee 100644 --- a/sc/source/ui/cctrl/dpcontrol.cxx +++ b/sc/source/ui/cctrl/dpcontrol.cxx @@ -66,7 +66,8 @@ ScDPFieldButton::ScDPFieldButton(OutputDevice* pOutDev, const StyleSettings* pSt mbBaseButton(true), mbPopupButton(false), mbHasHiddenMember(false), - mbPopupPressed(false) + mbPopupPressed(false), + mbPopupLeft(false) { if (pZoomX) maZoomX = *pZoomX; @@ -88,10 +89,15 @@ void ScDPFieldButton::setText(const OUString& rText) maText = rText; } -void ScDPFieldButton::setBoundingBox(const Point& rPos, const Size& rSize) +void ScDPFieldButton::setBoundingBox(const Point& rPos, const Size& rSize, bool bLayoutRTL) { maPos = rPos; maSize = rSize; + if (bLayoutRTL) + { + // rPos is the logical-left position, adjust maPos to visual-left (inside the cell border) + maPos.X() -= maSize.Width() - 1; + } } void ScDPFieldButton::setDrawBaseButton(bool b) @@ -114,6 +120,11 @@ void ScDPFieldButton::setPopupPressed(bool b) mbPopupPressed = b; } +void ScDPFieldButton::setPopupLeft(bool b) +{ + mbPopupLeft = b; +} + void ScDPFieldButton::draw() { const long nMargin = 2; @@ -179,7 +190,12 @@ void ScDPFieldButton::getPopupBoundingBox(Point& rPos, Size& rSize) const if (nH > 18) nH = 18; - rPos.setX(maPos.getX() + maSize.getWidth() - nW); + // #i114944# AutoFilter button is left-aligned in RTL. + // DataPilot button is always right-aligned for now, so text output isn't affected. + if (mbPopupLeft) + rPos.setX(maPos.getX()); + else + rPos.setX(maPos.getX() + maSize.getWidth() - nW); rPos.setY(maPos.getY() + maSize.getHeight() - nH); rSize.setWidth(nW); rSize.setHeight(nH); diff --git a/sc/source/ui/inc/dpcontrol.hxx b/sc/source/ui/inc/dpcontrol.hxx index 45badf0c88fd..25cb3e05acac 100644 --- a/sc/source/ui/inc/dpcontrol.hxx +++ b/sc/source/ui/inc/dpcontrol.hxx @@ -69,11 +69,12 @@ public: ~ScDPFieldButton(); void setText(const ::rtl::OUString& rText); - void setBoundingBox(const Point& rPos, const Size& rSize); + void setBoundingBox(const Point& rPos, const Size& rSize, bool bLayoutRTL); void setDrawBaseButton(bool b); void setDrawPopupButton(bool b); void setHasHiddenMember(bool b); void setPopupPressed(bool b); + void setPopupLeft(bool b); void draw(); void getPopupBoundingBox(Point& rPos, Size& rSize) const; @@ -94,6 +95,7 @@ private: bool mbPopupButton; bool mbHasHiddenMember; bool mbPopupPressed; + bool mbPopupLeft; }; // ============================================================================ diff --git a/sc/source/ui/view/gridwin2.cxx b/sc/source/ui/view/gridwin2.cxx index ec584213898c..669f1fda010d 100644 --- a/sc/source/ui/view/gridwin2.cxx +++ b/sc/source/ui/view/gridwin2.cxx @@ -145,7 +145,8 @@ bool ScGridWindow::DoAutoFilterButton( SCCOL nCol, SCROW nRow, const MouseEvent& // Check if the mouse cursor is clicking on the popup arrow box. mpFilterButton.reset(new ScDPFieldButton(this, &GetSettings().GetStyleSettings(), &pViewData->GetZoomX(), &pViewData->GetZoomY(), pDoc)); - mpFilterButton->setBoundingBox(aScrPos, aScrSize); + mpFilterButton->setBoundingBox(aScrPos, aScrSize, bLayoutRTL); + mpFilterButton->setPopupLeft(bLayoutRTL); // #i114944# AutoFilter button is left-aligned in RTL Point aPopupPos; Size aPopupSize; mpFilterButton->getPopupBoundingBox(aPopupPos, aPopupSize); @@ -371,6 +372,8 @@ void ScGridWindow::DPTestMouse( const MouseEvent& rMEvt, BOOL bMove ) bool ScGridWindow::DPTestFieldPopupArrow(const MouseEvent& rMEvt, const ScAddress& rPos, ScDPObject* pDPObj) { + BOOL bLayoutRTL = pViewData->GetDocument()->IsLayoutRTL( pViewData->GetTabNo() ); + // Get the geometry of the cell. Point aScrPos = pViewData->GetScrPos(rPos.Col(), rPos.Row(), eWhich); long nSizeX, nSizeY; @@ -379,7 +382,8 @@ bool ScGridWindow::DPTestFieldPopupArrow(const MouseEvent& rMEvt, const ScAddres // Check if the mouse cursor is clicking on the popup arrow box. ScDPFieldButton aBtn(this, &GetSettings().GetStyleSettings()); - aBtn.setBoundingBox(aScrPos, aScrSize); + aBtn.setBoundingBox(aScrPos, aScrSize, bLayoutRTL); + aBtn.setPopupLeft(false); // DataPilot popup is always right-aligned for now Point aPopupPos; Size aPopupSize; aBtn.getPopupBoundingBox(aPopupPos, aPopupSize); @@ -520,9 +524,16 @@ void ScGridWindow::DPLaunchFieldPopupMenu( } } + BOOL bLayoutRTL = pViewData->GetDocument()->IsLayoutRTL( pViewData->GetTabNo() ); + Rectangle aCellRect(rScrPos, rScrSize); const Size& rPopupSize = mpDPFieldPopup->getWindowSize(); - if (rScrSize.getWidth() > rPopupSize.getWidth()) + if (bLayoutRTL) + { + // RTL: rScrPos is logical-left (visual right) position, always right-align with that + aCellRect.SetPos(Point(rScrPos.X() - rPopupSize.Width() + 1, rScrPos.Y())); + } + else if (rScrSize.getWidth() > rPopupSize.getWidth()) { // If the cell width is larger than the popup window width, launch it // right-aligned with the cell. diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx index ba73fbf00269..372dcc582a45 100644 --- a/sc/source/ui/view/gridwin4.cxx +++ b/sc/source/ui/view/gridwin4.cxx @@ -1291,7 +1291,8 @@ void ScGridWindow::DrawButtons( SCCOL nX1, SCROW /*nY1*/, SCCOL nX2, SCROW /*nY2 pViewData->GetMergeSizePixel( nCol, nRow, nSizeX, nSizeY ); Point aScrPos = pViewData->GetScrPos( nCol, nRow, eWhich ); - aCellBtn.setBoundingBox(aScrPos, Size(nSizeX-1, nSizeY-1)); + aCellBtn.setBoundingBox(aScrPos, Size(nSizeX-1, nSizeY-1), bLayoutRTL); + aCellBtn.setPopupLeft(bLayoutRTL); // #i114944# AutoFilter button is left-aligned in RTL aCellBtn.setDrawBaseButton(false); aCellBtn.setDrawPopupButton(true); aCellBtn.setHasHiddenMember(bArrowState); @@ -1315,17 +1316,13 @@ void ScGridWindow::DrawButtons( SCCOL nX1, SCROW /*nY1*/, SCCOL nX2, SCROW /*nY2 pViewData->GetMergeSizePixel( nCol, nRow, nSizeX, nSizeY ); long nPosX = aScrPos.X(); long nPosY = aScrPos.Y(); - if ( bLayoutRTL ) - { - // overwrite the right, not left (visually) grid as long as the - // left/right colors of the button borders aren't mirrored. - nPosX -= nSizeX - 2; - } + // bLayoutRTL is handled in setBoundingBox String aStr; pDoc->GetString(nCol, nRow, nTab, aStr); aCellBtn.setText(aStr); - aCellBtn.setBoundingBox(Point(nPosX, nPosY), Size(nSizeX-1, nSizeY-1)); + aCellBtn.setBoundingBox(Point(nPosX, nPosY), Size(nSizeX-1, nSizeY-1), bLayoutRTL); + aCellBtn.setPopupLeft(false); // DataPilot popup is always right-aligned for now aCellBtn.setDrawBaseButton(true); aCellBtn.setDrawPopupButton(pInfo->bPopupButton); aCellBtn.setHasHiddenMember(pInfo->bFilterActive); diff --git a/sc/source/ui/view/output2.cxx b/sc/source/ui/view/output2.cxx index 6d40d304fb13..61289cc7f931 100644 --- a/sc/source/ui/view/output2.cxx +++ b/sc/source/ui/view/output2.cxx @@ -80,7 +80,7 @@ #include //! Autofilter-Breite mit column.cxx zusammenfassen -#define DROPDOWN_BITMAP_SIZE 17 +#define DROPDOWN_BITMAP_SIZE 18 #define DRAWTEXT_MAX 32767 @@ -1274,7 +1274,8 @@ void ScOutputData::GetOutputArea( SCCOL nX, SCSIZE nArrY, long nPosX, long nPosY ( static_cast(rPattern.GetItem(ATTR_MERGE_FLAG)).GetValue() & SC_MF_AUTO ) && ( !bBreak || pRefDevice == pFmtDevice ) ) { - long nFilter = Min( nMergeSizeY, (long) DROPDOWN_BITMAP_SIZE ); + // filter drop-down width is now independent from row height + const long nFilter = DROPDOWN_BITMAP_SIZE; BOOL bFit = ( nNeeded + nFilter <= nMergeSizeX ); if ( bFit || bCellIsValue ) { @@ -3516,20 +3517,11 @@ void ScOutputData::DrawRotated(BOOL bPixelToLogic) eOrient!=SVX_ORIENTATION_STACKED && pInfo && pInfo->bAutoFilter) { - if (pRowInfo[nArrY].nHeight < DROPDOWN_BITMAP_SIZE) - { - if (bPixelToLogic) - nAvailWidth -= pRefDevice->PixelToLogic(Size(0,pRowInfo[nArrY].nHeight)).Height(); - else - nAvailWidth -= pRowInfo[nArrY].nHeight; - } + // filter drop-down width is now independent from row height + if (bPixelToLogic) + nAvailWidth -= pRefDevice->PixelToLogic(Size(0,DROPDOWN_BITMAP_SIZE)).Height(); else - { - if (bPixelToLogic) - nAvailWidth -= pRefDevice->PixelToLogic(Size(0,DROPDOWN_BITMAP_SIZE)).Height(); - else - nAvailWidth -= DROPDOWN_BITMAP_SIZE; - } + nAvailWidth -= DROPDOWN_BITMAP_SIZE; long nComp = nEngineWidth; if (nAvailWidth