Line data Source code
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 <rtl/ustrbuf.hxx>
21 : #include <resourcemodel/LoggedResources.hxx>
22 : #include <resourcemodel/QNameToString.hxx>
23 :
24 : namespace writerfilter
25 : {
26 :
27 : #ifdef DEBUG_LOGGING
28 : // class: LoggedResourcesHelper
29 :
30 : LoggedResourcesHelper::LoggedResourcesHelper(TagLogger::Pointer_t pLogger, const string & sPrefix)
31 : : mpLogger(pLogger), msPrefix(sPrefix)
32 : {
33 : }
34 :
35 : LoggedResourcesHelper::~LoggedResourcesHelper()
36 : {
37 : }
38 :
39 : void LoggedResourcesHelper::startElement(const string & sElement)
40 : {
41 : mpLogger->startElement(msPrefix + "." + sElement);
42 : }
43 :
44 : void LoggedResourcesHelper::endElement(const string & /*sElement*/)
45 : {
46 : mpLogger->endElement();
47 : }
48 :
49 : void LoggedResourcesHelper::chars(const OUString & rChars)
50 : {
51 : mpLogger->chars(rChars);
52 : }
53 :
54 : void LoggedResourcesHelper::chars(const string & rChars)
55 : {
56 : mpLogger->chars(rChars);
57 : }
58 :
59 : void LoggedResourcesHelper::attribute(const string & rName, const string & rValue)
60 : {
61 : mpLogger->attribute(rName, rValue);
62 : }
63 :
64 : void LoggedResourcesHelper::attribute(const string & rName, sal_uInt32 nValue)
65 : {
66 : mpLogger->attribute(rName, nValue);
67 : }
68 :
69 : #endif
70 :
71 : // class: LoggedStream
72 :
73 3108 : LoggedStream::LoggedStream(
74 : #ifdef DEBUG_LOGGING
75 : TagLogger::Pointer_t pLogger,
76 : const string & sPrefix
77 : ) : mHelper(pLogger, sPrefix)
78 : #else
79 : TagLogger::Pointer_t,
80 : const string&
81 3108 : )
82 : #endif
83 : {
84 3108 : }
85 :
86 3108 : LoggedStream::~LoggedStream()
87 : {
88 3108 : }
89 :
90 1356 : void LoggedStream::startSectionGroup()
91 : {
92 : #ifdef DEBUG_LOGGING
93 : mHelper.startElement("section");
94 : #endif
95 :
96 1356 : lcl_startSectionGroup();
97 1356 : }
98 :
99 1351 : void LoggedStream::endSectionGroup()
100 : {
101 1351 : lcl_endSectionGroup();
102 :
103 : #ifdef DEBUG_LOGGING
104 : mHelper.endElement("section");
105 : #endif
106 1351 : }
107 :
108 21770 : void LoggedStream::startParagraphGroup()
109 : {
110 : #ifdef DEBUG_LOGGING
111 : mHelper.startElement("paragraph");
112 : #endif
113 :
114 21770 : lcl_startParagraphGroup();
115 21770 : }
116 :
117 21764 : void LoggedStream::endParagraphGroup()
118 : {
119 21764 : lcl_endParagraphGroup();
120 :
121 : #ifdef DEBUG_LOGGING
122 : mHelper.endElement("paragraph");
123 : #endif
124 21764 : }
125 :
126 :
127 53807 : void LoggedStream::startCharacterGroup()
128 : {
129 : #ifdef DEBUG_LOGGING
130 : mHelper.startElement("charactergroup");
131 : #endif
132 :
133 53807 : lcl_startCharacterGroup();
134 53807 : }
135 :
136 53804 : void LoggedStream::endCharacterGroup()
137 : {
138 53804 : lcl_endCharacterGroup();
139 :
140 : #ifdef DEBUG_LOGGING
141 : mHelper.endElement("charactergroup");
142 : #endif
143 53804 : }
144 :
145 1016 : void LoggedStream::startShape( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape )
146 : {
147 : #ifdef DEBUG_LOGGING
148 : mHelper.startElement("shape");
149 : #endif
150 :
151 1016 : lcl_startShape(xShape);
152 1016 : }
153 :
154 1016 : void LoggedStream::endShape()
155 : {
156 1016 : lcl_endShape();
157 :
158 : #ifdef DEBUG_LOGGING
159 : mHelper.endElement("shape");
160 : #endif
161 1016 : }
162 :
163 7003 : void LoggedStream::text(const sal_uInt8 * data, size_t len)
164 : {
165 : #ifdef DEBUG_LOGGING
166 : mHelper.startElement("text");
167 :
168 : OUString sText( (const sal_Char*) data, len, RTL_TEXTENCODING_MS_1252 );
169 :
170 : mHelper.startElement("data");
171 : mHelper.chars(sText);
172 : mHelper.endElement("data");
173 : #endif
174 :
175 7003 : lcl_text(data, len);
176 :
177 : #ifdef DEBUG_LOGGING
178 : mHelper.endElement("text");
179 : #endif
180 7003 : }
181 :
182 58964 : void LoggedStream::utext(const sal_uInt8 * data, size_t len)
183 : {
184 : #ifdef DEBUG_LOGGING
185 : mHelper.startElement("utext");
186 : mHelper.startElement("data");
187 :
188 : OUString sText;
189 : OUStringBuffer aBuffer = OUStringBuffer(len);
190 : aBuffer.append( (const sal_Unicode *) data, len);
191 : sText = aBuffer.makeStringAndClear();
192 :
193 : mHelper.chars(sText);
194 :
195 : mHelper.endElement("data");
196 : #endif
197 :
198 58964 : lcl_utext(data, len);
199 :
200 : #ifdef DEBUG_LOGGING
201 : mHelper.endElement("utext");
202 : #endif
203 58964 : }
204 :
205 637 : void LoggedStream::positivePercentage(const OUString& rText)
206 : {
207 : #ifdef DEBUG_LOGGING
208 : mHelper.startElement("positivePercentage");
209 : mHelper.chars(rText);
210 : #endif
211 :
212 637 : lcl_positivePercentage(rText);
213 :
214 : #ifdef DEBUG_LOGGING
215 : mHelper.endElement("positivePercentage");
216 : #endif
217 637 : }
218 :
219 114742 : void LoggedStream::props(writerfilter::Reference<Properties>::Pointer_t ref)
220 : {
221 : #ifdef DEBUG_LOGGING
222 : mHelper.startElement("props");
223 : #endif
224 :
225 114742 : lcl_props(ref);
226 :
227 : #ifdef DEBUG_LOGGING
228 : mHelper.endElement("props");
229 : #endif
230 114742 : }
231 :
232 4137 : void LoggedStream::table(Id name, writerfilter::Reference<Table>::Pointer_t ref)
233 : {
234 : #ifdef DEBUG_LOGGING
235 : mHelper.startElement("table");
236 : mHelper.attribute("name", (*QNameToString::Instance())(name));
237 : #endif
238 :
239 4137 : lcl_table(name, ref);
240 :
241 : #ifdef DEBUG_LOGGING
242 : mHelper.endElement("table");
243 : #endif
244 4137 : }
245 :
246 866 : void LoggedStream::substream(Id name, writerfilter::Reference<Stream>::Pointer_t ref)
247 : {
248 : #ifdef DEBUG_LOGGING
249 : mHelper.startElement("substream");
250 : mHelper.attribute("name", (*QNameToString::Instance())(name));
251 : #endif
252 :
253 866 : lcl_substream(name, ref);
254 :
255 : #ifdef DEBUG_LOGGING
256 : mHelper.endElement("substream");
257 : #endif
258 866 : }
259 :
260 19298 : void LoggedStream::info(const string & _info)
261 : {
262 : #ifdef DEBUG_LOGGING
263 : mHelper.startElement("info");
264 : mHelper.attribute("text", _info);
265 : #endif
266 :
267 19298 : lcl_info(_info);
268 :
269 : #ifdef DEBUG_LOGGING
270 : mHelper.endElement("info");
271 : #endif
272 19298 : }
273 :
274 : // class LoggedProperties
275 184596 : LoggedProperties::LoggedProperties(
276 : #ifdef DEBUG_LOGGING
277 : TagLogger::Pointer_t pLogger,
278 : const string & sPrefix
279 : ) : mHelper(pLogger, sPrefix)
280 : #else
281 : TagLogger::Pointer_t,
282 : const string&
283 184596 : )
284 : #endif
285 : {
286 184596 : }
287 :
288 184596 : LoggedProperties::~LoggedProperties()
289 : {
290 184596 : }
291 :
292 1109040 : void LoggedProperties::attribute(Id name, Value & val)
293 : {
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
300 :
301 1109040 : lcl_attribute(name, val);
302 1109040 : }
303 :
304 895794 : void LoggedProperties::sprm(Sprm & rSprm)
305 : {
306 : #ifdef DEBUG_LOGGING
307 : mHelper.startElement("sprm");
308 : mHelper.attribute("name", (*QNameToString::Instance())(rSprm.getId()));
309 : mHelper.chars(rSprm.toString());
310 : #endif
311 :
312 895794 : lcl_sprm(rSprm);
313 :
314 : #ifdef DEBUG_LOGGING
315 : mHelper.endElement("sprm");
316 : #endif
317 895794 : }
318 :
319 6458 : LoggedTable::LoggedTable(
320 : #ifdef DEBUG_LOGGING
321 : TagLogger::Pointer_t pLogger,
322 : const string & sPrefix
323 : ) : mHelper(pLogger, sPrefix)
324 : #else
325 : TagLogger::Pointer_t,
326 : const string&
327 6458 : )
328 : #endif
329 : {
330 6458 : }
331 :
332 6458 : LoggedTable::~LoggedTable()
333 : {
334 6458 : }
335 :
336 37459 : void LoggedTable::entry(int pos, writerfilter::Reference<Properties>::Pointer_t ref)
337 : {
338 : #ifdef DEBUG_LOGGING
339 : mHelper.startElement("entry");
340 : mHelper.attribute("pos", pos);
341 : #endif
342 :
343 37459 : lcl_entry(pos, ref);
344 :
345 : #ifdef DEBUG_LOGGING
346 : mHelper.endElement("entry");
347 : #endif
348 37459 : }
349 :
350 42 : }
351 :
352 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|