diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2021-08-12 22:48:31 +0900 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2021-08-13 06:21:45 +0200 |
commit | adf65471e889676a600a9c6d0454c75cbd549ad3 (patch) | |
tree | 7f9a3e48345a737dbb5a81b2daf105c0e600255a /sw/source/core/model | |
parent | be710c72a6302829bf7f632c8ad6dc72be51fd95 (diff) |
indexing: allow for multiple entries in search indexing data
Change-Id: Idb9bbbaa940b7cd48423c6cc65b9c7d0b94f57dc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120396
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 | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/sw/source/core/model/SearchResultLocator.cxx b/sw/source/core/model/SearchResultLocator.cxx index 9b22c61fa441..0b91c7a507e9 100644 --- a/sw/source/core/model/SearchResultLocator.cxx +++ b/sw/source/core/model/SearchResultLocator.cxx @@ -22,15 +22,14 @@ namespace sw::search { -LocationResult SearchResultLocator::find(SearchIndexData const& rSearchIndexData) +void SearchResultLocator::findOne(LocationResult& rResult, SearchIndexData const& rSearchIndexData) { - LocationResult aResult; - if (rSearchIndexData.eType == NodeType::WriterNode) + if (rSearchIndexData.meType == NodeType::WriterNode) { SwNodes const& rNodes = mpDocument->GetNodes(); - if (rSearchIndexData.nNodeIndex >= rNodes.Count()) - return aResult; - SwNode* pNode = rNodes[rSearchIndexData.nNodeIndex]; + if (rSearchIndexData.mnNodeIndex >= rNodes.Count()) + return; + SwNode* pNode = rNodes[rSearchIndexData.mnNodeIndex]; auto* pContentNode = pNode->GetContentNode(); auto* pShell = mpDocument->getIDocumentLayoutAccess().GetCurrentViewShell(); @@ -41,13 +40,13 @@ LocationResult SearchResultLocator::find(SearchIndexData const& rSearchIndexData = pContentNode->getLayoutFrame(pShell->GetLayout(), nullptr, nullptr); SwRect const& rArea = pFrame->getFrameArea(); - aResult.mbFound = true; - aResult.maRectangles.emplace_back(rArea.Left(), rArea.Top(), + rResult.mbFound = true; + rResult.maRectangles.emplace_back(rArea.Left(), rArea.Top(), rArea.Left() + rArea.Width(), rArea.Top() + rArea.Height()); } } - else if (rSearchIndexData.eType == NodeType::SdrObject) + else if (rSearchIndexData.meType == NodeType::SdrObject) { IDocumentDrawModelAccess& rDrawModelAccess = mpDocument->getIDocumentDrawModelAccess(); auto* pModel = rDrawModelAccess.GetDrawModel(); @@ -59,12 +58,12 @@ LocationResult SearchResultLocator::find(SearchIndexData const& rSearchIndexData SdrObject* pObject = pPage->GetObj(nObject); if (pObject) { - if (pObject->GetName() == rSearchIndexData.aObjectName) + if (pObject->GetName() == rSearchIndexData.maObjectName) { auto aRect = o3tl::convert(pObject->GetLogicRect(), o3tl::Length::mm100, o3tl::Length::twip); - aResult.mbFound = true; - aResult.maRectangles.emplace_back(aRect.Left(), aRect.Top(), + rResult.mbFound = true; + rResult.maRectangles.emplace_back(aRect.Left(), aRect.Top(), aRect.Left() + aRect.GetWidth(), aRect.Top() + aRect.GetHeight()); } @@ -72,6 +71,13 @@ LocationResult SearchResultLocator::find(SearchIndexData const& rSearchIndexData } } } +} + +LocationResult SearchResultLocator::find(std::vector<SearchIndexData> const& rSearchIndexDataVector) +{ + LocationResult aResult; + for (auto const& rSearchIndexData : rSearchIndexDataVector) + findOne(aResult, rSearchIndexData); return aResult; } |