diff options
-rw-r--r-- | include/sfx2/lokhelper.hxx | 11 | ||||
-rw-r--r-- | sc/source/ui/unoobj/docuno.cxx | 39 | ||||
-rw-r--r-- | sd/source/ui/unoidl/unomodel.cxx | 23 | ||||
-rw-r--r-- | sfx2/source/view/lokhelper.cxx | 40 | ||||
-rw-r--r-- | sw/source/uibase/uno/unotxdoc.cxx | 22 |
5 files changed, 63 insertions, 72 deletions
diff --git a/include/sfx2/lokhelper.hxx b/include/sfx2/lokhelper.hxx index 341febc7882a..7c4aefbc9be8 100644 --- a/include/sfx2/lokhelper.hxx +++ b/include/sfx2/lokhelper.hxx @@ -13,6 +13,8 @@ #include <vcl/IDialogRenderable.hxx> #include <vcl/ITiledRenderable.hxx> #include <vcl/event.hxx> +#include <vcl/vclptr.hxx> +#include <vcl/window.hxx> #include <sfx2/dllapi.h> #include <sfx2/viewsh.hxx> #include <tools/gen.hxx> @@ -163,6 +165,15 @@ public: /// This could be a new insertion or property modifications to an existing one. static void notifyMediaUpdate(boost::property_tree::ptree& json); + /// Process the mouse event in the currently active in-place component (if any). + /// Returns true if the event has been processed, and no further processing is necessary. + static bool testInPlaceComponentMouseEventHit(SfxViewShell* pViewShell, int nType, int nX, + int nY, int nCount, int nButtons, int nModifier, + double fScaleX, double fScaleY, + bool bNegativeX = false); + + static VclPtr<vcl::Window> getInPlaceDocWindow(SfxViewShell* pViewShell); + private: static int createView(SfxViewFrame* pViewFrame, ViewShellDocId docId); }; diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx index 298b9c951852..4b6d5ff3a2a9 100644 --- a/sc/source/ui/unoobj/docuno.cxx +++ b/sc/source/ui/unoobj/docuno.cxx @@ -639,20 +639,10 @@ VclPtr<vcl::Window> ScModelObj::getDocWindow() if (!pViewShell) return VclPtr<vcl::Window>(); - ScViewData* pViewData = &pViewShell->GetViewData(); - - VclPtr<vcl::Window> pWindow; - if (pViewData) - { - pWindow = pViewData->GetActiveWin(); + if (VclPtr<vcl::Window> pWindow = SfxLokHelper::getInPlaceDocWindow(pViewShell)) + return pWindow; - LokChartHelper aChartHelper(pViewData->GetViewShell()); - vcl::Window* pChartWindow = aChartHelper.GetWindow(); - if (pChartWindow) - pWindow = pChartWindow; - } - - return pWindow; + return pViewShell->GetViewData().GetActiveWin(); } Size ScModelObj::getDocumentSize() @@ -744,32 +734,15 @@ void ScModelObj::postMouseEvent(int nType, int nX, int nY, int nCount, int nButt if (!pGridWindow) return; - // check if user hit a chart which is being edited by him - ScTabViewShell * pTabViewShell = pViewData->GetViewShell(); SCTAB nTab = pViewData->GetTabNo(); 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, - pViewData->GetPPTX(), pViewData->GetPPTY())) - { + if (SfxLokHelper::testInPlaceComponentMouseEventHit(pViewShell, nType, nX, nY, nCount, + nButtons, nModifier, pViewData->GetPPTX(), + pViewData->GetPPTY(), bDrawNegativeX)) return; - } Point aPointTwip(nX, nY); - Point aPointTwipDraw(nDrawX, nY); - - // check if the user hit a chart which is being edited by someone else - // and, if so, skip current mouse event - if (nType != LOK_MOUSEEVENT_MOUSEMOVE) - { - if (LokChartHelper::HitAny(aPointTwipDraw, bDrawNegativeX)) - return; - } // Check if a control is hit Point aPointHMM = o3tl::convert(aPointTwip, o3tl::Length::twip, o3tl::Length::mm100); diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx index 789e00a8159b..122eed77f003 100644 --- a/sd/source/ui/unoidl/unomodel.cxx +++ b/sd/source/ui/unoidl/unomodel.cxx @@ -2414,10 +2414,7 @@ VclPtr<vcl::Window> SdXImpressDocument::getDocWindow() if (!pViewShell) return {}; - SfxViewShell* pSfxViewShell = pViewShell->GetViewShell(); - if (VclPtr<vcl::Window> pWindow = LokChartHelper(pSfxViewShell).GetWindow()) - return pWindow; - if (VclPtr<vcl::Window> pWindow = LokStarMathHelper(pSfxViewShell).GetWidgetWindow()) + if (VclPtr<vcl::Window> pWindow = SfxLokHelper::getInPlaceDocWindow(pViewShell->GetViewShell())) return pWindow; return pViewShell->GetActiveWindow(); @@ -2587,23 +2584,9 @@ void SdXImpressDocument::postMouseEvent(int nType, int nX, int nY, int nCount, i constexpr double fScale = o3tl::convert(1.0, o3tl::Length::twip, o3tl::Length::px); - // check if user hit a chart which is being edited by him - LokChartHelper aChartHelper(pViewShell->GetViewShell()); - if (aChartHelper.postMouseEvent(nType, nX, nY, - nCount, nButtons, nModifier, - fScale, fScale)) + if (SfxLokHelper::testInPlaceComponentMouseEventHit( + pViewShell->GetViewShell(), nType, nX, nY, 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 - if (nType != LOK_MOUSEEVENT_MOUSEMOVE) - { - if (LokChartHelper::HitAny(Point(nX, nY))) - return; - } const Point aPos(Point(convertTwipToMm100(nX), convertTwipToMm100(nY))); LokMouseEventData aMouseEventData(nType, aPos, nCount, MouseEventModifiers::SIMPLECLICK, diff --git a/sfx2/source/view/lokhelper.cxx b/sfx2/source/view/lokhelper.cxx index ba60402c2601..7dc104f7bea2 100644 --- a/sfx2/source/view/lokhelper.cxx +++ b/sfx2/source/view/lokhelper.cxx @@ -11,6 +11,7 @@ #include <string_view> +#include <sfx2/lokcomponenthelpers.hxx> #include <sfx2/lokhelper.hxx> #include <com/sun/star/frame/Desktop.hpp> @@ -920,4 +921,43 @@ void SfxLokHelper::notifyMediaUpdate(boost::property_tree::ptree& json) SfxLokHelper::notifyAllViews(LOK_CALLBACK_MEDIA_SHAPE, str.c_str()); } +bool SfxLokHelper::testInPlaceComponentMouseEventHit(SfxViewShell* pViewShell, int nType, int nX, + int nY, int nCount, int nButtons, + int nModifier, double fScaleX, double fScaleY, + bool bNegativeX) +{ + // In LOK RTL mode draw/svx operates in negative X coordinates + // But the coordinates from client is always positive, so negate nX. + if (bNegativeX) + nX = -nX; + + // check if the user hit a chart/math object which is being edited by this view + if (LokChartHelper aChartHelper(pViewShell, bNegativeX); + aChartHelper.postMouseEvent(nType, nX, nY, nCount, nButtons, nModifier, fScaleX, fScaleY)) + return true; + + if (LokStarMathHelper aMathHelper(pViewShell); + aMathHelper.postMouseEvent(nType, nX, nY, nCount, nButtons, nModifier, fScaleX, fScaleY)) + return true; + + // check if the user hit a chart which is being edited by someone else + // and, if so, skip current mouse event + if (nType != LOK_MOUSEEVENT_MOUSEMOVE) + { + if (LokChartHelper::HitAny({nX, nY}, bNegativeX)) + return true; + } + + return false; +} + +VclPtr<vcl::Window> SfxLokHelper::getInPlaceDocWindow(SfxViewShell* pViewShell) +{ + if (VclPtr<vcl::Window> pWindow = LokChartHelper(pViewShell).GetWindow()) + return pWindow; + if (VclPtr<vcl::Window> pWindow = LokStarMathHelper(pViewShell).GetWidgetWindow()) + return pWindow; + return {}; +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx index b23083cabc6a..9ab446907fdf 100644 --- a/sw/source/uibase/uno/unotxdoc.cxx +++ b/sw/source/uibase/uno/unotxdoc.cxx @@ -3542,9 +3542,7 @@ VclPtr<vcl::Window> SwXTextDocument::getDocWindow() if (!pView) return {}; - if (VclPtr<vcl::Window> pWindow = LokChartHelper(pView).GetWindow()) - return pWindow; - if (VclPtr<vcl::Window> pWindow = LokStarMathHelper(pView).GetWidgetWindow()) + if (VclPtr<vcl::Window> pWindow = SfxLokHelper::getInPlaceDocWindow(pView)) return pWindow; return &(pView->GetEditWin()); @@ -3642,24 +3640,10 @@ void SwXTextDocument::postMouseEvent(int nType, int nX, int nY, int nCount, int SwViewOption aOption(*(pWrtViewShell->GetViewOptions())); double fScale = aOption.GetZoom() / o3tl::convert(100.0, o3tl::Length::px, o3tl::Length::twip); - // check if the user hit a chart/math object which is being edited by this view - if (LokChartHelper(m_pDocShell->GetView()).postMouseEvent(nType, nX, nY, - nCount, nButtons, nModifier, - fScale, fScale)) - return; - if (LokStarMathHelper(m_pDocShell->GetView()).postMouseEvent(nType, nX, nY, - nCount, nButtons, nModifier, - fScale, fScale)) + if (SfxLokHelper::testInPlaceComponentMouseEventHit( + m_pDocShell->GetView(), 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 - if (nType != LOK_MOUSEEVENT_MOUSEMOVE) - { - if (LokChartHelper::HitAny(Point(nX, nY))) - return; - } - SwEditWin& rEditWin = m_pDocShell->GetView()->GetEditWin(); LokMouseEventData aMouseEventData(nType, Point(nX, nY), nCount, MouseEventModifiers::SIMPLECLICK, |