Blame SOURCES/0324-editeng-lok-respect-origin-of-map-mode-for-TEXT_SELE.patch

f325b2
From 72385a1ddf68d7c30813b7ca964850c96850a8de Mon Sep 17 00:00:00 2001
f325b2
From: Miklos Vajna <vmiklos@collabora.co.uk>
f325b2
Date: Fri, 13 Nov 2015 14:42:35 +0100
f325b2
Subject: [PATCH 324/398] editeng lok: respect origin of map mode for
f325b2
 TEXT_SELECTION
f325b2
f325b2
With this, selections of Writer comment text show up at the correct
f325b2
position, not at the top left corner of the window.
f325b2
f325b2
(cherry picked from commit 22e97c130868fe7d7529cfcfb2a240f775bd8916)
f325b2
f325b2
Change-Id: If865503d9a02a27730e382d65c42c706dd533a93
f325b2
---
f325b2
 editeng/source/editeng/impedit.cxx | 18 +++++++++++++-----
f325b2
 1 file changed, 13 insertions(+), 5 deletions(-)
f325b2
f325b2
diff --git a/editeng/source/editeng/impedit.cxx b/editeng/source/editeng/impedit.cxx
f325b2
index 8038ac6d3d41..0207155e4d75 100644
f325b2
--- a/editeng/source/editeng/impedit.cxx
f325b2
+++ b/editeng/source/editeng/impedit.cxx
f325b2
@@ -24,6 +24,7 @@
f325b2
 #include <vcl/settings.hxx>
f325b2
 
f325b2
 #include <impedit.hxx>
f325b2
+#include <comphelper/string.hxx>
f325b2
 #include <editeng/editeng.hxx>
f325b2
 #include <editeng/editview.hxx>
f325b2
 #include <tools/poly.hxx>
f325b2
@@ -327,6 +328,12 @@ void ImpEditView::DrawSelection( EditSelection aTmpSel, vcl::Region* pRegion, Ou
f325b2
         if (isTiledRendering() && !pOldRegion)
f325b2
         {
f325b2
             bool bMm100ToTwip = pOutWin->GetMapMode().GetMapUnit() == MAP_100TH_MM;
f325b2
+
f325b2
+            Point aOrigin;
f325b2
+            if (pOutWin->GetMapMode().GetMapUnit() == MAP_TWIP)
f325b2
+                // Writer comments: they use editeng, but are separate widgets.
f325b2
+                aOrigin = pOutWin->GetMapMode().GetOrigin();
f325b2
+
f325b2
             OString sRectangle;
f325b2
             // If we are not in selection mode, then the exported selection should be empty.
f325b2
             if (pEditEngine->pImpEditEngine->IsInSelectionMode())
f325b2
@@ -340,26 +347,27 @@ void ImpEditView::DrawSelection( EditSelection aTmpSel, vcl::Region* pRegion, Ou
f325b2
                     Rectangle aStart = Rectangle(rStart.Left(), rStart.Top(), rStart.Left() + 1, rStart.Bottom());
f325b2
                     if (bMm100ToTwip)
f325b2
                         aStart = OutputDevice::LogicToLogic(aStart, MAP_100TH_MM, MAP_TWIP);
f325b2
+                    aStart.Move(aOrigin.getX(), aOrigin.getY());
f325b2
                     libreOfficeKitCallback(LOK_CALLBACK_TEXT_SELECTION_START, aStart.toString().getStr());
f325b2
 
f325b2
                     Rectangle& rEnd = aRectangles.back();
f325b2
                     Rectangle aEnd = Rectangle(rEnd.Right() - 1, rEnd.Top(), rEnd.Right(), rEnd.Bottom());
f325b2
                     if (bMm100ToTwip)
f325b2
                         aEnd = OutputDevice::LogicToLogic(aEnd, MAP_100TH_MM, MAP_TWIP);
f325b2
+                    aEnd.Move(aOrigin.getX(), aOrigin.getY());
f325b2
                     libreOfficeKitCallback(LOK_CALLBACK_TEXT_SELECTION_END, aEnd.toString().getStr());
f325b2
                 }
f325b2
 
f325b2
-                std::stringstream ss;
f325b2
+                std::vector<OString> v;
f325b2
                 for (size_t i = 0; i < aRectangles.size(); ++i)
f325b2
                 {
f325b2
                     Rectangle& rRectangle = aRectangles[i];
f325b2
-                    if (i)
f325b2
-                        ss << "; ";
f325b2
                     if (bMm100ToTwip)
f325b2
                         rRectangle = OutputDevice::LogicToLogic(rRectangle, MAP_100TH_MM, MAP_TWIP);
f325b2
-                    ss << rRectangle.toString().getStr();
f325b2
+                    rRectangle.Move(aOrigin.getX(), aOrigin.getY());
f325b2
+                    v.push_back(rRectangle.toString().getStr());
f325b2
                 }
f325b2
-                sRectangle = ss.str().c_str();
f325b2
+                sRectangle = comphelper::string::join("; ", v);
f325b2
             }
f325b2
             libreOfficeKitCallback(LOK_CALLBACK_TEXT_SELECTION, sRectangle.getStr());
f325b2
         }
f325b2
-- 
f325b2
2.12.0
f325b2