1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23
24 #include <rtl/ustrbuf.hxx>
25 #include <resourcemodel/WW8ResourceModel.hxx>
26 #include <resourcemodel/LoggedResources.hxx>
27 #include <resourcemodel/QNameToString.hxx>
28
29 namespace writerfilter
30 {
31
32 // class: LoggedResourcesHelper
33
LoggedResourcesHelper(TagLogger::Pointer_t pLogger,const string & sPrefix)34 LoggedResourcesHelper::LoggedResourcesHelper(TagLogger::Pointer_t pLogger, const string & sPrefix)
35 : mpLogger(pLogger), msPrefix(sPrefix)
36 {
37 }
38
~LoggedResourcesHelper()39 LoggedResourcesHelper::~LoggedResourcesHelper()
40 {
41 }
42
startElement(const string & sElement)43 void LoggedResourcesHelper::startElement(const string & sElement)
44 {
45 mpLogger->startElement(msPrefix + "." + sElement);
46 }
47
endElement(const string & sElement)48 void LoggedResourcesHelper::endElement(const string & sElement)
49 {
50 mpLogger->endElement(msPrefix + "." + sElement);
51 }
52
chars(const::rtl::OUString & rChars)53 void LoggedResourcesHelper::chars(const ::rtl::OUString & rChars)
54 {
55 mpLogger->chars(rChars);
56 }
57
chars(const string & rChars)58 void LoggedResourcesHelper::chars(const string & rChars)
59 {
60 mpLogger->chars(rChars);
61 }
62
attribute(const string & rName,const string & rValue)63 void LoggedResourcesHelper::attribute(const string & rName, const string & rValue)
64 {
65 mpLogger->attribute(rName, rValue);
66 }
67
attribute(const string & rName,sal_uInt32 nValue)68 void LoggedResourcesHelper::attribute(const string & rName, sal_uInt32 nValue)
69 {
70 mpLogger->attribute(rName, nValue);
71 }
72
setPrefix(const string & rPrefix)73 void LoggedResourcesHelper::setPrefix(const string & rPrefix)
74 {
75 msPrefix = rPrefix;
76 }
77
78 // class: LoggedStream
79
LoggedStream(TagLogger::Pointer_t pLogger,const string & sPrefix)80 LoggedStream::LoggedStream(TagLogger::Pointer_t pLogger, const string & sPrefix)
81 : mHelper(pLogger, sPrefix)
82 {
83 }
84
~LoggedStream()85 LoggedStream::~LoggedStream()
86 {
87 }
88
startSectionGroup()89 void LoggedStream::startSectionGroup()
90 {
91 #ifdef DEBUG_LOGGING
92 mHelper.startElement("section");
93 #endif
94
95 lcl_startSectionGroup();
96 }
97
endSectionGroup()98 void LoggedStream::endSectionGroup()
99 {
100 lcl_endSectionGroup();
101
102 #ifdef DEBUG_LOGGING
103 mHelper.endElement("section");
104 #endif
105 }
106
startParagraphGroup()107 void LoggedStream::startParagraphGroup()
108 {
109 #ifdef DEBUG_LOGGING
110 mHelper.startElement("paragraph");
111 #endif
112
113 lcl_startParagraphGroup();
114 }
115
endParagraphGroup()116 void LoggedStream::endParagraphGroup()
117 {
118 lcl_endParagraphGroup();
119
120 #ifdef DEBUG_LOGGING
121 mHelper.endElement("paragraph");
122 #endif
123 }
124
125
startCharacterGroup()126 void LoggedStream::startCharacterGroup()
127 {
128 #ifdef DEBUG_LOGGING
129 mHelper.startElement("charactergroup");
130 #endif
131
132 lcl_startCharacterGroup();
133 }
134
endCharacterGroup()135 void LoggedStream::endCharacterGroup()
136 {
137 lcl_endCharacterGroup();
138
139 #ifdef DEBUG_LOGGING
140 mHelper.endElement("charactergroup");
141 #endif
142 }
143
startShape(::com::sun::star::uno::Reference<::com::sun::star::drawing::XShape> xShape)144 void LoggedStream::startShape( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape )
145 {
146 #ifdef DEBUG_LOGGING
147 mHelper.startElement("shape");
148 #endif
149
150 lcl_startShape(xShape);
151 }
152
endShape()153 void LoggedStream::endShape()
154 {
155 lcl_endShape();
156
157 #ifdef DEBUG_LOGGING
158 mHelper.endElement("shape");
159 #endif
160 }
161
text(const sal_uInt8 * data,size_t len)162 void LoggedStream::text(const sal_uInt8 * data, size_t len)
163 {
164 #ifdef DEBUG_LOGGING
165 mHelper.startElement("text");
166
167 ::rtl::OUString sText( (const sal_Char*) data, len, RTL_TEXTENCODING_MS_1252 );
168
169 mHelper.startElement("data");
170 mHelper.chars(sText);
171 mHelper.endElement("data");
172 #endif
173
174 lcl_text(data, len);
175
176 #ifdef DEBUG_LOGGING
177 mHelper.endElement("text");
178 #endif
179 }
180
utext(const sal_uInt8 * data,size_t len)181 void LoggedStream::utext(const sal_uInt8 * data, size_t len)
182 {
183 #ifdef DEBUG_LOGGING
184 mHelper.startElement("utext");
185 mHelper.startElement("data");
186
187 ::rtl::OUString sText;
188 ::rtl::OUStringBuffer aBuffer = ::rtl::OUStringBuffer(len);
189 aBuffer.append( (const sal_Unicode *) data, len);
190 sText = aBuffer.makeStringAndClear();
191
192 mHelper.chars(sText);
193
194 mHelper.endElement("data");
195 #endif
196
197 lcl_utext(data, len);
198
199 #ifdef DEBUG_LOGGING
200 mHelper.endElement("utext");
201 #endif
202 }
203
props(writerfilter::Reference<Properties>::Pointer_t ref)204 void LoggedStream::props(writerfilter::Reference<Properties>::Pointer_t ref)
205 {
206 #ifdef DEBUG_LOGGING
207 mHelper.startElement("props");
208 #endif
209
210 lcl_props(ref);
211
212 #ifdef DEBUG_LOGGING
213 mHelper.endElement("props");
214 #endif
215 }
216
table(Id name,writerfilter::Reference<Table>::Pointer_t ref)217 void LoggedStream::table(Id name, writerfilter::Reference<Table>::Pointer_t ref)
218 {
219 #ifdef DEBUG_LOGGING
220 mHelper.startElement("table");
221 mHelper.attribute("name", (*QNameToString::Instance())(name));
222 #endif
223
224 lcl_table(name, ref);
225
226 #ifdef DEBUG_LOGGING
227 mHelper.endElement("table");
228 #endif
229 }
230
substream(Id name,writerfilter::Reference<Stream>::Pointer_t ref)231 void LoggedStream::substream(Id name, writerfilter::Reference<Stream>::Pointer_t ref)
232 {
233 #ifdef DEBUG_LOGGING
234 mHelper.startElement("substream");
235 mHelper.attribute("name", (*QNameToString::Instance())(name));
236 #endif
237
238 lcl_substream(name, ref);
239
240 #ifdef DEBUG_LOGGING
241 mHelper.endElement("substream");
242 #endif
243 }
244
info(const string & _info)245 void LoggedStream::info(const string & _info)
246 {
247 #ifdef DEBUG_LOGGING
248 mHelper.startElement("info");
249 mHelper.attribute("text", _info);
250 #endif
251
252 lcl_info(_info);
253
254 #ifdef DEBUG_LOGGING
255 mHelper.endElement("info");
256 #endif
257 }
258
259 // class LoggedProperties
LoggedProperties(TagLogger::Pointer_t pLogger,const string & sPrefix)260 LoggedProperties::LoggedProperties(TagLogger::Pointer_t pLogger, const string & sPrefix)
261 : mHelper(pLogger, sPrefix)
262 {
263 }
264
~LoggedProperties()265 LoggedProperties::~LoggedProperties()
266 {
267 }
268
attribute(Id name,Value & val)269 void LoggedProperties::attribute(Id name, Value & val)
270 {
271 #ifdef DEBUG_LOGGING
272 mHelper.startElement("attribute");
273 mHelper.attribute("name", (*QNameToString::Instance())(name));
274 mHelper.attribute("value", val.toString());
275 mHelper.endElement("attribute");
276 #endif
277
278 lcl_attribute(name, val);
279 }
280
sprm(Sprm & _sprm)281 void LoggedProperties::sprm(Sprm & _sprm)
282 {
283 #ifdef DEBUG_LOGGING
284 mHelper.startElement("sprm");
285 mHelper.attribute("name", (*QNameToString::Instance())(_sprm.getId()));
286 mHelper.chars(_sprm.toString());
287 #endif
288
289 lcl_sprm(_sprm);
290
291 #ifdef DEBUG_LOGGING
292 mHelper.endElement("sprm");
293 #endif
294 }
295
LoggedTable(TagLogger::Pointer_t pLogger,const string & sPrefix)296 LoggedTable::LoggedTable(TagLogger::Pointer_t pLogger, const string & sPrefix)
297 : mHelper(pLogger, sPrefix)
298 {
299 }
300
~LoggedTable()301 LoggedTable::~LoggedTable()
302 {
303 }
304
entry(int pos,writerfilter::Reference<Properties>::Pointer_t ref)305 void LoggedTable::entry(int pos, writerfilter::Reference<Properties>::Pointer_t ref)
306 {
307 #ifdef DEBUG_LOGGING
308 mHelper.startElement("entry");
309 mHelper.attribute("pos", pos);
310 #endif
311
312 lcl_entry(pos, ref);
313
314 #ifdef DEBUG_LOGGING
315 mHelper.endElement("entry");
316 #endif
317 }
318
319 }
320