diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2022-11-05 15:17:00 +0300 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2022-11-07 17:15:06 +0100 |
commit | 6594e826d9f02670579feec84f65dcf6e98eb8cc (patch) | |
tree | 3aab3af557d6308497a670b566e89419a479ca04 | |
parent | lok: Introudce getDataArea for Calc (diff) | |
download | core-6594e826d9f02670579feec84f65dcf6e98eb8cc.tar.gz core-6594e826d9f02670579feec84f65dcf6e98eb8cc.zip |
lok: properly treat zoom in LokStarMathHelper::postMouseEvent
Previous naive implementation was dropped in commit
033a342a630dbb6329962156727e621866b77b48 (lok: use twips in Math,
Wed Nov 02 11:03:08 2022 +0300). Unlike chart, Math expects twips,
so PPT (pixel per twip) factor must be converted into percentage.
Change-Id: Icd936e004d961c0abc25c241391d4e24c44e8c14
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142319
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
(cherry picked from commit f0a88a6d214ebdcc3617d24beb4bb5148f72c3a4)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142295
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
-rw-r--r-- | include/sfx2/lokcomponenthelpers.hxx | 2 | ||||
-rw-r--r-- | sfx2/source/view/lokstarmathhelper.cxx | 13 |
2 files changed, 13 insertions, 2 deletions
diff --git a/include/sfx2/lokcomponenthelpers.hxx b/include/sfx2/lokcomponenthelpers.hxx index e659b6c91e43..a58e154e36d6 100644 --- a/include/sfx2/lokcomponenthelpers.hxx +++ b/include/sfx2/lokcomponenthelpers.hxx @@ -79,7 +79,7 @@ public: void Dispatch(const rtl::OUString& cmd, const css::uno::Sequence<css::beans::PropertyValue>& rArguments) const; bool postMouseEvent(int nType, int nX, int nY, int nCount, int nButtons, int nModifier, - double fScaleX = 1.0, double fScaleY = 1.0); + double fPPTScaleX, double fPPTScaleY); private: const SfxViewShell* mpViewShell; diff --git a/sfx2/source/view/lokstarmathhelper.cxx b/sfx2/source/view/lokstarmathhelper.cxx index 8ec65c45a274..a1ee4c2ccacb 100644 --- a/sfx2/source/view/lokstarmathhelper.cxx +++ b/sfx2/source/view/lokstarmathhelper.cxx @@ -139,7 +139,7 @@ tools::Rectangle LokStarMathHelper::GetBoundingBox() const } bool LokStarMathHelper::postMouseEvent(int nType, int nX, int nY, int nCount, int nButtons, - int nModifier, double /*fScaleX*/, double /*fScaleY*/) + int nModifier, double fPPTScaleX, double fPPTScaleY) { const tools::Rectangle rBBox = GetBoundingBox(); if (Point aMousePos(nX, nY); rBBox.Contains(aMousePos)) @@ -147,6 +147,17 @@ bool LokStarMathHelper::postMouseEvent(int nType, int nX, int nY, int nCount, in if (vcl::Window* pWindow = GetWidgetWindow()) { aMousePos -= rBBox.TopLeft(); + + // In lok, Math does not convert coordinates (see SmGraphicWidget::SetDrawingArea, + // which disables MapMode), and uses twips internally (see SmDocShell ctor and + // SmMapUnit), but the conversion factor can depend on the client zoom. + // 1. Remove the twip->pixel factor in the passed scales + double fScaleX = o3tl::convert(fPPTScaleX, o3tl::Length::px, o3tl::Length::twip); + double fScaleY = o3tl::convert(fPPTScaleY, o3tl::Length::px, o3tl::Length::twip); + // 2. Adjust the position according to the scales + aMousePos + = Point(std::round(aMousePos.X() * fScaleX), std::round(aMousePos.Y() * fScaleY)); + LokMouseEventData aMouseEventData( nType, aMousePos, nCount, MouseEventModifiers::SIMPLECLICK, nButtons, nModifier); SfxLokHelper::postMouseEventAsync(pWindow, aMouseEventData); |