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

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