summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2022-11-16 17:40:27 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2022-11-16 17:08:08 +0100
commit2d4cde2f75d4aaa3a69fdd65ee7584eb15d20275 (patch)
tree974fcea75daed2a7fbf5a89d202b9de844c469e7
parent6eb9529abef9d7588899f9b241f31baa0b2beee2 (diff)
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.kaganski@collabora.com>
-rw-r--r--sd/source/ui/unoidl/unomodel.cxx19
-rw-r--r--sfx2/source/view/lokstarmathhelper.cxx15
-rw-r--r--sw/source/uibase/uno/unotxdoc.cxx7
3 files changed, 28 insertions, 13 deletions
diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx
index 2125fe109ed5..db972faeb633 100644
--- a/sd/source/ui/unoidl/unomodel.cxx
+++ b/sd/source/ui/unoidl/unomodel.cxx
@@ -2429,16 +2429,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 )
@@ -2611,6 +2611,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 08746303cecf..146384c452f2 100644
--- a/sw/source/uibase/uno/unotxdoc.cxx
+++ b/sw/source/uibase/uno/unotxdoc.cxx
@@ -3534,16 +3534,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)