diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2021-09-07 15:40:42 +0900 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2021-09-08 06:58:07 +0200 |
commit | 83da70de985e1f9f7193676bef8dc71226803bb0 (patch) | |
tree | 82e077ff35e11873877b805361a27125ac099a45 /sw/source/core/model | |
parent | eac288d02cafc49c5a14fa27bb449c33eb4b1803 (diff) |
indexing: rename "type" for prargraph an object nodes
They are conflicting, so rename the one for paragraphs to
"node_type and the one for objects to "object_type". This needs
adusting all the tests. Also change the node_type from numerical
value (correcponding to a enum) to string based - "writer" or
"commom" values.
Change-Id: I0465cd4c2c6989e436d5a675db20c87066d19208
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121743
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'sw/source/core/model')
-rw-r--r-- | sw/source/core/model/SearchResultLocator.cxx | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/sw/source/core/model/SearchResultLocator.cxx b/sw/source/core/model/SearchResultLocator.cxx index 089859683cb4..b4f10a16ca72 100644 --- a/sw/source/core/model/SearchResultLocator.cxx +++ b/sw/source/core/model/SearchResultLocator.cxx @@ -51,7 +51,7 @@ void SearchResultLocator::findOne(LocationResult& rResult, SearchIndexData const rArea.Top() + rArea.Height()); } } - else if (rSearchIndexData.meType == NodeType::SdrObject) + else if (rSearchIndexData.meType == NodeType::CommonNode) { IDocumentDrawModelAccess& rDrawModelAccess = mpDocument->getIDocumentDrawModelAccess(); auto* pModel = rDrawModelAccess.GetDrawModel(); @@ -109,12 +109,18 @@ bool SearchResultLocator::tryParseJSON(const char* pPayload, { auto const& rEach = rEachNode.second; - sal_Int32 nType = rEach.get<sal_Int32>("type", 0); + std::string sType = rEach.get<std::string>("node_type", ""); + auto eNodeType = sw::search::NodeType::Undefined; + if (sType == "writer") + eNodeType = sw::search::NodeType::WriterNode; + else if (sType == "common") + eNodeType = sw::search::NodeType::CommonNode; + sal_Int32 nIndex = rEach.get<sal_Int32>("index", -1); // Don't add search data elements that don't have valid data - if (nType > 0 && nIndex >= 0) - rDataVector.emplace_back(sw::search::NodeType(nType), nIndex); + if (eNodeType != sw::search::NodeType::Undefined && nIndex >= 0) + rDataVector.emplace_back(eNodeType, nIndex); } return true; @@ -145,14 +151,20 @@ bool SearchResultLocator::tryParseXML(const char* pPayload, { if (aWalker.name() == "paragraph") { - OString sType = aWalker.attribute("type"); + OString sType = aWalker.attribute("node_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()); + auto eNodeType = sw::search::NodeType::Undefined; + if (sType == "writer") + eNodeType = sw::search::NodeType::WriterNode; + else if (sType == "common") + eNodeType = sw::search::NodeType::CommonNode; + + aData.meType = eNodeType; rDataVector.push_back(aData); } |