summaryrefslogtreecommitdiff
path: root/sw/source/core/model
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2021-09-08 00:00:57 +0900
committerTomaž Vajngerl <quikee@gmail.com>2021-09-08 11:55:35 +0200
commitcce5a278659b1dafacdf64da8dcfab02dba25d75 (patch)
treefc6d53160fbe04944c8eae316da6f54c9d20a497 /sw/source/core/model
parent9a2d65274073c7b56f0e45f82d580e21b03968b6 (diff)
indexing: rename "parent" attibute and parse the attribute back
Rename the attribute "parent" to "object_name" and "parent_index" and parse the "object_name" attribute for JSON and XML when used as input to SearchResultLocator. Change-Id: I46ad8d6aa14f15d1b759126af71284f7d73a7a96 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121797 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.cxx18
1 files changed, 16 insertions, 2 deletions
diff --git a/sw/source/core/model/SearchResultLocator.cxx b/sw/source/core/model/SearchResultLocator.cxx
index b4f10a16ca72..dd488780981e 100644
--- a/sw/source/core/model/SearchResultLocator.cxx
+++ b/sw/source/core/model/SearchResultLocator.cxx
@@ -110,17 +110,29 @@ bool SearchResultLocator::tryParseJSON(const char* pPayload,
auto const& rEach = rEachNode.second;
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;
+ std::string sJsonObjectName = rEach.get<std::string>("object_name", "");
+
sal_Int32 nIndex = rEach.get<sal_Int32>("index", -1);
// Don't add search data elements that don't have valid data
if (eNodeType != sw::search::NodeType::Undefined && nIndex >= 0)
- rDataVector.emplace_back(eNodeType, nIndex);
+ {
+ OUString sObjectName;
+ if (!sJsonObjectName.empty())
+ {
+ OString sObjectNameOString(sJsonObjectName.c_str());
+ sObjectName = OStringToOUString(sObjectNameOString, RTL_TEXTENCODING_UTF8);
+ }
+
+ rDataVector.emplace_back(eNodeType, nIndex, sObjectName);
+ }
}
return true;
@@ -153,6 +165,7 @@ bool SearchResultLocator::tryParseXML(const char* pPayload,
{
OString sType = aWalker.attribute("node_type");
OString sIndex = aWalker.attribute("index");
+ OString sObjectName = aWalker.attribute("object_name");
if (!sType.isEmpty() && !sIndex.isEmpty())
{
@@ -165,7 +178,8 @@ bool SearchResultLocator::tryParseXML(const char* pPayload,
eNodeType = sw::search::NodeType::CommonNode;
aData.meType = eNodeType;
-
+ if (!sObjectName.isEmpty())
+ aData.maObjectName = OStringToOUString(sObjectName, RTL_TEXTENCODING_UTF8);
rDataVector.push_back(aData);
}
}