bump product version to 4.1.6.2
[LibreOffice.git] / writerperfect / source / common / DocumentHandler.cxx
blob073b9429571b082aa6f30b6add19d4dc657ea659
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/.
7 * For further information visit http://libwpd.sourceforge.net
8 */
9 #include "DocumentHandler.hxx"
11 #include <string.h>
12 #include <com/sun/star/xml/sax/XDocumentHandler.hpp>
13 #include <com/sun/star/xml/sax/XAttributeList.hpp>
15 #include <xmloff/attrlist.hxx>
17 using com::sun::star::xml::sax::XAttributeList;
19 DocumentHandler::DocumentHandler(Reference < XDocumentHandler > &xHandler) :
20 mxHandler(xHandler)
24 void DocumentHandler::startDocument()
26 mxHandler->startDocument();
29 void DocumentHandler::endDocument()
31 mxHandler->endDocument();
34 void DocumentHandler::startElement(const char *psName, const WPXPropertyList &xPropList)
36 SvXMLAttributeList *pAttrList = new SvXMLAttributeList();
37 Reference < XAttributeList > xAttrList(pAttrList);
38 WPXPropertyList::Iter i(xPropList);
39 for (i.rewind(); i.next(); )
41 // filter out libwpd elements
42 if (strncmp(i.key(), "libwpd", 6) != 0)
44 OUString sName(i.key(), strlen(i.key()), RTL_TEXTENCODING_UTF8);
45 OUString sValue(i()->getStr().cstr(), strlen(i()->getStr().cstr()), RTL_TEXTENCODING_UTF8);
46 pAttrList->AddAttribute(sName, sValue);
50 OUString sElementName(psName, strlen(psName), RTL_TEXTENCODING_UTF8);
51 mxHandler->startElement(sElementName, xAttrList);
54 void DocumentHandler::endElement(const char *psName)
56 OUString sElementName(psName, strlen(psName), RTL_TEXTENCODING_UTF8);
57 mxHandler->endElement(sElementName);
60 void DocumentHandler::characters(const WPXString &sCharacters)
62 OUString sCharU16(sCharacters.cstr(), strlen(sCharacters.cstr()), RTL_TEXTENCODING_UTF8);
63 mxHandler->characters(sCharU16);
66 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */