drawinglayer/source/tools/primitive2dxmldump.cxx         |    9 ++++
 emfio/qa/cppunit/emf/EmfImportTest.cxx                   |   30 +++++++++++++++
 emfio/qa/cppunit/emf/data/TestDrawPolyLine16WithClip.emf |binary
 emfio/qa/cppunit/wmf/wmfimporttest.cxx                   |    9 ++--
 emfio/source/reader/mtftools.cxx                         |   27 +++----------
 5 files changed, 50 insertions(+), 25 deletions(-)

New commits:
commit 8deb9b3d2f8781628db73d3b2a3c7939ea4fcc2d
Author:     Bartosz Kosiorek <gan...@poczta.onet.pl>
AuthorDate: Fri Apr 2 16:06:11 2021 +0200
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Tue Apr 6 14:04:15 2021 +0200

    tdf#37281 tdf#45820 tdf#48916 tdf#55058 EMF Implement complex clipping
    
    As the visual glitches were resolved with:
    https://gerrit.libreoffice.org/c/core/+/113423
    
    It is time for enabling complex clipping.
    
    Change-Id: I12edc88fc9a55c8deedf3d87faeb50cfe0067a01
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113520
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caol...@redhat.com>
    Reviewed-by: Bartosz Kosiorek <gan...@poczta.onet.pl>
    (cherry picked from commit aa17ea3d36b8f1ea8cd3d2fb215e80051547439d)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113637
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/drawinglayer/source/tools/primitive2dxmldump.cxx 
b/drawinglayer/source/tools/primitive2dxmldump.cxx
index 7a19e0486c89..ade8cfaed89b 100644
--- a/drawinglayer/source/tools/primitive2dxmldump.cxx
+++ b/drawinglayer/source/tools/primitive2dxmldump.cxx
@@ -311,6 +311,15 @@ void Primitive2dXmlDump::decomposeAndWrite(
             }
             break;
 
+            case PRIMITIVE2D_ID_GROUPPRIMITIVE2D:
+            {
+                const GroupPrimitive2D& rGroupPrimitive2D = dynamic_cast<const 
GroupPrimitive2D&>(*pBasePrimitive);
+                rWriter.startElement("group");
+                decomposeAndWrite(rGroupPrimitive2D.getChildren(), rWriter);
+                rWriter.endElement();
+            }
+            break;
+
             case PRIMITIVE2D_ID_MASKPRIMITIVE2D:
             {
                 const MaskPrimitive2D& rMaskPrimitive2D = dynamic_cast<const 
MaskPrimitive2D&>(*pBasePrimitive);
diff --git a/emfio/qa/cppunit/emf/EmfImportTest.cxx 
b/emfio/qa/cppunit/emf/EmfImportTest.cxx
index f4c75e883d30..51c0cc115987 100644
--- a/emfio/qa/cppunit/emf/EmfImportTest.cxx
+++ b/emfio/qa/cppunit/emf/EmfImportTest.cxx
@@ -50,6 +50,7 @@ class Test : public test::BootstrapFixture, public 
XmlTestTools, public unotest:
     void TestLinearGradient();
     void TestTextMapMode();
     void TestEnglishMapMode();
+    void TestDrawPolyLine16WithClip();
     void TestFillRegion();
     void TestCreatePen();
     void TestPdfInEmf();
@@ -69,6 +70,7 @@ public:
     CPPUNIT_TEST(TestLinearGradient);
     CPPUNIT_TEST(TestTextMapMode);
     CPPUNIT_TEST(TestEnglishMapMode);
+    CPPUNIT_TEST(TestDrawPolyLine16WithClip);
     CPPUNIT_TEST(TestFillRegion);
     CPPUNIT_TEST(TestCreatePen);
     CPPUNIT_TEST(TestPdfInEmf);
@@ -310,6 +312,34 @@ void Test::TestEnglishMapMode()
 
 }
 
+void Test::TestDrawPolyLine16WithClip()
+{
+    // Check import of EMF image with records:
+    // CREATEBRUSHINDIRECT, FILLRGN, BEGINPATH, POLYGON16, SELECTCLIPPATH, 
MODIFYWORLDTRANSFORM, SELECTOBJECT
+    Primitive2DSequence aSequence = 
parseEmf(u"/emfio/qa/cppunit/emf/data/TestDrawPolyLine16WithClip.emf");
+    CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aSequence.getLength()));
+    drawinglayer::Primitive2dXmlDump dumper;
+    xmlDocUniquePtr pDocument = 
dumper.dumpAndParse(comphelper::sequenceToContainer<Primitive2DContainer>(aSequence));
+    CPPUNIT_ASSERT (pDocument);
+
+    assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polypolygon", 
"path", "m0 0h3943v3939h-3943z");
+
+    assertXPath(pDocument, 
"/primitive2D/metafile/transform/mask/polypolygoncolor", 1);
+    assertXPath(pDocument, 
"/primitive2D/metafile/transform/mask/polypolygoncolor[1]/polypolygon",
+                "path", "m1323 
0h1323v1322h1323v1322h-1323v1322h-1323v-1322h-1323v-1322h1323z");
+    assertXPath(pDocument, 
"/primitive2D/metafile/transform/mask/polypolygoncolor[1]", "color", "#b4ffff");
+
+    assertXPath(pDocument, 
"/primitive2D/metafile/transform/mask/polygonhairline", 1);
+    assertXPathContent(pDocument, 
"/primitive2D/metafile/transform/mask/polygonhairline[1]/polygon",
+                       "1323,0 2646,0 2646,1322 3969,1322 3969,2644 2646,2644 
2646,3966 1323,3966 1323,2644 0,2644 0,1322 1323,1322");
+    assertXPath(pDocument, 
"/primitive2D/metafile/transform/mask/polygonhairline[1]", "color", "#000000");
+
+
+    assertXPath(pDocument, 
"/primitive2D/metafile/transform/mask/group[1]/mask/polypolygon", "path", 
"m2646 0v1322h1323v1322h-1323v1322h-1323v-1322h-1323v-1322h1323v-1322");
+    assertXPathContent(pDocument, 
"/primitive2D/metafile/transform/mask/group[1]/mask/polygonstroke/polygon", 
"0,793 3969,4230");
+
+}
+
 void Test::TestFillRegion()
 {
     // Check import of EMF image with records: CREATEBRUSHINDIRECT, FILLRGN. 
The SETICMMODE is also used.
diff --git a/emfio/qa/cppunit/emf/data/TestDrawPolyLine16WithClip.emf 
b/emfio/qa/cppunit/emf/data/TestDrawPolyLine16WithClip.emf
new file mode 100644
index 000000000000..acb69cc34ce3
Binary files /dev/null and 
b/emfio/qa/cppunit/emf/data/TestDrawPolyLine16WithClip.emf differ
diff --git a/emfio/qa/cppunit/wmf/wmfimporttest.cxx 
b/emfio/qa/cppunit/wmf/wmfimporttest.cxx
index 5dfcfdad2041..f63138bfa4b6 100644
--- a/emfio/qa/cppunit/wmf/wmfimporttest.cxx
+++ b/emfio/qa/cppunit/wmf/wmfimporttest.cxx
@@ -122,10 +122,11 @@ void WmfTest::testEmfProblem()
 
     CPPUNIT_ASSERT(pDoc);
 
-    assertXPath(pDoc, "/metafile/sectrectclipregion[1]", "top", "427");
-    assertXPath(pDoc, "/metafile/sectrectclipregion[1]", "left", "740");
-    assertXPath(pDoc, "/metafile/sectrectclipregion[1]", "bottom", "2823");
-    assertXPath(pDoc, "/metafile/sectrectclipregion[1]", "right", "1876");
+    assertXPath(pDoc, "/metafile/sectrectclipregion", 2);
+    assertXPath(pDoc, "/metafile/sectrectclipregion[1]", "top", "2125");
+    assertXPath(pDoc, "/metafile/sectrectclipregion[1]", "left", "1084");
+    assertXPath(pDoc, "/metafile/sectrectclipregion[1]", "bottom", "2927");
+    assertXPath(pDoc, "/metafile/sectrectclipregion[1]", "right", "2376");
 }
 
 void WmfTest::testEmfLineStyles()
diff --git a/emfio/source/reader/mtftools.cxx b/emfio/source/reader/mtftools.cxx
index 94ddcd549cec..092e26d3a0d9 100644
--- a/emfio/source/reader/mtftools.cxx
+++ b/emfio/source/reader/mtftools.cxx
@@ -1170,31 +1170,16 @@ namespace emfio
         mbComplexClip = rClipPoly.count() > 1
             || !basegfx::utils::isRectangle(rClipPoly);
 
-        static bool bEnableComplexClipViaRegion = 
getenv("SAL_WMF_COMPLEXCLIP_VIA_REGION") != nullptr;
-
-        if (bEnableComplexClipViaRegion)
+        // This makes cases like tdf#45820 work in reasonable time.
+        if (mbComplexClip)
         {
-            //this makes cases like tdf#45820 work in reasonable time, and I 
feel in theory should
-            //be just fine. In practice I see the output is different so needs 
work before its the
-            //default, but for file fuzzing it should be good enough
-            if (mbComplexClip)
-            {
-                mpGDIMetaFile->AddAction(
-                    new MetaISectRegionClipRegionAction(
-                        vcl::Region(rClipPoly)));
-                mbComplexClip = false;
-            }
-            else
-            {
-                mpGDIMetaFile->AddAction(
-                    new MetaISectRectClipRegionAction(
-                        vcl::unotools::rectangleFromB2DRectangle(
-                            rClipPoly.getB2DRange())));
-            }
+            mpGDIMetaFile->AddAction(
+                new MetaISectRegionClipRegionAction(
+                    vcl::Region(rClipPoly)));
+            mbComplexClip = false;
         }
         else
         {
-            //normal case
             mpGDIMetaFile->AddAction(
                 new MetaISectRectClipRegionAction(
                     vcl::unotools::rectangleFromB2DRectangle(
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to