Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / sw / source / core / inc / SearchResultLocator.hxx
blobad48e075d27d980853da7d424aa17bcfce4ee4e6
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 */
11 #pragma once
13 #include <swdllapi.h>
14 #include <doc.hxx>
15 #include <basegfx/range/b2drange.hxx>
16 #include <utility>
18 namespace sw::search
20 enum class NodeType
22 Undefined = 0,
23 WriterNode = 1,
24 CommonNode = 2 // node in a SdrObject
27 struct SearchIndexData
29 NodeType meType = NodeType::Undefined;
30 SwNodeOffset mnNodeIndex{ 0 };
31 OUString maObjectName;
33 SearchIndexData() {}
35 SearchIndexData(NodeType eType, SwNodeOffset nNodeIndex, OUString aObjectName = OUString())
36 : meType(eType)
37 , mnNodeIndex(nNodeIndex)
38 , maObjectName(std::move(aObjectName))
43 struct LocationResult
45 bool mbFound = false;
46 std::vector<basegfx::B2DRange> maRectangles;
49 class SW_DLLPUBLIC SearchResultLocator
51 SwDoc* mpDocument;
53 void findOne(LocationResult& rResult, SearchIndexData const& rSearchIndexData);
54 static bool tryParseJSON(const char* pPayload,
55 std::vector<sw::search::SearchIndexData>& rDataVector);
56 static bool tryParseXML(const char* pPayload,
57 std::vector<sw::search::SearchIndexData>& rDataVector);
59 public:
60 SearchResultLocator(SwDoc* pDoc)
61 : mpDocument(pDoc)
65 LocationResult find(std::vector<SearchIndexData> const& rSearchIndexDataVector);
66 LocationResult findForPayload(const char* pPayload);
69 } // end sw namespace
71 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */