Blob Blame History Raw
From bade9dc2b36b7ee92fa9ada8e033639a8c49a593 Mon Sep 17 00:00:00 2001
From: Miklos Vajna <vmiklos@collabora.co.uk>
Date: Sat, 14 Nov 2015 13:39:02 +0100
Subject: [PATCH 330/398] sw lok comments: fix cursor position of a newly
 created sidebar window

With this, pressing ctrl-alt-c to create a new comment has the correct
cursor position.

Change-Id: Icb8d708dab015d8ffa9bcfe28de66238a75b50bc
(cherry picked from commit d78432e9a077725046419902c542ce4e5f515705)
---
 sw/source/uibase/docvw/SidebarWin.cxx | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/sw/source/uibase/docvw/SidebarWin.cxx b/sw/source/uibase/docvw/SidebarWin.cxx
index 32d8b78815ae..cf803b618263 100644
--- a/sw/source/uibase/docvw/SidebarWin.cxx
+++ b/sw/source/uibase/docvw/SidebarWin.cxx
@@ -666,7 +666,24 @@ void SwSidebarWin::SetPosAndSize()
     {
         bChange = true;
         SetSizePixel(mPosSize.GetSize());
+
+        if (comphelper::LibreOfficeKit::isActive())
+        {
+            // Position is not yet set at VCL level, but the map mode should
+            // contain the right origin to emit the correct cursor position.
+            mpSidebarTextControl->Push(PushFlags::MAPMODE);
+            Point aOffset(mPosSize.Left(), mPosSize.Top());
+            aOffset = PixelToLogic(aOffset);
+            MapMode aMapMode(mpSidebarTextControl->GetMapMode());
+            aMapMode.SetOrigin(aOffset);
+            mpSidebarTextControl->SetMapMode(aMapMode);
+            mpSidebarTextControl->EnableMapMode(false);
+        }
+
         DoResize();
+
+        if (comphelper::LibreOfficeKit::isActive())
+            mpSidebarTextControl->Pop();
     }
 
     if (GetPosPixel().X() != mPosSize.TopLeft().X() || (std::abs(GetPosPixel().Y() - mPosSize.TopLeft().Y()) > 5) )
-- 
2.12.0