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 808 : 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 808 : )
82 : #endif
83 : {
84 808 : }
85 :
86 808 : LoggedStream::~LoggedStream()
87 : {
88 808 : }
89 :
90 464 : void LoggedStream::startSectionGroup()
91 : {
92 : #ifdef DEBUG_LOGGING
93 : mHelper.startElement("section");
94 : #endif
95 :
96 464 : lcl_startSectionGroup();
97 464 : }
98 :
99 460 : void LoggedStream::endSectionGroup()
100 : {
101 460 : lcl_endSectionGroup();
102 :
103 : #ifdef DEBUG_LOGGING
104 : mHelper.endElement("section");
105 : #endif
106 460 : }
107 :
108 2334 : void LoggedStream::startParagraphGroup()
109 : {
110 : #ifdef DEBUG_LOGGING
111 : mHelper.startElement("paragraph");
112 : #endif
113 :
114 2334 : lcl_startParagraphGroup();
115 2334 : }
116 :
117 2280 : void LoggedStream::endParagraphGroup()
118 : {
119 2280 : lcl_endParagraphGroup();
120 :
121 : #ifdef DEBUG_LOGGING
122 : mHelper.endElement("paragraph");
123 : #endif
124 2280 : }
125 :
126 :
127 10400 : void LoggedStream::startCharacterGroup()
128 : {
129 : #ifdef DEBUG_LOGGING
130 : mHelper.startElement("charactergroup");
131 : #endif
132 :
133 10400 : lcl_startCharacterGroup();
134 10400 : }
135 :
136 10348 : void LoggedStream::endCharacterGroup()
137 : {
138 10348 : lcl_endCharacterGroup();
139 :
140 : #ifdef DEBUG_LOGGING
141 : mHelper.endElement("charactergroup");
142 : #endif
143 10348 : }
144 :
145 88 : 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 88 : lcl_startShape(xShape);
152 88 : }
153 :
154 88 : void LoggedStream::endShape()
155 : {
156 88 : lcl_endShape();
157 :
158 : #ifdef DEBUG_LOGGING
159 : mHelper.endElement("shape");
160 : #endif
161 88 : }
162 :
163 1234 : 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 1234 : lcl_text(data, len);
176 :
177 : #ifdef DEBUG_LOGGING
178 : mHelper.endElement("text");
179 : #endif
180 1234 : }
181 :
182 9824 : 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 9824 : lcl_utext(data, len);
199 :
200 : #ifdef DEBUG_LOGGING
201 : mHelper.endElement("utext");
202 : #endif
203 9824 : }
204 :
205 14224 : void LoggedStream::props(writerfilter::Reference<Properties>::Pointer_t ref)
206 : {
207 : #ifdef DEBUG_LOGGING
208 : mHelper.startElement("props");
209 : #endif
210 :
211 14224 : lcl_props(ref);
212 :
213 : #ifdef DEBUG_LOGGING
214 : mHelper.endElement("props");
215 : #endif
216 14224 : }
217 :
218 1112 : 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 1112 : lcl_table(name, ref);
226 :
227 : #ifdef DEBUG_LOGGING
228 : mHelper.endElement("table");
229 : #endif
230 1112 : }
231 :
232 70 : 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 70 : lcl_substream(name, ref);
240 :
241 : #ifdef DEBUG_LOGGING
242 : mHelper.endElement("substream");
243 : #endif
244 70 : }
245 :
246 1086 : void LoggedStream::info(const string & _info)
247 : {
248 : #ifdef DEBUG_LOGGING
249 : mHelper.startElement("info");
250 : mHelper.attribute("text", _info);
251 : #endif
252 :
253 1086 : lcl_info(_info);
254 :
255 : #ifdef DEBUG_LOGGING
256 : mHelper.endElement("info");
257 : #endif
258 1086 : }
259 :
260 : // class LoggedProperties
261 3560 : 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 3560 : )
270 : #endif
271 : {
272 3560 : }
273 :
274 3560 : LoggedProperties::~LoggedProperties()
275 : {
276 3560 : }
277 :
278 31262 : 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 31262 : lcl_attribute(name, val);
288 31262 : }
289 :
290 76346 : 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 76346 : lcl_sprm(rSprm);
299 :
300 : #ifdef DEBUG_LOGGING
301 : mHelper.endElement("sprm");
302 : #endif
303 76346 : }
304 :
305 1802 : 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 1802 : )
314 : #endif
315 : {
316 1802 : }
317 :
318 1802 : LoggedTable::~LoggedTable()
319 : {
320 1802 : }
321 :
322 4490 : 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 4490 : lcl_entry(pos, ref);
330 :
331 : #ifdef DEBUG_LOGGING
332 : mHelper.endElement("entry");
333 : #endif
334 4490 : }
335 :
336 30 : }
337 :
338 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|