2 * Copyright (C) 2004 William Lachance (william.lachance@sympatico.ca)
3 * Copyright (C) 2004 Net Integration Technologies (http://www.net-itech.com)
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
15 * You should have received a copy of the GNU Library General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 * For further information visit http://libwpd.sourceforge.net
22 #include "DocumentHandler.hxx"
23 #include "FilterInternal.hxx"
26 #include <com/sun/star/xml/sax/XDocumentHandler.hpp>
27 #include <com/sun/star/xml/sax/XAttributeList.hpp>
29 #ifndef _ATTRLIST_HPP_
30 #include <xmloff/attrlist.hxx>
33 using namespace ::rtl
;
36 using com::sun::star::xml::sax::XAttributeList
;
38 DocumentHandler::DocumentHandler(Reference
< XDocumentHandler
> &xHandler
) :
43 void DocumentHandler::startDocument()
45 WRITER_DEBUG_MSG(("DocumentHandler::startDocument\n"));
46 mxHandler
->startDocument();
49 void DocumentHandler::endDocument()
51 WRITER_DEBUG_MSG(("DocumentHandler::endDocument\n"));
52 mxHandler
->endDocument();
55 void DocumentHandler::startElement(const char *psName
, const WPXPropertyList
&xPropList
)
57 WRITER_DEBUG_MSG(("DocumentHandler::startElement\n"));
58 SvXMLAttributeList
*pAttrList
= new SvXMLAttributeList();
59 Reference
< XAttributeList
> xAttrList(pAttrList
);
60 WPXPropertyList::Iter
i(xPropList
);
61 for (i
.rewind(); i
.next(); )
63 // filter out libwpd elements
64 if (strncmp(i
.key(), "libwpd", 6) != 0)
65 pAttrList
->AddAttribute(OUString::createFromAscii(i
.key()),
66 OUString::createFromAscii(i()->getStr().cstr()));
69 mxHandler
->startElement(OUString::createFromAscii(psName
), xAttrList
);
72 void DocumentHandler::endElement(const char *psName
)
74 WRITER_DEBUG_MSG(("DocumentHandler::endElement\n"));
75 mxHandler
->endElement(OUString::createFromAscii(psName
));
78 void DocumentHandler::characters(const WPXString
&sCharacters
)
80 WRITER_DEBUG_MSG(("DocumentHandler::characters\n"));
81 OUString
sCharU16(sCharacters
.cstr(), strlen(sCharacters
.cstr()), RTL_TEXTENCODING_UTF8
);
82 mxHandler
->characters(sCharU16
);