From fd7a84aca0c94044bbc3bfb8852a1ae5115845bf Mon Sep 17 00:00:00 2001 From: Mike Kaganski Date: Wed, 2 Feb 2022 11:22:53 +0300 Subject: lok: find active SmViewShell reliably ... even after SfxViewShell::Current() had been set to parent document frame's viewshell (e.g., see LOKPostAsyncEvent grabbing focus, which replaces current frame and its associated viewshell). Change-Id: If63087f4c7f3f878ada93d93cc0af6c20a6c0a62 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129323 Tested-by: Jenkins Reviewed-by: Mike Kaganski --- sfx2/source/view/lokstarmathhelper.cxx | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) (limited to 'sfx2') diff --git a/sfx2/source/view/lokstarmathhelper.cxx b/sfx2/source/view/lokstarmathhelper.cxx index fedd931b08fd..885decdc2fea 100644 --- a/sfx2/source/view/lokstarmathhelper.cxx +++ b/sfx2/source/view/lokstarmathhelper.cxx @@ -83,28 +83,31 @@ vcl::Window* FindChildSmGraphicWidgetWindow(vcl::Window* pWin) } return nullptr; } - -vcl::Window* FindSmGraphicWidgetWindow(vcl::Window* pWin) -{ - return FindChildSmGraphicWidgetWindow(FindSmGraphicWindow(pWin)); -} } -vcl::Window* LokStarMathHelper::GetWindow() +vcl::Window* LokStarMathHelper::GetGraphicWindow() { - if (!mpWindow) + if (!mpGraphicWindow) { if (const css::uno::Reference& xController = GetXController()) { if (const css::uno::Reference xFrame = xController->getFrame()) { css::uno::Reference xDockerWin = xFrame->getContainerWindow(); - mpWindow.set(FindSmGraphicWidgetWindow(VCLUnoHelper::GetWindow(xDockerWin))); + mpGraphicWindow.set(FindSmGraphicWindow(VCLUnoHelper::GetWindow(xDockerWin))); } } } - return mpWindow.get(); + return mpGraphicWindow.get(); +} + +vcl::Window* LokStarMathHelper::GetWidgetWindow() +{ + if (!mpWidgetWindow) + mpWidgetWindow.set(FindChildSmGraphicWidgetWindow(GetGraphicWindow())); + + return mpWidgetWindow.get(); } tools::Rectangle LokStarMathHelper::GetBoundingBox() @@ -115,7 +118,7 @@ tools::Rectangle LokStarMathHelper::GetBoundingBox() { if (vcl::Window* pRootWin = pIPClient->GetEditWin()) { - if (vcl::Window* pWindow = GetWindow()) + if (vcl::Window* pWindow = GetWidgetWindow()) { // In all cases, the following code fragment // returns the bounding box in twips. @@ -143,7 +146,7 @@ tools::Rectangle LokStarMathHelper::GetBoundingBox() bool LokStarMathHelper::postMouseEvent(int nType, int nX, int nY, int nCount, int nButtons, int nModifier, double fScaleX, double fScaleY) { - if (vcl::Window* pWindow = GetWindow()) + if (vcl::Window* pWindow = GetWidgetWindow()) { Point aMousePos(nX, nY); tools::Rectangle rBBox = GetBoundingBox(); -- cgit