Blame SOURCES/0323-sw-lok-fix-blinking-cursor-position-of-comments.patch

f325b2
From 0964ec395a33e8299a5caebb122c73687d1b428e Mon Sep 17 00:00:00 2001
f325b2
From: Miklos Vajna <vmiklos@collabora.co.uk>
f325b2
Date: Fri, 13 Nov 2015 13:33:32 +0100
f325b2
Subject: [PATCH 323/398] sw lok: fix blinking cursor position of comments
f325b2
f325b2
With this, it is possible to click inside a comment (and get a blinking
f325b2
cursor inside a comment), and also possible to use the arrow keys to
f325b2
native around and still get correct blinking cursor position.
f325b2
f325b2
(cherry picked from commit 5fb91dfd804cd6f3d585bb4113b9a68083ac71ee)
f325b2
f325b2
Change-Id: I29eb1e60e4e571151f0b18bec8cf765ea09af09f
f325b2
---
f325b2
 sw/inc/SidebarWin.hxx                        |  5 ++--
f325b2
 sw/source/uibase/docvw/PostItMgr.cxx         |  4 ++--
f325b2
 sw/source/uibase/docvw/SidebarTxtControl.hxx |  2 +-
f325b2
 sw/source/uibase/docvw/SidebarWin.cxx        | 36 ++++++++++++++++++++++++----
f325b2
 sw/source/uibase/docvw/edtwin.cxx            |  7 ------
f325b2
 5 files changed, 38 insertions(+), 16 deletions(-)
f325b2
f325b2
diff --git a/sw/inc/SidebarWin.hxx b/sw/inc/SidebarWin.hxx
f325b2
index c41352749c28..e3899d5a1a8b 100644
f325b2
--- a/sw/inc/SidebarWin.hxx
f325b2
+++ b/sw/inc/SidebarWin.hxx
f325b2
@@ -179,9 +179,10 @@ class SwSidebarWin : public vcl::Window
f325b2
 
f325b2
         virtual void    Draw(OutputDevice* pDev, const Point&, const Size&, sal_uLong) override;
f325b2
         virtual void KeyInput(const KeyEvent& rKeyEvt) override;
f325b2
+        virtual void MouseButtonDown(const MouseEvent& rMouseEvent) 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
+        /// Is there a matching sub-widget inside this sidebar widget for rPointLogic?
f325b2
+        bool 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 703a433a44ee..871a642d24da 100644
f325b2
--- a/sw/source/uibase/docvw/PostItMgr.cxx
f325b2
+++ b/sw/source/uibase/docvw/PostItMgr.cxx
f325b2
@@ -1736,9 +1736,9 @@ vcl::Window* SwPostItMgr::IsHitSidebarWindow(const Point& rPointLogic)
f325b2
             if (!pPostIt)
f325b2
                 continue;
f325b2
 
f325b2
-            if (vcl::Window* pWindow = pPostIt->IsHitWindow(rPointLogic))
f325b2
+            if (pPostIt->IsHitWindow(rPointLogic))
f325b2
             {
f325b2
-                pRet = pWindow;
f325b2
+                pRet = pPostIt;
f325b2
                 break;
f325b2
             }
f325b2
         }
f325b2
diff --git a/sw/source/uibase/docvw/SidebarTxtControl.hxx b/sw/source/uibase/docvw/SidebarTxtControl.hxx
f325b2
index 4f47ef4a2177..43d6b98d82c1 100644
f325b2
--- a/sw/source/uibase/docvw/SidebarTxtControl.hxx
f325b2
+++ b/sw/source/uibase/docvw/SidebarTxtControl.hxx
f325b2
@@ -41,7 +41,6 @@ class SidebarTextControl : public Control
f325b2
     protected:
f325b2
         virtual void    Paint( vcl::RenderContext& rRenderContext, const Rectangle& rRect) SAL_OVERRIDE;
f325b2
         virtual void    MouseMove( const MouseEvent& rMEvt ) SAL_OVERRIDE;
f325b2
-        virtual void    MouseButtonDown( const MouseEvent& rMEvt ) SAL_OVERRIDE;
f325b2
         virtual void    MouseButtonUp( const MouseEvent& rMEvt ) SAL_OVERRIDE;
f325b2
         virtual void    Command( const CommandEvent& rCEvt ) SAL_OVERRIDE;
f325b2
         virtual void    LoseFocus() SAL_OVERRIDE;
f325b2
@@ -61,6 +60,7 @@ class SidebarTextControl : public Control
f325b2
 
f325b2
         virtual void GetFocus() override;
f325b2
         virtual void KeyInput( const KeyEvent& rKeyEvt ) override;
f325b2
+        virtual void MouseButtonDown(const MouseEvent& rMouseEvent) override;
f325b2
 
f325b2
         OutlinerView* GetTextView() const;
f325b2
 
f325b2
diff --git a/sw/source/uibase/docvw/SidebarWin.cxx b/sw/source/uibase/docvw/SidebarWin.cxx
f325b2
index a40c82de5470..dd8d2a6003b9 100644
f325b2
--- a/sw/source/uibase/docvw/SidebarWin.cxx
f325b2
+++ b/sw/source/uibase/docvw/SidebarWin.cxx
f325b2
@@ -280,12 +280,10 @@ void SwSidebarWin::PaintTile(vcl::RenderContext& rRenderContext, const Rectangle
f325b2
     rRenderContext.Push(PushFlags::NONE);
f325b2
 }
f325b2
 
f325b2
-vcl::Window* SwSidebarWin::IsHitWindow(const Point& rPointLogic)
f325b2
+bool 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
+    return aRectangleLogic.IsInside(rPointLogic);
f325b2
 }
f325b2
 
f325b2
 void SwSidebarWin::Draw(OutputDevice* pDev, const Point& rPt, const Size& rSz, sal_uLong nInFlags)
f325b2
@@ -356,10 +354,40 @@ void SwSidebarWin::Draw(OutputDevice* pDev, const Point& rPt, const Size& rSz, s
f325b2
     }
f325b2
 }
f325b2
 
f325b2
+/// We want to work in absolute twips: so set delta between rChild and rParent as origin on rChild, then disable map mode on rChild.
f325b2
+static void lcl_setAbsoluteTwips(vcl::Window& rParent, vcl::Window& rChild)
f325b2
+{
f325b2
+    Point aOffset(rChild.GetOutOffXPixel() - rParent.GetOutOffXPixel(), rChild.GetOutOffYPixel() - rParent.GetOutOffYPixel());
f325b2
+    MapMode aMapMode(rChild.GetMapMode());
f325b2
+    aMapMode.SetOrigin(rChild.PixelToLogic(aOffset));
f325b2
+    rChild.SetMapMode(aMapMode);
f325b2
+    rChild.EnableMapMode(false);
f325b2
+}
f325b2
+
f325b2
 void SwSidebarWin::KeyInput(const KeyEvent& rKeyEvent)
f325b2
 {
f325b2
     if (mpSidebarTextControl)
f325b2
+    {
f325b2
+        mpSidebarTextControl->Push(PushFlags::MAPMODE);
f325b2
+        lcl_setAbsoluteTwips(*EditWin(), *mpSidebarTextControl);
f325b2
+
f325b2
         mpSidebarTextControl->KeyInput(rKeyEvent);
f325b2
+
f325b2
+        mpSidebarTextControl->Pop();
f325b2
+    }
f325b2
+}
f325b2
+
f325b2
+void SwSidebarWin::MouseButtonDown(const MouseEvent& rMouseEvent)
f325b2
+{
f325b2
+    if (mpSidebarTextControl)
f325b2
+    {
f325b2
+        mpSidebarTextControl->Push(PushFlags::MAPMODE);
f325b2
+        lcl_setAbsoluteTwips(*EditWin(), *mpSidebarTextControl);
f325b2
+
f325b2
+        mpSidebarTextControl->MouseButtonDown(rMouseEvent);
f325b2
+
f325b2
+        mpSidebarTextControl->Pop();
f325b2
+    }
f325b2
 }
f325b2
 
f325b2
 void SwSidebarWin::SetPosSizePixelRect(long nX, long nY, long nWidth, long nHeight,
f325b2
diff --git a/sw/source/uibase/docvw/edtwin.cxx b/sw/source/uibase/docvw/edtwin.cxx
f325b2
index 10cdc0dca561..53d0afd38f94 100644
f325b2
--- a/sw/source/uibase/docvw/edtwin.cxx
f325b2
+++ b/sw/source/uibase/docvw/edtwin.cxx
f325b2
@@ -2771,14 +2771,7 @@ void SwEditWin::MouseButtonDown(const MouseEvent& _rMEvt)
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
2.12.0
f325b2