summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDennis Francis <dennis.francis@collabora.com>2022-02-09 12:31:49 +0530
committerDennis Francis <dennis.francis@collabora.com>2022-02-10 11:29:17 +0100
commit4fd2a14c6ee68f0574766ec7ec3dca35debe9d20 (patch)
tree2065d966b8ff0b28297a435b1fea01b7a7e686b3
parent38e4d2f422afdeced7904b44687800d308b93249 (diff)
lokCalcRTL: global RTL: fix chart edit mode renderingcp-21.06.16-1
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. Change-Id: I3e1666681af4e7ab1257bcc88d44bbdb053a7d47 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129704 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Szymon Kłos <szymon.klos@collabora.com>
-rw-r--r--include/sfx2/lokcharthelper.hxx6
-rw-r--r--sc/source/ui/unoobj/docuno.cxx4
-rw-r--r--sfx2/source/view/lokcharthelper.cxx14
3 files changed, 17 insertions, 7 deletions
diff --git a/include/sfx2/lokcharthelper.hxx b/include/sfx2/lokcharthelper.hxx
index aa7cfb5867ac..e447562e3dfd 100644
--- a/include/sfx2/lokcharthelper.hxx
+++ b/include/sfx2/lokcharthelper.hxx
@@ -28,11 +28,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();
@@ -42,7 +44,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 86bd13cb5a16..bfcde729dd0f 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -733,11 +733,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,
@@ -753,7 +753,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 b0b71aaa0353..49bdf5860784 100644
--- a/sfx2/source/view/lokcharthelper.cxx
+++ b/sfx2/source/view/lokcharthelper.cxx
@@ -18,6 +18,7 @@
#include <tools/mapunit.hxx>
#include <tools/UnitConversion.hxx>
#include <vcl/virdev.hxx>
+#include <sal/log.hxx>
#include <com/sun/star/embed/XEmbeddedObject.hpp>
#include <com/sun/star/frame/XDispatch.hpp>
@@ -137,6 +138,13 @@ tools::Rectangle LokChartHelper::GetChartBoundingBox()
double fXScale( aCWMapMode.GetScaleX() );
double fYScale( aCWMapMode.GetScaleY() );
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.setX( aOffset.X() * (TWIPS_PER_PIXEL / fXScale) );
aOffset.setY( aOffset.Y() * (TWIPS_PER_PIXEL / fYScale) );
Size aSize = pWindow->GetSizePixel();
@@ -171,7 +179,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;
@@ -180,7 +188,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;
}
@@ -265,7 +273,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);