writerperfect/Library_wpftcalc.mk | 6 writerperfect/Library_wpftdraw.mk | 5 writerperfect/inc/writerperfect/DocumentHandlerFor.hxx | 28 ++ writerperfect/inc/writerperfect/ImportFilter.hxx | 206 +++++++++++++++++ writerperfect/source/calc/DocumentHandlerForOds.hxx | 31 ++ writerperfect/source/calc/ImportFilterBase.cxx | 182 --------------- writerperfect/source/calc/ImportFilterBase.hxx | 113 --------- writerperfect/source/calc/MSWorksCalcImportFilter.cxx | 2 writerperfect/source/calc/MSWorksCalcImportFilter.hxx | 10 writerperfect/source/calc/MWAWCalcImportFilter.cxx | 2 writerperfect/source/calc/MWAWCalcImportFilter.hxx | 10 writerperfect/source/draw/CDRImportFilter.cxx | 2 writerperfect/source/draw/CDRImportFilter.hxx | 2 writerperfect/source/draw/CMXImportFilter.cxx | 2 writerperfect/source/draw/CMXImportFilter.hxx | 2 writerperfect/source/draw/FreehandImportFilter.cxx | 2 writerperfect/source/draw/FreehandImportFilter.hxx | 2 writerperfect/source/draw/ImportFilterBase.cxx | 3 writerperfect/source/draw/ImportFilterBase.hxx | 4 writerperfect/source/draw/MSPUBImportFilter.cxx | 2 writerperfect/source/draw/MSPUBImportFilter.hxx | 2 writerperfect/source/draw/MWAWDrawImportFilter.cxx | 2 writerperfect/source/draw/MWAWDrawImportFilter.hxx | 2 writerperfect/source/draw/PageMakerImportFilter.cxx | 2 writerperfect/source/draw/PageMakerImportFilter.hxx | 2 writerperfect/source/draw/VisioImportFilter.cxx | 2 writerperfect/source/draw/VisioImportFilter.hxx | 2 writerperfect/source/draw/WPGImportFilter.cxx | 2 writerperfect/source/draw/WPGImportFilter.hxx | 2 writerperfect/source/writer/AbiWordImportFilter.cxx | 2 writerperfect/source/writer/AbiWordImportFilter.hxx | 2 writerperfect/source/writer/EBookImportFilter.cxx | 19 - writerperfect/source/writer/EBookImportFilter.hxx | 2 writerperfect/source/writer/ImportFilterBase.cxx | 3 writerperfect/source/writer/ImportFilterBase.hxx | 4 writerperfect/source/writer/MSWorksImportFilter.cxx | 2 writerperfect/source/writer/MSWorksImportFilter.hxx | 2 writerperfect/source/writer/MWAWImportFilter.cxx | 2 writerperfect/source/writer/MWAWImportFilter.hxx | 2 39 files changed, 334 insertions(+), 340 deletions(-)
New commits: commit 006a5d5be6071b27551baa3048c805891a1eae63 Author: David Tardon <dtar...@redhat.com> Date: Wed Sep 17 18:53:37 2014 +0200 use MediaDescriptor to get input stream Change-Id: Iecc7f373d0d352281b53324ef8824c5d7073fe8a diff --git a/writerperfect/inc/writerperfect/ImportFilter.hxx b/writerperfect/inc/writerperfect/ImportFilter.hxx index 294dd46..ec59c09 100644 --- a/writerperfect/inc/writerperfect/ImportFilter.hxx +++ b/writerperfect/inc/writerperfect/ImportFilter.hxx @@ -68,14 +68,9 @@ public: virtual sal_Bool SAL_CALL filter(const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > &rDescriptor) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE { - sal_Int32 nLength = rDescriptor.getLength(); - const css::beans::PropertyValue *pValue = rDescriptor.getConstArray(); + utl::MediaDescriptor aDescriptor(rDescriptor); css::uno::Reference < css::io::XInputStream > xInputStream; - for (sal_Int32 i = 0 ; i < nLength; i++) - { - if (pValue[i].Name == "InputStream") - pValue[i].Value >>= xInputStream; - } + aDescriptor[utl::MediaDescriptor::PROP_INPUTSTREAM()] >>= xInputStream; if (!xInputStream.is()) { OSL_ASSERT(false); @@ -103,7 +98,6 @@ public: this->doRegisterHandlers(exporter); - utl::MediaDescriptor aDescriptor(rDescriptor); return this->doImportDocument(input, exporter, aDescriptor); } commit a23a51af899b31bcf93781637371ffd8ef813bf5 Author: David Tardon <dtar...@redhat.com> Date: Wed Sep 17 18:41:45 2014 +0200 convert wpftcalc to use ImportFilter base class Change-Id: I6692aee51753cddf57aaca1b7b7a94afafe60a9d diff --git a/writerperfect/Library_wpftcalc.mk b/writerperfect/Library_wpftcalc.mk index e09c195..49d4b6c 100644 --- a/writerperfect/Library_wpftcalc.mk +++ b/writerperfect/Library_wpftcalc.mk @@ -19,6 +19,11 @@ $(eval $(call gb_Library_Library,wpftcalc)) +$(eval $(call gb_Library_set_include,wpftcalc,\ + -I$(SRCDIR)/writerperfect/inc \ + $$(INCLUDE) \ +)) + $(eval $(call gb_Library_set_componentfile,wpftcalc,writerperfect/source/calc/wpftcalc)) $(eval $(call gb_Library_use_sdk_api,wpftcalc)) @@ -49,7 +54,6 @@ $(eval $(call gb_Library_use_externals,wpftcalc,\ )) $(eval $(call gb_Library_add_exception_objects,wpftcalc,\ - writerperfect/source/calc/ImportFilterBase \ writerperfect/source/calc/MSWorksCalcImportFilter \ writerperfect/source/calc/MWAWCalcImportFilter \ writerperfect/source/calc/wpftcalc_genericfilter \ diff --git a/writerperfect/Library_wpftdraw.mk b/writerperfect/Library_wpftdraw.mk index 973431c..106fc97 100644 --- a/writerperfect/Library_wpftdraw.mk +++ b/writerperfect/Library_wpftdraw.mk @@ -19,6 +19,11 @@ $(eval $(call gb_Library_Library,wpftdraw)) +$(eval $(call gb_Library_set_include,wpftdraw,\ + -I$(SRCDIR)/writerperfect/inc \ + $$(INCLUDE) \ +)) + $(eval $(call gb_Library_set_componentfile,wpftdraw,writerperfect/source/draw/wpftdraw)) $(eval $(call gb_Library_use_sdk_api,wpftdraw)) diff --git a/writerperfect/source/calc/DocumentHandlerForOds.hxx b/writerperfect/source/calc/DocumentHandlerForOds.hxx new file mode 100644 index 0000000..9eb0484 --- /dev/null +++ b/writerperfect/source/calc/DocumentHandlerForOds.hxx @@ -0,0 +1,31 @@ +/* -*- 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/. + */ + +#ifndef INCLUDED_WRITERPERFECT_SOURCE_CALC_DOCUMENTHANDLERFORODS_HXX +#define INCLUDED_WRITERPERFECT_SOURCE_CALC_DOCUMENTHANDLERFORODS_HXX + +#include <libodfgen/libodfgen.hxx> + +#include "writerperfect/DocumentHandlerFor.hxx" + +namespace writerperfect +{ + +template<> +struct DocumentHandlerFor<OdsGenerator> +{ + static const rtl::OUString name() + { + return rtl::OUString("com.sun.star.comp.Calc.XMLOasisImporter"); + } +}; + +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/writerperfect/source/calc/ImportFilterBase.cxx b/writerperfect/source/calc/ImportFilterBase.cxx deleted file mode 100644 index 1f9ede0..0000000 --- a/writerperfect/source/calc/ImportFilterBase.cxx +++ /dev/null @@ -1,183 +0,0 @@ -/* -*- 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/. - */ - -#include <com/sun/star/beans/PropertyValue.hpp> -#include <com/sun/star/io/XInputStream.hpp> -#include <com/sun/star/uno/XComponentContext.hpp> -#include <com/sun/star/xml/sax/XAttributeList.hpp> -#include <com/sun/star/xml/sax/XDocumentHandler.hpp> -#include <com/sun/star/xml/sax/InputSource.hpp> -#include <com/sun/star/xml/sax/XParser.hpp> -#include <com/sun/star/io/XSeekable.hpp> -#include <com/sun/star/uno/Reference.h> - -#include <writerperfect/DocumentHandler.hxx> -#include <writerperfect/WPXSvInputStream.hxx> - -#include <xmloff/attrlist.hxx> - -#include <libodfgen/libodfgen.hxx> - -#include "ImportFilterBase.hxx" - -namespace writerperfect -{ -namespace calc -{ - -using com::sun::star::uno::Reference; -using com::sun::star::io::XInputStream; -using com::sun::star::io::XSeekable; -using com::sun::star::uno::Sequence; -using com::sun::star::uno::Any; -using com::sun::star::uno::UNO_QUERY; -using com::sun::star::uno::XInterface; -using com::sun::star::uno::Exception; -using com::sun::star::uno::RuntimeException; -using com::sun::star::beans::PropertyValue; -using com::sun::star::document::XFilter; -using com::sun::star::document::XExtendedFilterDetection; -using com::sun::star::document::XImporter; -using com::sun::star::xml::sax::InputSource; -using com::sun::star::xml::sax::XAttributeList; -using com::sun::star::xml::sax::XDocumentHandler; -using com::sun::star::xml::sax::XParser; - -using writerperfect::DocumentHandler; -using writerperfect::WPXSvInputStream; - -ImportFilterImpl::ImportFilterImpl(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > &rxContext) - : mxContext(rxContext) -{ -} - -ImportFilterImpl::~ImportFilterImpl() -{ -} - -sal_Bool SAL_CALL ImportFilterImpl::filter(const Sequence< ::com::sun::star::beans::PropertyValue > &aDescriptor) -throw (RuntimeException, std::exception) -{ - sal_Int32 nLength = aDescriptor.getLength(); - const PropertyValue *pValue = aDescriptor.getConstArray(); - Reference < XInputStream > xInputStream; - for (sal_Int32 i = 0 ; i < nLength; i++) - { - if (pValue[i].Name == "InputStream") - pValue[i].Value >>= xInputStream; - } - if (!xInputStream.is()) - { - OSL_ASSERT(false); - return sal_False; - } - - // An XML import service: what we push sax messages to.. - Reference < XDocumentHandler > xInternalHandler( - mxContext->getServiceManager()->createInstanceWithContext( - "com.sun.star.comp.Calc.XMLOasisImporter", mxContext), - css::uno::UNO_QUERY_THROW); - - // The XImporter sets up an empty target document for XDocumentHandler to write to.. - Reference < XImporter > xImporter(xInternalHandler, UNO_QUERY); - xImporter->setTargetDocument(mxDoc); - - // OO Graphics Handler: abstract class to handle document SAX messages, concrete implementation here - // writes to in-memory target doc - DocumentHandler xHandler(xInternalHandler); - - WPXSvInputStream input(xInputStream); - - OdsGenerator exporter; - exporter.addDocumentHandler(&xHandler, ODF_FLAT_XML); - - doRegisterHandlers(exporter); - - utl::MediaDescriptor aMediaDescriptor(aDescriptor); - return doImportDocument(input, exporter, aMediaDescriptor); -} - -void SAL_CALL ImportFilterImpl::cancel() -throw (RuntimeException, std::exception) -{ -} - -// XImporter -void SAL_CALL ImportFilterImpl::setTargetDocument(const Reference< ::com::sun::star::lang::XComponent > &xDoc) -throw (::com::sun::star::lang::IllegalArgumentException, RuntimeException, std::exception) -{ - mxDoc = xDoc; -} - -// XExtendedFilterDetection -OUString SAL_CALL ImportFilterImpl::detect(com::sun::star::uno::Sequence< PropertyValue > &Descriptor) -throw(com::sun::star::uno::RuntimeException, std::exception) -{ - OUString sTypeName; - sal_Int32 nLength = Descriptor.getLength(); - sal_Int32 location = nLength; - const PropertyValue *pValue = Descriptor.getConstArray(); - Reference < XInputStream > xInputStream; - for (sal_Int32 i = 0 ; i < nLength; i++) - { - if (pValue[i].Name == "TypeName") - location=i; - else if (pValue[i].Name == "InputStream") - pValue[i].Value >>= xInputStream; - } - - if (!xInputStream.is()) - return OUString(); - - WPXSvInputStream input(xInputStream); - - if (doDetectFormat(input, sTypeName)) - { - assert(!sTypeName.isEmpty()); - - if (location == nLength) - { - Descriptor.realloc(nLength+1); - Descriptor[location].Name = "TypeName"; - } - - Descriptor[location].Value <<=sTypeName; - } - - return sTypeName; -} - - -// XInitialization -void SAL_CALL ImportFilterImpl::initialize(const Sequence< Any > &aArguments) -throw (Exception, RuntimeException, std::exception) -{ - Sequence < PropertyValue > aAnySeq; - sal_Int32 nLength = aArguments.getLength(); - if (nLength && (aArguments[0] >>= aAnySeq)) - { - const PropertyValue *pValue = aAnySeq.getConstArray(); - nLength = aAnySeq.getLength(); - for (sal_Int32 i = 0 ; i < nLength; i++) - { - if (pValue[i].Name == "Type") - { - pValue[i].Value >>= msFilterName; - break; - } - } - } -} - -void ImportFilterImpl::doRegisterHandlers(OdsGenerator &) -{ -} - -} -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/writerperfect/source/calc/ImportFilterBase.hxx b/writerperfect/source/calc/ImportFilterBase.hxx deleted file mode 100644 index 4b9d11d..0000000 --- a/writerperfect/source/calc/ImportFilterBase.hxx +++ /dev/null @@ -1,115 +0,0 @@ -/* -*- 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/. - */ - -#ifndef INCLUDED_WRITERPERFECT_SOURCE_CALC_IMPORTFILTERBASE_HXX -#define INCLUDED_WRITERPERFECT_SOURCE_CALC_IMPORTFILTERBASE_HXX - -#include <librevenge/librevenge.h> - -#include <librevenge-stream/librevenge-stream.h> - -#include <com/sun/star/document/XFilter.hpp> -#include <com/sun/star/document/XImporter.hpp> -#include <com/sun/star/document/XExtendedFilterDetection.hpp> -#include <com/sun/star/lang/XInitialization.hpp> -#include <com/sun/star/lang/XServiceInfo.hpp> -#include <cppuhelper/implbase1.hxx> -#include <cppuhelper/implbase4.hxx> - -#include <unotools/mediadescriptor.hxx> - -namespace com -{ -namespace sun -{ -namespace star -{ -namespace beans -{ -struct PropertyValue; -} -namespace lang -{ -class XComponent; -} -namespace uno -{ -class XComponentContext; -} -namespace xml -{ -namespace sax -{ -class XDocumentHandler; -} -} -} -} -} - -class OdsGenerator; - -namespace writerperfect -{ -namespace calc -{ - -/* This component will be instantiated for both import or export. Whether it calls - * setSourceDocument or setTargetDocument determines which Impl function the filter - * member calls */ -class ImportFilterImpl : public cppu::WeakImplHelper4 - < - com::sun::star::document::XFilter, - com::sun::star::document::XImporter, - com::sun::star::document::XExtendedFilterDetection, - com::sun::star::lang::XInitialization - > -{ -public: - ImportFilterImpl(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > &rxContext); - virtual ~ImportFilterImpl(); - - // 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, std::exception) SAL_OVERRIDE; - virtual void SAL_CALL cancel() - throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE; - - // 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, std::exception) SAL_OVERRIDE; - - //XExtendedFilterDetection - virtual OUString SAL_CALL detect(com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue > &Descriptor) - throw(com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE; - - // 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, std::exception) SAL_OVERRIDE; - -private: - virtual bool doDetectFormat(librevenge::RVNGInputStream &rInput, OUString &rTypeName) = 0; - virtual bool doImportDocument(librevenge::RVNGInputStream &rInput, librevenge::RVNGSpreadsheetInterface &rGenerator, utl::MediaDescriptor &) = 0; - virtual void doRegisterHandlers(OdsGenerator &rGenerator); - -private: - ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > mxContext; - ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > mxDoc; - OUString msFilterName; - ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler > mxHandler; -}; - -/** A base class for import filters. - */ -typedef cppu::ImplInheritanceHelper1<ImportFilterImpl, com::sun::star::lang::XServiceInfo> ImportFilterBase; - -} -} - -#endif // INCLUDED_WRITERPERFECT_SOURCE_CALC_IMPORTFILTERBASE_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/writerperfect/source/calc/MSWorksCalcImportFilter.cxx b/writerperfect/source/calc/MSWorksCalcImportFilter.cxx index fb38787..d897638 100644 --- a/writerperfect/source/calc/MSWorksCalcImportFilter.cxx +++ b/writerperfect/source/calc/MSWorksCalcImportFilter.cxx @@ -24,7 +24,7 @@ using com::sun::star::uno::Exception; using com::sun::star::uno::RuntimeException; using com::sun::star::uno::XComponentContext; -bool MSWorksCalcImportFilter::doImportDocument(librevenge::RVNGInputStream &rInput, librevenge::RVNGSpreadsheetInterface &rGenerator, utl::MediaDescriptor &) +bool MSWorksCalcImportFilter::doImportDocument(librevenge::RVNGInputStream &rInput, OdsGenerator &rGenerator, utl::MediaDescriptor &) { return libwps::WPS_OK == libwps::WPSDocument::parse(&rInput, &rGenerator); } diff --git a/writerperfect/source/calc/MSWorksCalcImportFilter.hxx b/writerperfect/source/calc/MSWorksCalcImportFilter.hxx index c719d71..6825463 100644 --- a/writerperfect/source/calc/MSWorksCalcImportFilter.hxx +++ b/writerperfect/source/calc/MSWorksCalcImportFilter.hxx @@ -13,16 +13,18 @@ #include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/uno/XComponentContext.hpp> -#include "ImportFilterBase.hxx" +#include "writerperfect/ImportFilter.hxx" + +#include "DocumentHandlerForOds.hxx" /* This component will be instantiated for both import or export. Whether it calls * setSourceDocument or setTargetDocument determines which Impl function the filter * member calls */ -class MSWorksCalcImportFilter : public writerperfect::calc::ImportFilterBase +class MSWorksCalcImportFilter : public writerperfect::ImportFilter<OdsGenerator> { public: MSWorksCalcImportFilter(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > &rxContext) - : writerperfect::calc::ImportFilterBase(rxContext) {} + : writerperfect::ImportFilter<OdsGenerator>(rxContext) {} // XServiceInfo virtual OUString SAL_CALL getImplementationName() @@ -34,7 +36,7 @@ public: private: virtual bool doDetectFormat(librevenge::RVNGInputStream &rInput, OUString &rTypeName) SAL_OVERRIDE; - virtual bool doImportDocument(librevenge::RVNGInputStream &rInput, librevenge::RVNGSpreadsheetInterface &rGenerator, utl::MediaDescriptor &) SAL_OVERRIDE; + virtual bool doImportDocument(librevenge::RVNGInputStream &rInput, OdsGenerator &rGenerator, utl::MediaDescriptor &) SAL_OVERRIDE; virtual void doRegisterHandlers(OdsGenerator &rGenerator) SAL_OVERRIDE; }; diff --git a/writerperfect/source/calc/MWAWCalcImportFilter.cxx b/writerperfect/source/calc/MWAWCalcImportFilter.cxx index 435fc98..a923b6b 100644 --- a/writerperfect/source/calc/MWAWCalcImportFilter.cxx +++ b/writerperfect/source/calc/MWAWCalcImportFilter.cxx @@ -39,7 +39,7 @@ static bool handleEmbeddedMWAWSpreadsheetObject(const librevenge::RVNGBinaryData return MWAWDocument::decodeSpreadsheet(data, &exporter); } -bool MWAWCalcImportFilter::doImportDocument(librevenge::RVNGInputStream &rInput, librevenge::RVNGSpreadsheetInterface &rGenerator, utl::MediaDescriptor &) +bool MWAWCalcImportFilter::doImportDocument(librevenge::RVNGInputStream &rInput, OdsGenerator &rGenerator, utl::MediaDescriptor &) { return MWAWDocument::MWAW_R_OK == MWAWDocument::parse(&rInput, &rGenerator); } diff --git a/writerperfect/source/calc/MWAWCalcImportFilter.hxx b/writerperfect/source/calc/MWAWCalcImportFilter.hxx index 97714e7..f33b8a3 100644 --- a/writerperfect/source/calc/MWAWCalcImportFilter.hxx +++ b/writerperfect/source/calc/MWAWCalcImportFilter.hxx @@ -13,16 +13,18 @@ #include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/uno/XComponentContext.hpp> -#include "ImportFilterBase.hxx" +#include "writerperfect/ImportFilter.hxx" + +#include "DocumentHandlerForOds.hxx" /* This component will be instantiated for both import or export. Whether it calls * setSourceDocument or setTargetDocument determines which Impl function the filter * member calls */ -class MWAWCalcImportFilter : public writerperfect::calc::ImportFilterBase +class MWAWCalcImportFilter : public writerperfect::ImportFilter<OdsGenerator> { public: MWAWCalcImportFilter(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > &rxContext) - : writerperfect::calc::ImportFilterBase(rxContext) {} + : writerperfect::ImportFilter<OdsGenerator>(rxContext) {} // XServiceInfo virtual OUString SAL_CALL getImplementationName() @@ -34,7 +36,7 @@ public: private: virtual bool doDetectFormat(librevenge::RVNGInputStream &rInput, OUString &rTypeName) SAL_OVERRIDE; - virtual bool doImportDocument(librevenge::RVNGInputStream &rInput, librevenge::RVNGSpreadsheetInterface &rGenerator, utl::MediaDescriptor &) SAL_OVERRIDE; + virtual bool doImportDocument(librevenge::RVNGInputStream &rInput, OdsGenerator &rGenerator, utl::MediaDescriptor &) SAL_OVERRIDE; virtual void doRegisterHandlers(OdsGenerator &rGenerator) SAL_OVERRIDE; }; commit 563401545828111f9da413be157b7a91a0f361ab Author: David Tardon <dtar...@redhat.com> Date: Wed Sep 17 18:39:24 2014 +0200 generalize ImportFilterBase a bit more Currently there is a nearly exact copy of that class for every ODF document type. That suggests that it might be a good idea to use a template :-) Change-Id: I2a24eb5bd63cc584569a948df63266c7eb703bd3 diff --git a/writerperfect/inc/writerperfect/DocumentHandlerFor.hxx b/writerperfect/inc/writerperfect/DocumentHandlerFor.hxx new file mode 100644 index 0000000..fbe10a7 --- /dev/null +++ b/writerperfect/inc/writerperfect/DocumentHandlerFor.hxx @@ -0,0 +1,28 @@ +/* -*- 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/. + */ + +#ifndef INCLUDED_WRITERPERFECT_INC_WRITERPERFECT_DOCUMENTHANDLERFOR_HXX +#define INCLUDED_WRITERPERFECT_INC_WRITERPERFECT_DOCUMENTHANDLERFOR_HXX + +namespace writerperfect +{ + +/** Definition of XML import service used with a Generator. + + This template must be specialized for every libodfgen generator. + */ +template<class Generator> +struct DocumentHandlerFor +{ + // static const rtl::OUString name(); +}; + +} + +#endif // INCLUDED_WRITERPERFECT_INC_WRITERPERFECT_DOCUMENTHANDLERFOR_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/writerperfect/inc/writerperfect/ImportFilter.hxx b/writerperfect/inc/writerperfect/ImportFilter.hxx new file mode 100644 index 0000000..294dd46 --- /dev/null +++ b/writerperfect/inc/writerperfect/ImportFilter.hxx @@ -0,0 +1,212 @@ +/* -*- 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/. + */ + +#ifndef INCLUDED_WRITERPERFECT_INC_WRITERPERFECT_IMPORTFILTER_HXX +#define INCLUDED_WRITERPERFECT_INC_WRITERPERFECT_IMPORTFILTER_HXX + +#include <libodfgen/libodfgen.hxx> + +#include <librevenge/librevenge.h> + +#include <librevenge-stream/librevenge-stream.h> + +#include <com/sun/star/beans/PropertyValue.hpp> +#include <com/sun/star/document/XExtendedFilterDetection.hpp> +#include <com/sun/star/document/XFilter.hpp> +#include <com/sun/star/document/XImporter.hpp> +#include <com/sun/star/io/XInputStream.hpp> +#include <com/sun/star/io/XSeekable.hpp> +#include <com/sun/star/lang/XInitialization.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/uno/Reference.h> +#include <com/sun/star/uno/XComponentContext.hpp> +#include <com/sun/star/xml/sax/InputSource.hpp> +#include <com/sun/star/xml/sax/XDocumentHandler.hpp> + +#include <cppuhelper/implbase1.hxx> +#include <cppuhelper/implbase4.hxx> + +#include <unotools/mediadescriptor.hxx> + +#include <writerperfect/DocumentHandler.hxx> +#include <writerperfect/WPXSvInputStream.hxx> + +#include <xmloff/attrlist.hxx> + +#include "writerperfect/DocumentHandlerFor.hxx" + +namespace writerperfect +{ + +namespace detail +{ + +template<class Generator> +class ImportFilterImpl : public cppu::WeakImplHelper4 + < + com::sun::star::document::XFilter, + com::sun::star::document::XImporter, + com::sun::star::document::XExtendedFilterDetection, + com::sun::star::lang::XInitialization + > +{ +public: + ImportFilterImpl(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > &rxContext) + : mxContext(rxContext) + { + } + + virtual ~ImportFilterImpl() + { + } + + // XFilter + virtual sal_Bool SAL_CALL filter(const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > &rDescriptor) + throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE + { + sal_Int32 nLength = rDescriptor.getLength(); + const css::beans::PropertyValue *pValue = rDescriptor.getConstArray(); + css::uno::Reference < css::io::XInputStream > xInputStream; + for (sal_Int32 i = 0 ; i < nLength; i++) + { + if (pValue[i].Name == "InputStream") + pValue[i].Value >>= xInputStream; + } + if (!xInputStream.is()) + { + OSL_ASSERT(false); + return sal_False; + } + + // An XML import service: what we push sax messages to.. + css::uno::Reference < css::xml::sax::XDocumentHandler > xInternalHandler( + mxContext->getServiceManager()->createInstanceWithContext( + DocumentHandlerFor<Generator>::name(), mxContext), + css::uno::UNO_QUERY_THROW); + + // The XImporter sets up an empty target document for XDocumentHandler to write to.. + css::uno::Reference < css::document::XImporter > xImporter(xInternalHandler, css::uno::UNO_QUERY); + xImporter->setTargetDocument(mxDoc); + + // OO Graphics Handler: abstract class to handle document SAX messages, concrete implementation here + // writes to in-memory target doc + DocumentHandler xHandler(xInternalHandler); + + WPXSvInputStream input(xInputStream); + + Generator exporter; + exporter.addDocumentHandler(&xHandler, ODF_FLAT_XML); + + this->doRegisterHandlers(exporter); + + utl::MediaDescriptor aDescriptor(rDescriptor); + return this->doImportDocument(input, exporter, aDescriptor); + } + + virtual void SAL_CALL cancel() + throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE + { + } + + // 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, std::exception) SAL_OVERRIDE + { + mxDoc = xDoc; + } + + //XExtendedFilterDetection + virtual OUString SAL_CALL detect(com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue > &Descriptor) + throw(com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE + { + OUString sTypeName; + sal_Int32 nLength = Descriptor.getLength(); + sal_Int32 location = nLength; + const css::beans::PropertyValue *pValue = Descriptor.getConstArray(); + css::uno::Reference < css::io::XInputStream > xInputStream; + for (sal_Int32 i = 0 ; i < nLength; i++) + { + if (pValue[i].Name == "TypeName") + location=i; + else if (pValue[i].Name == "InputStream") + pValue[i].Value >>= xInputStream; + } + + if (!xInputStream.is()) + return OUString(); + + WPXSvInputStream input(xInputStream); + + if (this->doDetectFormat(input, sTypeName)) + { + assert(!sTypeName.isEmpty()); + + if (location == nLength) + { + Descriptor.realloc(nLength+1); + Descriptor[location].Name = "TypeName"; + } + + Descriptor[location].Value <<=sTypeName; + } + + return sTypeName; + } + + // 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, std::exception) SAL_OVERRIDE + { + css::uno::Sequence < css::beans::PropertyValue > aAnySeq; + sal_Int32 nLength = aArguments.getLength(); + if (nLength && (aArguments[0] >>= aAnySeq)) + { + const css::beans::PropertyValue *pValue = aAnySeq.getConstArray(); + nLength = aAnySeq.getLength(); + for (sal_Int32 i = 0 ; i < nLength; i++) + { + if (pValue[i].Name == "Type") + { + pValue[i].Value >>= msFilterName; + break; + } + } + } + } + +private: + virtual bool doDetectFormat(librevenge::RVNGInputStream &rInput, OUString &rTypeName) = 0; + virtual bool doImportDocument(librevenge::RVNGInputStream &rInput, Generator &rGenerator, utl::MediaDescriptor &rDescriptor) = 0; + virtual void doRegisterHandlers(Generator &) + { + } + +private: + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > mxContext; + ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > mxDoc; + OUString msFilterName; + ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler > mxHandler; +}; + +} + +/** A base class for import filters. + */ +template<class Generator> +struct ImportFilter : public cppu::ImplInheritanceHelper1<detail::ImportFilterImpl<Generator>, com::sun::star::lang::XServiceInfo> +{ + ImportFilter(const css::uno::Reference<css::uno::XComponentContext> &rxContext) + : cppu::ImplInheritanceHelper1<detail::ImportFilterImpl<Generator>, com::sun::star::lang::XServiceInfo>(rxContext) + { + } +}; + +} + +#endif // INCLUDED_WRITERPERFECT_INC_WRITERPERFECT_IMPORTFILTER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ commit 10572dbff870228e802b08da6728a5e28d1928b5 Author: David Tardon <dtar...@redhat.com> Date: Wed Sep 17 10:24:01 2014 +0200 pass media descriptor to import functions Change-Id: I0c3e9c7ba83ef886958789706929b2eede30c343 diff --git a/writerperfect/source/calc/ImportFilterBase.cxx b/writerperfect/source/calc/ImportFilterBase.cxx index 330cb6e..1f9ede0 100644 --- a/writerperfect/source/calc/ImportFilterBase.cxx +++ b/writerperfect/source/calc/ImportFilterBase.cxx @@ -97,7 +97,8 @@ throw (RuntimeException, std::exception) doRegisterHandlers(exporter); - return doImportDocument(input, exporter); + utl::MediaDescriptor aMediaDescriptor(aDescriptor); + return doImportDocument(input, exporter, aMediaDescriptor); } void SAL_CALL ImportFilterImpl::cancel() diff --git a/writerperfect/source/calc/ImportFilterBase.hxx b/writerperfect/source/calc/ImportFilterBase.hxx index dafeffc..4b9d11d 100644 --- a/writerperfect/source/calc/ImportFilterBase.hxx +++ b/writerperfect/source/calc/ImportFilterBase.hxx @@ -20,6 +20,8 @@ #include <cppuhelper/implbase1.hxx> #include <cppuhelper/implbase4.hxx> +#include <unotools/mediadescriptor.hxx> + namespace com { namespace sun @@ -91,7 +93,7 @@ public: private: virtual bool doDetectFormat(librevenge::RVNGInputStream &rInput, OUString &rTypeName) = 0; - virtual bool doImportDocument(librevenge::RVNGInputStream &rInput, librevenge::RVNGSpreadsheetInterface &rGenerator) = 0; + virtual bool doImportDocument(librevenge::RVNGInputStream &rInput, librevenge::RVNGSpreadsheetInterface &rGenerator, utl::MediaDescriptor &) = 0; virtual void doRegisterHandlers(OdsGenerator &rGenerator); private: diff --git a/writerperfect/source/calc/MSWorksCalcImportFilter.cxx b/writerperfect/source/calc/MSWorksCalcImportFilter.cxx index 6c9e316..fb38787 100644 --- a/writerperfect/source/calc/MSWorksCalcImportFilter.cxx +++ b/writerperfect/source/calc/MSWorksCalcImportFilter.cxx @@ -24,7 +24,7 @@ using com::sun::star::uno::Exception; using com::sun::star::uno::RuntimeException; using com::sun::star::uno::XComponentContext; -bool MSWorksCalcImportFilter::doImportDocument(librevenge::RVNGInputStream &rInput, librevenge::RVNGSpreadsheetInterface &rGenerator) +bool MSWorksCalcImportFilter::doImportDocument(librevenge::RVNGInputStream &rInput, librevenge::RVNGSpreadsheetInterface &rGenerator, utl::MediaDescriptor &) { return libwps::WPS_OK == libwps::WPSDocument::parse(&rInput, &rGenerator); } diff --git a/writerperfect/source/calc/MSWorksCalcImportFilter.hxx b/writerperfect/source/calc/MSWorksCalcImportFilter.hxx index dfe43d1..c719d71 100644 --- a/writerperfect/source/calc/MSWorksCalcImportFilter.hxx +++ b/writerperfect/source/calc/MSWorksCalcImportFilter.hxx @@ -34,7 +34,7 @@ public: private: virtual bool doDetectFormat(librevenge::RVNGInputStream &rInput, OUString &rTypeName) SAL_OVERRIDE; - virtual bool doImportDocument(librevenge::RVNGInputStream &rInput, librevenge::RVNGSpreadsheetInterface &rGenerator) SAL_OVERRIDE; + virtual bool doImportDocument(librevenge::RVNGInputStream &rInput, librevenge::RVNGSpreadsheetInterface &rGenerator, utl::MediaDescriptor &) SAL_OVERRIDE; virtual void doRegisterHandlers(OdsGenerator &rGenerator) SAL_OVERRIDE; }; diff --git a/writerperfect/source/calc/MWAWCalcImportFilter.cxx b/writerperfect/source/calc/MWAWCalcImportFilter.cxx index e7a7e3e..435fc98 100644 --- a/writerperfect/source/calc/MWAWCalcImportFilter.cxx +++ b/writerperfect/source/calc/MWAWCalcImportFilter.cxx @@ -39,7 +39,7 @@ static bool handleEmbeddedMWAWSpreadsheetObject(const librevenge::RVNGBinaryData return MWAWDocument::decodeSpreadsheet(data, &exporter); } -bool MWAWCalcImportFilter::doImportDocument(librevenge::RVNGInputStream &rInput, librevenge::RVNGSpreadsheetInterface &rGenerator) +bool MWAWCalcImportFilter::doImportDocument(librevenge::RVNGInputStream &rInput, librevenge::RVNGSpreadsheetInterface &rGenerator, utl::MediaDescriptor &) { return MWAWDocument::MWAW_R_OK == MWAWDocument::parse(&rInput, &rGenerator); } diff --git a/writerperfect/source/calc/MWAWCalcImportFilter.hxx b/writerperfect/source/calc/MWAWCalcImportFilter.hxx index 2624fe2..97714e7 100644 --- a/writerperfect/source/calc/MWAWCalcImportFilter.hxx +++ b/writerperfect/source/calc/MWAWCalcImportFilter.hxx @@ -34,7 +34,7 @@ public: private: virtual bool doDetectFormat(librevenge::RVNGInputStream &rInput, OUString &rTypeName) SAL_OVERRIDE; - virtual bool doImportDocument(librevenge::RVNGInputStream &rInput, librevenge::RVNGSpreadsheetInterface &rGenerator) SAL_OVERRIDE; + virtual bool doImportDocument(librevenge::RVNGInputStream &rInput, librevenge::RVNGSpreadsheetInterface &rGenerator, utl::MediaDescriptor &) SAL_OVERRIDE; virtual void doRegisterHandlers(OdsGenerator &rGenerator) SAL_OVERRIDE; }; diff --git a/writerperfect/source/draw/CDRImportFilter.cxx b/writerperfect/source/draw/CDRImportFilter.cxx index c5fa269..8bb8fe8 100644 --- a/writerperfect/source/draw/CDRImportFilter.cxx +++ b/writerperfect/source/draw/CDRImportFilter.cxx @@ -27,7 +27,7 @@ using com::sun::star::uno::Sequence; using com::sun::star::uno::XComponentContext; using com::sun::star::uno::XInterface; -bool CDRImportFilter::doImportDocument(librevenge::RVNGInputStream &rInput, librevenge::RVNGDrawingInterface &rGenerator) +bool CDRImportFilter::doImportDocument(librevenge::RVNGInputStream &rInput, librevenge::RVNGDrawingInterface &rGenerator, utl::MediaDescriptor &) { return libcdr::CDRDocument::parse(&rInput, &rGenerator); } diff --git a/writerperfect/source/draw/CDRImportFilter.hxx b/writerperfect/source/draw/CDRImportFilter.hxx index 2b8526a..f2a4d45 100644 --- a/writerperfect/source/draw/CDRImportFilter.hxx +++ b/writerperfect/source/draw/CDRImportFilter.hxx @@ -34,7 +34,7 @@ public: private: virtual bool doDetectFormat(librevenge::RVNGInputStream &rInput, OUString &rTypeName) SAL_OVERRIDE; - virtual bool doImportDocument(librevenge::RVNGInputStream &rInput, librevenge::RVNGDrawingInterface &rGenerator) SAL_OVERRIDE; + virtual bool doImportDocument(librevenge::RVNGInputStream &rInput, librevenge::RVNGDrawingInterface &rGenerator, utl::MediaDescriptor &) SAL_OVERRIDE; }; OUString CDRImportFilter_getImplementationName() diff --git a/writerperfect/source/draw/CMXImportFilter.cxx b/writerperfect/source/draw/CMXImportFilter.cxx index 6b6d5a8..120e985 100644 --- a/writerperfect/source/draw/CMXImportFilter.cxx +++ b/writerperfect/source/draw/CMXImportFilter.cxx @@ -27,7 +27,7 @@ using com::sun::star::uno::Sequence; using com::sun::star::uno::XComponentContext; using com::sun::star::uno::XInterface; -bool CMXImportFilter::doImportDocument(librevenge::RVNGInputStream &rInput, librevenge::RVNGDrawingInterface &rGenerator) +bool CMXImportFilter::doImportDocument(librevenge::RVNGInputStream &rInput, librevenge::RVNGDrawingInterface &rGenerator, utl::MediaDescriptor &) { return libcdr::CMXDocument::parse(&rInput, &rGenerator); } diff --git a/writerperfect/source/draw/CMXImportFilter.hxx b/writerperfect/source/draw/CMXImportFilter.hxx index 0c7f0b2..dcb43e8 100644 --- a/writerperfect/source/draw/CMXImportFilter.hxx +++ b/writerperfect/source/draw/CMXImportFilter.hxx @@ -34,7 +34,7 @@ public: private: virtual bool doDetectFormat(librevenge::RVNGInputStream &rInput, OUString &rTypeName) SAL_OVERRIDE; - virtual bool doImportDocument(librevenge::RVNGInputStream &rInput, librevenge::RVNGDrawingInterface &rGenerator) SAL_OVERRIDE; + virtual bool doImportDocument(librevenge::RVNGInputStream &rInput, librevenge::RVNGDrawingInterface &rGenerator, utl::MediaDescriptor &) SAL_OVERRIDE; }; OUString CMXImportFilter_getImplementationName() diff --git a/writerperfect/source/draw/FreehandImportFilter.cxx b/writerperfect/source/draw/FreehandImportFilter.cxx index 86002f3..c977db3 100644 --- a/writerperfect/source/draw/FreehandImportFilter.cxx +++ b/writerperfect/source/draw/FreehandImportFilter.cxx @@ -23,7 +23,7 @@ using com::sun::star::uno::Sequence; using com::sun::star::uno::XComponentContext; using com::sun::star::uno::XInterface; -bool FreehandImportFilter::doImportDocument(librevenge::RVNGInputStream &rInput, librevenge::RVNGDrawingInterface &rGenerator) +bool FreehandImportFilter::doImportDocument(librevenge::RVNGInputStream &rInput, librevenge::RVNGDrawingInterface &rGenerator, utl::MediaDescriptor &) { return libfreehand::FreeHandDocument::parse(&rInput, &rGenerator); } diff --git a/writerperfect/source/draw/FreehandImportFilter.hxx b/writerperfect/source/draw/FreehandImportFilter.hxx index 6b1c94d..e6dd231 100644 --- a/writerperfect/source/draw/FreehandImportFilter.hxx +++ b/writerperfect/source/draw/FreehandImportFilter.hxx @@ -31,7 +31,7 @@ public: private: virtual bool doDetectFormat(librevenge::RVNGInputStream &rInput, OUString &rTypeName) SAL_OVERRIDE; - virtual bool doImportDocument(librevenge::RVNGInputStream &rInput, librevenge::RVNGDrawingInterface &rGenerator) SAL_OVERRIDE; + virtual bool doImportDocument(librevenge::RVNGInputStream &rInput, librevenge::RVNGDrawingInterface &rGenerator, utl::MediaDescriptor &) SAL_OVERRIDE; }; OUString FreehandImportFilter_getImplementationName() diff --git a/writerperfect/source/draw/ImportFilterBase.cxx b/writerperfect/source/draw/ImportFilterBase.cxx index 9d2258c..cc8da90 100644 --- a/writerperfect/source/draw/ImportFilterBase.cxx +++ b/writerperfect/source/draw/ImportFilterBase.cxx @@ -97,7 +97,8 @@ throw (RuntimeException, std::exception) doRegisterHandlers(exporter); - return doImportDocument(input, exporter); + utl::MediaDescriptor aMediaDescriptor(aDescriptor); + return doImportDocument(input, exporter, aMediaDescriptor); } void SAL_CALL ImportFilterImpl::cancel() diff --git a/writerperfect/source/draw/ImportFilterBase.hxx b/writerperfect/source/draw/ImportFilterBase.hxx index 4b7e917..1701af1 100644 --- a/writerperfect/source/draw/ImportFilterBase.hxx +++ b/writerperfect/source/draw/ImportFilterBase.hxx @@ -20,6 +20,8 @@ #include <cppuhelper/implbase1.hxx> #include <cppuhelper/implbase4.hxx> +#include <unotools/mediadescriptor.hxx> + namespace com { namespace sun @@ -91,7 +93,7 @@ public: private: virtual bool doDetectFormat(librevenge::RVNGInputStream &rInput, OUString &rTypeName) = 0; - virtual bool doImportDocument(librevenge::RVNGInputStream &rInput, librevenge::RVNGDrawingInterface &rGenerator) = 0; + virtual bool doImportDocument(librevenge::RVNGInputStream &rInput, librevenge::RVNGDrawingInterface &rGenerator, utl::MediaDescriptor &) = 0; virtual void doRegisterHandlers(OdgGenerator &rGenerator); private: diff --git a/writerperfect/source/draw/MSPUBImportFilter.cxx b/writerperfect/source/draw/MSPUBImportFilter.cxx index 4a09651..97231de 100644 --- a/writerperfect/source/draw/MSPUBImportFilter.cxx +++ b/writerperfect/source/draw/MSPUBImportFilter.cxx @@ -25,7 +25,7 @@ using com::sun::star::uno::Sequence; using com::sun::star::uno::XComponentContext; using com::sun::star::uno::XInterface; -bool MSPUBImportFilter::doImportDocument(librevenge::RVNGInputStream &rInput, librevenge::RVNGDrawingInterface &rGenerator) +bool MSPUBImportFilter::doImportDocument(librevenge::RVNGInputStream &rInput, librevenge::RVNGDrawingInterface &rGenerator, utl::MediaDescriptor &) { return libmspub::MSPUBDocument::parse(&rInput, &rGenerator); } diff --git a/writerperfect/source/draw/MSPUBImportFilter.hxx b/writerperfect/source/draw/MSPUBImportFilter.hxx index c0e702c..8fe58ba 100644 --- a/writerperfect/source/draw/MSPUBImportFilter.hxx +++ b/writerperfect/source/draw/MSPUBImportFilter.hxx @@ -31,7 +31,7 @@ public: private: virtual bool doDetectFormat(librevenge::RVNGInputStream &rInput, OUString &rTypeName) SAL_OVERRIDE; - virtual bool doImportDocument(librevenge::RVNGInputStream &rInput, librevenge::RVNGDrawingInterface &rGenerator) SAL_OVERRIDE; + virtual bool doImportDocument(librevenge::RVNGInputStream &rInput, librevenge::RVNGDrawingInterface &rGenerator, utl::MediaDescriptor &) SAL_OVERRIDE; }; OUString MSPUBImportFilter_getImplementationName() diff --git a/writerperfect/source/draw/MWAWDrawImportFilter.cxx b/writerperfect/source/draw/MWAWDrawImportFilter.cxx index 96b007f..694bb3f 100644 --- a/writerperfect/source/draw/MWAWDrawImportFilter.cxx +++ b/writerperfect/source/draw/MWAWDrawImportFilter.cxx @@ -39,7 +39,7 @@ static bool handleEmbeddedMWAWSpreadsheetObject(const librevenge::RVNGBinaryData return MWAWDocument::decodeSpreadsheet(data, &exporter); } -bool MWAWDrawImportFilter::doImportDocument(librevenge::RVNGInputStream &rInput, librevenge::RVNGDrawingInterface &rGenerator) +bool MWAWDrawImportFilter::doImportDocument(librevenge::RVNGInputStream &rInput, librevenge::RVNGDrawingInterface &rGenerator, utl::MediaDescriptor &) { return MWAWDocument::MWAW_R_OK == MWAWDocument::parse(&rInput, &rGenerator); } diff --git a/writerperfect/source/draw/MWAWDrawImportFilter.hxx b/writerperfect/source/draw/MWAWDrawImportFilter.hxx index 2a23e6b..84a562b 100644 --- a/writerperfect/source/draw/MWAWDrawImportFilter.hxx +++ b/writerperfect/source/draw/MWAWDrawImportFilter.hxx @@ -34,7 +34,7 @@ public: private: virtual bool doDetectFormat(librevenge::RVNGInputStream &rInput, OUString &rTypeName) SAL_OVERRIDE; - virtual bool doImportDocument(librevenge::RVNGInputStream &rInput, librevenge::RVNGDrawingInterface &rGenerator) SAL_OVERRIDE; + virtual bool doImportDocument(librevenge::RVNGInputStream &rInput, librevenge::RVNGDrawingInterface &rGenerator, utl::MediaDescriptor &) SAL_OVERRIDE; virtual void doRegisterHandlers(OdgGenerator &rGenerator) SAL_OVERRIDE; }; diff --git a/writerperfect/source/draw/PageMakerImportFilter.cxx b/writerperfect/source/draw/PageMakerImportFilter.cxx index bb836d3..fa08c76 100644 --- a/writerperfect/source/draw/PageMakerImportFilter.cxx +++ b/writerperfect/source/draw/PageMakerImportFilter.cxx @@ -25,7 +25,7 @@ using com::sun::star::uno::Sequence; using com::sun::star::uno::XComponentContext; using com::sun::star::uno::XInterface; -bool PageMakerImportFilter::doImportDocument(librevenge::RVNGInputStream &rInput, librevenge::RVNGDrawingInterface &rGenerator) +bool PageMakerImportFilter::doImportDocument(librevenge::RVNGInputStream &rInput, librevenge::RVNGDrawingInterface &rGenerator, utl::MediaDescriptor &) { return libpagemaker::PMDocument::parse(&rInput, &rGenerator); } diff --git a/writerperfect/source/draw/PageMakerImportFilter.hxx b/writerperfect/source/draw/PageMakerImportFilter.hxx index e69474e..5665759 100644 --- a/writerperfect/source/draw/PageMakerImportFilter.hxx +++ b/writerperfect/source/draw/PageMakerImportFilter.hxx @@ -31,7 +31,7 @@ public: private: virtual bool doDetectFormat(librevenge::RVNGInputStream &rInput, OUString &rTypeName) SAL_OVERRIDE; - virtual bool doImportDocument(librevenge::RVNGInputStream &rInput, librevenge::RVNGDrawingInterface &rGenerator) SAL_OVERRIDE; + virtual bool doImportDocument(librevenge::RVNGInputStream &rInput, librevenge::RVNGDrawingInterface &rGenerator, utl::MediaDescriptor &) SAL_OVERRIDE; }; OUString PageMakerImportFilter_getImplementationName() diff --git a/writerperfect/source/draw/VisioImportFilter.cxx b/writerperfect/source/draw/VisioImportFilter.cxx index deae25a..d68e413 100644 --- a/writerperfect/source/draw/VisioImportFilter.cxx +++ b/writerperfect/source/draw/VisioImportFilter.cxx @@ -23,7 +23,7 @@ using com::sun::star::uno::Sequence; using com::sun::star::uno::XComponentContext; using com::sun::star::uno::XInterface; -bool VisioImportFilter::doImportDocument(librevenge::RVNGInputStream &rInput, librevenge::RVNGDrawingInterface &rGenerator) +bool VisioImportFilter::doImportDocument(librevenge::RVNGInputStream &rInput, librevenge::RVNGDrawingInterface &rGenerator, utl::MediaDescriptor &) { return libvisio::VisioDocument::parse(&rInput, &rGenerator); } diff --git a/writerperfect/source/draw/VisioImportFilter.hxx b/writerperfect/source/draw/VisioImportFilter.hxx index 5f2120f..175dfa3 100644 --- a/writerperfect/source/draw/VisioImportFilter.hxx +++ b/writerperfect/source/draw/VisioImportFilter.hxx @@ -31,7 +31,7 @@ public: private: virtual bool doDetectFormat(librevenge::RVNGInputStream &rInput, OUString &rTypeName) SAL_OVERRIDE; - virtual bool doImportDocument(librevenge::RVNGInputStream &rInput, librevenge::RVNGDrawingInterface &rGenerator) SAL_OVERRIDE; + virtual bool doImportDocument(librevenge::RVNGInputStream &rInput, librevenge::RVNGDrawingInterface &rGenerator, utl::MediaDescriptor &) SAL_OVERRIDE; }; OUString VisioImportFilter_getImplementationName() diff --git a/writerperfect/source/draw/WPGImportFilter.cxx b/writerperfect/source/draw/WPGImportFilter.cxx index 7c7ff88..fbf06b3 100644 --- a/writerperfect/source/draw/WPGImportFilter.cxx +++ b/writerperfect/source/draw/WPGImportFilter.cxx @@ -30,7 +30,7 @@ using com::sun::star::uno::Sequence; using com::sun::star::uno::XComponentContext; using com::sun::star::uno::XInterface; -bool WPGImportFilter::doImportDocument(librevenge::RVNGInputStream &rInput, librevenge::RVNGDrawingInterface &rGenerator) +bool WPGImportFilter::doImportDocument(librevenge::RVNGInputStream &rInput, librevenge::RVNGDrawingInterface &rGenerator, utl::MediaDescriptor &) { return libwpg::WPGraphics::parse(&rInput, &rGenerator); } diff --git a/writerperfect/source/draw/WPGImportFilter.hxx b/writerperfect/source/draw/WPGImportFilter.hxx index b55c9fe..98bbf65 100644 --- a/writerperfect/source/draw/WPGImportFilter.hxx +++ b/writerperfect/source/draw/WPGImportFilter.hxx @@ -36,7 +36,7 @@ public: private: virtual bool doDetectFormat(librevenge::RVNGInputStream &rInput, OUString &rTypeName) SAL_OVERRIDE; - virtual bool doImportDocument(librevenge::RVNGInputStream &rInput, librevenge::RVNGDrawingInterface &rGenerator) SAL_OVERRIDE; + virtual bool doImportDocument(librevenge::RVNGInputStream &rInput, librevenge::RVNGDrawingInterface &rGenerator, utl::MediaDescriptor &) SAL_OVERRIDE; }; OUString WPGImportFilter_getImplementationName() commit 3c8af5367de69ea74506f6f630276e9dfd8ff51f Author: David Tardon <dtar...@redhat.com> Date: Wed Sep 17 10:44:51 2014 +0200 pass the whole descriptor instead of filter name Change-Id: I874e53a00d48ba84588126c1ecdb90c801a9b1d6 diff --git a/writerperfect/source/writer/AbiWordImportFilter.cxx b/writerperfect/source/writer/AbiWordImportFilter.cxx index e35d4ef..87a2a6e 100644 --- a/writerperfect/source/writer/AbiWordImportFilter.cxx +++ b/writerperfect/source/writer/AbiWordImportFilter.cxx @@ -24,7 +24,7 @@ using com::sun::star::uno::RuntimeException; using com::sun::star::uno::XComponentContext; using com::sun::star::uno::XInterface; -bool AbiWordImportFilter::doImportDocument(librevenge::RVNGInputStream &rInput, const rtl::OUString &, librevenge::RVNGTextInterface &rGenerator) +bool AbiWordImportFilter::doImportDocument(librevenge::RVNGInputStream &rInput, librevenge::RVNGTextInterface &rGenerator, utl::MediaDescriptor &) { return libabw::AbiDocument::parse(&rInput, &rGenerator); } diff --git a/writerperfect/source/writer/AbiWordImportFilter.hxx b/writerperfect/source/writer/AbiWordImportFilter.hxx index 50a5b7d6..b0ea57e 100644 --- a/writerperfect/source/writer/AbiWordImportFilter.hxx +++ b/writerperfect/source/writer/AbiWordImportFilter.hxx @@ -34,7 +34,7 @@ public: private: virtual bool doDetectFormat(librevenge::RVNGInputStream &rInput, OUString &rTypeName) SAL_OVERRIDE; - virtual bool doImportDocument(librevenge::RVNGInputStream &rInput, const rtl::OUString &rFilterName, librevenge::RVNGTextInterface &rGenerator) SAL_OVERRIDE; + virtual bool doImportDocument(librevenge::RVNGInputStream &rInput, librevenge::RVNGTextInterface &rGenerator, utl::MediaDescriptor &) SAL_OVERRIDE; }; OUString AbiWordImportFilter_getImplementationName() diff --git a/writerperfect/source/writer/EBookImportFilter.cxx b/writerperfect/source/writer/EBookImportFilter.cxx index 003e603..14c4a48 100644 --- a/writerperfect/source/writer/EBookImportFilter.cxx +++ b/writerperfect/source/writer/EBookImportFilter.cxx @@ -26,21 +26,26 @@ using com::sun::star::uno::XComponentContext; using libebook::EBOOKDocument; -bool EBookImportFilter::doImportDocument(librevenge::RVNGInputStream &rInput, const rtl::OUString &rFilterName, librevenge::RVNGTextInterface &rGenerator) +bool EBookImportFilter::doImportDocument(librevenge::RVNGInputStream &rInput, librevenge::RVNGTextInterface &rGenerator, utl::MediaDescriptor &rDescriptor) { EBOOKDocument::Type type = EBOOKDocument::TYPE_UNKNOWN; - if (rFilterName == "FictionBook 2") + rtl::OUString aFilterName; + + rDescriptor[utl::MediaDescriptor::PROP_FILTERNAME()] >>= aFilterName; + assert(!aFilterName.isEmpty()); + + if (aFilterName == "FictionBook 2") type = EBOOKDocument::TYPE_FICTIONBOOK2; - else if (rFilterName == "PalmDoc") + else if (aFilterName == "PalmDoc") type = EBOOKDocument::TYPE_PALMDOC; - else if (rFilterName == "Plucker eBook") + else if (aFilterName == "Plucker eBook") type = EBOOKDocument::TYPE_PLUCKER; - else if (rFilterName == "eReader eBook") + else if (aFilterName == "eReader eBook") type = EBOOKDocument::TYPE_PEANUTPRESS; - else if (rFilterName == "TealDoc") + else if (aFilterName == "TealDoc") type = EBOOKDocument::TYPE_TEALDOC; - else if (rFilterName == "zTXT") + else if (aFilterName == "zTXT") type = EBOOKDocument::TYPE_ZTXT; if (EBOOKDocument::TYPE_UNKNOWN != type) diff --git a/writerperfect/source/writer/EBookImportFilter.hxx b/writerperfect/source/writer/EBookImportFilter.hxx index 1fcf754..b7047d8 100644 --- a/writerperfect/source/writer/EBookImportFilter.hxx +++ b/writerperfect/source/writer/EBookImportFilter.hxx @@ -34,7 +34,7 @@ public: private: virtual bool doDetectFormat(librevenge::RVNGInputStream &rInput, OUString &rTypeName) SAL_OVERRIDE; - virtual bool doImportDocument(librevenge::RVNGInputStream &rInput, const rtl::OUString &rFilterName, librevenge::RVNGTextInterface &rGenerator) SAL_OVERRIDE; + virtual bool doImportDocument(librevenge::RVNGInputStream &rInput, librevenge::RVNGTextInterface &rGenerator, utl::MediaDescriptor &rDescriptor) SAL_OVERRIDE; }; OUString EBookImportFilter_getImplementationName() diff --git a/writerperfect/source/writer/ImportFilterBase.cxx b/writerperfect/source/writer/ImportFilterBase.cxx index a0507a6..9437c5d 100644 --- a/writerperfect/source/writer/ImportFilterBase.cxx +++ b/writerperfect/source/writer/ImportFilterBase.cxx @@ -98,7 +98,8 @@ throw (RuntimeException, std::exception) doRegisterHandlers(exporter); - return doImportDocument(input, sFilterName, exporter); + utl::MediaDescriptor aMediaDescriptor(aDescriptor); + return doImportDocument(input, exporter, aMediaDescriptor); } void SAL_CALL ImportFilterImpl::cancel() diff --git a/writerperfect/source/writer/ImportFilterBase.hxx b/writerperfect/source/writer/ImportFilterBase.hxx index dd9e4d9..bee7612 100644 --- a/writerperfect/source/writer/ImportFilterBase.hxx +++ b/writerperfect/source/writer/ImportFilterBase.hxx @@ -21,6 +21,8 @@ #include <cppuhelper/implbase1.hxx> #include <cppuhelper/implbase4.hxx> +#include <unotools/mediadescriptor.hxx> + namespace com { namespace sun @@ -90,7 +92,7 @@ public: private: virtual bool doDetectFormat(librevenge::RVNGInputStream &rInput, OUString &rTypeName) = 0; - virtual bool doImportDocument(librevenge::RVNGInputStream &rInput, const rtl::OUString &rFilterName, librevenge::RVNGTextInterface &rGenerator) = 0; + virtual bool doImportDocument(librevenge::RVNGInputStream &rInput, librevenge::RVNGTextInterface &rGenerator, utl::MediaDescriptor &rDescriptor) = 0; virtual void doRegisterHandlers(OdtGenerator &rGenerator); private: diff --git a/writerperfect/source/writer/MSWorksImportFilter.cxx b/writerperfect/source/writer/MSWorksImportFilter.cxx index 2cd4996..21657a1 100644 --- a/writerperfect/source/writer/MSWorksImportFilter.cxx +++ b/writerperfect/source/writer/MSWorksImportFilter.cxx @@ -31,7 +31,7 @@ static bool handleEmbeddedWKSObject(const librevenge::RVNGBinaryData &data, OdfD return libwps::WPSDocument::parse(data.getDataStream(), &exporter)==libwps::WPS_OK; } -bool MSWorksImportFilter::doImportDocument(librevenge::RVNGInputStream &rInput, const rtl::OUString &, librevenge::RVNGTextInterface &rGenerator) +bool MSWorksImportFilter::doImportDocument(librevenge::RVNGInputStream &rInput, librevenge::RVNGTextInterface &rGenerator, utl::MediaDescriptor &) { return libwps::WPS_OK == libwps::WPSDocument::parse(&rInput, &rGenerator); } diff --git a/writerperfect/source/writer/MSWorksImportFilter.hxx b/writerperfect/source/writer/MSWorksImportFilter.hxx index 4e1782b..42ff7d2 100644 --- a/writerperfect/source/writer/MSWorksImportFilter.hxx +++ b/writerperfect/source/writer/MSWorksImportFilter.hxx @@ -34,7 +34,7 @@ public: private: virtual bool doDetectFormat(librevenge::RVNGInputStream &rInput, OUString &rTypeName) SAL_OVERRIDE; - virtual bool doImportDocument(librevenge::RVNGInputStream &rInput, const rtl::OUString &rFilterName, librevenge::RVNGTextInterface &rGenerator) SAL_OVERRIDE; + virtual bool doImportDocument(librevenge::RVNGInputStream &rInput, librevenge::RVNGTextInterface &rGenerator, utl::MediaDescriptor &) SAL_OVERRIDE; virtual void doRegisterHandlers(OdtGenerator &rGenerator) SAL_OVERRIDE; }; diff --git a/writerperfect/source/writer/MWAWImportFilter.cxx b/writerperfect/source/writer/MWAWImportFilter.cxx index 5a59575..1d37ff0 100644 --- a/writerperfect/source/writer/MWAWImportFilter.cxx +++ b/writerperfect/source/writer/MWAWImportFilter.cxx @@ -38,7 +38,7 @@ static bool handleEmbeddedMWAWSpreadsheetObject(const librevenge::RVNGBinaryData return MWAWDocument::decodeSpreadsheet(data, &exporter); } -bool MWAWImportFilter::doImportDocument(librevenge::RVNGInputStream &rInput, const rtl::OUString &, librevenge::RVNGTextInterface &rGenerator) +bool MWAWImportFilter::doImportDocument(librevenge::RVNGInputStream &rInput, librevenge::RVNGTextInterface &rGenerator, utl::MediaDescriptor &) { return MWAWDocument::MWAW_R_OK == MWAWDocument::parse(&rInput, &rGenerator); } diff --git a/writerperfect/source/writer/MWAWImportFilter.hxx b/writerperfect/source/writer/MWAWImportFilter.hxx index 9ea3418..b2883bb 100644 --- a/writerperfect/source/writer/MWAWImportFilter.hxx +++ b/writerperfect/source/writer/MWAWImportFilter.hxx @@ -34,7 +34,7 @@ public: private: virtual bool doDetectFormat(librevenge::RVNGInputStream &rInput, OUString &rTypeName) SAL_OVERRIDE; - virtual bool doImportDocument(librevenge::RVNGInputStream &rInput, const rtl::OUString &rFilterName, librevenge::RVNGTextInterface &rGenerator) SAL_OVERRIDE; + virtual bool doImportDocument(librevenge::RVNGInputStream &rInput, librevenge::RVNGTextInterface &rGenerator, utl::MediaDescriptor &) SAL_OVERRIDE; virtual void doRegisterHandlers(OdtGenerator &rGenerator) SAL_OVERRIDE; }; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits