summaryrefslogtreecommitdiff
path: root/emfio
diff options
context:
space:
mode:
authorArmin Le Grand <Armin.Le.Grand@cib.de>2017-06-09 19:55:17 +0200
committerThorsten Behrens <Thorsten.Behrens@CIB.de>2017-07-15 11:01:29 +0200
commit83535a28c57ffb59f795dd35332d6b3426071e32 (patch)
treea35406c5ed8c7971681385cbb081aad325e1cf54 /emfio
parent79f5cb620984c4d04d53a497e698472b2192d2bb (diff)
emfplus: create a wmf/emf/emf+ primitive based importer
First steps to organize an importer that can read/interpret wmf/emf/emf+ and deliver a primitive representation for the content by parsing it. Use the same mechanisms as already applied for Svg, so to reuse abilities to keep original binary data to allow save again and embedding in files and have an implemented replacement bitmap based representation. For this, unify the used helper classes to handle more than just Svg. For 1st try, add test code and static bool switches Change-Id: I6e0a82943541d811a8f8d65a84115569fcd8cee7
Diffstat (limited to 'emfio')
-rw-r--r--emfio/CppunitTest_emfio.mk67
-rw-r--r--emfio/Library_emfio.mk51
-rw-r--r--emfio/Makefile14
-rw-r--r--emfio/Module_emfio.mk29
-rw-r--r--emfio/README1
-rw-r--r--emfio/emfio.component25
-rw-r--r--emfio/inc/pch/precompiled_emfio.cxx12
-rw-r--r--emfio/inc/pch/precompiled_emfio.hxx29
-rw-r--r--emfio/qa/cppunit/EmfImportTest.cxx102
-rw-r--r--emfio/qa/cppunit/data/fdo79679-2.emfbin0 -> 34236 bytes
-rw-r--r--emfio/source/emfuno/emfuno.cxx46
-rw-r--r--emfio/source/emfuno/xemfparser.cxx210
-rw-r--r--emfio/source/emfuno/xemfparser.hxx50
13 files changed, 636 insertions, 0 deletions
diff --git a/emfio/CppunitTest_emfio.mk b/emfio/CppunitTest_emfio.mk
new file mode 100644
index 000000000000..8214bc87e794
--- /dev/null
+++ b/emfio/CppunitTest_emfio.mk
@@ -0,0 +1,67 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# 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/.
+#
+
+$(eval $(call gb_CppunitTest_CppunitTest,emfio))
+
+$(eval $(call gb_CppunitTest_set_componentfile,emfio,emfio/emfio))
+
+$(eval $(call gb_CppunitTest_set_include,emfio,\
+ $$(INCLUDE) \
+ -I$(SRCDIR)/emfio/inc \
+))
+
+$(eval $(call gb_CppunitTest_use_externals,emfio,\
+ boost_headers \
+ libxml2 \
+))
+
+$(eval $(call gb_CppunitTest_use_sdk_api,emfio))
+
+$(eval $(call gb_CppunitTest_use_library_objects,emfio,\
+ emfio \
+))
+
+$(eval $(call gb_CppunitTest_use_libraries,emfio,\
+ basegfx \
+ drawinglayer \
+ cppu \
+ cppuhelper \
+ comphelper \
+ sal \
+ svt \
+ test \
+ unotest \
+ tl \
+ vcl \
+))
+
+$(eval $(call gb_CppunitTest_add_exception_objects,emfio,\
+ emfio/qa/cppunit/EmfImportTest \
+))
+
+$(eval $(call gb_CppunitTest_use_ure,emfio))
+$(eval $(call gb_CppunitTest_use_vcl,emfio))
+
+$(eval $(call gb_CppunitTest_use_components,emfio,\
+ configmgr/source/configmgr \
+ dtrans/util/mcnttype \
+ framework/util/fwk \
+ i18npool/util/i18npool \
+ package/source/xstor/xstor \
+ package/util/package2 \
+ toolkit/util/tk \
+ sfx2/util/sfx \
+ ucb/source/core/ucb1 \
+ ucb/source/ucp/file/ucpfile1 \
+ unotools/util/utl \
+))
+
+$(eval $(call gb_CppunitTest_use_configuration,emfio))
+
+# vim: set noet sw=4 ts=4:
diff --git a/emfio/Library_emfio.mk b/emfio/Library_emfio.mk
new file mode 100644
index 000000000000..c0a2dc2d42ff
--- /dev/null
+++ b/emfio/Library_emfio.mk
@@ -0,0 +1,51 @@
+#
+# 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 .
+#
+
+$(eval $(call gb_Library_Library,emfio))
+
+$(eval $(call gb_Library_set_componentfile,emfio,emfio/emfio))
+
+$(eval $(call gb_Library_set_include,emfio,\
+ $$(INCLUDE) \
+ -I$(SRCDIR)/emfio/inc \
+))
+
+$(eval $(call gb_Library_use_external,emfio,boost_headers))
+
+$(eval $(call gb_Library_set_precompiled_header,emfio,$(SRCDIR)/emfio/inc/pch/precompiled_emfio))
+
+$(eval $(call gb_Library_use_sdk_api,emfio))
+
+$(eval $(call gb_Library_use_libraries,emfio,\
+ basegfx \
+ drawinglayer \
+ cppu \
+ cppuhelper \
+ sal \
+ tl \
+ sax \
+ vcl \
+ svt \
+))
+
+$(eval $(call gb_Library_add_exception_objects,emfio,\
+ emfio/source/emfuno/emfuno \
+ emfio/source/emfuno/xemfparser \
+))
+
+# vim: set noet sw=4 ts=4:
diff --git a/emfio/Makefile b/emfio/Makefile
new file mode 100644
index 000000000000..0997e628485b
--- /dev/null
+++ b/emfio/Makefile
@@ -0,0 +1,14 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# 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/.
+#
+
+module_directory:=$(dir $(realpath $(firstword $(MAKEFILE_LIST))))
+
+include $(module_directory)/../solenv/gbuild/partial_build.mk
+
+# vim: set noet sw=4 ts=4:
diff --git a/emfio/Module_emfio.mk b/emfio/Module_emfio.mk
new file mode 100644
index 000000000000..719bd0180628
--- /dev/null
+++ b/emfio/Module_emfio.mk
@@ -0,0 +1,29 @@
+#
+# 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 .
+#
+
+$(eval $(call gb_Module_Module,emfio))
+
+$(eval $(call gb_Module_add_targets,emfio,\
+ Library_emfio \
+))
+
+$(eval $(call gb_Module_add_check_targets,emfio,\
+ CppunitTest_emfio \
+))
+
+# vim: set noet ts=4 sw=4:
diff --git a/emfio/README b/emfio/README
new file mode 100644
index 000000000000..c68aa72ec90b
--- /dev/null
+++ b/emfio/README
@@ -0,0 +1 @@
+It contains emfio/source/emfeader which is used for "Insert->Picture->From File".
diff --git a/emfio/emfio.component b/emfio/emfio.component
new file mode 100644
index 000000000000..a0ea552950cd
--- /dev/null
+++ b/emfio/emfio.component
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * 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 .
+ -->
+
+<component loader="com.sun.star.loader.SharedLibrary" environment="@CPPU_ENV@"
+ prefix="emfio" xmlns="http://openoffice.org/2010/uno-components">
+ <implementation name="emfio::emfreader::XEmfParser">
+ <service name="com.sun.star.graphic.EmfTools"/>
+ </implementation>
+</component>
diff --git a/emfio/inc/pch/precompiled_emfio.cxx b/emfio/inc/pch/precompiled_emfio.cxx
new file mode 100644
index 000000000000..d87142820e5d
--- /dev/null
+++ b/emfio/inc/pch/precompiled_emfio.cxx
@@ -0,0 +1,12 @@
+/* -*- 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/.
+ */
+
+#include "precompiled_emfio.hxx"
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/emfio/inc/pch/precompiled_emfio.hxx b/emfio/inc/pch/precompiled_emfio.hxx
new file mode 100644
index 000000000000..fac038537e53
--- /dev/null
+++ b/emfio/inc/pch/precompiled_emfio.hxx
@@ -0,0 +1,29 @@
+/* -*- 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 has been autogenerated by update_pch.sh. It is possible to edit it
+ manually (such as when an include file has been moved/renamed/removed). All such
+ manual changes will be rewritten by the next run of update_pch.sh (which presumably
+ also fixes all possible problems, so it's usually better to use it).
+
+ Generated on 2017-06-09 17:33:30 using:
+ bin/update_pch emfio emfio --cutoff=8 --exclude:system --exclude:module --include:local
+
+ If after updating build fails, use the following command to locate conflicting headers:
+ ./bin/update_pch_bisect ./emfio/inc/pch/precompiled_emfio.hxx "make emfio.build" --find-conflicts
+*/
+
+#include <osl/diagnose.h>
+#include <rtl/instance.hxx>
+#include <rtl/unload.h>
+#include <rtl/ustring.hxx>
+#include <sal/types.h>
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/emfio/qa/cppunit/EmfImportTest.cxx b/emfio/qa/cppunit/EmfImportTest.cxx
new file mode 100644
index 000000000000..f315fc8937d0
--- /dev/null
+++ b/emfio/qa/cppunit/EmfImportTest.cxx
@@ -0,0 +1,102 @@
+/* -*- 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/.
+ */
+
+#include <sal/config.h>
+
+#include <test/bootstrapfixture.hxx>
+#include <test/primitive2dxmldump.hxx>
+#include <test/xmltesttools.hxx>
+
+#include <comphelper/processfactory.hxx>
+#include <comphelper/seqstream.hxx>
+#include <comphelper/sequence.hxx>
+
+#include <com/sun/star/graphic/EmfTools.hpp>
+#include <com/sun/star/graphic/Primitive2DTools.hpp>
+#include <com/sun/star/graphic/XPrimitive2D.hpp>
+
+#include <drawinglayer/primitive2d/baseprimitive2d.hxx>
+
+#include <memory>
+
+namespace
+{
+
+using namespace css::uno;
+using namespace css::io;
+using namespace css::graphic;
+using drawinglayer::primitive2d::Primitive2DSequence;
+using drawinglayer::primitive2d::Primitive2DContainer;
+
+class Test : public test::BootstrapFixture, public XmlTestTools
+{
+ void checkRectPrimitive(Primitive2DSequence& rPrimitive);
+
+ void testWorking();
+
+ Primitive2DSequence parseEmf(const char* aSource);
+
+public:
+ CPPUNIT_TEST_SUITE(Test);
+ CPPUNIT_TEST(testWorking);
+ CPPUNIT_TEST_SUITE_END();
+};
+
+Primitive2DSequence Test::parseEmf(const char* aSource)
+{
+ const Reference<XEmfParser> xEmfParser = EmfTools::create(m_xContext);
+
+ OUString aUrl = m_directories.getURLFromSrc(aSource);
+ OUString aPath = m_directories.getPathFromSrc(aSource);
+
+ SvFileStream aFileStream(aUrl, StreamMode::READ);
+ std::size_t nSize = aFileStream.remainingSize();
+ std::unique_ptr<sal_Int8[]> pBuffer(new sal_Int8[nSize + 1]);
+ aFileStream.ReadBytes(pBuffer.get(), nSize);
+ pBuffer[nSize] = 0;
+
+ Sequence<sal_Int8> aData(pBuffer.get(), nSize + 1);
+ Reference<XInputStream> aInputStream(new comphelper::SequenceInputStream(aData));
+
+ return xEmfParser->getDecomposition(aInputStream, aPath);
+}
+
+void Test::checkRectPrimitive(Primitive2DSequence& rPrimitive)
+{
+ Primitive2dXmlDump dumper;
+ xmlDocPtr pDocument = dumper.dumpAndParse(comphelper::sequenceToContainer<Primitive2DContainer>(rPrimitive));
+
+ CPPUNIT_ASSERT (pDocument);
+
+ // emfio: add examples
+ // assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor", "color", "#00cc00"); // rect background color
+ // assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor", "height", "100"); // rect background height
+ // assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor", "width", "100"); // rect background width
+ // assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor", "minx", "10");
+ // assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor", "miny", "10");
+ // assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor", "maxx", "110");
+ // assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor", "maxy", "110");
+ // assertXPath(pDocument, "/primitive2D/transform/polypolygonstroke/line", "color", "#ff0000"); // rect stroke color
+ // assertXPath(pDocument, "/primitive2D/transform/polypolygonstroke/line", "width", "3"); // rect stroke width
+}
+
+void Test::testWorking()
+{
+ Primitive2DSequence aSequenceRect = parseEmf("/emfio/qa/cppunit/data/fdo79679-2.emf");
+ CPPUNIT_ASSERT_EQUAL(1, (int) aSequenceRect.getLength());
+ checkRectPrimitive(aSequenceRect);
+}
+
+CPPUNIT_TEST_SUITE_REGISTRATION(Test);
+
+}
+
+CPPUNIT_PLUGIN_IMPLEMENT();
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/emfio/qa/cppunit/data/fdo79679-2.emf b/emfio/qa/cppunit/data/fdo79679-2.emf
new file mode 100644
index 000000000000..0962dc122152
--- /dev/null
+++ b/emfio/qa/cppunit/data/fdo79679-2.emf
Binary files differ
diff --git a/emfio/source/emfuno/emfuno.cxx b/emfio/source/emfuno/emfuno.cxx
new file mode 100644
index 000000000000..b027c5fe3cc2
--- /dev/null
+++ b/emfio/source/emfuno/emfuno.cxx
@@ -0,0 +1,46 @@
+/* -*- 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 .
+ */
+
+#include <sal/config.h>
+
+#include <cppuhelper/factory.hxx>
+#include <cppuhelper/implementationentry.hxx>
+#include <sal/types.h>
+
+#include "xemfparser.hxx"
+
+namespace {
+
+static cppu::ImplementationEntry const services[] = {
+ { &emfio::emfreader::XEmfParser_createInstance,
+ &emfio::emfreader::XEmfParser_getImplementationName,
+ &emfio::emfreader::XEmfParser_getSupportedServiceNames,
+ &cppu::createSingleComponentFactory, nullptr, 0 },
+ { nullptr, nullptr, nullptr, nullptr, nullptr, 0 } };
+
+}
+
+extern "C" SAL_DLLPUBLIC_EXPORT void * SAL_CALL emfio_component_getFactory(
+ char const * pImplName, void * pServiceManager, void * pRegistryKey)
+{
+ return cppu::component_getFactoryHelper(
+ pImplName, pServiceManager, pRegistryKey, services);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/emfio/source/emfuno/xemfparser.cxx b/emfio/source/emfuno/xemfparser.cxx
new file mode 100644
index 000000000000..ce18d4be3a3a
--- /dev/null
+++ b/emfio/source/emfuno/xemfparser.cxx
@@ -0,0 +1,210 @@
+/* -*- 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 .
+ */
+
+#include <sal/config.h>
+
+#include <com/sun/star/graphic/XEmfParser.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/lang/XInitialization.hpp>
+#include <cppuhelper/implbase2.hxx>
+#include <cppuhelper/supportsservice.hxx>
+#include <comphelper/sequence.hxx>
+#include <drawinglayer/primitive2d/baseprimitive2d.hxx>
+#include <basegfx/color/bcolor.hxx>
+#include <basegfx/polygon/b2dpolygon.hxx>
+#include <basegfx/polygon/b2dpolygontools.hxx>
+#include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx>
+
+//#include <com/sun/star/xml/sax/XParser.hpp>
+//#include <com/sun/star/xml/sax/Parser.hpp>
+//#include <com/sun/star/xml/sax/InputSource.hpp>
+//#include <drawinglayer/geometry/viewinformation2d.hxx>
+//#include <svgdocumenthandler.hxx>
+
+#include "xemfparser.hxx"
+
+using namespace ::com::sun::star;
+
+namespace emfio
+{
+ namespace emfreader
+ {
+ class XEmfParser : public ::cppu::WeakAggImplHelper2< graphic::XEmfParser, lang::XServiceInfo >
+ {
+ private:
+ uno::Reference< uno::XComponentContext > context_;
+
+ protected:
+ public:
+ explicit XEmfParser(
+ uno::Reference< uno::XComponentContext > const & context);
+ XEmfParser(const XEmfParser&) = delete;
+ XEmfParser& operator=(const XEmfParser&) = delete;
+
+ // XEmfParser
+ virtual uno::Sequence< uno::Reference< ::graphic::XPrimitive2D > > SAL_CALL getDecomposition(
+ const uno::Reference< ::io::XInputStream >& xEmfStream,
+ const OUString& aAbsolutePath) override;
+
+ // XServiceInfo
+ virtual OUString SAL_CALL getImplementationName() override;
+ virtual sal_Bool SAL_CALL supportsService(const OUString&) override;
+ virtual uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
+ };
+ } // end of namespace emfreader
+} // end of namespace emfio
+
+// uno functions
+namespace emfio
+{
+ namespace emfreader
+ {
+ uno::Sequence< OUString > XEmfParser_getSupportedServiceNames()
+ {
+ return uno::Sequence< OUString > { "com.sun.star.graphic.EmfTools" };
+ }
+
+ OUString XEmfParser_getImplementationName()
+ {
+ return OUString( "emfio::emfreader::XEmfParser" );
+ }
+
+ uno::Reference< uno::XInterface > SAL_CALL XEmfParser_createInstance(const uno::Reference< uno::XComponentContext >& context)
+ {
+ return static_cast< ::cppu::OWeakObject* >(new XEmfParser(context));
+ }
+ } // end of namespace emfreader
+} // end of namespace emfio
+
+namespace emfio
+{
+ namespace emfreader
+ {
+ XEmfParser::XEmfParser(
+ uno::Reference< uno::XComponentContext > const & context):
+ context_(context)
+ {
+ }
+
+ uno::Sequence< uno::Reference< ::graphic::XPrimitive2D > > XEmfParser::getDecomposition(
+ const uno::Reference< ::io::XInputStream >& xEmfStream,
+ const OUString& aAbsolutePath )
+ {
+ drawinglayer::primitive2d::Primitive2DContainer aRetval;
+
+ if (xEmfStream.is())
+ {
+ static bool bTestCode(true);
+
+ if (bTestCode)
+ {
+ // for test, just create some graphic data
+ const basegfx::B2DRange aRange(1000, 1000, 5000, 5000);
+ const basegfx::BColor aColor(1.0, 0.0, 0.0);
+ const basegfx::B2DPolygon aOutline(basegfx::tools::createPolygonFromRect(aRange));
+
+ aRetval.push_back(new drawinglayer::primitive2d::PolyPolygonColorPrimitive2D(basegfx::B2DPolyPolygon(aOutline), aColor));
+ }
+ else
+ {
+ // new parser here
+ bool bBla = true;
+
+
+
+
+ // // local document handler
+ // SvgDocHdl* pSvgDocHdl = new SvgDocHdl(aAbsolutePath);
+ // uno::Reference< xml::sax::XDocumentHandler > xSvgDocHdl(pSvgDocHdl);
+ //
+ // try
+ // {
+ // // prepare ParserInputSrouce
+ // xml::sax::InputSource myInputSource;
+ // myInputSource.aInputStream = xEmfStream;
+ //
+ // // get parser
+ // uno::Reference< xml::sax::XParser > xParser(
+ // xml::sax::Parser::create(context_));
+ // // fdo#60471 need to enable internal entities because
+ // // certain ... popular proprietary products write SVG files
+ // // that use entities to define XML namespaces.
+ // uno::Reference<lang::XInitialization> const xInit(xParser,
+ // uno::UNO_QUERY_THROW);
+ // uno::Sequence<uno::Any> args(1);
+ // args[0] <<= OUString("DoSmeplease");
+ // xInit->initialize(args);
+ //
+ // // connect parser and filter
+ // xParser->setDocumentHandler(xSvgDocHdl);
+ //
+ // // finally, parse the stream to a hierarchy of
+ // // SVGGraphicPrimitive2D which will be embedded to the
+ // // primitive sequence. Their decompositions will in the
+ // // end create local low-level primitives, thus SVG will
+ // // be processable from all our processors
+ // xParser->parseStream(myInputSource);
+ // }
+ // catch(const uno::Exception& e)
+ // {
+ // SAL_WARN( "svg", "Parse error! : " << e.Message);
+ // }
+ //
+ // // decompose to primitives
+ // const SvgNodeVector& rResults = pSvgDocHdl->getSvgDocument().getSvgNodeVector();
+ // const sal_uInt32 nCount(rResults.size());
+ //
+ // for(sal_uInt32 a(0); a < nCount; a++)
+ // {
+ // SvgNode* pCandidate = rResults[a];
+ //
+ // if(Display_none != pCandidate->getDisplay())
+ // {
+ // pCandidate->decomposeSvgNode(aRetval, false);
+ // }
+ // }
+ }
+ }
+ else
+ {
+ OSL_ENSURE(false, "Invalid stream (!)");
+ }
+
+ return comphelper::containerToSequence(aRetval);
+ }
+
+ OUString SAL_CALL XEmfParser::getImplementationName()
+ {
+ return(XEmfParser_getImplementationName());
+ }
+
+ sal_Bool SAL_CALL XEmfParser::supportsService(const OUString& rServiceName)
+ {
+ return cppu::supportsService(this, rServiceName);
+ }
+
+ uno::Sequence< OUString > SAL_CALL XEmfParser::getSupportedServiceNames()
+ {
+ return XEmfParser_getSupportedServiceNames();
+ }
+
+ } // end of namespace emfreader
+} // end of namespace emfio
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/emfio/source/emfuno/xemfparser.hxx b/emfio/source/emfuno/xemfparser.hxx
new file mode 100644
index 000000000000..da78322028dc
--- /dev/null
+++ b/emfio/source/emfuno/xemfparser.hxx
@@ -0,0 +1,50 @@
+/* -*- 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_EMFIO_SOURCE_EMFUNO_XEMFARSER_HXX
+#define INCLUDED_EMFIO_SOURCE_EMFUNO_XEMFARSER_HXX
+
+#include <sal/config.h>
+
+#include <com/sun/star/uno/Reference.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+#include <sal/types.h>
+
+namespace com { namespace sun { namespace star {
+ namespace uno {
+ class XComponentContext;
+ class XInterface;
+ }
+} } }
+
+namespace emfio { namespace emfreader {
+
+css::uno::Reference< css::uno::XInterface > SAL_CALL
+XEmfParser_createInstance( css::uno::Reference< css::uno::XComponentContext > const &);
+
+OUString SAL_CALL XEmfParser_getImplementationName();
+
+css::uno::Sequence< OUString > SAL_CALL
+XEmfParser_getSupportedServiceNames();
+
+} }
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */