[Libreoffice-commits] core.git: drawinglayer/source

Armin Le Grand Armin.Le.Grand at cib.de
Sat Oct 28 01:43:51 UTC 2017


 drawinglayer/source/primitive2d/metafileprimitive2d.cxx |   60 ++++++----------
 1 file changed, 25 insertions(+), 35 deletions(-)

New commits:
commit bdb9cc1702d4e125db8c379f3b535bbd9f845b95
Author: Armin Le Grand <Armin.Le.Grand at cib.de>
Date:   Tue Oct 24 11:36:49 2017 +0200

    tdf#113197 Add MaskPrimitive (clip) to EMF/WMF if needed
    
    When the content of an imported EMF/WMF overlaps the defined
    size in PrefMapMode/PrefSize, add clipping to hide it. This
    was done in imports before EMF+ changes and is done in SVG, too.
    If needed, orig contained size and content still accessible
    using MetafilePrimitive2D::accessMetafile
    
    Change-Id: Id86ff3c0a9820637e3601c0c4f489a2d67d190d0
    Reviewed-on: https://gerrit.libreoffice.org/43746
    Reviewed-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>
    Tested-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>

diff --git a/drawinglayer/source/primitive2d/metafileprimitive2d.cxx b/drawinglayer/source/primitive2d/metafileprimitive2d.cxx
index bb3d243b4beb..5ace807a264d 100644
--- a/drawinglayer/source/primitive2d/metafileprimitive2d.cxx
+++ b/drawinglayer/source/primitive2d/metafileprimitive2d.cxx
@@ -20,43 +20,10 @@
 #include <drawinglayer/primitive2d/metafileprimitive2d.hxx>
 #include <wmfemfhelper.hxx>
 
-//#include <basegfx/utils/canvastools.hxx>
 #include <drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx>
-//#include <basegfx/color/bcolor.hxx>
-//#include <drawinglayer/primitive2d/pointarrayprimitive2d.hxx>
-//#include <vcl/lineinfo.hxx>
-//#include <drawinglayer/attribute/lineattribute.hxx>
-//#include <drawinglayer/attribute/strokeattribute.hxx>
-//#include <drawinglayer/primitive2d/polygonprimitive2d.hxx>
-//#include <vcl/metaact.hxx>
 #include <drawinglayer/primitive2d/transformprimitive2d.hxx>
-//#include <basegfx/matrix/b2dhommatrixtools.hxx>
-//#include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx>
-//#include <basegfx/polygon/b2dpolygontools.hxx>
-//#include <drawinglayer/primitive2d/discretebitmapprimitive2d.hxx>
-//#include <drawinglayer/primitive2d/bitmapprimitive2d.hxx>
-//#include <vcl/salbtype.hxx>
-//#include <drawinglayer/primitive2d/unifiedtransparenceprimitive2d.hxx>
-//#include <drawinglayer/primitive2d/fillgradientprimitive2d.hxx>
-//#include <vcl/svapp.hxx>
-//#include <drawinglayer/primitive2d/transparenceprimitive2d.hxx>
-//#include <drawinglayer/primitive2d/fillhatchprimitive2d.hxx>
-//#include <drawinglayer/primitive2d/maskprimitive2d.hxx>
-//#include <basegfx/polygon/b2dpolygonclipper.hxx>
-//#include <drawinglayer/primitive2d/invertprimitive2d.hxx>
-//#include <drawinglayer/primitive2d/modifiedcolorprimitive2d.hxx>
-//#include <drawinglayer/primitive2d/fillgraphicprimitive2d.hxx>
-//#include <drawinglayer/primitive2d/wallpaperprimitive2d.hxx>
-//#include <drawinglayer/primitive2d/textprimitive2d.hxx>
-//#include <drawinglayer/primitive2d/textlayoutdevice.hxx>
-//#include <drawinglayer/primitive2d/textdecoratedprimitive2d.hxx>
-//#include <i18nlangtag/languagetag.hxx>
-//#include <drawinglayer/primitive2d/textlineprimitive2d.hxx>
-//#include <drawinglayer/primitive2d/textstrikeoutprimitive2d.hxx>
-//#include <drawinglayer/primitive2d/epsprimitive2d.hxx>
-//#include <tools/fract.hxx>
-//#include <numeric>
-//#include <emfplushelper.hxx>
+#include <basegfx/polygon/b2dpolygontools.hxx>
+#include <drawinglayer/primitive2d/maskprimitive2d.hxx>
 
 using namespace com::sun::star;
 
@@ -74,6 +41,29 @@ namespace drawinglayer
             {
                 // get target size
                 const ::tools::Rectangle aMtfTarget(getMetaFile().GetPrefMapMode().GetOrigin(), getMetaFile().GetPrefSize());
+                const basegfx::B2DRange aMtfRange(aMtfTarget.Left(), aMtfTarget.Top(), aMtfTarget.Right(), aMtfTarget.Bottom());
+
+                // tdf#113197 get content range and check if we have an overlap with
+                // defined target range (aMtfRange)
+                if (!aMtfRange.isEmpty())
+                {
+                    const basegfx::B2DRange aContentRange(xRetval.getB2DRange(rViewInformation));
+
+                    // also test equal since isInside gives also true for equal
+                    if (!aMtfRange.equal(aContentRange) && !aMtfRange.isInside(aContentRange))
+                    {
+                        // contentRange is partly larger than aMtfRange (stuff sticks
+                        // outside), clipping is needed
+                        const drawinglayer::primitive2d::Primitive2DReference xMask(
+                            new drawinglayer::primitive2d::MaskPrimitive2D(
+                                basegfx::B2DPolyPolygon(
+                                    basegfx::utils::createPolygonFromRect(
+                                        aMtfRange)),
+                                xRetval));
+
+                        xRetval = drawinglayer::primitive2d::Primitive2DContainer{ xMask };
+                    }
+                }
 
                 // create transformation
                 basegfx::B2DHomMatrix aAdaptedTransform;


More information about the Libreoffice-commits mailing list