From aaed6fe55a67ee3e92bedf9eed2e2f7c044be19d Mon Sep 17 00:00:00 2001 From: Aleksas Pantechovskis Date: Wed, 22 Jun 2016 19:02:29 +0300 Subject: integrate libzmf Change-Id: I0c7ea5b56ea4ed4839ff38798c0b915aaca81774 Reviewed-on: https://gerrit.libreoffice.org/26574 Tested-by: Jenkins Reviewed-by: David Tardon --- writerperfect/Library_wpftdraw.mk | 2 + writerperfect/source/draw/ZMFImportFilter.cxx | 69 +++++++++++++++++++++++++++ writerperfect/source/draw/ZMFImportFilter.hxx | 41 ++++++++++++++++ writerperfect/source/draw/wpftdraw.component | 5 ++ 4 files changed, 117 insertions(+) create mode 100644 writerperfect/source/draw/ZMFImportFilter.cxx create mode 100644 writerperfect/source/draw/ZMFImportFilter.hxx (limited to 'writerperfect') diff --git a/writerperfect/Library_wpftdraw.mk b/writerperfect/Library_wpftdraw.mk index b6927db98ffc..cdec02962383 100644 --- a/writerperfect/Library_wpftdraw.mk +++ b/writerperfect/Library_wpftdraw.mk @@ -56,6 +56,7 @@ $(eval $(call gb_Library_use_externals,wpftdraw,\ wpg \ wpd \ zlib \ + zmf \ lcms2 \ libxml2 \ icui18n \ @@ -71,6 +72,7 @@ $(eval $(call gb_Library_add_exception_objects,wpftdraw,\ writerperfect/source/draw/PageMakerImportFilter \ writerperfect/source/draw/VisioImportFilter \ writerperfect/source/draw/WPGImportFilter \ + writerperfect/source/draw/ZMFImportFilter \ )) # vim: set noet sw=4 ts=4: diff --git a/writerperfect/source/draw/ZMFImportFilter.cxx b/writerperfect/source/draw/ZMFImportFilter.cxx new file mode 100644 index 000000000000..0eabfc1c5ffb --- /dev/null +++ b/writerperfect/source/draw/ZMFImportFilter.cxx @@ -0,0 +1,69 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* ZMFImportFilter: Sets up the filter, and calls OdgExporter + * to do the actual filtering + * + * 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 + +#include + +#include + +#include + +#include "ZMFImportFilter.hxx" + +using com::sun::star::uno::RuntimeException; +using com::sun::star::uno::Sequence; +using com::sun::star::uno::XComponentContext; +using com::sun::star::uno::XInterface; + +bool ZMFImportFilter::doImportDocument(librevenge::RVNGInputStream &rInput, OdgGenerator &rGenerator, utl::MediaDescriptor &) +{ + return libzmf::ZMFDocument::parse(&rInput, &rGenerator); +} + +bool ZMFImportFilter::doDetectFormat(librevenge::RVNGInputStream &rInput, OUString &rTypeName) +{ + if (libzmf::ZMFDocument::isSupported(&rInput)) + { + rTypeName = "draw_ZMF_Document"; + return true; + } + + return false; +} + +// XServiceInfo +OUString SAL_CALL ZMFImportFilter::getImplementationName() +throw (RuntimeException, std::exception) +{ + return OUString("org.libreoffice.comp.Draw.ZMFImportFilter"); +} + +sal_Bool SAL_CALL ZMFImportFilter::supportsService(const OUString &rServiceName) +throw (RuntimeException, std::exception) +{ + return cppu::supportsService(this, rServiceName); +} + +Sequence< OUString > SAL_CALL ZMFImportFilter::getSupportedServiceNames() +throw (RuntimeException, std::exception) +{ + return Sequence< OUString >{"com.sun.star.document.ImportFilter", "com.sun.star.document.ExtendedTypeDetection"}; +} + +extern "C" +SAL_DLLPUBLIC_EXPORT css::uno::XInterface *SAL_CALL +org_libreoffice_comp_Draw_ZMFImportFilter_get_implementation( + css::uno::XComponentContext *const context, + const css::uno::Sequence &) +{ + return cppu::acquire(new ZMFImportFilter(context)); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/writerperfect/source/draw/ZMFImportFilter.hxx b/writerperfect/source/draw/ZMFImportFilter.hxx new file mode 100644 index 000000000000..a5eb9f20b0f5 --- /dev/null +++ b/writerperfect/source/draw/ZMFImportFilter.hxx @@ -0,0 +1,41 @@ +/* -*- 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_DRAW_ZMFIMPORTFILTER_HXX +#define INCLUDED_WRITERPERFECT_SOURCE_DRAW_ZMFIMPORTFILTER_HXX + +#include "ImportFilter.hxx" + +#include "DocumentHandlerForOdg.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 ZMFImportFilter : public writerperfect::ImportFilter +{ +public: + explicit ZMFImportFilter(const css::uno::Reference< css::uno::XComponentContext > &rxContext) + : writerperfect::ImportFilter(rxContext) + { + } + + // XServiceInfo + virtual OUString SAL_CALL getImplementationName() + throw (css::uno::RuntimeException, std::exception) override; + virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) + throw (css::uno::RuntimeException, std::exception) override; + virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() + throw (css::uno::RuntimeException, std::exception) override; + +private: + virtual bool doDetectFormat(librevenge::RVNGInputStream &rInput, OUString &rTypeName) override; + virtual bool doImportDocument(librevenge::RVNGInputStream &rInput, OdgGenerator &rGenerator, utl::MediaDescriptor &) override; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/writerperfect/source/draw/wpftdraw.component b/writerperfect/source/draw/wpftdraw.component index c1535394a02a..c315fa9f4dd3 100644 --- a/writerperfect/source/draw/wpftdraw.component +++ b/writerperfect/source/draw/wpftdraw.component @@ -49,4 +49,9 @@ + + + + -- cgit