summaryrefslogtreecommitdiffstats
path: root/writerperfect/source/common/DocumentHandler.cxx
diff options
context:
space:
mode:
authorFridrich Štrba <fridrich.strba@bluewin.ch>2013-05-02 15:04:05 +0200
committerFridrich Štrba <fridrich.strba@bluewin.ch>2013-05-02 15:12:00 +0200
commite1ffd555b5c70e4bdc693711917ebffbb2423579 (patch)
treebb906f7c842d0a7cafe2f5d600c866e55279aea6 /writerperfect/source/common/DocumentHandler.cxx
parentdo not fail when using disabled liblangtag external; just do nothing (diff)
downloadcore-e1ffd555b5c70e4bdc693711917ebffbb2423579.tar.gz
core-e1ffd555b5c70e4bdc693711917ebffbb2423579.zip
simplify writerperfect structure and prepare for libodfgen
Change-Id: Ib2e56280a5a6bfdfee18a5b213dd67b9fbfc8949
Diffstat (limited to 'writerperfect/source/common/DocumentHandler.cxx')
-rw-r--r--writerperfect/source/common/DocumentHandler.cxx64
1 files changed, 64 insertions, 0 deletions
diff --git a/writerperfect/source/common/DocumentHandler.cxx b/writerperfect/source/common/DocumentHandler.cxx
new file mode 100644
index 000000000000..67d1b5e053ca
--- /dev/null
+++ b/writerperfect/source/common/DocumentHandler.cxx
@@ -0,0 +1,64 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * For further information visit http://libwpd.sourceforge.net
+ */
+#include "DocumentHandler.hxx"
+#include "FilterInternal.hxx"
+
+#include <string.h>
+#include <com/sun/star/xml/sax/XDocumentHandler.hpp>
+#include <com/sun/star/xml/sax/XAttributeList.hpp>
+
+#include <xmloff/attrlist.hxx>
+
+using com::sun::star::xml::sax::XAttributeList;
+
+DocumentHandler::DocumentHandler(Reference < XDocumentHandler > &xHandler) :
+ mxHandler(xHandler)
+{
+}
+
+void DocumentHandler::startDocument()
+{
+ mxHandler->startDocument();
+}
+
+void DocumentHandler::endDocument()
+{
+ mxHandler->endDocument();
+}
+
+void DocumentHandler::startElement(const char *psName, const WPXPropertyList &xPropList)
+{
+ SvXMLAttributeList *pAttrList = new SvXMLAttributeList();
+ Reference < XAttributeList > xAttrList(pAttrList);
+ WPXPropertyList::Iter i(xPropList);
+ for (i.rewind(); i.next(); )
+ {
+ // filter out libwpd elements
+ if (strncmp(i.key(), "libwpd", 6) != 0)
+ {
+ pAttrList->AddAttribute(OUString::createFromAscii(i.key()),
+ OUString::createFromAscii(i()->getStr().cstr()));
+ }
+ }
+
+ mxHandler->startElement(OUString::createFromAscii(psName), xAttrList);
+}
+
+void DocumentHandler::endElement(const char *psName)
+{
+ mxHandler->endElement(OUString::createFromAscii(psName));
+}
+
+void DocumentHandler::characters(const WPXString &sCharacters)
+{
+ OUString sCharU16(sCharacters.cstr(), strlen(sCharacters.cstr()), RTL_TEXTENCODING_UTF8);
+ mxHandler->characters(sCharU16);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */