1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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
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
);
71 // class: LoggedStream
73 LoggedStream::LoggedStream(
75 TagLogger::Pointer_t pLogger
,
76 const std::string
& sPrefix
77 ) : mHelper(pLogger
, sPrefix
)
86 LoggedStream::~LoggedStream()
90 void LoggedStream::startSectionGroup()
93 mHelper
.startElement("section");
96 lcl_startSectionGroup();
99 void LoggedStream::endSectionGroup()
101 lcl_endSectionGroup();
104 mHelper
.endElement("section");
108 void LoggedStream::startParagraphGroup()
111 mHelper
.startElement("paragraph");
114 lcl_startParagraphGroup();
117 void LoggedStream::endParagraphGroup()
119 lcl_endParagraphGroup();
122 mHelper
.endElement("paragraph");
127 void LoggedStream::startCharacterGroup()
130 mHelper
.startElement("charactergroup");
133 lcl_startCharacterGroup();
136 void LoggedStream::endCharacterGroup()
138 lcl_endCharacterGroup();
141 mHelper
.endElement("charactergroup");
145 void LoggedStream::startShape( ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XShape
> xShape
)
148 mHelper
.startElement("shape");
151 lcl_startShape(xShape
);
154 void LoggedStream::endShape()
159 mHelper
.endElement("shape");
163 void LoggedStream::text(const sal_uInt8
* data
, size_t len
)
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");
178 mHelper
.endElement("text");
182 void LoggedStream::utext(const sal_uInt8
* data
, size_t len
)
185 mHelper
.startElement("utext");
186 mHelper
.startElement("data");
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");
198 lcl_utext(data
, len
);
201 mHelper
.endElement("utext");
205 void LoggedStream::positivePercentage(const OUString
& rText
)
208 mHelper
.startElement("positivePercentage");
209 mHelper
.chars(rText
);
212 lcl_positivePercentage(rText
);
215 mHelper
.endElement("positivePercentage");
219 void LoggedStream::props(writerfilter::Reference
<Properties
>::Pointer_t ref
)
222 mHelper
.startElement("props");
228 mHelper
.endElement("props");
232 void LoggedStream::table(Id name
, writerfilter::Reference
<Table
>::Pointer_t ref
)
235 mHelper
.startElement("table");
236 mHelper
.attribute("name", (*QNameToString::Instance())(name
));
239 lcl_table(name
, ref
);
242 mHelper
.endElement("table");
246 void LoggedStream::substream(Id name
, writerfilter::Reference
<Stream
>::Pointer_t ref
)
249 mHelper
.startElement("substream");
250 mHelper
.attribute("name", (*QNameToString::Instance())(name
));
253 lcl_substream(name
, ref
);
256 mHelper
.endElement("substream");
260 void LoggedStream::info(const std::string
& _info
)
263 mHelper
.startElement("info");
264 mHelper
.attribute("text", _info
);
270 mHelper
.endElement("info");
274 // class LoggedProperties
275 LoggedProperties::LoggedProperties(
277 TagLogger::Pointer_t pLogger
,
278 const std::string
& sPrefix
279 ) : mHelper(pLogger
, sPrefix
)
281 TagLogger::Pointer_t
,
288 LoggedProperties::~LoggedProperties()
292 void LoggedProperties::attribute(Id name
, Value
& val
)
295 mHelper
.startElement("attribute");
296 mHelper
.attribute("name", (*QNameToString::Instance())(name
));
297 mHelper
.attribute("value", val
.toString());
298 mHelper
.endElement("attribute");
301 lcl_attribute(name
, val
);
304 void LoggedProperties::sprm(Sprm
& rSprm
)
307 mHelper
.startElement("sprm");
308 mHelper
.attribute("name", (*QNameToString::Instance())(rSprm
.getId()));
309 mHelper
.chars(rSprm
.toString());
315 mHelper
.endElement("sprm");
319 LoggedTable::LoggedTable(
321 TagLogger::Pointer_t pLogger
,
322 const std::string
& sPrefix
323 ) : mHelper(pLogger
, sPrefix
)
325 TagLogger::Pointer_t
,
332 LoggedTable::~LoggedTable()
336 void LoggedTable::entry(int pos
, writerfilter::Reference
<Properties
>::Pointer_t ref
)
339 mHelper
.startElement("entry");
340 mHelper
.attribute("pos", pos
);
346 mHelper
.endElement("entry");
352 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */