Blame SOURCES/0203-sd-tiled-rendering-implement-LOK_CALLBACK_SEARCH_RES.patch

135360
From 32147fe3622284f6da6a2b3e577698a2a188a4b4 Mon Sep 17 00:00:00 2001
135360
From: Miklos Vajna <vmiklos@collabora.co.uk>
135360
Date: Tue, 13 Oct 2015 15:55:55 +0200
135360
Subject: [PATCH 203/398] sd tiled rendering: implement
135360
 LOK_CALLBACK_SEARCH_RESULT_SELECTION
135360
135360
Given that sd doesn't support find-all yet, this works for normal find
135360
only at the moment (so it may report multiple rectangles, but always a
135360
single match).
135360
135360
Change-Id: I47bd0d0161b9d1dc843bb503f5521f311fc158c4
135360
(cherry picked from commit 395cfab05752b87ae419304789d894c0fe9a98c2)
135360
---
135360
 sd/source/ui/view/Outliner.cxx | 25 ++++++++++++++++++++++++-
135360
 1 file changed, 24 insertions(+), 1 deletion(-)
135360
135360
diff --git a/sd/source/ui/view/Outliner.cxx b/sd/source/ui/view/Outliner.cxx
135360
index 8d88518c931f..41bf43d253f4 100644
135360
--- a/sd/source/ui/view/Outliner.cxx
135360
+++ b/sd/source/ui/view/Outliner.cxx
135360
@@ -18,6 +18,7 @@
135360
  */
135360
 
135360
 #include "Outliner.hxx"
135360
+#include <boost/property_tree/json_parser.hpp>
135360
 #include <vcl/wrkwin.hxx>
135360
 #include <vcl/settings.hxx>
135360
 
135360
@@ -71,6 +72,7 @@
135360
 #include <svx/svxids.hrc>
135360
 #include <editeng/editerr.hxx>
135360
 #include <LibreOfficeKit/LibreOfficeKitEnums.h>
135360
+#include <comphelper/string.hxx>
135360
 
135360
 using namespace ::com::sun::star;
135360
 using namespace ::com::sun::star::uno;
135360
@@ -720,11 +722,32 @@ bool Outliner::SearchAndReplaceOnce()
135360
 
135360
     mpDrawDocument->GetDocSh()->SetWaitCursor( false );
135360
 
135360
-    // notify LibreOfficeKit about changed page
135360
     if (pViewShell && pViewShell->GetDoc()->isTiledRendering() && mbStringFound)
135360
     {
135360
+        // notify LibreOfficeKit about changed page
135360
         OString aPayload = OString::number(maCurrentPosition.mnPageIndex);
135360
         pViewShell->GetDoc()->libreOfficeKitCallback(LOK_CALLBACK_SET_PART, aPayload.getStr());
135360
+
135360
+        // also about search result selections
135360
+        std::vector<Rectangle> aLogicRects;
135360
+        pOutlinerView->GetSelectionRectangles(aLogicRects);
135360
+
135360
+        boost::property_tree::ptree aTree;
135360
+        aTree.put("searchString", mpSearchItem->GetSearchString().toUtf8().getStr());
135360
+
135360
+        std::vector<OString> aLogicRectStrings;
135360
+        std::transform(aLogicRects.begin(), aLogicRects.end(), std::back_inserter(aLogicRectStrings), [](const Rectangle& rRectangle) { return rRectangle.toString(); });
135360
+        OString sRectangles = comphelper::string::join("; ", aLogicRectStrings);
135360
+        boost::property_tree::ptree aChildren;
135360
+        boost::property_tree::ptree aChild;
135360
+        aChild.put("", sRectangles.getStr());
135360
+        aChildren.push_back(std::make_pair("", aChild));
135360
+        aTree.add_child("searchResultSelection", aChildren);
135360
+
135360
+        std::stringstream aStream;
135360
+        boost::property_tree::write_json(aStream, aTree);
135360
+        aPayload = aStream.str().c_str();
135360
+        pViewShell->GetDoc()->libreOfficeKitCallback(LOK_CALLBACK_SEARCH_RESULT_SELECTION, aPayload.getStr());
135360
     }
135360
 
135360
     return mbEndOfSearch;
135360
-- 
135360
2.12.0
135360