diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2015-02-21 10:41:07 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2015-02-21 19:03:00 +0100 |
commit | af986d2be777e7dd31ce94a70e60af754bac7131 (patch) | |
tree | 7d51ec210fc30005e18efc3c905dc829ec7f04cd | |
parent | 949b9dc8ed2f5cdfd6f99531fc4ac2b8c201b145 (diff) |
writerfilter: clean up RtfFilter
Change-Id: I4bcff4ddde2869a4aeecfdfda02c685d61d65531
-rw-r--r-- | writerfilter/source/filter/RtfFilter.cxx | 84 | ||||
-rw-r--r-- | writerfilter/source/filter/RtfFilter.hxx | 82 |
2 files changed, 57 insertions, 109 deletions
diff --git a/writerfilter/source/filter/RtfFilter.cxx b/writerfilter/source/filter/RtfFilter.cxx index de5b5053133a..6ab493492b08 100644 --- a/writerfilter/source/filter/RtfFilter.cxx +++ b/writerfilter/source/filter/RtfFilter.cxx @@ -17,21 +17,65 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#include <RtfFilter.hxx> -#include <cppuhelper/implementationentry.hxx> -#include <unotools/mediadescriptor.hxx> -#include <cppuhelper/supportsservice.hxx> -#include <dmapper/DomainMapperFactory.hxx> -#include <rtftok/RTFDocument.hxx> +#include <memory> + +#include <com/sun/star/document/XExporter.hpp> +#include <com/sun/star/document/XFilter.hpp> +#include <com/sun/star/document/XImporter.hpp> #include <com/sun/star/io/WrongFormatException.hpp> #include <com/sun/star/lang/WrappedTargetRuntimeException.hpp> -#include <memory> +#include <com/sun/star/lang/XInitialization.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <cppuhelper/implbase.hxx> +#include <cppuhelper/implementationentry.hxx> +#include <cppuhelper/supportsservice.hxx> #include <unotools/localfilehelper.hxx> -#include <unotools/ucbstreamhelper.hxx> +#include <unotools/mediadescriptor.hxx> #include <unotools/streamwrap.hxx> +#include <unotools/ucbstreamhelper.hxx> + +#include <dmapper/DomainMapperFactory.hxx> +#include <rtftok/RTFDocument.hxx> using namespace ::com::sun::star; +/// Invokes the RTF tokenizer + dmapper or RtfExportFilter in sw via UNO. +class RtfFilter : public cppu::WeakImplHelper + < + document::XFilter, + document::XImporter, + document::XExporter, + lang::XInitialization, + lang::XServiceInfo + > +{ + uno::Reference<uno::XComponentContext> m_xContext; + uno::Reference<lang::XComponent> m_xSrcDoc, m_xDstDoc; + +public: + RtfFilter(const uno::Reference<uno::XComponentContext>& xContext); + virtual ~RtfFilter(); + + // XFilter + virtual sal_Bool SAL_CALL filter(const uno::Sequence<beans::PropertyValue>& rDescriptor) throw (uno::RuntimeException, std::exception) SAL_OVERRIDE; + virtual void SAL_CALL cancel() throw (uno::RuntimeException, std::exception) SAL_OVERRIDE; + + // XImporter + virtual void SAL_CALL setTargetDocument(const uno::Reference<lang::XComponent>& xDoc) throw (lang::IllegalArgumentException, uno::RuntimeException, std::exception) SAL_OVERRIDE; + + // XExporter + virtual void SAL_CALL setSourceDocument(const uno::Reference<lang::XComponent>& xDoc) throw (lang::IllegalArgumentException, uno::RuntimeException, std::exception) SAL_OVERRIDE; + + // XInitialization + virtual void SAL_CALL initialize(const uno::Sequence<uno::Any>& rArguments) throw (uno::Exception, uno::RuntimeException, std::exception) SAL_OVERRIDE; + + // XServiceInfo + virtual OUString SAL_CALL getImplementationName() throw (uno::RuntimeException, std::exception) SAL_OVERRIDE; + virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) throw (uno::RuntimeException, std::exception) SAL_OVERRIDE; + virtual uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() throw (uno::RuntimeException, std::exception) SAL_OVERRIDE; + +}; + RtfFilter::RtfFilter(const uno::Reference< uno::XComponentContext >& rxContext) : m_xContext(rxContext) { @@ -103,8 +147,7 @@ sal_Bool RtfFilter::filter(const uno::Sequence< beans::PropertyValue >& aDescrip writerfilter::dmapper::SourceDocumentType eType = writerfilter::dmapper::SourceDocumentType::RTF; writerfilter::Stream::Pointer_t pStream( writerfilter::dmapper::DomainMapperFactory::createMapper(m_xContext, xInputStream, m_xDstDoc, bRepairStorage, eType, xInsertTextRange, aMediaDesc)); - writerfilter::rtftok::RTFDocument::Pointer_t const pDocument( - writerfilter::rtftok::RTFDocumentFactory::createDocument(m_xContext, xInputStream, m_xDstDoc, xFrame, xStatusIndicator)); + writerfilter::rtftok::RTFDocument::Pointer_t pDocument(writerfilter::rtftok::RTFDocumentFactory::createDocument(m_xContext, xInputStream, m_xDstDoc, xFrame, xStatusIndicator)); pDocument->resolve(*pStream); bResult = true; sal_uInt32 nEndTime = osl_getGlobalTimer(); @@ -148,7 +191,7 @@ void RtfFilter::initialize(const uno::Sequence< uno::Any >& /*aArguments*/) thro OUString RtfFilter::getImplementationName() throw(uno::RuntimeException, std::exception) { - return RtfFilter_getImplementationName(); + return OUString("com.sun.star.comp.Writer.RtfFilter"); } sal_Bool RtfFilter::supportsService(const OUString& rServiceName) throw(uno::RuntimeException, std::exception) @@ -156,18 +199,7 @@ sal_Bool RtfFilter::supportsService(const OUString& rServiceName) throw(uno::Run return cppu::supportsService(this, rServiceName); } -uno::Sequence< OUString > RtfFilter::getSupportedServiceNames() throw(uno::RuntimeException, std::exception) -{ - return RtfFilter_getSupportedServiceNames(); -} - -/* Helpers, used by shared lib exports. */ -OUString RtfFilter_getImplementationName() throw(uno::RuntimeException) -{ - return OUString("com.sun.star.comp.Writer.RtfFilter"); -} - -uno::Sequence<OUString> RtfFilter_getSupportedServiceNames() throw(uno::RuntimeException) +uno::Sequence<OUString> RtfFilter::getSupportedServiceNames() throw(uno::RuntimeException, std::exception) { uno::Sequence<OUString> aRet = { @@ -177,10 +209,8 @@ uno::Sequence<OUString> RtfFilter_getSupportedServiceNames() throw(uno::RuntimeE return aRet; } -extern "C" SAL_DLLPUBLIC_EXPORT ::com::sun::star::uno::XInterface* SAL_CALL -com_sun_star_comp_Writer_RtfFilter_get_implementation(::com::sun::star::uno::XComponentContext* component, - ::com::sun::star::uno::Sequence<css::uno::Any> const &) +extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface* SAL_CALL com_sun_star_comp_Writer_RtfFilter_get_implementation(uno::XComponentContext* pComponent, uno::Sequence<uno::Any> const&) { - return cppu::acquire(new RtfFilter(component)); + return cppu::acquire(new RtfFilter(pComponent)); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/writerfilter/source/filter/RtfFilter.hxx b/writerfilter/source/filter/RtfFilter.hxx deleted file mode 100644 index dcd3a2e4c17e..000000000000 --- a/writerfilter/source/filter/RtfFilter.hxx +++ /dev/null @@ -1,82 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * 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/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#ifndef INCLUDED_WRITERFILTER_SOURCE_FILTER_RTFFILTER_HXX -#define INCLUDED_WRITERFILTER_SOURCE_FILTER_RTFFILTER_HXX - -#include <com/sun/star/document/XExporter.hpp> -#include <com/sun/star/document/XFilter.hpp> -#include <com/sun/star/document/XImporter.hpp> -#include <com/sun/star/lang/XInitialization.hpp> -#include <com/sun/star/lang/XServiceInfo.hpp> -#include <com/sun/star/uno/XComponentContext.hpp> -#include <com/sun/star/xml/sax/XDocumentHandler.hpp> -#include <cppuhelper/implbase.hxx> - -/// Common RTF filter, calls RtfImportFilter and RtfExportFilter via UNO. -class RtfFilter : public cppu::WeakImplHelper - < - css::document::XFilter, - css::document::XImporter, - css::document::XExporter, - css::lang::XInitialization, - css::lang::XServiceInfo - > -{ - -protected: - css::uno::Reference<css::uno::XComponentContext> m_xContext; - css::uno::Reference<css::lang::XComponent> m_xSrcDoc, m_xDstDoc; - OUString m_sFilterName; - css::uno::Reference<css::xml::sax::XDocumentHandler> m_xHandler; - - -public: - RtfFilter(const css::uno::Reference<css::uno::XComponentContext>& xContext); - virtual ~RtfFilter(); - - // XFilter - virtual sal_Bool SAL_CALL filter(const css::uno::Sequence<css::beans::PropertyValue>& rDescriptor) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE; - virtual void SAL_CALL cancel() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE; - - // XImporter - virtual void SAL_CALL setTargetDocument(const css::uno::Reference<css::lang::XComponent>& xDoc) - throw (css::lang::IllegalArgumentException, css::uno::RuntimeException, std::exception) SAL_OVERRIDE; - - // XExporter - virtual void SAL_CALL setSourceDocument(const css::uno::Reference<css::lang::XComponent>& xDoc) - throw (css::lang::IllegalArgumentException, css::uno::RuntimeException, std::exception) SAL_OVERRIDE; - - // XInitialization - virtual void SAL_CALL initialize(const css::uno::Sequence<css::uno::Any>& rArguments) throw (css::uno::Exception, css::uno::RuntimeException, std::exception) SAL_OVERRIDE; - - // XServiceInfo - virtual OUString SAL_CALL getImplementationName() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE; - virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE; - virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE; - -}; - - -OUString RtfFilter_getImplementationName() throw (css::uno::RuntimeException); -css::uno::Sequence<OUString> SAL_CALL RtfFilter_getSupportedServiceNames() throw (css::uno::RuntimeException); - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |