include/sfx2/lokcomponenthelpers.hxx | 6 ++++-- sc/source/ui/unoobj/docuno.cxx | 4 ++-- sfx2/source/view/lokcharthelper.cxx | 18 ++++++++++++++---- 3 files changed, 20 insertions(+), 8 deletions(-)
New commits: commit 59460f4e02cc312062d76a8fc315800129bb9219 Author: Dennis Francis <dennis.fran...@collabora.com> AuthorDate: Wed Feb 9 12:31:49 2022 +0530 Commit: Dennis Francis <dennis.fran...@collabora.com> CommitDate: Fri Feb 11 05:39:00 2022 +0100 lokCalcRTL: global RTL: fix chart edit mode rendering If global RTL flag is set, vcl-window X offset of chart window is mirrored w.r.t parent window rectangle. This has to be undone to get the correct chart bounding box in negative X document coordinates so that the offset calculations for tile rendering remains the same for RTL documents irrespective of the system/global RTL setting. Conflicts: include/sfx2/lokcharthelper.hxx sfx2/source/view/lokcharthelper.cxx Change-Id: I3e1666681af4e7ab1257bcc88d44bbdb053a7d47 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129704 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Szymon Kłos <szymon.k...@collabora.com> (cherry picked from commit 4fd2a14c6ee68f0574766ec7ec3dca35debe9d20) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129778 Tested-by: Jenkins Reviewed-by: Dennis Francis <dennis.fran...@collabora.com> diff --git a/include/sfx2/lokcomponenthelpers.hxx b/include/sfx2/lokcomponenthelpers.hxx index c9468b7d1c3b..6a3d964689b4 100644 --- a/include/sfx2/lokcomponenthelpers.hxx +++ b/include/sfx2/lokcomponenthelpers.hxx @@ -29,11 +29,13 @@ private: css::uno::Reference<css::frame::XController> mxController; css::uno::Reference<css::frame::XDispatch> mxDispatcher; VclPtr<vcl::Window> mpWindow; + bool mbNegativeX; public: - LokChartHelper(SfxViewShell* pViewShell) + LokChartHelper(SfxViewShell* pViewShell, bool bNegativeX = false) : mpViewShell(pViewShell) , mpWindow(nullptr) + , mbNegativeX(bNegativeX) {} css::uno::Reference<css::frame::XController>& GetXController(); @@ -43,7 +45,7 @@ public: void Invalidate(); bool Hit(const Point& aPos); - static bool HitAny(const Point& aPos); + static bool HitAny(const Point& aPos, bool bNegativeX = false); void PaintTile(VirtualDevice& rRenderContext, const tools::Rectangle& rTileRect); static void PaintAllChartsOnTile(VirtualDevice& rDevice, int nOutputWidth, int nOutputHeight, diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx index ca7cb56fee5f..563d34b3c2c2 100644 --- a/sc/source/ui/unoobj/docuno.cxx +++ b/sc/source/ui/unoobj/docuno.cxx @@ -725,11 +725,11 @@ void ScModelObj::postMouseEvent(int nType, int nX, int nY, int nCount, int nButt // check if user hit a chart which is being edited by him ScTabViewShell * pTabViewShell = pViewData->GetViewShell(); SCTAB nTab = pViewData->GetTabNo(); - LokChartHelper aChartHelper(pTabViewShell); const ScDocument& rDoc = pDocShell->GetDocument(); // In LOK RTL mode draw/svx operates in negative X coordinates // But the coordinates from client is always positive, so negate nX for draw. bool bDrawNegativeX = rDoc.IsNegativePage(nTab); + LokChartHelper aChartHelper(pTabViewShell, bDrawNegativeX); int nDrawX = bDrawNegativeX ? -nX : nX; if (aChartHelper.postMouseEvent(nType, nDrawX, nY, nCount, nButtons, nModifier, @@ -745,7 +745,7 @@ void ScModelObj::postMouseEvent(int nType, int nX, int nY, int nCount, int nButt // and, if so, skip current mouse event if (nType != LOK_MOUSEEVENT_MOUSEMOVE) { - if (LokChartHelper::HitAny(aPointTwipDraw)) + if (LokChartHelper::HitAny(aPointTwipDraw, bDrawNegativeX)) return; } diff --git a/sfx2/source/view/lokcharthelper.cxx b/sfx2/source/view/lokcharthelper.cxx index a87388832755..c7941e6aa2ac 100644 --- a/sfx2/source/view/lokcharthelper.cxx +++ b/sfx2/source/view/lokcharthelper.cxx @@ -127,7 +127,17 @@ tools::Rectangle LokChartHelper::GetChartBoundingBox() const auto nYNum = p.first * scaleY.GetDenominator(); const auto nYDen = p.second * scaleY.GetNumerator(); - Point aOffset = pWindow->GetOffsetPixelFrom(*pRootWin).scale(nXNum, nXDen, nYNum, nYDen); + Point aOffset = pWindow->GetOffsetPixelFrom(*pRootWin); + if (mbNegativeX && AllSettings::GetLayoutRTL()) + { + // If global RTL flag is set, vcl-window X offset of chart window is + // mirrored w.r.t parent window rectangle. This needs to be reverted. + aOffset.setX(pRootWin->GetOutOffXPixel() + pRootWin->GetSizePixel().Width() + - pWindow->GetOutOffXPixel() - pWindow->GetSizePixel().Width()); + + } + + aOffset = aOffset.scale(nXNum, nXDen, nYNum, nYDen); Size aSize = pWindow->GetSizePixel().scale(nXNum, nXDen, nYNum, nYDen); aBBox = tools::Rectangle(aOffset, aSize); } @@ -158,7 +168,7 @@ bool LokChartHelper::Hit(const Point& aPos) return false; } -bool LokChartHelper::HitAny(const Point& aPos) +bool LokChartHelper::HitAny(const Point& aPos, bool bNegativeX) { SfxViewShell* pCurView = SfxViewShell::Current(); int nPartForCurView = pCurView ? pCurView->getPart() : -1; @@ -167,7 +177,7 @@ bool LokChartHelper::HitAny(const Point& aPos) { if (pViewShell->GetDocId() == pCurView->GetDocId() && pViewShell->getPart() == nPartForCurView) { - LokChartHelper aChartHelper(pViewShell); + LokChartHelper aChartHelper(pViewShell, bNegativeX); if (aChartHelper.Hit(aPos)) return true; } @@ -253,7 +263,7 @@ void LokChartHelper::PaintAllChartsOnTile(VirtualDevice& rDevice, { if (pCurView && pViewShell->GetDocId() == pCurView->GetDocId() && pViewShell->getPart() == nPartForCurView) { - LokChartHelper aChartHelper(pViewShell); + LokChartHelper aChartHelper(pViewShell, bNegativeX); aChartHelper.PaintTile(rDevice, aTileRect); } pViewShell = SfxViewShell::GetNext(*pViewShell);