diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-10-19 09:08:35 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-10-21 15:25:56 +0200 |
commit | 5f9ffc31cd1b5433c354c7d39ce1d80fa0e57fc8 (patch) | |
tree | 8736f233563535eb3aa5fa019bb92a9970970428 /sw/source/core/model | |
parent | 81debfba86b1d67d1c2e0ecd9c10ca35c3e7de5e (diff) |
introduce SwNodeOffset strong typedef
for indexing into node children. Replaces various usage
of sal_uLong, tools::Long, sal_uInt32 with an underlying
type of sal_Int32.
Also add a NODE_OFFSET_MAX constant to replace usage
of ULONG_MAX
Change-Id: I2f466922e1ebc19029bb2883d2b29aa4c0614170
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123892
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sw/source/core/model')
-rw-r--r-- | sw/source/core/model/ModelTraverser.cxx | 2 | ||||
-rw-r--r-- | sw/source/core/model/SearchResultLocator.cxx | 8 |
2 files changed, 5 insertions, 5 deletions
diff --git a/sw/source/core/model/ModelTraverser.cxx b/sw/source/core/model/ModelTraverser.cxx index bb959a95dec6..b7d2b2200dd6 100644 --- a/sw/source/core/model/ModelTraverser.cxx +++ b/sw/source/core/model/ModelTraverser.cxx @@ -25,7 +25,7 @@ void ModelTraverser::traverse() auto const& pNodes = m_pDoc->GetNodes(); SwNode* pNode = nullptr; - for (sal_uLong n = 0; n < pNodes.Count(); ++n) + for (SwNodeOffset n(0); n < pNodes.Count(); ++n) { pNode = pNodes[n]; if (pNode) diff --git a/sw/source/core/model/SearchResultLocator.cxx b/sw/source/core/model/SearchResultLocator.cxx index 79ba42a97b7c..8ce21c7255ec 100644 --- a/sw/source/core/model/SearchResultLocator.cxx +++ b/sw/source/core/model/SearchResultLocator.cxx @@ -32,7 +32,7 @@ void SearchResultLocator::findOne(LocationResult& rResult, SearchIndexData const if (rSearchIndexData.meType == NodeType::WriterNode) { SwNodes const& rNodes = mpDocument->GetNodes(); - if (rSearchIndexData.mnNodeIndex >= sal_Int32(rNodes.Count())) + if (rSearchIndexData.mnNodeIndex >= rNodes.Count()) return; SwNode* pNode = rNodes[rSearchIndexData.mnNodeIndex]; @@ -118,10 +118,10 @@ bool SearchResultLocator::tryParseJSON(const char* pPayload, std::string sJsonObjectName = rEach.get<std::string>("object_name", ""); - sal_Int32 nIndex = rEach.get<sal_Int32>("index", -1); + SwNodeOffset 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) + if (eNodeType != sw::search::NodeType::Undefined && nIndex >= SwNodeOffset(0)) { OUString sObjectName; if (!sJsonObjectName.empty()) @@ -169,7 +169,7 @@ bool SearchResultLocator::tryParseXML(const char* pPayload, if (!sType.isEmpty() && !sIndex.isEmpty()) { sw::search::SearchIndexData aData; - aData.mnNodeIndex = sIndex.toInt32(); + aData.mnNodeIndex = SwNodeOffset(sIndex.toInt32()); auto eNodeType = sw::search::NodeType::Undefined; if (sType == "writer") eNodeType = sw::search::NodeType::WriterNode; |