summaryrefslogtreecommitdiff
path: root/writerfilter/source
diff options
context:
space:
mode:
authoros <os@openoffice.org>2010-09-23 12:54:46 +0200
committeros <os@openoffice.org>2010-09-23 12:54:46 +0200
commita7326cb13e5970dee9d16d99faf4ae055625f026 (patch)
tree9df495aab1fd0564493ed5d1e8e0c98ec4781b29 /writerfilter/source
parentcbd0136b9f5ae01d8ce243706286950f77efc004 (diff)
parent661d7b756c2fc702a0d3750fc1d399681555ab0d (diff)
merged
Diffstat (limited to 'writerfilter/source')
-rw-r--r--writerfilter/source/filter/RtfFilter.cxx146
-rw-r--r--writerfilter/source/filter/RtfFilter.hxx102
-rw-r--r--writerfilter/source/filter/WriterFilter.cxx2
-rw-r--r--writerfilter/source/filter/makefile.mk3
4 files changed, 252 insertions, 1 deletions
diff --git a/writerfilter/source/filter/RtfFilter.cxx b/writerfilter/source/filter/RtfFilter.cxx
new file mode 100644
index 000000000000..040843afd7ce
--- /dev/null
+++ b/writerfilter/source/filter/RtfFilter.cxx
@@ -0,0 +1,146 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * Copyright 2010 Miklos Vajna.
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef _CPPUHELPER_IMPLEMENTATIONENTRY_
+#include <cppuhelper/implementationentry.hxx>
+#endif
+#include <osl/module.hxx>
+#include <tools/solar.h>
+#include <RtfFilter.hxx>
+
+using namespace ::rtl;
+using namespace ::cppu;
+using namespace ::com::sun::star;
+
+RtfFilter::RtfFilter( const uno::Reference< uno::XComponentContext >& rxContext) :
+ m_xContext( rxContext )
+{
+}
+
+RtfFilter::~RtfFilter()
+{
+}
+
+sal_Bool RtfFilter::filter( const uno::Sequence< beans::PropertyValue >& aDescriptor )
+ throw (uno::RuntimeException)
+{
+ OSL_TRACE("%s", OSL_THIS_FUNC);
+ if( m_xSrcDoc.is() )
+ {
+ uno::Reference< lang::XMultiServiceFactory > xMSF(m_xContext->getServiceManager(), uno::UNO_QUERY_THROW);
+ uno::Reference< uno::XInterface > xIfc( xMSF->createInstance( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.comp.Writer.RtfExport" ))), uno::UNO_QUERY_THROW);
+ if (!xIfc.is())
+ return sal_False;
+ uno::Reference< document::XExporter > xExprtr(xIfc, uno::UNO_QUERY_THROW);
+ uno::Reference< document::XFilter > xFltr(xIfc, uno::UNO_QUERY_THROW);
+ if (!xExprtr.is() || !xFltr.is())
+ return sal_False;
+ xExprtr->setSourceDocument(m_xSrcDoc);
+ return xFltr->filter(aDescriptor);
+ }
+ else if ( m_xDstDoc.is() )
+ {
+ uno::Reference< lang::XMultiServiceFactory > xMSF(m_xContext->getServiceManager(), uno::UNO_QUERY_THROW);
+ uno::Reference< uno::XInterface > xIfc( xMSF->createInstance( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.comp.Writer.RtfImport" ))), uno::UNO_QUERY_THROW);
+ if (!xIfc.is())
+ return sal_False;
+ uno::Reference< document::XImporter > xImprtr(xIfc, uno::UNO_QUERY_THROW);
+ uno::Reference< document::XFilter > xFltr(xIfc, uno::UNO_QUERY_THROW);
+ if (!xImprtr.is() || !xFltr.is())
+ return sal_False;
+ xImprtr->setTargetDocument(m_xDstDoc);
+ return xFltr->filter(aDescriptor);
+ }
+ return sal_False;
+}
+
+void RtfFilter::cancel( ) throw (uno::RuntimeException)
+{
+}
+
+void RtfFilter::setSourceDocument( const uno::Reference< lang::XComponent >& xDoc )
+ throw (lang::IllegalArgumentException, uno::RuntimeException)
+{
+ m_xSrcDoc = xDoc;
+}
+
+void RtfFilter::setTargetDocument( const uno::Reference< lang::XComponent >& xDoc )
+ throw (lang::IllegalArgumentException, uno::RuntimeException)
+{
+ m_xDstDoc = xDoc;
+}
+
+void RtfFilter::initialize( const uno::Sequence< uno::Any >& /*aArguments*/ ) throw (uno::Exception, uno::RuntimeException)
+{
+ // The DOCX exporter here extracts 'type' of the filter, ie 'Word' or
+ // 'Word Template' but we don't need it for RTF.
+}
+
+OUString RtfFilter::getImplementationName( ) throw (uno::RuntimeException)
+{
+ return RtfFilter_getImplementationName();
+}
+
+#define SERVICE_NAME1 "com.sun.star.document.ImportFilter"
+#define SERVICE_NAME2 "com.sun.star.document.ExportFilter"
+sal_Bool RtfFilter::supportsService( const OUString& rServiceName ) throw (uno::RuntimeException)
+{
+ return (rServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( SERVICE_NAME1 ) ) ||
+ rServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( SERVICE_NAME2 ) ));
+}
+
+uno::Sequence< OUString > RtfFilter::getSupportedServiceNames( ) throw (uno::RuntimeException)
+{
+ return RtfFilter_getSupportedServiceNames();
+}
+
+/* Helpers, used by shared lib exports. */
+
+OUString RtfFilter_getImplementationName () throw (uno::RuntimeException)
+{
+ return OUString ( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.comp.Writer.RtfFilter" ) );
+}
+
+uno::Sequence< OUString > RtfFilter_getSupportedServiceNames( ) throw (uno::RuntimeException)
+{
+ uno::Sequence < OUString > aRet(2);
+ OUString* pArray = aRet.getArray();
+ pArray[0] = OUString ( RTL_CONSTASCII_USTRINGPARAM ( SERVICE_NAME1 ) );
+ pArray[1] = OUString ( RTL_CONSTASCII_USTRINGPARAM ( SERVICE_NAME2 ) );
+ return aRet;
+}
+#undef SERVICE_NAME1
+#undef SERVICE_NAME2
+
+uno::Reference< uno::XInterface > RtfFilter_createInstance( const uno::Reference< uno::XComponentContext >& xContext)
+ throw( uno::Exception )
+{
+ return (cppu::OWeakObject*) new RtfFilter( xContext );
+}
+
+/* vi:set shiftwidth=4 expandtab: */
diff --git a/writerfilter/source/filter/RtfFilter.hxx b/writerfilter/source/filter/RtfFilter.hxx
new file mode 100644
index 000000000000..3a4be622ab17
--- /dev/null
+++ b/writerfilter/source/filter/RtfFilter.hxx
@@ -0,0 +1,102 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * Copyright 2010 Miklos Vajna.
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef _RTFFILTER_HXX
+#define _RTFFILTER_HXX
+
+#include <com/sun/star/document/XFilter.hpp>
+#include <com/sun/star/document/XImporter.hpp>
+#include <com/sun/star/document/XExporter.hpp>
+#include <com/sun/star/lang/XInitialization.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/xml/sax/XDocumentHandler.hpp>
+#include <cppuhelper/implbase5.hxx>
+#include <WriterFilterDllApi.hxx>
+
+class WRITERFILTER_DLLPUBLIC RtfFilter : public cppu::WeakImplHelper5
+<
+ com::sun::star::document::XFilter,
+ com::sun::star::document::XImporter,
+ com::sun::star::document::XExporter,
+ com::sun::star::lang::XInitialization,
+ com::sun::star::lang::XServiceInfo
+>
+{
+
+protected:
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext;
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > m_xSrcDoc, m_xDstDoc;
+ ::rtl::OUString m_sFilterName;
+ ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler > m_xHandler;
+
+
+public:
+ RtfFilter( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext);
+ virtual ~RtfFilter();
+
+ // XFilter
+ virtual sal_Bool SAL_CALL filter( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aDescriptor )
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL cancel( )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ // XImporter
+ virtual void SAL_CALL setTargetDocument( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >& xDoc )
+ throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
+
+ // XExporter
+ virtual void SAL_CALL setSourceDocument( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >& xDoc )
+ throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
+
+ // XInitialization
+ virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments )
+ throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
+
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName( )
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames()
+ throw (::com::sun::star::uno::RuntimeException);
+
+};
+
+
+::rtl::OUString RtfFilter_getImplementationName()
+ throw ( ::com::sun::star::uno::RuntimeException );
+
+::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL RtfFilter_getSupportedServiceNames( )
+ throw ( ::com::sun::star::uno::RuntimeException );
+
+::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL RtfFilter_createInstance(
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::uno::XComponentContext > &xContext)
+ throw( ::com::sun::star::uno::Exception );
+#endif
+
diff --git a/writerfilter/source/filter/WriterFilter.cxx b/writerfilter/source/filter/WriterFilter.cxx
index 71a97d72f391..cd744238f314 100644
--- a/writerfilter/source/filter/WriterFilter.cxx
+++ b/writerfilter/source/filter/WriterFilter.cxx
@@ -30,6 +30,7 @@
#endif
#include <WriterFilter.hxx>
#include <WriterFilterDetection.hxx>
+#include <RtfFilter.hxx>
using namespace ::rtl;
using namespace ::cppu;
@@ -56,6 +57,7 @@ static struct ::cppu::ImplementationEntry s_component_entries [] =
{
{ WriterFilter_createInstance, WriterFilter_getImplementationName, WriterFilter_getSupportedServiceNames, ::cppu::createSingleComponentFactory, 0, 0 },
{ WriterFilterDetection_createInstance, WriterFilterDetection_getImplementationName, WriterFilterDetection_getSupportedServiceNames, ::cppu::createSingleComponentFactory, 0, 0} ,
+ { RtfFilter_createInstance, RtfFilter_getImplementationName, RtfFilter_getSupportedServiceNames, ::cppu::createSingleComponentFactory, 0, 0 },
{ 0, 0, 0, 0, 0, 0 } // terminate with NULL
};
diff --git a/writerfilter/source/filter/makefile.mk b/writerfilter/source/filter/makefile.mk
index f578e2853243..6b11fd4ff1f3 100644
--- a/writerfilter/source/filter/makefile.mk
+++ b/writerfilter/source/filter/makefile.mk
@@ -40,7 +40,8 @@ ENABLE_EXCEPTIONS=TRUE
SLOFILES= $(SLO)$/WriterFilter.obj \
$(SLO)$/WriterFilterDetection.obj \
- $(SLO)$/ImportFilter.obj
+ $(SLO)$/ImportFilter.obj \
+ $(SLO)$/RtfFilter.obj
# --- Targets ----------------------------------