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 <rtl/ustrbuf.hxx>
21 #include "LoggedResources.hxx"
22 #include <ooxml/QNameToString.hxx>
24 using namespace ::com::sun::star
;
26 namespace writerfilter
29 #ifdef DEBUG_WRITERFILTER
30 // class: LoggedResourcesHelper
32 LoggedResourcesHelper::LoggedResourcesHelper(const std::string
& sPrefix
)
37 LoggedResourcesHelper::~LoggedResourcesHelper()
41 void LoggedResourcesHelper::startElement(const std::string
& sElement
)
43 TagLogger::getInstance().startElement(msPrefix
+ "." + sElement
);
46 void LoggedResourcesHelper::endElement()
48 TagLogger::getInstance().endElement();
51 void LoggedResourcesHelper::chars(const OUString
& rChars
)
53 TagLogger::getInstance().chars(rChars
);
56 void LoggedResourcesHelper::chars(const std::string
& rChars
)
58 TagLogger::getInstance().chars(rChars
);
61 void LoggedResourcesHelper::attribute(const std::string
& rName
, const std::string
& rValue
)
63 TagLogger::getInstance().attribute(rName
, rValue
);
66 void LoggedResourcesHelper::attribute(const std::string
& rName
, sal_uInt32 nValue
)
68 TagLogger::getInstance().attribute(rName
, nValue
);
73 // class: LoggedStream
75 LoggedStream::LoggedStream(
76 #ifdef DEBUG_WRITERFILTER
77 const std::string
& sPrefix
86 LoggedStream::~LoggedStream()
90 void LoggedStream::startSectionGroup()
92 #ifdef DEBUG_WRITERFILTER
93 mHelper
.startElement("section");
96 lcl_startSectionGroup();
99 void LoggedStream::endSectionGroup()
101 lcl_endSectionGroup();
103 #ifdef DEBUG_WRITERFILTER
104 LoggedResourcesHelper::endElement();
108 void LoggedStream::startParagraphGroup()
110 #ifdef DEBUG_WRITERFILTER
111 mHelper
.startElement("paragraph");
114 lcl_startParagraphGroup();
117 void LoggedStream::endParagraphGroup()
119 lcl_endParagraphGroup();
121 #ifdef DEBUG_WRITERFILTER
122 LoggedResourcesHelper::endElement();
127 void LoggedStream::startCharacterGroup()
129 #ifdef DEBUG_WRITERFILTER
130 mHelper
.startElement("charactergroup");
133 lcl_startCharacterGroup();
136 void LoggedStream::endCharacterGroup()
138 lcl_endCharacterGroup();
140 #ifdef DEBUG_WRITERFILTER
141 LoggedResourcesHelper::endElement();
145 void LoggedStream::startShape(uno::Reference
<drawing::XShape
> const& xShape
)
147 #ifdef DEBUG_WRITERFILTER
148 mHelper
.startElement("shape");
151 lcl_startShape(xShape
);
154 void LoggedStream::endShape()
158 #ifdef DEBUG_WRITERFILTER
159 LoggedResourcesHelper::endElement();
163 void LoggedStream::text(const sal_uInt8
* data
, size_t len
)
165 #ifdef DEBUG_WRITERFILTER
166 mHelper
.startElement("text");
168 OUString
sText( reinterpret_cast<const char*>(data
), len
, RTL_TEXTENCODING_MS_1252
);
170 mHelper
.startElement("data");
171 LoggedResourcesHelper::chars(sText
);
172 LoggedResourcesHelper::endElement();
177 #ifdef DEBUG_WRITERFILTER
178 LoggedResourcesHelper::endElement();
182 void LoggedStream::utext(const sal_uInt8
* data
, size_t len
)
184 #ifdef DEBUG_WRITERFILTER
185 mHelper
.startElement("utext");
186 mHelper
.startElement("data");
189 OUStringBuffer aBuffer
= OUStringBuffer(sal::static_int_cast
<int>(len
));
190 aBuffer
.append( reinterpret_cast<const sal_Unicode
*>(data
), len
);
191 sText
= aBuffer
.makeStringAndClear();
193 LoggedResourcesHelper::chars(sText
);
195 LoggedResourcesHelper::endElement();
198 lcl_utext(data
, len
);
200 #ifdef DEBUG_WRITERFILTER
201 LoggedResourcesHelper::endElement();
205 void LoggedStream::positionOffset(const OUString
& rText
, bool bVertical
)
207 #ifdef DEBUG_WRITERFILTER
208 mHelper
.startElement("positionOffset");
209 LoggedResourcesHelper::attribute("vertical", static_cast<int>(bVertical
));
210 LoggedResourcesHelper::chars(rText
);
213 lcl_positionOffset(rText
, bVertical
);
215 #ifdef DEBUG_WRITERFILTER
216 LoggedResourcesHelper::endElement();
220 void LoggedStream::align(const OUString
& rText
, bool bVertical
)
222 #ifdef DEBUG_WRITERFILTER
223 mHelper
.startElement("align");
224 LoggedResourcesHelper::attribute("vertical", static_cast<int>(bVertical
));
225 LoggedResourcesHelper::chars(rText
);
228 lcl_align(rText
, bVertical
);
230 #ifdef DEBUG_WRITERFILTER
231 LoggedResourcesHelper::endElement();
235 void LoggedStream::positivePercentage(const OUString
& rText
)
237 #ifdef DEBUG_WRITERFILTER
238 mHelper
.startElement("positivePercentage");
239 LoggedResourcesHelper::chars(rText
);
242 lcl_positivePercentage(rText
);
244 #ifdef DEBUG_WRITERFILTER
245 LoggedResourcesHelper::endElement();
249 void LoggedStream::props(writerfilter::Reference
<Properties
>::Pointer_t ref
)
251 #ifdef DEBUG_WRITERFILTER
252 mHelper
.startElement("props");
257 #ifdef DEBUG_WRITERFILTER
258 LoggedResourcesHelper::endElement();
262 void LoggedStream::table(Id name
, writerfilter::Reference
<Table
>::Pointer_t ref
)
264 #ifdef DEBUG_WRITERFILTER
265 mHelper
.startElement("table");
266 LoggedResourcesHelper::attribute("name", (*QNameToString::Instance())(name
));
269 lcl_table(name
, ref
);
271 #ifdef DEBUG_WRITERFILTER
272 LoggedResourcesHelper::endElement();
276 void LoggedStream::substream(Id name
, writerfilter::Reference
<Stream
>::Pointer_t ref
)
278 #ifdef DEBUG_WRITERFILTER
279 mHelper
.startElement("substream");
280 LoggedResourcesHelper::attribute("name", (*QNameToString::Instance())(name
));
283 lcl_substream(name
, ref
);
285 #ifdef DEBUG_WRITERFILTER
286 LoggedResourcesHelper::endElement();
290 void LoggedStream::info(const std::string
& _info
)
292 #ifdef DEBUG_WRITERFILTER
293 mHelper
.startElement("info");
294 LoggedResourcesHelper::attribute("text", _info
);
299 #ifdef DEBUG_WRITERFILTER
300 LoggedResourcesHelper::endElement();
304 void LoggedStream::startGlossaryEntry()
306 #ifdef DEBUG_WRITERFILTER
307 mHelper
.startElement("startGlossaryEntry");
310 lcl_startGlossaryEntry();
312 #ifdef DEBUG_WRITERFILTER
313 LoggedResourcesHelper::endElement();
317 void LoggedStream::endGlossaryEntry()
319 #ifdef DEBUG_WRITERFILTER
320 mHelper
.startElement("endGlossaryEntry");
323 lcl_endGlossaryEntry();
325 #ifdef DEBUG_WRITERFILTER
326 LoggedResourcesHelper::endElement();
330 // class LoggedProperties
331 LoggedProperties::LoggedProperties(
332 #ifdef DEBUG_WRITERFILTER
333 const std::string
& sPrefix
342 LoggedProperties::~LoggedProperties()
346 void LoggedProperties::attribute(Id name
, Value
& val
)
348 #ifdef DEBUG_WRITERFILTER
349 mHelper
.startElement("attribute");
350 LoggedResourcesHelper::attribute("name", (*QNameToString::Instance())(name
));
351 LoggedResourcesHelper::attribute("value", val
.toString());
352 LoggedResourcesHelper::endElement();
355 lcl_attribute(name
, val
);
358 void LoggedProperties::sprm(Sprm
& rSprm
)
360 #ifdef DEBUG_WRITERFILTER
361 mHelper
.startElement("sprm");
362 LoggedResourcesHelper::attribute("name", (*QNameToString::Instance())(rSprm
.getId()));
363 LoggedResourcesHelper::chars(rSprm
.toString());
368 #ifdef DEBUG_WRITERFILTER
369 LoggedResourcesHelper::endElement();
373 LoggedTable::LoggedTable(
374 #ifdef DEBUG_WRITERFILTER
375 const std::string
& sPrefix
384 LoggedTable::~LoggedTable()
388 void LoggedTable::entry(int pos
, writerfilter::Reference
<Properties
>::Pointer_t ref
)
390 #ifdef DEBUG_WRITERFILTER
391 mHelper
.startElement("entry");
392 LoggedResourcesHelper::attribute("pos", pos
);
397 #ifdef DEBUG_WRITERFILTER
398 LoggedResourcesHelper::endElement();
404 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */