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

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