Bump version to 4.3-4
[LibreOffice.git] / writerfilter / source / resourcemodel / LoggedResources.cxx
blobbdff38ae1ebc9ad90048e4b009ff1aa009e51d80
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 * 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 <resourcemodel/LoggedResources.hxx>
22 #include <resourcemodel/QNameToString.hxx>
24 namespace writerfilter
27 #ifdef DEBUG_LOGGING
28 // class: LoggedResourcesHelper
30 LoggedResourcesHelper::LoggedResourcesHelper(TagLogger::Pointer_t pLogger, const std::string & sPrefix)
31 : mpLogger(pLogger), msPrefix(sPrefix)
35 LoggedResourcesHelper::~LoggedResourcesHelper()
39 void LoggedResourcesHelper::startElement(const std::string & sElement)
41 mpLogger->startElement(msPrefix + "." + sElement);
44 void LoggedResourcesHelper::endElement(const std::string & /*sElement*/)
46 mpLogger->endElement();
49 void LoggedResourcesHelper::chars(const OUString & rChars)
51 mpLogger->chars(rChars);
54 void LoggedResourcesHelper::chars(const std::string & rChars)
56 mpLogger->chars(rChars);
59 void LoggedResourcesHelper::attribute(const std::string & rName, const std::string & rValue)
61 mpLogger->attribute(rName, rValue);
64 void LoggedResourcesHelper::attribute(const std::string & rName, sal_uInt32 nValue)
66 mpLogger->attribute(rName, nValue);
69 #endif
71 // class: LoggedStream
73 LoggedStream::LoggedStream(
74 #ifdef DEBUG_LOGGING
75 TagLogger::Pointer_t pLogger,
76 const std::string & sPrefix
77 ) : mHelper(pLogger, sPrefix)
78 #else
79 TagLogger::Pointer_t,
80 const std::string&
82 #endif
86 LoggedStream::~LoggedStream()
90 void LoggedStream::startSectionGroup()
92 #ifdef DEBUG_LOGGING
93 mHelper.startElement("section");
94 #endif
96 lcl_startSectionGroup();
99 void LoggedStream::endSectionGroup()
101 lcl_endSectionGroup();
103 #ifdef DEBUG_LOGGING
104 mHelper.endElement("section");
105 #endif
108 void LoggedStream::startParagraphGroup()
110 #ifdef DEBUG_LOGGING
111 mHelper.startElement("paragraph");
112 #endif
114 lcl_startParagraphGroup();
117 void LoggedStream::endParagraphGroup()
119 lcl_endParagraphGroup();
121 #ifdef DEBUG_LOGGING
122 mHelper.endElement("paragraph");
123 #endif
127 void LoggedStream::startCharacterGroup()
129 #ifdef DEBUG_LOGGING
130 mHelper.startElement("charactergroup");
131 #endif
133 lcl_startCharacterGroup();
136 void LoggedStream::endCharacterGroup()
138 lcl_endCharacterGroup();
140 #ifdef DEBUG_LOGGING
141 mHelper.endElement("charactergroup");
142 #endif
145 void LoggedStream::startShape( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape )
147 #ifdef DEBUG_LOGGING
148 mHelper.startElement("shape");
149 #endif
151 lcl_startShape(xShape);
154 void LoggedStream::endShape()
156 lcl_endShape();
158 #ifdef DEBUG_LOGGING
159 mHelper.endElement("shape");
160 #endif
163 void LoggedStream::text(const sal_uInt8 * data, size_t len)
165 #ifdef DEBUG_LOGGING
166 mHelper.startElement("text");
168 OUString sText( (const sal_Char*) data, len, RTL_TEXTENCODING_MS_1252 );
170 mHelper.startElement("data");
171 mHelper.chars(sText);
172 mHelper.endElement("data");
173 #endif
175 lcl_text(data, len);
177 #ifdef DEBUG_LOGGING
178 mHelper.endElement("text");
179 #endif
182 void LoggedStream::utext(const sal_uInt8 * data, size_t len)
184 #ifdef DEBUG_LOGGING
185 mHelper.startElement("utext");
186 mHelper.startElement("data");
188 OUString sText;
189 OUStringBuffer aBuffer = OUStringBuffer(len);
190 aBuffer.append( (const sal_Unicode *) data, len);
191 sText = aBuffer.makeStringAndClear();
193 mHelper.chars(sText);
195 mHelper.endElement("data");
196 #endif
198 lcl_utext(data, len);
200 #ifdef DEBUG_LOGGING
201 mHelper.endElement("utext");
202 #endif
205 void LoggedStream::positivePercentage(const OUString& rText)
207 #ifdef DEBUG_LOGGING
208 mHelper.startElement("positivePercentage");
209 mHelper.chars(rText);
210 #endif
212 lcl_positivePercentage(rText);
214 #ifdef DEBUG_LOGGING
215 mHelper.endElement("positivePercentage");
216 #endif
219 void LoggedStream::props(writerfilter::Reference<Properties>::Pointer_t ref)
221 #ifdef DEBUG_LOGGING
222 mHelper.startElement("props");
223 #endif
225 lcl_props(ref);
227 #ifdef DEBUG_LOGGING
228 mHelper.endElement("props");
229 #endif
232 void LoggedStream::table(Id name, writerfilter::Reference<Table>::Pointer_t ref)
234 #ifdef DEBUG_LOGGING
235 mHelper.startElement("table");
236 mHelper.attribute("name", (*QNameToString::Instance())(name));
237 #endif
239 lcl_table(name, ref);
241 #ifdef DEBUG_LOGGING
242 mHelper.endElement("table");
243 #endif
246 void LoggedStream::substream(Id name, writerfilter::Reference<Stream>::Pointer_t ref)
248 #ifdef DEBUG_LOGGING
249 mHelper.startElement("substream");
250 mHelper.attribute("name", (*QNameToString::Instance())(name));
251 #endif
253 lcl_substream(name, ref);
255 #ifdef DEBUG_LOGGING
256 mHelper.endElement("substream");
257 #endif
260 void LoggedStream::info(const std::string & _info)
262 #ifdef DEBUG_LOGGING
263 mHelper.startElement("info");
264 mHelper.attribute("text", _info);
265 #endif
267 lcl_info(_info);
269 #ifdef DEBUG_LOGGING
270 mHelper.endElement("info");
271 #endif
274 // class LoggedProperties
275 LoggedProperties::LoggedProperties(
276 #ifdef DEBUG_LOGGING
277 TagLogger::Pointer_t pLogger,
278 const std::string & sPrefix
279 ) : mHelper(pLogger, sPrefix)
280 #else
281 TagLogger::Pointer_t,
282 const std::string&
284 #endif
288 LoggedProperties::~LoggedProperties()
292 void LoggedProperties::attribute(Id name, Value & val)
294 #ifdef DEBUG_LOGGING
295 mHelper.startElement("attribute");
296 mHelper.attribute("name", (*QNameToString::Instance())(name));
297 mHelper.attribute("value", val.toString());
298 mHelper.endElement("attribute");
299 #endif
301 lcl_attribute(name, val);
304 void LoggedProperties::sprm(Sprm & rSprm)
306 #ifdef DEBUG_LOGGING
307 mHelper.startElement("sprm");
308 mHelper.attribute("name", (*QNameToString::Instance())(rSprm.getId()));
309 mHelper.chars(rSprm.toString());
310 #endif
312 lcl_sprm(rSprm);
314 #ifdef DEBUG_LOGGING
315 mHelper.endElement("sprm");
316 #endif
319 LoggedTable::LoggedTable(
320 #ifdef DEBUG_LOGGING
321 TagLogger::Pointer_t pLogger,
322 const std::string & sPrefix
323 ) : mHelper(pLogger, sPrefix)
324 #else
325 TagLogger::Pointer_t,
326 const std::string&
328 #endif
332 LoggedTable::~LoggedTable()
336 void LoggedTable::entry(int pos, writerfilter::Reference<Properties>::Pointer_t ref)
338 #ifdef DEBUG_LOGGING
339 mHelper.startElement("entry");
340 mHelper.attribute("pos", pos);
341 #endif
343 lcl_entry(pos, ref);
345 #ifdef DEBUG_LOGGING
346 mHelper.endElement("entry");
347 #endif
352 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */