sd/source/ui/unoidl/unomodel.cxx       |   19 +++++++++++--------
 sfx2/source/view/lokstarmathhelper.cxx |   15 ++++++++++++++-
 sw/source/uibase/uno/unotxdoc.cxx      |    7 +++----
 3 files changed, 28 insertions(+), 13 deletions(-)

New commits:
commit 9fdf1cd68e3cfe2ee64ed4092b75b15b2eea33dd
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Wed Nov 16 17:40:27 2022 +0300
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Wed Nov 16 18:59:27 2022 +0100

    lok: handle mouse/keyboard events in Math embedded in Impress/Draw
    
    Since Impress/Draw use mm100, we need to convert object area that
    SfxInPlaceClient provides, which is in parent units, into twips.
    TODO: how would taking the units from object shell with Calc, given
    that it does not call SetMapUnit in ScDocShell ctor?
    
    Change-Id: I8de2088a3e0e7f9070d6c3c234b40038b6e00f15
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142777
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>
    (cherry picked from commit 2d4cde2f75d4aaa3a69fdd65ee7584eb15d20275)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142692
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>

diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx
index a71f3e9d1747..789e00a8159b 100644
--- a/sd/source/ui/unoidl/unomodel.cxx
+++ b/sd/source/ui/unoidl/unomodel.cxx
@@ -2411,16 +2411,16 @@ VclPtr<vcl::Window> SdXImpressDocument::getDocWindow()
 {
     SolarMutexGuard aGuard;
     DrawViewShell* pViewShell = GetViewShell();
-    VclPtr<vcl::Window> pWindow;
-    if (pViewShell)
-        pWindow = pViewShell->GetActiveWindow();
+    if (!pViewShell)
+        return {};
 
-    LokChartHelper aChartHelper(pViewShell->GetViewShell());
-    VclPtr<vcl::Window> pChartWindow = aChartHelper.GetWindow();
-    if (pChartWindow)
-        pWindow = pChartWindow;
+    SfxViewShell* pSfxViewShell = pViewShell->GetViewShell();
+    if (VclPtr<vcl::Window> pWindow = 
LokChartHelper(pSfxViewShell).GetWindow())
+        return pWindow;
+    if (VclPtr<vcl::Window> pWindow = 
LokStarMathHelper(pSfxViewShell).GetWidgetWindow())
+        return pWindow;
 
-    return pWindow;
+    return pViewShell->GetActiveWindow();
 }
 
 void SdXImpressDocument::setPartMode( int nPartMode )
@@ -2593,6 +2593,9 @@ void SdXImpressDocument::postMouseEvent(int nType, int 
nX, int nY, int nCount, i
                                     nCount, nButtons, nModifier,
                                     fScale, fScale))
         return;
+    if (LokStarMathHelper(pViewShell->GetViewShell())
+            .postMouseEvent(nType, nX, nY, nCount, nButtons, nModifier, 
fScale, fScale))
+        return;
 
     // check if the user hit a chart which is being edited by someone else
     // and, if so, skip current mouse event
diff --git a/sfx2/source/view/lokstarmathhelper.cxx 
b/sfx2/source/view/lokstarmathhelper.cxx
index a1ee4c2ccacb..d9c559746ba2 100644
--- a/sfx2/source/view/lokstarmathhelper.cxx
+++ b/sfx2/source/view/lokstarmathhelper.cxx
@@ -12,10 +12,12 @@
 #include <sfx2/ipclient.hxx>
 #include <sfx2/lokcomponenthelpers.hxx>
 #include <sfx2/lokhelper.hxx>
+#include <sfx2/objsh.hxx>
 
 #include <comphelper/dispatchcommand.hxx>
 #include <toolkit/helper/vclunohelper.hxx>
 #include <tools/fract.hxx>
+#include <tools/UnitConversion.hxx>
 #include <vcl/layout.hxx>
 #include <vcl/window.hxx>
 
@@ -135,7 +137,18 @@ const SfxViewShell* LokStarMathHelper::GetSmViewShell()
 
 tools::Rectangle LokStarMathHelper::GetBoundingBox() const
 {
-    return mpIPClient ? mpIPClient->GetObjArea() : tools::Rectangle{};
+    if (mpIPClient)
+    {
+        tools::Rectangle r(mpIPClient->GetObjArea());
+        if (SfxObjectShell* pObjShell = 
const_cast<SfxViewShell*>(mpViewShell)->GetObjectShell())
+        {
+            const o3tl::Length unit = MapToO3tlLength(pObjShell->GetMapUnit());
+            if (unit != o3tl::Length::twip && unit != o3tl::Length::invalid)
+                r = o3tl::convert(r, unit, o3tl::Length::twip);
+        }
+        return r;
+    }
+    return {};
 }
 
 bool LokStarMathHelper::postMouseEvent(int nType, int nX, int nY, int nCount, 
int nButtons,
diff --git a/sw/source/uibase/uno/unotxdoc.cxx 
b/sw/source/uibase/uno/unotxdoc.cxx
index 696529b61ab0..b23083cabc6a 100644
--- a/sw/source/uibase/uno/unotxdoc.cxx
+++ b/sw/source/uibase/uno/unotxdoc.cxx
@@ -3539,16 +3539,15 @@ VclPtr<vcl::Window> SwXTextDocument::getDocWindow()
 {
     SolarMutexGuard aGuard;
     SwView* pView = m_pDocShell->GetView();
+    if (!pView)
+        return {};
 
     if (VclPtr<vcl::Window> pWindow = LokChartHelper(pView).GetWindow())
         return pWindow;
     if (VclPtr<vcl::Window> pWindow = 
LokStarMathHelper(pView).GetWidgetWindow())
         return pWindow;
 
-    if (pView)
-        return &(pView->GetEditWin());
-
-    return {};
+    return &(pView->GetEditWin());
 }
 
 void SwXTextDocument::initializeForTiledRendering(const 
css::uno::Sequence<css::beans::PropertyValue>& rArguments)

Reply via email to