diff options
author | Dennis Francis <dennis.francis@collabora.com> | 2021-11-25 16:02:35 +0530 |
---|---|---|
committer | Dennis Francis <dennis.francis@collabora.com> | 2022-02-01 06:13:30 +0100 |
commit | 3b7aae08f26a2e6dc1112985024aa946550124aa (patch) | |
tree | 5e2510fa63bcc87806064b1ee781d95dbe66f1ff | |
parent | beb6c62e990599d91ac5d9183164c94d269027d3 (diff) |
lokCalcRTL: adjustments for shapes rendering
In LOK-RTL mode GetScrPos() always returns document pixel coordinates
and not something mirrored w.r.t gridwindow width.
* Grid offset must have the opposite sign since the SdrObjects/ranges
have negative coordinates with no offset.
* Drawing area rectangle and the pixel-offset for tile rendering device
also needs adjustments when painting the drawing layers.
Conflicts:
sc/source/ui/view/gridwin4.cxx
Change-Id: I987a6876983aee129c06b3577918dbc62d6e7c4c
(cherry picked from commit 2e7d02ab55754ffbc9e799c98cb7c8e37394a420)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129189
Tested-by: Jenkins
Reviewed-by: Dennis Francis <dennis.francis@collabora.com>
-rw-r--r-- | sc/source/ui/view/drawview.cxx | 16 | ||||
-rw-r--r-- | sc/source/ui/view/gridwin4.cxx | 23 |
2 files changed, 25 insertions, 14 deletions
diff --git a/sc/source/ui/view/drawview.cxx b/sc/source/ui/view/drawview.cxx index 71dd9809b0d0..2774e962aa67 100644 --- a/sc/source/ui/view/drawview.cxx +++ b/sc/source/ui/view/drawview.cxx @@ -969,7 +969,7 @@ void ScDrawView::SyncForGrid( SdrObject* pObj ) Point aCurPosHmm = pGridWin->PixelToLogic(aCurPos, aDrawMode ); Point aGridOff = aCurPosHmm - aOldPos; // fdo#63878 Fix the X position for RTL Sheet - if( rDoc.IsNegativePage( GetTab() ) ) + if( rDoc.IsNegativePage( GetTab() ) && !comphelper::LibreOfficeKit::isActive() ) aGridOff.setX( aCurPosHmm.getX() + aOldPos.getX() ); } @@ -1048,13 +1048,16 @@ bool ScDrawView::calculateGridOffsetForSdrObject( Point aCurPosHmm(pGridWin->PixelToLogic(aCurPos, aDrawMode)); Point aGridOff(aCurPosHmm - aOldPos); + bool bLOKActive = comphelper::LibreOfficeKit::isActive(); + bool bNegativePage = rDoc.IsNegativePage(GetTab()); + // fdo#63878 Fix the X position for RTL Sheet - if(rDoc.IsNegativePage(GetTab())) + if(bNegativePage && !bLOKActive) { aGridOff.setX(aCurPosHmm.getX() + aOldPos.getX()); } - rTarget.setX(aGridOff.X()); + rTarget.setX(bNegativePage && bLOKActive ? -aGridOff.X() : aGridOff.X()); rTarget.setY(aGridOff.Y()); return true; } @@ -1096,13 +1099,16 @@ bool ScDrawView::calculateGridOffsetForB2DRange( Point aCurPosHmm(pGridWin->PixelToLogic(aCurPos, aDrawMode)); Point aGridOff(aCurPosHmm - aOldPos); + bool bLOKActive = comphelper::LibreOfficeKit::isActive(); + bool bNegativePage = rDoc.IsNegativePage(GetTab()); + // fdo#63878 Fix the X position for RTL Sheet - if(rDoc.IsNegativePage(GetTab())) + if(bNegativePage && !bLOKActive) { aGridOff.setX(aCurPosHmm.getX() + aOldPos.getX()); } - rTarget.setX(aGridOff.X()); + rTarget.setX(bLOKActive && bNegativePage ? -aGridOff.X() : aGridOff.X()); rTarget.setY(aGridOff.Y()); return true; } diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx index c48b206ef891..5a21738bb9c3 100644 --- a/sc/source/ui/view/gridwin4.cxx +++ b/sc/source/ui/view/gridwin4.cxx @@ -736,17 +736,20 @@ void ScGridWindow::DrawContent(OutputDevice &rDevice, const ScTableInfo& rTableI } tools::Rectangle aDrawingRectLogic; bool bLayoutRTL = rDoc.IsLayoutRTL( nTab ); + bool bLokRTL = bLayoutRTL && bIsTiledRendering; std::unique_ptr<ScLokRTLContext> pLokRTLCtxt( - bIsTiledRendering && bLayoutRTL ? + bLokRTL ? new ScLokRTLContext(aOutputData, o3tl::convert(aOriginalMode.GetOrigin().X(), o3tl::Length::twip, o3tl::Length::px)) : nullptr); { // get drawing pixel rect - tools::Rectangle aDrawingRectPixel(Point(nScrX, nScrY), Size(aOutputData.GetScrW(), aOutputData.GetScrH())); + tools::Rectangle aDrawingRectPixel( + bLokRTL ? Point(-(nScrX + aOutputData.GetScrW()), nScrY) : Point(nScrX, nScrY), + Size(aOutputData.GetScrW(), aOutputData.GetScrH())); // correct for border (left/right) - if(rDoc.MaxCol() == nX2) + if(rDoc.MaxCol() == nX2 && !bLokRTL) { if(bLayoutRTL) { @@ -970,8 +973,10 @@ void ScGridWindow::DrawContent(OutputDevice &rDevice, const ScTableInfo& rTableI if (bIsTiledRendering) { Point aOrigin = aOriginalMode.GetOrigin(); - Size aPixelOffset(o3tl::convert(aOrigin.getX(), o3tl::Length::twip, o3tl::Length::px), - o3tl::convert(aOrigin.getY(), o3tl::Length::twip, o3tl::Length::px)); + tools::Long nXOffset = bLayoutRTL ? + (-o3tl::convert(aOrigin.getX(), o3tl::Length::twip, o3tl::Length::px) + aOutputData.GetScrW()) : + o3tl::convert(aOrigin.getX(), o3tl::Length::twip, o3tl::Length::px); + Size aPixelOffset(nXOffset, o3tl::convert(aOrigin.getY(), o3tl::Length::twip, o3tl::Length::px)); pContentDev->SetPixelOffset(aPixelOffset); comphelper::LibreOfficeKit::setLocalRendering(); } @@ -1094,7 +1099,7 @@ void ScGridWindow::DrawContent(OutputDevice &rDevice, const ScTableInfo& rTableI Point aStart = mrViewData.GetScrPos( nCol1, nRow1, eOtherWhich ); Point aEnd = mrViewData.GetScrPos( nCol2+1, nRow2+1, eOtherWhich ); - if (bIsTiledRendering && bLayoutRTL) + if (bLokRTL) { // Transform the cell range X coordinates such that the edit cell area is // horizontally mirrored w.r.t the (combined-)tile. @@ -1108,7 +1113,7 @@ void ScGridWindow::DrawContent(OutputDevice &rDevice, const ScTableInfo& rTableI aEnd.AdjustY( -2 ); tools::Rectangle aBackground(aStart, aEnd); - if (bIsTiledRendering && bLayoutRTL) + if (bLokRTL) aBackground.Justify(); // Need to draw the background in absolute coords. @@ -1188,7 +1193,7 @@ void ScGridWindow::DrawContent(OutputDevice &rDevice, const ScTableInfo& rTableI Point aStart = mrViewData.GetScrPos( nCol1, nRow1, eWhich ); Point aEnd = mrViewData.GetScrPos( nCol2+1, nRow2+1, eWhich ); - if (bIsTiledRendering && bLayoutRTL) + if (bLokRTL) { // Transform the cell range X coordinates such that the edit cell area is // horizontally mirrored w.r.t the (combined-)tile. @@ -1203,7 +1208,7 @@ void ScGridWindow::DrawContent(OutputDevice &rDevice, const ScTableInfo& rTableI // set the correct mapmode tools::Rectangle aBackground(aStart, aEnd); - if (bIsTiledRendering && bLayoutRTL) + if (bLokRTL) aBackground.Justify(); tools::Rectangle aBGAbs(aBackground); |