From 2e7d02ab55754ffbc9e799c98cb7c8e37394a420 Mon Sep 17 00:00:00 2001 From: Dennis Francis Date: Thu, 25 Nov 2021 16:02:35 +0530 Subject: 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. Change-Id: I987a6876983aee129c06b3577918dbc62d6e7c4c --- sc/source/ui/view/drawview.cxx | 16 +++++++++++----- sc/source/ui/view/gridwin4.cxx | 20 ++++++++++++-------- 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/sc/source/ui/view/drawview.cxx b/sc/source/ui/view/drawview.cxx index 43704c80e17d..86042772f399 100644 --- a/sc/source/ui/view/drawview.cxx +++ b/sc/source/ui/view/drawview.cxx @@ -965,7 +965,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() ); } @@ -1044,13 +1044,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; } @@ -1092,13 +1095,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 827ae1074175..83cb7459afa9 100644 --- a/sc/source/ui/view/gridwin4.cxx +++ b/sc/source/ui/view/gridwin4.cxx @@ -729,17 +729,20 @@ void ScGridWindow::DrawContent(OutputDevice &rDevice, const ScTableInfo& rTableI } tools::Rectangle aDrawingRectLogic; bool bLayoutRTL = rDoc.IsLayoutRTL( nTab ); + bool bLokRTL = bLayoutRTL && bIsTiledRendering; std::unique_ptr pLokRTLCtxt( - bIsTiledRendering && bLayoutRTL ? + bLokRTL ? new ScLokRTLContext(aOutputData, aOriginalMode.GetOrigin().X() / TWIPS_PER_PIXEL) : 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) { @@ -960,7 +963,8 @@ void ScGridWindow::DrawContent(OutputDevice &rDevice, const ScTableInfo& rTableI if (bIsTiledRendering) { Point aOrigin = aOriginalMode.GetOrigin(); - Size aPixelOffset(aOrigin.getX() / TWIPS_PER_PIXEL, aOrigin.getY() / TWIPS_PER_PIXEL); + tools::Long nXOffset = bLayoutRTL ? (-aOrigin.getX() / TWIPS_PER_PIXEL + aOutputData.GetScrW()) : aOrigin.getX() / TWIPS_PER_PIXEL; + Size aPixelOffset(nXOffset, aOrigin.getY() / TWIPS_PER_PIXEL); pContentDev->SetPixelOffset(aPixelOffset); comphelper::LibreOfficeKit::setLocalRendering(); } @@ -1081,7 +1085,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. @@ -1095,7 +1099,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. @@ -1171,7 +1175,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. @@ -1186,7 +1190,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); -- cgit