Blame SOURCES/0307-sw-lok-route-SwEditWin-MouseButtonDown-to-SidebarTex.patch

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