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

Chr. Rossmanith ChrRossmanith at gmx.de
Tue Nov 10 16:52:02 PST 2015


 filter/source/svg/svgreader.cxx |   54 ++++++++++++++++++++++++++++++++++++----
 1 file changed, 49 insertions(+), 5 deletions(-)

New commits:
commit 591903a1b1b64e68322f7454d3e61b2503028b9a
Author: Chr. Rossmanith <ChrRossmanith at gmx.de>
Date:   Tue Nov 10 21:17:54 2015 +0100

    tdf#51165: handle mixture of open and closed polygons in a path
    
    Change-Id: I66c7fb2b627d3380c09b6e5e495905bed67c2824
    Reviewed-on: https://gerrit.libreoffice.org/19860
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>

diff --git a/filter/source/svg/svgreader.cxx b/filter/source/svg/svgreader.cxx
index e30acf3..04d8e01 100644
--- a/filter/source/svg/svgreader.cxx
+++ b/filter/source/svg/svgreader.cxx
@@ -128,6 +128,35 @@ double colorDiffSquared(const ARGBColor& rCol1, const ARGBColor& rCol2)
         + square(rCol1.b-rCol2.b);
 }
 
+/**
+    check whether a polypolygon contains both open and closed
+    polygons
+**/
+bool PolyPolygonIsMixedOpenAndClosed( const basegfx::B2DPolyPolygon& rPoly )
+{
+    bool bRetval(false);
+    bool bOpen(false);
+    bool bClosed(false);
+
+    // PolyPolygon is mixed open and closed if there is more than one
+    // polygon and there are both closed and open polygons.
+    for( sal_uInt32 a(0L); !bRetval && a < rPoly.count(); a++ )
+    {
+        if ( (rPoly.getB2DPolygon(a)).isClosed() )
+        {
+            bClosed = true;
+        }
+        else
+        {
+            bOpen = true;
+        }
+
+        bRetval = (bClosed && bOpen);
+    }
+
+    return bRetval;
+}
+
 typedef std::map<OUString,sal_Size> ElementRefMapType;
 
 struct AnnotatingVisitor
@@ -1366,11 +1395,26 @@ struct ShapeWritingVisitor
                     aPoly.setClosed(true);
                 }
 
-                writePathShape(xAttrs,
-                               xUnoAttrs,
-                               xElem,
-                               sStyleId,
-                               aPoly);
+                // tdf#51165: rendering of paths with open and closed polygons is not implemented
+                // split mixed polypolygons into single polygons and add them one by one
+                if( PolyPolygonIsMixedOpenAndClosed(aPoly) )
+                {
+                    for( sal_uInt32 i(0L); i<aPoly.count(); ++i ) {
+                        writePathShape(xAttrs,
+                                       xUnoAttrs,
+                                       xElem,
+                                       sStyleId,
+                                       basegfx::B2DPolyPolygon(aPoly.getB2DPolygon(i)));
+                    }
+                }
+                else
+                {
+                    writePathShape(xAttrs,
+                                   xUnoAttrs,
+                                   xElem,
+                                   sStyleId,
+                                   aPoly);
+                }
                 break;
             }
             case XML_CIRCLE:


More information about the Libreoffice-commits mailing list