summaryrefslogtreecommitdiff
path: root/sw/source/uibase/uno/unotxdoc.cxx
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2021-08-25 20:16:57 +0900
committerTomaž Vajngerl <quikee@gmail.com>2021-08-26 04:47:01 +0200
commit0b698aa6eb26d75ca4baf677a461aee095f69317 (patch)
tree74c45ae224b31919a97fc6e5f307df5a996c06ee /sw/source/uibase/uno/unotxdoc.cxx
parent0484630164275e2828f1420b055f05e94b8c73ee (diff)
indexing: move xml parsing into SearchResultLocator
Let's keep unneeded complexity out of SwXTextDocument, so move parsing into SearchResultLocator. As a bonus we can now test parsing. Change-Id: I944bfc43e6953523eee19b26b7f483aa401809aa Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121032 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'sw/source/uibase/uno/unotxdoc.cxx')
-rw-r--r--sw/source/uibase/uno/unotxdoc.cxx55
1 files changed, 8 insertions, 47 deletions
diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx
index e991de6df09c..e778f4fc8621 100644
--- a/sw/source/uibase/uno/unotxdoc.cxx
+++ b/sw/source/uibase/uno/unotxdoc.cxx
@@ -164,7 +164,6 @@
#include <IDocumentOutlineNodes.hxx>
#include <SearchResultLocator.hxx>
-#include <tools/XmlWalker.hxx>
#define TWIPS_PER_PIXEL 15
@@ -3395,55 +3394,17 @@ void SwXTextDocument::executeFromFieldEvent(const StringMap& aArguments)
std::vector<basegfx::B2DRange>
SwXTextDocument::getSearchResultRectangles(const char* pPayload)
{
- std::vector<basegfx::B2DRange> aRectangles;
-
- const OString aPayloadString(pPayload);
-
- SvMemoryStream aStream(const_cast<char *>(aPayloadString.getStr()), aPayloadString.getLength(), StreamMode::READ);
- tools::XmlWalker aWalker;
- if (!aWalker.open(&aStream))
- return aRectangles;
+ SwDoc* pDoc = m_pDocShell->GetDoc();
+ if (!pDoc)
+ return std::vector<basegfx::B2DRange>();
- if (aWalker.name() == "indexing")
+ sw::search::SearchResultLocator aLocator(pDoc);
+ sw::search::LocationResult aResult = aLocator.findForPayload(pPayload);
+ if (aResult.mbFound)
{
- SwDoc* pDoc = m_pDocShell->GetDoc();
-
- 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())
- {
- sw::search::SearchResultLocator aLocator(pDoc);
- sw::search::LocationResult aResult = aLocator.find(aDataVector);
- if (aResult.mbFound)
- {
- for (auto const & rRect : aResult.maRectangles)
- aRectangles.push_back(rRect);
- }
- }
+ return aResult.maRectangles;
}
-
- return aRectangles;
+ return std::vector<basegfx::B2DRange>();
}
int SwXTextDocument::getPart()