Branch data 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 : 904 : 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 : 904 : )
82 : : #endif
83 : : {
84 : 904 : }
85 : :
86 : 904 : LoggedStream::~LoggedStream()
87 : : {
88 [ - + ]: 904 : }
89 : :
90 : 530 : void LoggedStream::startSectionGroup()
91 : : {
92 : : #ifdef DEBUG_LOGGING
93 : : mHelper.startElement("section");
94 : : #endif
95 : :
96 : 530 : lcl_startSectionGroup();
97 : 530 : }
98 : :
99 : 524 : void LoggedStream::endSectionGroup()
100 : : {
101 : 524 : lcl_endSectionGroup();
102 : :
103 : : #ifdef DEBUG_LOGGING
104 : : mHelper.endElement("section");
105 : : #endif
106 : 524 : }
107 : :
108 : 2516 : void LoggedStream::startParagraphGroup()
109 : : {
110 : : #ifdef DEBUG_LOGGING
111 : : mHelper.startElement("paragraph");
112 : : #endif
113 : :
114 : 2516 : lcl_startParagraphGroup();
115 : 2516 : }
116 : :
117 : 2480 : void LoggedStream::endParagraphGroup()
118 : : {
119 : 2480 : lcl_endParagraphGroup();
120 : :
121 : : #ifdef DEBUG_LOGGING
122 : : mHelper.endElement("paragraph");
123 : : #endif
124 : 2480 : }
125 : :
126 : :
127 : 14511 : void LoggedStream::startCharacterGroup()
128 : : {
129 : : #ifdef DEBUG_LOGGING
130 : : mHelper.startElement("charactergroup");
131 : : #endif
132 : :
133 : 14511 : lcl_startCharacterGroup();
134 : 14511 : }
135 : :
136 : 14478 : void LoggedStream::endCharacterGroup()
137 : : {
138 : 14478 : lcl_endCharacterGroup();
139 : :
140 : : #ifdef DEBUG_LOGGING
141 : : mHelper.endElement("charactergroup");
142 : : #endif
143 : 14478 : }
144 : :
145 : 75 : 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 [ + - ]: 75 : lcl_startShape(xShape);
152 : 75 : }
153 : :
154 : 75 : void LoggedStream::endShape()
155 : : {
156 : 75 : lcl_endShape();
157 : :
158 : : #ifdef DEBUG_LOGGING
159 : : mHelper.endElement("shape");
160 : : #endif
161 : 75 : }
162 : :
163 : 1608 : 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 : 1608 : lcl_text(data, len);
176 : :
177 : : #ifdef DEBUG_LOGGING
178 : : mHelper.endElement("text");
179 : : #endif
180 : 1608 : }
181 : :
182 : 13650 : 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 : 13650 : lcl_utext(data, len);
199 : :
200 : : #ifdef DEBUG_LOGGING
201 : : mHelper.endElement("utext");
202 : : #endif
203 : 13650 : }
204 : :
205 : 17500 : void LoggedStream::props(writerfilter::Reference<Properties>::Pointer_t ref)
206 : : {
207 : : #ifdef DEBUG_LOGGING
208 : : mHelper.startElement("props");
209 : : #endif
210 : :
211 [ + - ]: 17500 : lcl_props(ref);
212 : :
213 : : #ifdef DEBUG_LOGGING
214 : : mHelper.endElement("props");
215 : : #endif
216 : 17500 : }
217 : :
218 : 1250 : void LoggedStream::table(Id name, writerfilter::Reference<Table>::Pointer_t ref)
219 : : {
220 : : #ifdef DEBUG_LOGGING
221 : : mHelper.startElement("table");
222 : : mHelper.attribute("name", (*QNameToString::Instance())(name));
223 : : #endif
224 : :
225 [ + - ]: 1250 : lcl_table(name, ref);
226 : :
227 : : #ifdef DEBUG_LOGGING
228 : : mHelper.endElement("table");
229 : : #endif
230 : 1250 : }
231 : :
232 : 57 : void LoggedStream::substream(Id name, writerfilter::Reference<Stream>::Pointer_t ref)
233 : : {
234 : : #ifdef DEBUG_LOGGING
235 : : mHelper.startElement("substream");
236 : : mHelper.attribute("name", (*QNameToString::Instance())(name));
237 : : #endif
238 : :
239 [ + - ]: 57 : lcl_substream(name, ref);
240 : :
241 : : #ifdef DEBUG_LOGGING
242 : : mHelper.endElement("substream");
243 : : #endif
244 : 57 : }
245 : :
246 : 969 : void LoggedStream::info(const string & _info)
247 : : {
248 : : #ifdef DEBUG_LOGGING
249 : : mHelper.startElement("info");
250 : : mHelper.attribute("text", _info);
251 : : #endif
252 : :
253 : 969 : lcl_info(_info);
254 : :
255 : : #ifdef DEBUG_LOGGING
256 : : mHelper.endElement("info");
257 : : #endif
258 : 969 : }
259 : :
260 : : // class LoggedProperties
261 : 3080 : LoggedProperties::LoggedProperties(
262 : : #ifdef DEBUG_LOGGING
263 : : TagLogger::Pointer_t pLogger,
264 : : const string & sPrefix
265 : : ) : mHelper(pLogger, sPrefix)
266 : : #else
267 : : TagLogger::Pointer_t,
268 : : const string&
269 : 3080 : )
270 : : #endif
271 : : {
272 : 3080 : }
273 : :
274 : 3080 : LoggedProperties::~LoggedProperties()
275 : : {
276 [ - + ]: 3080 : }
277 : :
278 : 30305 : void LoggedProperties::attribute(Id name, Value & val)
279 : : {
280 : : #ifdef DEBUG_LOGGING
281 : : mHelper.startElement("attribute");
282 : : mHelper.attribute("name", (*QNameToString::Instance())(name));
283 : : mHelper.attribute("value", val.toString());
284 : : mHelper.endElement("attribute");
285 : : #endif
286 : :
287 : 30305 : lcl_attribute(name, val);
288 : 30305 : }
289 : :
290 : 90160 : void LoggedProperties::sprm(Sprm & rSprm)
291 : : {
292 : : #ifdef DEBUG_LOGGING
293 : : mHelper.startElement("sprm");
294 : : mHelper.attribute("name", (*QNameToString::Instance())(rSprm.getId()));
295 : : mHelper.chars(rSprm.toString());
296 : : #endif
297 : :
298 : 90160 : lcl_sprm(rSprm);
299 : :
300 : : #ifdef DEBUG_LOGGING
301 : : mHelper.endElement("sprm");
302 : : #endif
303 : 90160 : }
304 : :
305 : 2023 : LoggedTable::LoggedTable(
306 : : #ifdef DEBUG_LOGGING
307 : : TagLogger::Pointer_t pLogger,
308 : : const string & sPrefix
309 : : ) : mHelper(pLogger, sPrefix)
310 : : #else
311 : : TagLogger::Pointer_t,
312 : : const string&
313 : 2023 : )
314 : : #endif
315 : : {
316 : 2023 : }
317 : :
318 : 2023 : LoggedTable::~LoggedTable()
319 : : {
320 [ - + ]: 2023 : }
321 : :
322 : 4910 : void LoggedTable::entry(int pos, writerfilter::Reference<Properties>::Pointer_t ref)
323 : : {
324 : : #ifdef DEBUG_LOGGING
325 : : mHelper.startElement("entry");
326 : : mHelper.attribute("pos", pos);
327 : : #endif
328 : :
329 [ + - ]: 4910 : lcl_entry(pos, ref);
330 : :
331 : : #ifdef DEBUG_LOGGING
332 : : mHelper.endElement("entry");
333 : : #endif
334 : 4910 : }
335 : :
336 [ + - ][ + - ]: 60 : }
337 : :
338 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|