LibreOffice Module writerfilter (master) 1
LoggedResources.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#include "LoggedResources.hxx"
21#include "TagLogger.hxx"
23#include <utility>
24
25using namespace ::com::sun::star;
26
27namespace writerfilter
28{
29#ifdef DBG_UTIL
30
32 : msPrefix(std::move(sPrefix))
33{
34}
35
37
38void LoggedResourcesHelper::startElement(const std::string& sElement)
39{
41}
42
44
45void LoggedResourcesHelper::chars(std::u16string_view rChars)
46{
48}
49
50void LoggedResourcesHelper::chars(const std::string& rChars)
51{
53}
54
55void LoggedResourcesHelper::attribute(const std::string& rName, const std::string& rValue)
56{
57 TagLogger::getInstance().attribute(rName, rValue);
58}
59
60void LoggedResourcesHelper::attribute(const std::string& rName, sal_uInt32 nValue)
61{
63}
64
65#endif
66
68#ifdef DBG_UTIL
69 const std::string& sPrefix)
70 : mHelper(sPrefix)
71#else
72 const std::string&)
73#endif
74{
75}
76
78
80{
81#ifdef DBG_UTIL
82 mHelper.startElement("section");
83#endif
84
86}
87
89{
91
92#ifdef DBG_UTIL
94#endif
95}
96
98{
99#ifdef DBG_UTIL
100 mHelper.startElement("paragraph");
101#endif
102
104}
105
107{
109
110#ifdef DBG_UTIL
112#endif
113}
114
116{
117#ifdef DBG_UTIL
118 mHelper.startElement("charactergroup");
119#endif
120
122}
123
125{
127
128#ifdef DBG_UTIL
130#endif
131}
132
134{
135#ifdef DBG_UTIL
136 mHelper.startElement("shape");
137#endif
138
139 lcl_startShape(xShape);
140}
141
143{
144 lcl_endShape();
145
146#ifdef DBG_UTIL
148#endif
149}
150
152
154
155void LoggedStream::text(const sal_uInt8* data, size_t len)
156{
157#ifdef DBG_UTIL
158 mHelper.startElement("text");
159
160 OUString sText(reinterpret_cast<const char*>(data), len, RTL_TEXTENCODING_MS_1252);
161
162 mHelper.startElement("data");
165#endif
166
167 lcl_text(data, len);
168
169#ifdef DBG_UTIL
171#endif
172}
173
174void LoggedStream::utext(const sal_uInt8* data, size_t len)
175{
176#ifdef DBG_UTIL
177 mHelper.startElement("utext");
178 mHelper.startElement("data");
179
180 OUString sText(reinterpret_cast<const sal_Unicode*>(data), len);
181
183
185#endif
186
187 lcl_utext(data, len);
188
189#ifdef DBG_UTIL
191#endif
192}
193
194void LoggedStream::positionOffset(const OUString& rText, bool bVertical)
195{
196#ifdef DBG_UTIL
197 mHelper.startElement("positionOffset");
198 LoggedResourcesHelper::attribute("vertical", static_cast<int>(bVertical));
200#endif
201
202 lcl_positionOffset(rText, bVertical);
203
204#ifdef DBG_UTIL
206#endif
207}
208
209void LoggedStream::align(const OUString& rText, bool bVertical)
210{
211#ifdef DBG_UTIL
212 mHelper.startElement("align");
213 LoggedResourcesHelper::attribute("vertical", static_cast<int>(bVertical));
215#endif
216
217 lcl_align(rText, bVertical);
218
219#ifdef DBG_UTIL
221#endif
222}
223
224void LoggedStream::positivePercentage(const OUString& rText)
225{
226#ifdef DBG_UTIL
227 mHelper.startElement("positivePercentage");
229#endif
230
232
233#ifdef DBG_UTIL
235#endif
236}
237
239{
240#ifdef DBG_UTIL
241 mHelper.startElement("props");
242#endif
243
244 lcl_props(ref);
245
246#ifdef DBG_UTIL
248#endif
249}
250
252{
253#ifdef DBG_UTIL
254 mHelper.startElement("table");
256#endif
257
258 lcl_table(name, ref);
259
260#ifdef DBG_UTIL
262#endif
263}
264
266{
267#ifdef DBG_UTIL
268 mHelper.startElement("substream");
270#endif
271
272 lcl_substream(name, ref);
273
274#ifdef DBG_UTIL
276#endif
277}
278
279void LoggedStream::info(const std::string& _info)
280{
281#ifdef DBG_UTIL
282 mHelper.startElement("info");
284#else
285 (void)_info;
286#endif
287
288#ifdef DBG_UTIL
290#endif
291}
292
294{
295#ifdef DBG_UTIL
296 mHelper.startElement("startGlossaryEntry");
297#endif
298
300
301#ifdef DBG_UTIL
303#endif
304}
305
307{
308#ifdef DBG_UTIL
309 mHelper.startElement("endGlossaryEntry");
310#endif
311
313
314#ifdef DBG_UTIL
316#endif
317}
318
319void LoggedStream::checkId(const sal_Int32 nId)
320{
321#ifdef DBG_UTIL
322 mHelper.startElement("checkId");
323 LoggedResourcesHelper::chars(OUString::number(nId));
324#endif
325
327
328#ifdef DBG_UTIL
330#endif
331}
332
334#ifdef DBG_UTIL
335 const std::string& sPrefix)
336 : mHelper(sPrefix)
337#else
338 const std::string&)
339#endif
340{
341}
342
344
346{
347#ifdef DBG_UTIL
348 mHelper.startElement("attribute");
352#endif
353
354 lcl_attribute(name, val);
355}
356
358{
359#ifdef DBG_UTIL
360 mHelper.startElement("sprm");
363#endif
364
365 lcl_sprm(rSprm);
366
367#ifdef DBG_UTIL
369#endif
370}
371
373#ifdef DBG_UTIL
374 const std::string& sPrefix)
375 : mHelper(sPrefix)
376#else
377 const std::string&)
378#endif
379{
380}
381
383
385{
386#ifdef DBG_UTIL
387 mHelper.startElement("entry");
389#else
390 (void)pos;
391#endif
392
393 lcl_entry(ref);
394
395#ifdef DBG_UTIL
397#endif
398}
399}
400
401/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void sprm(Sprm &sprm) override
Receives a SPRM.
virtual void lcl_attribute(Id name, Value &val)=0
virtual ~LoggedProperties() override
void attribute(Id name, Value &val) override
Receives an attribute.
LoggedProperties(const std::string &sPrefix)
virtual void lcl_sprm(Sprm &sprm)=0
static void chars(std::u16string_view rChars)
void startElement(const std::string &sElement)
static void attribute(const std::string &rName, const std::string &rValue)
LoggedResourcesHelper(std::string sPrefix)
virtual void lcl_startSectionGroup()=0
void startCharacterGroup() override
Receives start mark for group with the same character properties.
virtual void lcl_utext(const sal_uInt8 *data, size_t len)=0
virtual void lcl_text(const sal_uInt8 *data, size_t len)=0
virtual void lcl_startCharacterGroup()=0
void startGlossaryEntry() override
Receives start mark for glossary document entry.
virtual void lcl_props(writerfilter::Reference< Properties >::Pointer_t ref)=0
LoggedResourcesHelper mHelper
virtual void lcl_startShape(css::uno::Reference< css::drawing::XShape > const &xShape)=0
virtual void lcl_substream(Id name, writerfilter::Reference< Stream >::Pointer_t ref)=0
void endParagraphGroup() override
Receives end mark for group with the same paragraph properties.
virtual void lcl_startParagraphGroup()=0
virtual void lcl_startGlossaryEntry()
void props(writerfilter::Reference< Properties >::Pointer_t ref) override
Receives properties of the current run of text.
void table(Id name, writerfilter::Reference< Table >::Pointer_t ref) override
Receives table.
void endCharacterGroup() override
Receives end mark for group with the same character properties.
void substream(Id name, writerfilter::Reference< Stream >::Pointer_t ref) override
Receives a substream.
void align(const OUString &rText, bool bVertical) override
Horizontal and vertical alignment for a shape.
virtual void lcl_positionOffset(const OUString &, bool)
void startSectionGroup() override
Receives start mark for group with the same section properties.
virtual void lcl_startTextBoxContent()=0
LoggedStream(const std::string &sPrefix)
virtual void lcl_endSectionGroup()=0
void text(const sal_uInt8 *data, size_t len) override
Receives 8-bit per character text.
virtual ~LoggedStream() override
void checkId(const sal_Int32 nId) override
Receives identifier for node entry.
virtual void lcl_endParagraphGroup()=0
void endSectionGroup() override
Receives end mark for group with the same section properties.
void utext(const sal_uInt8 *data, size_t len) override
Receives 16-bit per character text.
void positivePercentage(const OUString &rText) override
virtual void lcl_positivePercentage(const OUString &)
void info(const std::string &info) override
Debugging: Receives information about current point in stream.
virtual void lcl_align(const OUString &, bool)
virtual void lcl_endCharacterGroup()=0
virtual void lcl_checkId(const sal_Int32)
void startTextBoxContent() override
Receives a text-box-content.
virtual void lcl_table(Id name, writerfilter::Reference< Table >::Pointer_t ref)=0
void positionOffset(const OUString &rText, bool bVertical) override
Offset in EMUs for a shape.
virtual void lcl_endTextBoxContent()=0
void startParagraphGroup() override
Receives start mark for group with the same paragraph properties.
void endGlossaryEntry() override
Receives end mark for glossary document entry.
virtual void lcl_endShape()=0
void startShape(css::uno::Reference< css::drawing::XShape > const &xShape) override
Receives a shape.
virtual void lcl_entry(writerfilter::Reference< Properties >::Pointer_t ref)=0
LoggedTable(const std::string &sPrefix)
LoggedResourcesHelper mHelper
void entry(int pos, writerfilter::Reference< Properties >::Pointer_t ref) override
Receives an entry of the table.
virtual ~LoggedTable() override
An SPRM: Section, Paragraph and Run Modifier.
virtual sal_uInt32 getId() const =0
Returns id of the SPRM.
virtual std::string toString() const =0
Returns string representation of sprm.
static TagLogger & getInstance()
Definition: TagLogger.cxx:95
void startElement(const std::string &name)
Definition: TagLogger.cxx:140
void chars(const std::string &chars)
Definition: TagLogger.cxx:215
void attribute(const std::string &name, const std::string &value)
Definition: TagLogger.cxx:150
virtual std::string toString() const =0
Returns string representation of this value.
sal_Int16 nValue
OUString sPrefix
const char * name
std::string QNameToString(Id)
sal_Int16 nId
sal_uInt32 Id
unsigned char sal_uInt8
sal_uInt16 sal_Unicode
size_t pos