23#include <boost/property_tree/json_parser.hpp>
42 if (pContentNode && pShell)
45 = pContentNode->getLayoutFrame(pShell->GetLayout(),
nullptr,
nullptr);
58 for (sal_uInt16 nPage = 0; nPage < pModel->GetPageCount(); ++nPage)
60 SdrPage* pPage = pModel->GetPage(nPage);
61 for (
size_t nObject = 0; nObject < pPage->
GetObjCount(); ++nObject)
68 auto aRect =
pObject->GetLogicRect();
70 rResult.
maRectangles.emplace_back(aRect.Left(), aRect.Top(),
71 aRect.Left() + aRect.GetWidth(),
72 aRect.Top() + aRect.GetHeight());
83 for (
auto const& rSearchIndexData : rSearchIndexDataVector)
84 findOne(aResult, rSearchIndexData);
94 std::vector<sw::search::SearchIndexData>& rDataVector)
96 boost::property_tree::ptree aTree;
97 std::stringstream aStream(pPayload);
100 boost::property_tree::read_json(aStream, aTree);
102 catch (
const boost::property_tree::json_parser_error& )
107 for (
const auto& rEachNode : boost::make_iterator_range(aTree.equal_range(
"")))
109 auto const& rEach = rEachNode.second;
111 std::string
sType = rEach.get<std::string>(
"node_type",
"");
114 if (
sType ==
"writer")
116 else if (
sType ==
"common")
119 std::string sJsonObjectName = rEach.get<std::string>(
"object_name",
"");
126 OUString sObjectName;
127 if (!sJsonObjectName.empty())
129 OString sObjectNameOString(sJsonObjectName);
130 sObjectName = OStringToOUString(sObjectNameOString, RTL_TEXTENCODING_UTF8);
133 rDataVector.emplace_back(eNodeType,
nIndex, sObjectName);
145 std::vector<sw::search::SearchIndexData>& rDataVector)
147 const OString aPayloadString(pPayload);
149 SvMemoryStream aStream(
const_cast<char*
>(aPayloadString.getStr()), aPayloadString.getLength(),
154 if (!aWalker.
open(&aStream))
157 if (aWalker.
name() !=
"indexing")
163 if (aWalker.
name() ==
"paragraph")
166 OString sIndex = aWalker.
attribute(
"index");
167 OString sObjectName = aWalker.
attribute(
"object_name");
169 if (!
sType.isEmpty() && !sIndex.isEmpty())
174 if (
sType ==
"writer")
176 else if (
sType ==
"common")
179 aData.meType = eNodeType;
180 if (!sObjectName.isEmpty())
181 aData.maObjectName = OStringToOUString(sObjectName, RTL_TEXTENCODING_UTF8);
182 rDataVector.push_back(
aData);
193 std::vector<sw::search::SearchIndexData> aDataVector;
199 return find(aDataVector);
virtual const SwDrawModel * GetDrawModel() const =0
Draw Model and id accessors.
virtual const SwViewShell * GetCurrentViewShell() const =0
Returns the layout set at the document.
SdrObject * GetObj(size_t nNum) const
size_t GetObjCount() const
IDocumentLayoutAccess const & getIDocumentLayoutAccess() const
IDocumentDrawModelAccess const & getIDocumentDrawModelAccess() const
const SwRect & getFrameArea() const
Base class of the Writer layout elements.
Base class of the Writer document model elements.
SwContentNode * GetContentNode()
SwNodeOffset Count() const
Of course Writer needs its own rectangles.
void Height(tools::Long nNew)
void Top(const tools::Long nTop)
void Left(const tools::Long nLeft)
void Width(tools::Long nNew)
void findOne(LocationResult &rResult, SearchIndexData const &rSearchIndexData)
static bool tryParseXML(const char *pPayload, std::vector< sw::search::SearchIndexData > &rDataVector)
Trying to parse the payload as XML.
static bool tryParseJSON(const char *pPayload, std::vector< sw::search::SearchIndexData > &rDataVector)
Trying to parse the payload as JSON.
LocationResult findForPayload(const char *pPayload)
LocationResult find(std::vector< SearchIndexData > const &rSearchIndexDataVector)
EmbeddedObjectRef * pObject
constexpr OUStringLiteral aData
o3tl::strong_int< sal_Int32, struct Tag_SwNodeOffset > SwNodeOffset
std::vector< basegfx::B2DRange > maRectangles