From 2770d40660412006fec7a5b0441293b89512dadf Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Thu, 12 Nov 2015 14:21:03 +0100 Subject: [PATCH 307/398] sw lok: route SwEditWin::MouseButtonDown to SidebarTextControl if necessary LOK sends all mouse events to SwEditWin, so add initial hit testing in its mouse handler to forward the mouse events to the right VCL widget. (cherry picked from commit b7ecf6279ef3343f12fce776862c027bfeff6617) Change-Id: I67e8e19f47156261fd7c7eafd4e63f743e0c4ce9 --- sw/inc/PostItMgr.hxx | 6 ++++-- sw/inc/SidebarWin.hxx | 2 ++ sw/source/uibase/docvw/PostItMgr.cxx | 31 +++++++++++++++++++++++++++++++ sw/source/uibase/docvw/SidebarWin.cxx | 8 ++++++++ sw/source/uibase/docvw/edtwin.cxx | 18 +++++++++++++++++- 5 files changed, 62 insertions(+), 3 deletions(-) diff --git a/sw/inc/PostItMgr.hxx b/sw/inc/PostItMgr.hxx index f306f57ba86c..4356f6daa416 100644 --- a/sw/inc/PostItMgr.hxx +++ b/sw/inc/PostItMgr.hxx @@ -233,8 +233,10 @@ class SwPostItMgr: public SfxListener Rectangle GetBottomScrollRect(const unsigned long aPage) const; Rectangle GetTopScrollRect(const unsigned long aPage) const; - bool IsHit(const Point &aPointPixel); - Color GetArrowColor(sal_uInt16 aDirection,unsigned long aPage) const; + bool IsHit(const Point &aPointPixel); + /// Get the matching window that is responsible for handling mouse events of rPointLogic, if any. + vcl::Window* IsHitSidebarWindow(const Point& rPointLogic); + Color GetArrowColor(sal_uInt16 aDirection,unsigned long aPage) const; sw::annotation::SwAnnotationWin* GetAnnotationWin(const SwPostItField* pField) const; diff --git a/sw/inc/SidebarWin.hxx b/sw/inc/SidebarWin.hxx index d21d50d5d7d5..1eaf982ebf07 100644 --- a/sw/inc/SidebarWin.hxx +++ b/sw/inc/SidebarWin.hxx @@ -179,6 +179,8 @@ class SwSidebarWin : public vcl::Window virtual void Draw(OutputDevice* pDev, const Point&, const Size&, sal_uLong) override; void PaintTile(vcl::RenderContext& rRenderContext, const Rectangle& rRect); + /// Get the matching sub-widget inside this sidebar widget for rPointLogic, if any. + vcl::Window* IsHitWindow(const Point& rPointLogic); protected: virtual void DataChanged( const DataChangedEvent& aEvent) SAL_OVERRIDE; diff --git a/sw/source/uibase/docvw/PostItMgr.cxx b/sw/source/uibase/docvw/PostItMgr.cxx index 2a2e5d596056..eb5755e20cf9 100644 --- a/sw/source/uibase/docvw/PostItMgr.cxx +++ b/sw/source/uibase/docvw/PostItMgr.cxx @@ -1706,6 +1706,37 @@ bool SwPostItMgr::IsHit(const Point &aPointPixel) } return false; } + +vcl::Window* SwPostItMgr::IsHitSidebarWindow(const Point& rPointLogic) +{ + vcl::Window* pRet = 0; + + if (HasNotes() && ShowNotes()) + { + bool bEnableMapMode = !mpEditWin->IsMapModeEnabled(); + if (bEnableMapMode) + mpEditWin->EnableMapMode(); + + for (SwSidebarItem* pItem : mvPostItFields) + { + SwSidebarWin* pPostIt = pItem->pPostIt; + if (!pPostIt) + continue; + + if (vcl::Window* pWindow = pPostIt->IsHitWindow(rPointLogic)) + { + pRet = pWindow; + break; + } + } + + if (bEnableMapMode) + mpEditWin->EnableMapMode(false); + } + + return pRet; +} + Rectangle SwPostItMgr::GetBottomScrollRect(const unsigned long aPage) const { SwRect aPageRect = mPages[aPage-1]->mPageRect; diff --git a/sw/source/uibase/docvw/SidebarWin.cxx b/sw/source/uibase/docvw/SidebarWin.cxx index 202a96767a39..87a86fbc9dc8 100644 --- a/sw/source/uibase/docvw/SidebarWin.cxx +++ b/sw/source/uibase/docvw/SidebarWin.cxx @@ -280,6 +280,14 @@ void SwSidebarWin::PaintTile(vcl::RenderContext& rRenderContext, const Rectangle rRenderContext.Push(PushFlags::NONE); } +vcl::Window* SwSidebarWin::IsHitWindow(const Point& rPointLogic) +{ + Rectangle aRectangleLogic(EditWin().PixelToLogic(GetPosPixel()), EditWin().PixelToLogic(GetSizePixel())); + if (aRectangleLogic.IsInside(rPointLogic)) + return mpSidebarTextControl; + return 0; +} + void SwSidebarWin::Draw(OutputDevice* pDev, const Point& rPt, const Size& rSz, sal_uLong nInFlags) { if (mpMetadataAuthor->IsVisible() ) diff --git a/sw/source/uibase/docvw/edtwin.cxx b/sw/source/uibase/docvw/edtwin.cxx index f392010fb6b1..b4ed61becbfb 100644 --- a/sw/source/uibase/docvw/edtwin.cxx +++ b/sw/source/uibase/docvw/edtwin.cxx @@ -2756,7 +2756,23 @@ void SwEditWin::MouseButtonDown(const MouseEvent& _rMEvt) if (m_rView.GetPostItMgr()->IsHit(rMEvt.GetPosPixel())) return; - m_rView.GetPostItMgr()->SetActiveSidebarWin(0); + if (comphelper::LibreOfficeKit::isActive()) + { + if (vcl::Window* pWindow = m_rView.GetPostItMgr()->IsHitSidebarWindow(rMEvt.GetPosPixel())) + { + bool bDisableMapMode = pWindow->IsMapModeEnabled(); + if (bDisableMapMode) + pWindow->EnableMapMode(false); + + pWindow->MouseButtonDown(rMEvt); + + if (bDisableMapMode) + pWindow->EnableMapMode(); + return; + } + } + + m_rView.GetPostItMgr()->SetActiveSidebarWin(nullptr); GrabFocus(); -- 2.12.0