Blame SOURCES/0328-sw-lok-comments-implement-setTextSelection-API.patch

f325b2
From 03db067b74739dabe787dbce6af1f4b776ce888a Mon Sep 17 00:00:00 2001
f325b2
From: Miklos Vajna <vmiklos@collabora.co.uk>
f325b2
Date: Sat, 14 Nov 2015 10:37:45 +0100
f325b2
Subject: [PATCH 328/398] sw lok comments: implement setTextSelection() API
f325b2
f325b2
So that it's possible to drag the text selection start/end handles in
f325b2
comment text when there is an existing selection.
f325b2
f325b2
(cherry picked from commit e320d070bb0d4dd0ceb696f2c7cc5afb7c4273c3)
f325b2
f325b2
Change-Id: I3acc4770928d4f385f0ca09a2484a9e112409907
f325b2
---
f325b2
 sw/inc/SidebarWin.hxx                 |  2 ++
f325b2
 sw/source/uibase/docvw/SidebarWin.cxx | 60 +++++++++++++++++++++++------------
f325b2
 sw/source/uibase/docvw/edtwin.cxx     | 10 ++++++
f325b2
 3 files changed, 51 insertions(+), 21 deletions(-)
f325b2
f325b2
diff --git a/sw/inc/SidebarWin.hxx b/sw/inc/SidebarWin.hxx
f325b2
index e3899d5a1a8b..503f8f8a9771 100644
f325b2
--- a/sw/inc/SidebarWin.hxx
f325b2
+++ b/sw/inc/SidebarWin.hxx
f325b2
@@ -183,6 +183,8 @@ class SwSidebarWin : public vcl::Window
f325b2
         void PaintTile(vcl::RenderContext& rRenderContext, const Rectangle& rRect);
f325b2
         /// Is there a matching sub-widget inside this sidebar widget for rPointLogic?
f325b2
         bool IsHitWindow(const Point& rPointLogic);
f325b2
+        /// Allows adjusting the point or mark of the selection to a document coordinate.
f325b2
+        void SetCursorLogicPosition(const Point& rPosition, bool bPoint, bool bClearMark);
f325b2
 
f325b2
     protected:
f325b2
         virtual void    DataChanged( const DataChangedEvent& aEvent) SAL_OVERRIDE;
f325b2
diff --git a/sw/source/uibase/docvw/SidebarWin.cxx b/sw/source/uibase/docvw/SidebarWin.cxx
f325b2
index 71b763b84224..721ef95e4acf 100644
f325b2
--- a/sw/source/uibase/docvw/SidebarWin.cxx
f325b2
+++ b/sw/source/uibase/docvw/SidebarWin.cxx
f325b2
@@ -83,6 +83,32 @@
f325b2
 #include <memory>
f325b2
 #include <comphelper/lok.hxx>
f325b2
 
f325b2
+namespace
f325b2
+{
f325b2
+
f325b2
+/// Translate absolute <-> relative twips: LOK wants absolute coordinates as output and gives absolute coordinates as input.
f325b2
+void lcl_translateTwips(vcl::Window& rParent, vcl::Window& rChild, MouseEvent* pMouseEvent)
f325b2
+{
f325b2
+    // Set map mode, so that callback payloads will contain absolute coordinates instead of relative ones.
f325b2
+    Point aOffset(rChild.GetOutOffXPixel() - rParent.GetOutOffXPixel(), rChild.GetOutOffYPixel() - rParent.GetOutOffYPixel());
f325b2
+    aOffset = rChild.PixelToLogic(aOffset);
f325b2
+    MapMode aMapMode(rChild.GetMapMode());
f325b2
+    aMapMode.SetOrigin(aOffset);
f325b2
+    rChild.SetMapMode(aMapMode);
f325b2
+    rChild.EnableMapMode(false);
f325b2
+
f325b2
+    if (pMouseEvent)
f325b2
+    {
f325b2
+        // Set event coordinates, so they contain relative coordinates instead of absolute ones.
f325b2
+        Point aPos = pMouseEvent->GetPosPixel();
f325b2
+        aPos.Move(-aOffset.getX(), -aOffset.getY());
f325b2
+        MouseEvent aMouseEvent(aPos, pMouseEvent->GetClicks(), pMouseEvent->GetMode(), pMouseEvent->GetButtons(), pMouseEvent->GetModifier());
f325b2
+        *pMouseEvent = aMouseEvent;
f325b2
+    }
f325b2
+}
f325b2
+
f325b2
+}
f325b2
+
f325b2
 namespace sw { namespace sidebarwindows {
f325b2
 
f325b2
 #define METABUTTON_WIDTH        16
f325b2
@@ -290,6 +316,19 @@ bool SwSidebarWin::IsHitWindow(const Point& rPointLogic)
f325b2
     return aRectangleLogic.IsInside(rPointLogic);
f325b2
 }
f325b2
 
f325b2
+void SwSidebarWin::SetCursorLogicPosition(const Point& rPosition, bool bPoint, bool bClearMark)
f325b2
+{
f325b2
+    mpSidebarTextControl->Push(PushFlags::MAPMODE);
f325b2
+    MouseEvent aMouseEvent(rPosition);
f325b2
+    lcl_translateTwips(*EditWin(), *mpSidebarTextControl, &aMouseEvent);
f325b2
+    Point aPosition(aMouseEvent.GetPosPixel());
f325b2
+
f325b2
+    EditView& rEditView = GetOutlinerView()->GetEditView();
f325b2
+    rEditView.SetCursorLogicPosition(aPosition, bPoint, bClearMark);
f325b2
+
f325b2
+    mpSidebarTextControl->Pop();
f325b2
+}
f325b2
+
f325b2
 void SwSidebarWin::Draw(OutputDevice* pDev, const Point& rPt, const Size& rSz, sal_uLong nInFlags)
f325b2
 {
f325b2
     if (mpMetadataAuthor->IsVisible() )
f325b2
@@ -358,27 +397,6 @@ void SwSidebarWin::Draw(OutputDevice* pDev, const Point& rPt, const Size& rSz, s
f325b2
     }
f325b2
 }
f325b2
 
f325b2
-/// Translate absolute <-> relative twips: LOK wants absolute coordinates as output and gives absolute coordinates as input.
f325b2
-static void lcl_translateTwips(vcl::Window& rParent, vcl::Window& rChild, MouseEvent* pMouseEvent)
f325b2
-{
f325b2
-    // Set map mode, so that callback payloads will contain absolute coordinates instead of relative ones.
f325b2
-    Point aOffset(rChild.GetOutOffXPixel() - rParent.GetOutOffXPixel(), rChild.GetOutOffYPixel() - rParent.GetOutOffYPixel());
f325b2
-    aOffset = rChild.PixelToLogic(aOffset);
f325b2
-    MapMode aMapMode(rChild.GetMapMode());
f325b2
-    aMapMode.SetOrigin(aOffset);
f325b2
-    rChild.SetMapMode(aMapMode);
f325b2
-    rChild.EnableMapMode(false);
f325b2
-
f325b2
-    if (pMouseEvent)
f325b2
-    {
f325b2
-        // Set event coordinates, so they contain relative coordinates instead of absolute ones.
f325b2
-        Point aPos = pMouseEvent->GetPosPixel();
f325b2
-        aPos.Move(-aOffset.getX(), -aOffset.getY());
f325b2
-        MouseEvent aMouseEvent(aPos, pMouseEvent->GetClicks(), pMouseEvent->GetMode(), pMouseEvent->GetButtons(), pMouseEvent->GetModifier());
f325b2
-        *pMouseEvent = aMouseEvent;
f325b2
-    }
f325b2
-}
f325b2
-
f325b2
 void SwSidebarWin::KeyInput(const KeyEvent& rKeyEvent)
f325b2
 {
f325b2
     if (mpSidebarTextControl)
f325b2
diff --git a/sw/source/uibase/docvw/edtwin.cxx b/sw/source/uibase/docvw/edtwin.cxx
f325b2
index 53d0afd38f94..b9777914c5b4 100644
f325b2
--- a/sw/source/uibase/docvw/edtwin.cxx
f325b2
+++ b/sw/source/uibase/docvw/edtwin.cxx
f325b2
@@ -6299,6 +6299,16 @@ void SwEditWin::SetCursorTwipPosition(const Point& rPosition, bool bPoint, bool
f325b2
         }
f325b2
     }
f325b2
 
f325b2
+    if (m_rView.GetPostItMgr())
f325b2
+    {
f325b2
+        if (sw::sidebarwindows::SwSidebarWin* pWin = m_rView.GetPostItMgr()->GetActiveSidebarWin())
f325b2
+        {
f325b2
+            // Editing postit text.
f325b2
+            pWin->SetCursorLogicPosition(rPosition, bPoint, bClearMark);
f325b2
+            return;
f325b2
+        }
f325b2
+    }
f325b2
+
f325b2
     // Not an SwWrtShell, as that would make SwCrsrShell::GetCrsr() inaccessible.
f325b2
     SwEditShell& rShell = m_rView.GetWrtShell();
f325b2
 
f325b2
-- 
f325b2
2.12.0
f325b2