[PATCH 5/5] Add alternative implementation of flat xml filter w/o xslt.
Peter Jentsch
pjotr at guineapics.de
Mon Jan 10 12:30:04 PST 2011
This filter implementation is directly based on
XmlFilterAdaptor and simply dumps the SAX events
provided by the XmlFilterAdaptor to an outputstream.
It currently still lacks the advanced pretty printing
available through split-long-lines.xsl in the xslt based
flat xml filter.
---
filter/prj/build.lst | 1 +
.../config/fragments/filters/ODG_FlatXML.xcu | 2 +-
.../config/fragments/filters/ODP_FlatXML.xcu | 2 +-
.../config/fragments/filters/ODS_FlatXML.xcu | 2 +-
.../config/fragments/filters/ODT_FlatXML.xcu | 2 +-
filter/source/odfflatxml/FlatXml.cxx | 365 ++++++++++++++++++++
filter/source/odfflatxml/FlatXml.hxx | 144 ++++++++
filter/source/odfflatxml/makefile.mk | 56 +++
8 files changed, 570 insertions(+), 4 deletions(-)
create mode 100644 filter/source/odfflatxml/FlatXml.cxx
create mode 100644 filter/source/odfflatxml/FlatXml.hxx
create mode 100644 filter/source/odfflatxml/makefile.mk
diff --git a/filter/prj/build.lst b/filter/prj/build.lst
index bed99e4..502ecff 100644
--- a/filter/prj/build.lst
+++ b/filter/prj/build.lst
@@ -11,6 +11,7 @@ fl filter\source\svg nmake - all fl_svg fl_inc NULL
fl filter\source\placeware nmake - all fl_placeware fl_inc NULL
fl filter\source\flash nmake - all fl_flash fl_pdf fl_inc NULL
fl filter\source\filtertracer nmake - all fl_filtertracer fl_inc NULL
+fl filter\source\odfflatxml nmake - all fl_odfflatxml fl_inc NULL
fl filter\source\xsltfilter nmake - all fl_xsltfilter fl_inc NULL
fl filter\source\xsltvalidate nmake - all fl_xsltvalidate fl_xsltfilter fl_inc NULL
fl filter\source\xsltdialog nmake - all fl_xsltdialog fl_flash fl_inc NULL
diff --git a/filter/source/config/fragments/filters/ODG_FlatXML.xcu b/filter/source/config/fragments/filters/ODG_FlatXML.xcu
index 2a5a4a0..f528248 100644
--- a/filter/source/config/fragments/filters/ODG_FlatXML.xcu
+++ b/filter/source/config/fragments/filters/ODG_FlatXML.xcu
@@ -3,7 +3,7 @@
<prop oor:name="Type"><value>draw_ODG_FlatXML</value></prop>
<prop oor:name="DocumentService"><value>com.sun.star.drawing.DrawingDocument</value></prop>
<prop oor:name="UIComponent"/>
- <prop oor:name="UserData"><value oor:separator=",">com.sun.star.documentconversion.XSLTFilter,,com.sun.star.comp.Draw.XMLOasisImporter,com.sun.star.comp.Draw.XMLOasisExporter,../share/xslt/odfflatxml/odfflatxmlimport.xsl,../share/xslt/odfflatxml/odfflatxmlexport.xsl</value></prop>
+ <prop oor:name="UserData"><value oor:separator=",">com.sun.star.comp.filter.FlatXmlCpp,,com.sun.star.comp.Draw.XMLOasisImporter,com.sun.star.comp.Draw.XMLOasisExporter,,,true</value></prop>
<prop oor:name="FilterService"><value>com.sun.star.comp.Writer.XmlFilterAdaptor</value></prop>
<prop oor:name="TemplateName"/>
<prop oor:name="UIName">
diff --git a/filter/source/config/fragments/filters/ODP_FlatXML.xcu b/filter/source/config/fragments/filters/ODP_FlatXML.xcu
index 175936c..8f15d7c 100644
--- a/filter/source/config/fragments/filters/ODP_FlatXML.xcu
+++ b/filter/source/config/fragments/filters/ODP_FlatXML.xcu
@@ -3,7 +3,7 @@
<prop oor:name="Type"><value>impress_ODP_FlatXML</value></prop>
<prop oor:name="DocumentService"><value>com.sun.star.presentation.PresentationDocument</value></prop>
<prop oor:name="UIComponent"/>
- <prop oor:name="UserData"><value oor:separator=",">com.sun.star.documentconversion.XSLTFilter,,com.sun.star.comp.Impress.XMLOasisImporter,com.sun.star.comp.Impress.XMLOasisExporter,../share/xslt/odfflatxml/odfflatxmlimport.xsl,../share/xslt/odfflatxml/odfflatxmlexport.xsl</value></prop>
+ <prop oor:name="UserData"><value oor:separator=",">com.sun.star.comp.filter.FlatXmlCpp,,com.sun.star.comp.Impress.XMLOasisImporter,com.sun.star.comp.Impress.XMLOasisExporter,,,true</value></prop>
<prop oor:name="FilterService"><value>com.sun.star.comp.Writer.XmlFilterAdaptor</value></prop>
<prop oor:name="TemplateName"/>
<prop oor:name="UIName">
diff --git a/filter/source/config/fragments/filters/ODS_FlatXML.xcu b/filter/source/config/fragments/filters/ODS_FlatXML.xcu
index a780901..df8e856 100644
--- a/filter/source/config/fragments/filters/ODS_FlatXML.xcu
+++ b/filter/source/config/fragments/filters/ODS_FlatXML.xcu
@@ -3,7 +3,7 @@
<prop oor:name="Type"><value>calc_ODS_FlatXML</value></prop>
<prop oor:name="DocumentService"><value>com.sun.star.sheet.SpreadsheetDocument</value></prop>
<prop oor:name="UIComponent"/>
- <prop oor:name="UserData"><value oor:separator=",">com.sun.star.documentconversion.XSLTFilter,,com.sun.star.comp.Calc.XMLOasisImporter,com.sun.star.comp.Calc.XMLOasisExporter,../share/xslt/odfflatxml/odfflatxmlimport.xsl,../share/xslt/odfflatxml/odfflatxmlexport.xsl</value></prop>
+ <prop oor:name="UserData"><value oor:separator=",">com.sun.star.comp.filter.FlatXmlCpp,,com.sun.star.comp.Calc.XMLOasisImporter,com.sun.star.comp.Calc.XMLOasisExporter,,,true</value></prop>
<prop oor:name="FilterService"><value>com.sun.star.comp.Writer.XmlFilterAdaptor</value></prop>
<prop oor:name="TemplateName"/>
<prop oor:name="UIName">
diff --git a/filter/source/config/fragments/filters/ODT_FlatXML.xcu b/filter/source/config/fragments/filters/ODT_FlatXML.xcu
index b931543..cf764ec 100644
--- a/filter/source/config/fragments/filters/ODT_FlatXML.xcu
+++ b/filter/source/config/fragments/filters/ODT_FlatXML.xcu
@@ -3,7 +3,7 @@
<prop oor:name="Type"><value>writer_ODT_FlatXML</value></prop>
<prop oor:name="DocumentService"><value>com.sun.star.text.TextDocument</value></prop>
<prop oor:name="UIComponent"/>
- <prop oor:name="UserData"><value oor:separator=",">com.sun.star.documentconversion.XSLTFilter,,com.sun.star.comp.Writer.XMLOasisImporter,com.sun.star.comp.Writer.XMLOasisExporter,../share/xslt/odfflatxml/odfflatxmlimport.xsl,../share/xslt/odfflatxml/odfflatxmlexport.xsl</value></prop>
+ <prop oor:name="UserData"><value oor:separator=",">com.sun.star.comp.filter.FlatXmlCpp,,com.sun.star.comp.Writer.XMLOasisImporter,com.sun.star.comp.Writer.XMLOasisExporter,,,true</value></prop>
<prop oor:name="FilterService"><value>com.sun.star.comp.Writer.XmlFilterAdaptor</value></prop>
<prop oor:name="TemplateName"/>
<prop oor:name="UIName">
diff --git a/filter/source/odfflatxml/FlatXml.cxx b/filter/source/odfflatxml/FlatXml.cxx
new file mode 100644
index 0000000..f6d7543
--- /dev/null
+++ b/filter/source/odfflatxml/FlatXml.cxx
@@ -0,0 +1,365 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+#include <cppuhelper/factory.hxx>
+#include <cppuhelper/servicefactory.hxx>
+#include <cppuhelper/implbase1.hxx>
+#include <cppuhelper/implbase2.hxx>
+#include <cppuhelper/implbase3.hxx>
+#include <cppuhelper/implbase.hxx>
+
+#include <com/sun/star/lang/XComponent.hpp>
+
+#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/uno/Type.hxx>
+
+#include <com/sun/star/beans/PropertyValue.hpp>
+
+#include <com/sun/star/xml/sax/XParser.hpp>
+#include <com/sun/star/xml/sax/InputSource.hpp>
+#include <com/sun/star/xml/sax/XDocumentHandler.hpp>
+#include <com/sun/star/xml/sax/XExtendedDocumentHandler.hpp>
+#include <com/sun/star/xml/sax/SAXException.hpp>
+#include <com/sun/star/xml/XImportFilter.hpp>
+#include <com/sun/star/xml/XExportFilter.hpp>
+
+#include <com/sun/star/io/XInputStream.hpp>
+#include <com/sun/star/io/XOutputStream.hpp>
+#include <com/sun/star/io/XActiveDataSource.hpp>
+#include <com/sun/star/io/XSeekable.hpp>
+
+#include "FlatXml.hxx"
+
+using namespace ::rtl;
+using namespace ::cppu;
+using namespace ::osl;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::io;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::registry;
+using namespace ::com::sun::star::xml;
+using namespace ::com::sun::star::xml::sax;
+
+namespace XFlatXml
+{
+
+ sal_Bool
+ XFlatXml::importer(const Sequence<PropertyValue>& aSourceData,
+ const Reference<XDocumentHandler>& xHandler, const Sequence<
+ OUString>& /* msUserData */) throw (RuntimeException)
+ {
+ // get information from media descriptor
+ // the imput stream that represents the imported file
+ // is most important here since we need to supply it to
+ // the sax parser that drives the supplied document handler
+ sal_Int32 nLength = aSourceData.getLength();
+ OUString aName, aFileName, aURL;
+ Reference<XInputStream> xInputStream;
+ for (sal_Int32 i = 0; i < nLength; i++)
+ {
+ aName = aSourceData[i].Name;
+ if (aName.equalsAscii("InputStream"))
+ aSourceData[i].Value >>= xInputStream;
+ else if (aName.equalsAscii("FileName"))
+ aSourceData[i].Value >>= aFileName;
+ else if (aName.equalsAscii("URL"))
+ aSourceData[i].Value >>= aURL;
+ }
+
+ // we need an input stream
+ OSL_ASSERT(xInputStream.is());
+ if (!xInputStream.is())
+ return sal_False;
+
+ // rewind seekable stream
+ Reference<XSeekable> xSeek(xInputStream, UNO_QUERY);
+ if (xSeek.is())
+ xSeek->seek(0);
+
+ // create SAX parser that will read the document file
+ // and provide events to xHandler passed to this call
+ Reference<XParser>
+ xSaxParser(
+ m_rServiceFactory->createInstance(
+ OUString(
+ RTL_CONSTASCII_USTRINGPARAM("com.sun.star.xml.sax.Parser"))),
+ UNO_QUERY);
+ OSL_ASSERT(xSaxParser.is());
+ if (!xSaxParser.is())
+ return sal_False;
+
+ // let the parser try to send the sax event to the document handler
+ try
+ {
+ InputSource aInput;
+ aInput.sSystemId = aURL;
+ aInput.sPublicId = aURL;
+ aInput.aInputStream = xInputStream;
+ xSaxParser->setDocumentHandler(xHandler);
+ xSaxParser->parseStream(aInput);
+ }
+ catch (Exception &exc)
+ {
+ // something went wrong
+ OString msg = OUStringToOString(exc.Message,
+ RTL_TEXTENCODING_ASCII_US);
+ OSL_ENSURE(0, msg);
+ return sal_False;
+ }
+
+ // done
+ return sal_True;
+ }
+
+ sal_Bool
+ XFlatXml::exporter(const Sequence<PropertyValue>& aSourceData,
+ const Sequence<OUString>& /*msUserData*/) throw (RuntimeException)
+ {
+
+ // read source data
+ // we are especialy interested in the output stream
+ // since that is where our xml-writer will push the data
+ // from it's data-source interface
+ OUString aName, sURL;
+ Reference<XOutputStream> rOutputStream;
+ sal_Int32 nLength = aSourceData.getLength();
+ for (sal_Int32 i = 0; i < nLength; i++)
+ {
+ aName = aSourceData[i].Name;
+ if (aName.equalsAscii("OutputStream"))
+ aSourceData[i].Value >>= rOutputStream;
+ else if (aName.equalsAscii("URL"))
+ aSourceData[i].Value >>= sURL;
+ }
+
+ if (!m_rDocumentHandler.is())
+ {
+ // get the document writer
+ m_rDocumentHandler
+ = Reference<XExtendedDocumentHandler> (
+ m_rServiceFactory->createInstance(
+ OUString(
+ RTL_CONSTASCII_USTRINGPARAM("com.sun.star.xml.sax.Writer"))),
+ UNO_QUERY);
+ OSL_ASSERT(m_rDocumentHandler.is());
+ if (!m_rDocumentHandler.is())
+ return sal_False;
+ }
+ // get data source interface ...
+ Reference<XActiveDataSource> rDataSource(m_rDocumentHandler, UNO_QUERY);
+ OSL_ASSERT(rDataSource.is());
+ if (!rDataSource.is())
+ return sal_False;
+ OSL_ASSERT(rOutputStream.is());
+ if (!rOutputStream.is())
+ return sal_False;
+ // ... and set output stream
+ rDataSource->setOutputStream(rOutputStream);
+
+ return sal_True;
+ }
+
+ // for the DocumentHandler implementation, we just proxy the the
+ // events to the XML writer that we created upon the output stream
+ // that was provided by the XMLFilterAdapter
+ void
+ XFlatXml::startDocument() throw (SAXException, RuntimeException)
+ {
+ OSL_ASSERT(m_rDocumentHandler.is());
+ m_rDocumentHandler->startDocument();
+ }
+
+ void
+ XFlatXml::endDocument() throw (SAXException, RuntimeException)
+ {
+ OSL_ASSERT(m_rDocumentHandler.is());
+ m_rDocumentHandler->endDocument();
+ }
+
+ void
+ XFlatXml::startElement(const OUString& str,
+ const Reference<XAttributeList>& attriblist) throw (SAXException,
+ RuntimeException)
+ {
+ OSL_ASSERT(m_rDocumentHandler.is());
+ m_rDocumentHandler->startElement(str, attriblist);
+ }
+
+ void
+ XFlatXml::endElement(const OUString& str) throw (SAXException,
+ RuntimeException)
+ {
+ OSL_ASSERT(m_rDocumentHandler.is());
+ m_rDocumentHandler->endElement(str);
+ }
+
+ void
+ XFlatXml::characters(const OUString& str) throw (SAXException,
+ RuntimeException)
+ {
+ OSL_ASSERT(m_rDocumentHandler.is());
+ m_rDocumentHandler->characters(str);
+ }
+
+ void
+ XFlatXml::ignorableWhitespace(const OUString& str) throw (SAXException,
+ RuntimeException)
+ {
+ OSL_ASSERT(m_rDocumentHandler.is());
+ if (!m_bPrettyPrint)
+ return;
+ m_rDocumentHandler->ignorableWhitespace(str);
+ }
+
+ void
+ XFlatXml::processingInstruction(const OUString& str, const OUString& str2)
+ throw (SAXException, RuntimeException)
+ {
+ OSL_ASSERT(m_rDocumentHandler.is());
+ m_rDocumentHandler->processingInstruction(str, str2);
+ }
+
+ void
+ XFlatXml::setDocumentLocator(const Reference<XLocator>& doclocator)
+ throw (SAXException, RuntimeException)
+ {
+ OSL_ASSERT(m_rDocumentHandler.is());
+ m_rDocumentHandler->setDocumentLocator(doclocator);
+ }
+
+ // --------------------------------------
+ // Component management
+ // --------------------------------------
+ Reference<XInterface> SAL_CALL
+ CreateInstance(const Reference<XMultiServiceFactory> &r)
+ {
+ return Reference<XInterface> ((OWeakObject *) new XFlatXml(r));
+ }
+
+ Sequence<OUString>
+ getSupportedServiceNames()
+ {
+ static Sequence<OUString> *pNames = 0;
+ if (!pNames)
+ {
+ MutexGuard guard(Mutex::getGlobalMutex());
+ if (!pNames)
+ {
+ static Sequence<OUString> seqNames(2);
+ seqNames.getArray()[0] = OUString(
+ RTL_CONSTASCII_USTRINGPARAM(
+ "com.sun.star.document.ImportFilter"));
+ seqNames.getArray()[1] = OUString(
+ RTL_CONSTASCII_USTRINGPARAM(
+ "com.sun.star.document.ExportFilter"));
+ pNames = &seqNames;
+ }
+ }
+ return *pNames;
+ }
+
+}
+
+using namespace XFlatXml;
+#define IMPLEMENTATION_NAME "com.sun.star.comp.filter.FlatXmlCpp"
+
+extern "C"
+{
+ void SAL_CALL
+ component_getImplementationEnvironment(const sal_Char ** ppEnvTypeName,
+ uno_Environment ** /* ppEnv */)
+ {
+ *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
+ }
+
+ sal_Bool SAL_CALL
+ component_writeInfo(void * /* pServiceManager */, void * pRegistryKey)
+ {
+ if (pRegistryKey)
+ {
+ try
+ {
+ Reference<XRegistryKey>
+ xNewKey(
+ reinterpret_cast<XRegistryKey *> (pRegistryKey)->createKey(
+ OUString(
+ RTL_CONSTASCII_USTRINGPARAM( "/" IMPLEMENTATION_NAME "/UNO/SERVICES" ))));
+
+ const Sequence<OUString> & rSNL =
+ getSupportedServiceNames();
+ const OUString * pArray = rSNL.getConstArray();
+ for (sal_Int32 nPos = rSNL.getLength(); nPos--;)
+ xNewKey->createKey(pArray[nPos]);
+
+ return sal_True;
+ }
+ catch (InvalidRegistryException &)
+ {
+ OSL_ENSURE( sal_False, "### InvalidRegistryException!" );
+ }
+ }
+ return sal_False;
+ }
+
+ void *
+ SAL_CALL component_getFactory(const sal_Char * pImplName,
+ void * pServiceManager, void * /* pRegistryKey */)
+ {
+ void * pRet = 0;
+
+ if (pServiceManager && rtl_str_compare(pImplName, IMPLEMENTATION_NAME)
+ == 0)
+ {
+ Reference<XSingleServiceFactory>
+ xFactory(
+ createSingleFactory(
+ reinterpret_cast<XMultiServiceFactory *> (pServiceManager),
+ OUString::createFromAscii(pImplName),
+ CreateInstance,
+ getSupportedServiceNames()));
+
+ if (xFactory.is())
+ {
+ xFactory->acquire();
+ pRet = xFactory.get();
+ }
+ }
+ return pRet;
+ }
+
+} // extern "C"
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/filter/source/odfflatxml/FlatXml.hxx b/filter/source/odfflatxml/FlatXml.hxx
new file mode 100644
index 0000000..8b72f1e
--- /dev/null
+++ b/filter/source/odfflatxml/FlatXml.hxx
@@ -0,0 +1,144 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+#ifndef __XFLATXML_HXX__
+#define __XFLATXML_HXX__
+
+#include <cppuhelper/factory.hxx>
+#include <cppuhelper/servicefactory.hxx>
+#include <cppuhelper/implbase1.hxx>
+#include <cppuhelper/implbase2.hxx>
+#include <cppuhelper/implbase3.hxx>
+#include <cppuhelper/implbase.hxx>
+
+#include <com/sun/star/lang/XComponent.hpp>
+
+#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/uno/Type.hxx>
+
+#include <com/sun/star/beans/PropertyValue.hpp>
+
+#include <com/sun/star/xml/sax/XParser.hpp>
+#include <com/sun/star/xml/sax/InputSource.hpp>
+#include <com/sun/star/xml/sax/XDocumentHandler.hpp>
+#include <com/sun/star/xml/sax/XExtendedDocumentHandler.hpp>
+#include <com/sun/star/xml/sax/SAXException.hpp>
+#include <com/sun/star/xml/XImportFilter.hpp>
+#include <com/sun/star/xml/XExportFilter.hpp>
+
+#include <com/sun/star/io/XInputStream.hpp>
+#include <com/sun/star/io/XOutputStream.hpp>
+#include <com/sun/star/io/XActiveDataSource.hpp>
+#include <com/sun/star/io/XSeekable.hpp>
+
+using namespace ::rtl;
+using namespace ::cppu;
+using namespace ::osl;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::io;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::registry;
+using namespace ::com::sun::star::xml;
+using namespace ::com::sun::star::xml::sax;
+
+namespace XFlatXml
+{
+
+ /*
+ * XFlatXml export and imports ODF flat XML documents by plumbing a pass-through
+ * filter implementation to XmlFilterAdaptor.
+ *
+ * XXX: Currently, this code adds nothing to the flat XML filter implementation
+ * provided with the ODK.
+ */
+ class XFlatXml : public WeakImplHelper3<XImportFilter, XExportFilter,
+ XDocumentHandler>
+ {
+ private:
+ // the UNO ServiceFactory
+ Reference<XMultiServiceFactory> m_rServiceFactory;
+
+ // DocumentHandler interface of the css::xml::sax::Writer service
+ Reference<XExtendedDocumentHandler> m_rDocumentHandler;
+
+ // controls pretty-printing
+ sal_Bool m_bPrettyPrint;
+
+ public:
+
+ // ctor...
+ XFlatXml(const Reference<XMultiServiceFactory> &r) :
+ m_rServiceFactory(r), m_bPrettyPrint(sal_True)
+ {
+ }
+
+ // XImportFilter
+ virtual sal_Bool SAL_CALL
+ importer(const Sequence<PropertyValue>& aSourceData, const Reference<
+ XDocumentHandler>& xHandler,
+ const Sequence<OUString>& msUserData) throw (RuntimeException);
+
+ // XExportFilter
+ virtual sal_Bool SAL_CALL
+ exporter(const Sequence<PropertyValue>& aSourceData, const Sequence<
+ OUString>& msUserData) throw (RuntimeException);
+
+ // XDocumentHandler
+ virtual void SAL_CALL
+ startDocument() throw (SAXException, RuntimeException);
+ virtual void SAL_CALL
+ endDocument() throw (SAXException, RuntimeException);
+ virtual void SAL_CALL
+ startElement(const OUString& str,
+ const Reference<XAttributeList>& attriblist)
+ throw (SAXException, RuntimeException);
+ virtual void SAL_CALL
+ endElement(const OUString& str) throw (SAXException, RuntimeException);
+ virtual void SAL_CALL
+ characters(const OUString& str) throw (SAXException, RuntimeException);
+ virtual void SAL_CALL
+ ignorableWhitespace(const OUString& str) throw (SAXException,
+ RuntimeException);
+ virtual void SAL_CALL
+ processingInstruction(const OUString& str, const OUString& str2)
+ throw (com::sun::star::xml::sax::SAXException,
+ RuntimeException);
+ virtual void SAL_CALL
+ setDocumentLocator(const Reference<XLocator>& doclocator)
+ throw (SAXException, RuntimeException);
+ };
+}
+#endif // __XFLATXML_HXX__
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/filter/source/odfflatxml/makefile.mk b/filter/source/odfflatxml/makefile.mk
new file mode 100644
index 0000000..ee56789
--- /dev/null
+++ b/filter/source/odfflatxml/makefile.mk
@@ -0,0 +1,56 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+PRJ = ..$/..
+PRJNAME = filter
+TARGET = odfflatxml
+ENABLE_EXCEPTIONS=TRUE
+LIBTARGET=NO
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE: settings.mk
+
+SLOFILES=$(SLO)$/FlatXml.obj
+LIBNAME=odfflatxml
+SHL1TARGETDEPN=makefile.mk
+SHL1OBJS=$(SLOFILES)
+SHL1TARGET=$(LIBNAME)$(DLLPOSTFIX)
+SHL1IMPLIB=i$(LIBNAME)
+SHL1VERSIONMAP=$(SOLARENV)/src/component.map
+SHL1DEF=$(MISC)$/$(SHL1TARGET).def
+DEF1NAME=$(SHL1TARGET)
+
+SHL1STDLIBS= \
+ $(TOOLSLIB) \
+ $(CPPUHELPERLIB) \
+ $(CPPULIB) \
+ $(XMLOFFLIB) \
+ $(SALLIB) \
+ $(UCBHELPERLIB)
+
+# --- Targets ------------------------------------------------------
+.INCLUDE : target.mk
--
1.7.1
--=-5p4WVWLfqqyD+dNfhU1+--
More information about the LibreOffice
mailing list