summaryrefslogtreecommitdiff
path: root/sw/source/core/model/SearchResultLocator.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'sw/source/core/model/SearchResultLocator.cxx')
-rw-r--r--sw/source/core/model/SearchResultLocator.cxx50
1 files changed, 50 insertions, 0 deletions
diff --git a/sw/source/core/model/SearchResultLocator.cxx b/sw/source/core/model/SearchResultLocator.cxx
index 0b91c7a507e9..a0e405b2ed33 100644
--- a/sw/source/core/model/SearchResultLocator.cxx
+++ b/sw/source/core/model/SearchResultLocator.cxx
@@ -17,6 +17,9 @@
#include <IDocumentDrawModelAccess.hxx>
#include <IDocumentLayoutAccess.hxx>
+#include <tools/XmlWalker.hxx>
+#include <tools/stream.hxx>
+
#include <svx/svdpage.hxx>
#include <svx/svdobj.hxx>
@@ -82,6 +85,53 @@ LocationResult SearchResultLocator::find(std::vector<SearchIndexData> const& rSe
return aResult;
}
+LocationResult SearchResultLocator::findForPayload(const char* pPayload)
+{
+ LocationResult aResult;
+
+ const OString aPayloadString(pPayload);
+
+ SvMemoryStream aStream(const_cast<char*>(aPayloadString.getStr()), aPayloadString.getLength(),
+ StreamMode::READ);
+ tools::XmlWalker aWalker;
+
+ if (!aWalker.open(&aStream))
+ return aResult;
+
+ if (aWalker.name() == "indexing")
+ {
+ std::vector<sw::search::SearchIndexData> aDataVector;
+ aWalker.children();
+ while (aWalker.isValid())
+ {
+ if (aWalker.name() == "paragraph")
+ {
+ OString sType = aWalker.attribute("type");
+ OString sIndex = aWalker.attribute("index");
+
+ if (!sType.isEmpty() && !sIndex.isEmpty())
+ {
+ sw::search::SearchIndexData aData;
+ aData.mnNodeIndex = sIndex.toInt32();
+ aData.meType = sw::search::NodeType(sType.toInt32());
+
+ aDataVector.push_back(aData);
+ }
+ }
+ aWalker.next();
+ }
+ aWalker.parent();
+
+ if (!aDataVector.empty())
+ {
+ for (auto const& rSearchIndexData : aDataVector)
+ findOne(aResult, rSearchIndexData);
+ }
+ }
+
+ return aResult;
+}
+
} // end sw namespace
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */