Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This Source Code Form is subject to the terms of the Mozilla Public
4 : * License, v. 2.0. If a copy of the MPL was not distributed with this
5 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
6 : *
7 : * For further information visit http://libwpd.sourceforge.net
8 : */
9 : #include "DocumentHandler.hxx"
10 :
11 : #include <string.h>
12 : #include <com/sun/star/xml/sax/XDocumentHandler.hpp>
13 : #include <com/sun/star/xml/sax/XAttributeList.hpp>
14 :
15 : #include <xmloff/attrlist.hxx>
16 :
17 : using com::sun::star::xml::sax::XAttributeList;
18 :
19 0 : DocumentHandler::DocumentHandler(Reference < XDocumentHandler > &xHandler) :
20 0 : mxHandler(xHandler)
21 : {
22 0 : }
23 :
24 0 : void DocumentHandler::startDocument()
25 : {
26 0 : mxHandler->startDocument();
27 0 : }
28 :
29 0 : void DocumentHandler::endDocument()
30 : {
31 0 : mxHandler->endDocument();
32 0 : }
33 :
34 0 : void DocumentHandler::startElement(const char *psName, const WPXPropertyList &xPropList)
35 : {
36 0 : SvXMLAttributeList *pAttrList = new SvXMLAttributeList();
37 0 : Reference < XAttributeList > xAttrList(pAttrList);
38 0 : WPXPropertyList::Iter i(xPropList);
39 0 : for (i.rewind(); i.next(); )
40 : {
41 : // filter out libwpd elements
42 0 : if (strncmp(i.key(), "libwpd", 6) != 0)
43 : {
44 0 : OUString sName(i.key(), strlen(i.key()), RTL_TEXTENCODING_UTF8);
45 0 : OUString sValue(i()->getStr().cstr(), strlen(i()->getStr().cstr()), RTL_TEXTENCODING_UTF8);
46 0 : pAttrList->AddAttribute(sName, sValue);
47 : }
48 : }
49 :
50 0 : OUString sElementName(psName, strlen(psName), RTL_TEXTENCODING_UTF8);
51 0 : mxHandler->startElement(sElementName, xAttrList);
52 0 : }
53 :
54 0 : void DocumentHandler::endElement(const char *psName)
55 : {
56 0 : OUString sElementName(psName, strlen(psName), RTL_TEXTENCODING_UTF8);
57 0 : mxHandler->endElement(sElementName);
58 0 : }
59 :
60 0 : void DocumentHandler::characters(const WPXString &sCharacters)
61 : {
62 0 : OUString sCharU16(sCharacters.cstr(), strlen(sCharacters.cstr()), RTL_TEXTENCODING_UTF8);
63 0 : mxHandler->characters(sCharU16);
64 0 : }
65 :
66 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|