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

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