1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "LoggedResources.hxx"
21 #include "TagLogger.hxx"
22 #include <ooxml/QNameToString.hxx>
25 using namespace ::com::sun::star
;
27 namespace writerfilter
31 LoggedResourcesHelper::LoggedResourcesHelper(std::string sPrefix
)
32 : msPrefix(std::move(sPrefix
))
36 LoggedResourcesHelper::~LoggedResourcesHelper() {}
38 void LoggedResourcesHelper::startElement(const std::string
& sElement
)
40 TagLogger::getInstance().startElement(msPrefix
+ "." + sElement
);
43 void LoggedResourcesHelper::endElement() { TagLogger::getInstance().endElement(); }
45 void LoggedResourcesHelper::chars(std::u16string_view rChars
)
47 TagLogger::getInstance().chars(rChars
);
50 void LoggedResourcesHelper::chars(const std::string
& rChars
)
52 TagLogger::getInstance().chars(rChars
);
55 void LoggedResourcesHelper::attribute(const std::string
& rName
, const std::string
& rValue
)
57 TagLogger::getInstance().attribute(rName
, rValue
);
60 void LoggedResourcesHelper::attribute(const std::string
& rName
, sal_uInt32 nValue
)
62 TagLogger::getInstance().attribute(rName
, nValue
);
67 LoggedStream::LoggedStream(
69 const std::string
& sPrefix
)
77 LoggedStream::~LoggedStream() {}
79 void LoggedStream::startSectionGroup()
82 mHelper
.startElement("section");
85 lcl_startSectionGroup();
88 void LoggedStream::endSectionGroup()
90 lcl_endSectionGroup();
93 LoggedResourcesHelper::endElement();
97 void LoggedStream::startParagraphGroup()
100 mHelper
.startElement("paragraph");
103 lcl_startParagraphGroup();
106 void LoggedStream::endParagraphGroup()
108 lcl_endParagraphGroup();
111 LoggedResourcesHelper::endElement();
115 void LoggedStream::startCharacterGroup()
118 mHelper
.startElement("charactergroup");
121 lcl_startCharacterGroup();
124 void LoggedStream::endCharacterGroup()
126 lcl_endCharacterGroup();
129 LoggedResourcesHelper::endElement();
133 void LoggedStream::startShape(uno::Reference
<drawing::XShape
> const& xShape
)
136 mHelper
.startElement("shape");
139 lcl_startShape(xShape
);
142 void LoggedStream::endShape()
147 LoggedResourcesHelper::endElement();
151 void LoggedStream::startTextBoxContent() { lcl_startTextBoxContent(); }
153 void LoggedStream::endTextBoxContent() { lcl_endTextBoxContent(); }
155 void LoggedStream::text(const sal_uInt8
* data
, size_t len
)
158 mHelper
.startElement("text");
160 OUString
sText(reinterpret_cast<const char*>(data
), len
, RTL_TEXTENCODING_MS_1252
);
162 mHelper
.startElement("data");
163 LoggedResourcesHelper::chars(sText
);
164 LoggedResourcesHelper::endElement();
170 LoggedResourcesHelper::endElement();
174 void LoggedStream::utext(const sal_uInt8
* data
, size_t len
)
177 mHelper
.startElement("utext");
178 mHelper
.startElement("data");
180 OUString
sText(reinterpret_cast<const sal_Unicode
*>(data
), len
);
182 LoggedResourcesHelper::chars(sText
);
184 LoggedResourcesHelper::endElement();
187 lcl_utext(data
, len
);
190 LoggedResourcesHelper::endElement();
194 void LoggedStream::positionOffset(const OUString
& rText
, bool bVertical
)
197 mHelper
.startElement("positionOffset");
198 LoggedResourcesHelper::attribute("vertical", static_cast<int>(bVertical
));
199 LoggedResourcesHelper::chars(rText
);
202 lcl_positionOffset(rText
, bVertical
);
205 LoggedResourcesHelper::endElement();
209 void LoggedStream::align(const OUString
& rText
, bool bVertical
)
212 mHelper
.startElement("align");
213 LoggedResourcesHelper::attribute("vertical", static_cast<int>(bVertical
));
214 LoggedResourcesHelper::chars(rText
);
217 lcl_align(rText
, bVertical
);
220 LoggedResourcesHelper::endElement();
224 void LoggedStream::positivePercentage(const OUString
& rText
)
227 mHelper
.startElement("positivePercentage");
228 LoggedResourcesHelper::chars(rText
);
231 lcl_positivePercentage(rText
);
234 LoggedResourcesHelper::endElement();
238 void LoggedStream::props(writerfilter::Reference
<Properties
>::Pointer_t ref
)
241 mHelper
.startElement("props");
247 LoggedResourcesHelper::endElement();
251 void LoggedStream::table(Id name
, writerfilter::Reference
<Table
>::Pointer_t ref
)
254 mHelper
.startElement("table");
255 LoggedResourcesHelper::attribute("name", QNameToString(name
));
258 lcl_table(name
, ref
);
261 LoggedResourcesHelper::endElement();
265 void LoggedStream::substream(Id name
, writerfilter::Reference
<Stream
>::Pointer_t ref
)
268 mHelper
.startElement("substream");
269 LoggedResourcesHelper::attribute("name", QNameToString(name
));
272 lcl_substream(name
, ref
);
275 LoggedResourcesHelper::endElement();
279 void LoggedStream::info(const std::string
& _info
)
282 mHelper
.startElement("info");
283 LoggedResourcesHelper::attribute("text", _info
);
289 LoggedResourcesHelper::endElement();
293 void LoggedStream::startGlossaryEntry()
296 mHelper
.startElement("startGlossaryEntry");
299 lcl_startGlossaryEntry();
302 LoggedResourcesHelper::endElement();
306 void LoggedStream::endGlossaryEntry()
309 mHelper
.startElement("endGlossaryEntry");
312 lcl_endGlossaryEntry();
315 LoggedResourcesHelper::endElement();
319 void LoggedStream::checkId(const sal_Int32 nId
)
322 mHelper
.startElement("checkId");
323 LoggedResourcesHelper::chars(OUString::number(nId
));
329 LoggedResourcesHelper::endElement();
333 LoggedProperties::LoggedProperties(
335 const std::string
& sPrefix
)
343 LoggedProperties::~LoggedProperties() {}
345 void LoggedProperties::attribute(Id name
, Value
& val
)
348 mHelper
.startElement("attribute");
349 LoggedResourcesHelper::attribute("name", QNameToString(name
));
350 LoggedResourcesHelper::attribute("value", val
.toString());
351 LoggedResourcesHelper::endElement();
354 lcl_attribute(name
, val
);
357 void LoggedProperties::sprm(Sprm
& rSprm
)
360 mHelper
.startElement("sprm");
361 LoggedResourcesHelper::attribute("name", QNameToString(rSprm
.getId()));
362 LoggedResourcesHelper::chars(rSprm
.toString());
368 LoggedResourcesHelper::endElement();
372 LoggedTable::LoggedTable(
374 const std::string
& sPrefix
)
382 LoggedTable::~LoggedTable() {}
384 void LoggedTable::entry(int pos
, writerfilter::Reference
<Properties
>::Pointer_t ref
)
387 mHelper
.startElement("entry");
388 LoggedResourcesHelper::attribute("pos", pos
);
396 LoggedResourcesHelper::endElement();
401 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */