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