[Libreoffice-commits] core.git: Branch 'feature/emfplusprimitiveparser' - 2 commits - emfio/Library_emfio.mk emfio/source include/vcl

Armin Le Grand Armin.Le.Grand at cib.de
Mon Jun 12 17:52:32 UTC 2017


 emfio/Library_emfio.mk             |    1 
 emfio/source/emfuno/xemfparser.cxx |   54 ++++++++++++++++++++++++++++++++-----
 include/vcl/wmf.hxx                |    3 +-
 3 files changed, 51 insertions(+), 7 deletions(-)

New commits:
commit 42bdd2cbc1a05eea081dd21596f26820d94961bb
Author: Armin Le Grand <Armin.Le.Grand at cib.de>
Date:   Mon Jun 12 19:54:12 2017 +0200

    emfplus: use size of image of metafile fallback
    
    Change-Id: I0de82e0e431c0ce4527a909c2f98194f465ace8d

diff --git a/emfio/source/emfuno/xemfparser.cxx b/emfio/source/emfuno/xemfparser.cxx
index 6fb27aadde23..3b6e9ad731fa 100644
--- a/emfio/source/emfuno/xemfparser.cxx
+++ b/emfio/source/emfuno/xemfparser.cxx
@@ -31,6 +31,7 @@
 #include <basegfx/polygon/b2dpolygontools.hxx>
 #include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx>
 
+#include <vcl/svapp.hxx>
 #include <basegfx/matrix/b2dhommatrixtools.hxx>
 #include <vcl/wmf.hxx>
 #include <unotools/ucbstreamhelper.hxx>
@@ -128,10 +129,22 @@ namespace emfio
 
                         if (pStream && ConvertWMFToGDIMetaFile(*pStream, aMtf, nullptr, nullptr))
                         {
+
+                            Size aSize(aMtf.GetPrefSize());
+
+                            if (aMtf.GetPrefMapMode().GetMapUnit() == MapUnit::MapPixel)
+                            {
+                                aSize = Application::GetDefaultDevice()->PixelToLogic(aSize, MapUnit::Map100thMM);
+                            }
+                            else
+                            {
+                                aSize = OutputDevice::LogicToLogic(aSize, aMtf.GetPrefMapMode(), MapMode(MapUnit::Map100thMM));
+                            }
+
                             const basegfx::B2DHomMatrix aMetafileTransform(
-                                basegfx::tools::createScaleTranslateB2DHomMatrix(
-                                    5000.0, 5000.0,
-                                    1000.0, 1000.0));
+                                basegfx::tools::createScaleB2DHomMatrix(
+                                    aSize.Width(),
+                                    aSize.Height()));
 
                             aRetval.push_back(
                                 new drawinglayer::primitive2d::MetafilePrimitive2D(
commit fa09533253a6f191b690d1f79a236bf48451ba8c
Author: Armin Le Grand <Armin.Le.Grand at cib.de>
Date:   Mon Jun 12 19:31:10 2017 +0200

    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

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 <basegfx/polygon/b2dpolygontools.hxx>
 #include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx>
 
+#include <basegfx/matrix/b2dhommatrixtools.hxx>
+#include <vcl/wmf.hxx>
+#include <unotools/ucbstreamhelper.hxx>
+#include <drawinglayer/primitive2d/metafileprimitive2d.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>
@@ -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<SvStream> 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
                 {
diff --git a/include/vcl/wmf.hxx b/include/vcl/wmf.hxx
index bea47d225052..67d6aa4f122b 100644
--- a/include/vcl/wmf.hxx
+++ b/include/vcl/wmf.hxx
@@ -55,7 +55,8 @@ struct WMF_EXTERNALHEADER
     }
 };
 
-bool ConvertWMFToGDIMetaFile( SvStream & rStreamWMF, GDIMetaFile & rGDIMetaFile, FilterConfigItem* pConfigItem, WMF_EXTERNALHEADER *pExtHeader );
+// for 1st test, export
+VCL_DLLPUBLIC bool ConvertWMFToGDIMetaFile( SvStream & rStreamWMF, GDIMetaFile & rGDIMetaFile, FilterConfigItem* pConfigItem, WMF_EXTERNALHEADER *pExtHeader );
 
 VCL_DLLPUBLIC bool ReadWindowMetafile( SvStream& rStream, GDIMetaFile& rMTF );
 


More information about the Libreoffice-commits mailing list