From 600a2aa24085cb972686b46061f9045785208a9e Mon Sep 17 00:00:00 2001 From: Armin Le Grand Date: Mon, 12 Jun 2017 19:31:10 +0200 Subject: emfplus: for convenience added fallback For development and to not be dependent of the progress of the coming EMF+ importer, for now add fallback to using the old Metafile importer, plus conversion to primitive representation. That way the whole encapsulation is ready and can already be used Change-Id: I29afadaaaba71d75d0f5593852f4cc0cb3dd13f8 --- emfio/Library_emfio.mk | 1 + emfio/source/emfuno/xemfparser.cxx | 41 ++++++++++++++++++++++++++++++++------ 2 files changed, 36 insertions(+), 6 deletions(-) (limited to 'emfio') diff --git a/emfio/Library_emfio.mk b/emfio/Library_emfio.mk index c0a2dc2d42ff..e9a14249271a 100644 --- a/emfio/Library_emfio.mk +++ b/emfio/Library_emfio.mk @@ -41,6 +41,7 @@ $(eval $(call gb_Library_use_libraries,emfio,\ sax \ vcl \ svt \ + utl \ )) $(eval $(call gb_Library_add_exception_objects,emfio,\ diff --git a/emfio/source/emfuno/xemfparser.cxx b/emfio/source/emfuno/xemfparser.cxx index ce18d4be3a3a..6fb27aadde23 100644 --- a/emfio/source/emfuno/xemfparser.cxx +++ b/emfio/source/emfuno/xemfparser.cxx @@ -31,6 +31,11 @@ #include #include +#include +#include +#include +#include + //#include //#include //#include @@ -114,12 +119,36 @@ namespace emfio 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)); + static bool bUseOldFilterEmbedded(true); + + if (bUseOldFilterEmbedded) + { + GDIMetaFile aMtf; + std::unique_ptr pStream(::utl::UcbStreamHelper::CreateStream(xEmfStream)); + + if (pStream && ConvertWMFToGDIMetaFile(*pStream, aMtf, nullptr, nullptr)) + { + const basegfx::B2DHomMatrix aMetafileTransform( + basegfx::tools::createScaleTranslateB2DHomMatrix( + 5000.0, 5000.0, + 1000.0, 1000.0)); + + aRetval.push_back( + new drawinglayer::primitive2d::MetafilePrimitive2D( + aMetafileTransform, + aMtf)); + } + } + + if(aRetval.empty()) + { + // for test, just create some graphic data that will get visualized + 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 { -- cgit