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

Bartosz Kosiorek gang65 at poczta.onet.pl
Thu Nov 9 12:24:15 UTC 2017


 drawinglayer/source/tools/emfphelperdata.cxx |   65 +++++++++++++++------------
 1 file changed, 37 insertions(+), 28 deletions(-)

New commits:
commit e49aa9303f047d7610b2b8334404db120d7bc8db
Author: Bartosz Kosiorek <gang65 at poczta.onet.pl>
Date:   Mon Nov 6 23:44:34 2017 +0100

    tdf#77229 tdf#113635 EMF+ Add support for Clip Union, Exclude and Complement
    
    Union: Replaces the existing region with the union of the existing and new regions.
    Exclude: Replaces the existing region with the part of itself that is not in the new
    region.
    Complement: Replaces the existing region with the part of the new region that is not
    in the existing region.
    
    Change-Id: Iabbe0ddfa082a332e94dd85b6444b234d1bdee35
    Reviewed-on: https://gerrit.libreoffice.org/44380
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Bartosz Kosiorek <gang65 at poczta.onet.pl>

diff --git a/drawinglayer/source/tools/emfphelperdata.cxx b/drawinglayer/source/tools/emfphelperdata.cxx
index ebce2fbbd411..77f5d8f0c912 100644
--- a/drawinglayer/source/tools/emfphelperdata.cxx
+++ b/drawinglayer/source/tools/emfphelperdata.cxx
@@ -37,6 +37,7 @@
 #include <basegfx/matrix/b2dhommatrixtools.hxx>
 #include <basegfx/polygon/b2dpolygonclipper.hxx>
 #include <basegfx/polygon/b2dpolygontools.hxx>
+#include <basegfx/polygon/b2dpolypolygoncutter.hxx>
 #include <o3tl/make_unique.hxx>
 #include <vcl/svapp.hxx>
 #include <vcl/settings.hxx>
@@ -702,30 +703,10 @@ namespace emfplushelper
         switch (combineMode)
         {
         case EmfPlusCombineModeReplace:
-        case EmfPlusCombineModeUnion:
-        case EmfPlusCombineModeComplement:
         {
             HandleNewClipRegion(polygon, mrTargetHolders, mrPropertyHolders);
             break;
         }
-        case EmfPlusCombineModeXOR:
-        {
-            basegfx::B2DPolyPolygon aOriginalPolyPolygon(
-                        mrPropertyHolders.Current().getClipPolyPolygon());
-
-            if (!aOriginalPolyPolygon.count())
-            {
-                HandleNewClipRegion(polygon, mrTargetHolders, mrPropertyHolders);
-            }
-            else
-            {
-                aOriginalPolyPolygon.append(polygon);
-                // use existing tooling from wmfemfhelper
-                HandleNewClipRegion(aOriginalPolyPolygon, mrTargetHolders, mrPropertyHolders);
-            }
-
-            break;
-        }
         case EmfPlusCombineModeIntersect:
         {
             const basegfx::B2DPolyPolygon aOriginalPolyPolygon(
@@ -734,7 +715,6 @@ namespace emfplushelper
             basegfx::B2DPolyPolygon aClippedPolyPolygon;
             if (aOriginalPolyPolygon.count())
             {
-
                 aClippedPolyPolygon = basegfx::utils::clipPolyPolygonOnPolyPolygon(
                             aOriginalPolyPolygon,
                             polygon,
@@ -742,13 +722,47 @@ namespace emfplushelper
                             false);
             }
 
-            // use existing tooling from wmfemfhelper
             HandleNewClipRegion(aClippedPolyPolygon, mrTargetHolders, mrPropertyHolders);
             break;
         }
+        case EmfPlusCombineModeUnion:
+        {
+            basegfx::B2DPolyPolygon aOriginalPolyPolygon(
+                        mrPropertyHolders.Current().getClipPolyPolygon());
+
+            aOriginalPolyPolygon = ::basegfx::utils::solvePolygonOperationOr(aOriginalPolyPolygon, polygon);
+            HandleNewClipRegion(aOriginalPolyPolygon, mrTargetHolders, mrPropertyHolders);
+
+            break;
+        }
+        case EmfPlusCombineModeXOR:
+        {
+            basegfx::B2DPolyPolygon aOriginalPolyPolygon(
+                        mrPropertyHolders.Current().getClipPolyPolygon());
+
+            aOriginalPolyPolygon = ::basegfx::utils::solvePolygonOperationXor(aOriginalPolyPolygon, polygon);
+            HandleNewClipRegion(aOriginalPolyPolygon, mrTargetHolders, mrPropertyHolders);
+
+            break;
+        }
         case EmfPlusCombineModeExclude:
         {
-            // Not doing anything is better then including exactly what we wanted to exclude.
+            // Replaces the existing region with the part of itself that is not in the new region.
+            basegfx::B2DPolyPolygon aOriginalPolyPolygon(
+                        mrPropertyHolders.Current().getClipPolyPolygon());
+
+            aOriginalPolyPolygon = ::basegfx::utils::solvePolygonOperationDiff(aOriginalPolyPolygon, polygon);
+            HandleNewClipRegion(aOriginalPolyPolygon, mrTargetHolders, mrPropertyHolders);
+            break;
+        }
+        case EmfPlusCombineModeComplement:
+        {
+            // Replaces the existing region with the part of the new region that is not in the existing region.
+            basegfx::B2DPolyPolygon aOriginalPolyPolygon(
+                        mrPropertyHolders.Current().getClipPolyPolygon());
+
+            aOriginalPolyPolygon = ::basegfx::utils::solvePolygonOperationDiff(polygon, aOriginalPolyPolygon);
+            HandleNewClipRegion(aOriginalPolyPolygon, mrTargetHolders, mrPropertyHolders);
             break;
         }
         }
@@ -1507,11 +1521,6 @@ namespace emfplushelper
                         int combineMode = (flags >> 8) & 0xf;
 
                         SAL_INFO("drawinglayer", "EMF+ SetClipRect combine mode: " << combineMode);
-#if OSL_DEBUG_LEVEL > 1
-                        if (combineMode > 1) {
-                            SAL_WARN("drawinglayer", "EMF+ \tSetClipRect TODO combine mode > 1");
-                        }
-#endif
 
                         float dx, dy, dw, dh;
                         ReadRectangle(rMS, dx, dy, dw, dh);


More information about the Libreoffice-commits mailing list