[Libreoffice-commits] core.git: svgio/qa svgio/source

Xisco Fauli anistenis at gmail.com
Tue Aug 30 20:41:30 UTC 2016


 svgio/qa/cppunit/SvgImportTest.cxx            |   20 ++++++++++++++++++++
 svgio/qa/cppunit/data/tdf101237.svg           |   11 +++++++++++
 svgio/source/svgreader/svgstyleattributes.cxx |   24 ++++++++++++++++++------
 3 files changed, 49 insertions(+), 6 deletions(-)

New commits:
commit 75003438e4b429ffb3f013afd0e36d70545833cc
Author: Xisco Fauli <anistenis at gmail.com>
Date:   Tue Aug 30 16:21:52 2016 +0200

    tdf#101237 SVGIO: Use black as default when parents' fill...
    
    ...attributes are empty or none and there's a reference
    to a clip-path present.
    
    Change-Id: I4dc4e3bcaac43a007fbdb8a1d006cbd39c737396
    Reviewed-on: https://gerrit.libreoffice.org/28500
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Xisco FaulĂ­ <anistenis at gmail.com>

diff --git a/svgio/qa/cppunit/SvgImportTest.cxx b/svgio/qa/cppunit/SvgImportTest.cxx
index 218f9e8..8bded0f 100644
--- a/svgio/qa/cppunit/SvgImportTest.cxx
+++ b/svgio/qa/cppunit/SvgImportTest.cxx
@@ -61,6 +61,7 @@ class Test : public test::BootstrapFixture, public XmlTestTools
     void test47446b();
     void testMaskText();
     void testTdf99994();
+    void testTdf101237();
 
     Primitive2DSequence parseSvg(const char* aSource);
 
@@ -91,6 +92,7 @@ public:
     CPPUNIT_TEST(test47446b);
     CPPUNIT_TEST(testMaskText);
     CPPUNIT_TEST(testTdf99994);
+    CPPUNIT_TEST(testTdf101237);
     CPPUNIT_TEST_SUITE_END();
 };
 
@@ -620,6 +622,24 @@ void Test::testTdf99994()
     assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", "familyname", "Sans");
 }
 
+void Test::testTdf101237()
+{
+    //Check that fill color, stroke color and stroke-width are inherited from use element
+    //when the element is within a clipPath element
+    Primitive2DSequence aSequenceTdf101237 = parseSvg("/svgio/qa/cppunit/data/tdf101237.svg");
+    CPPUNIT_ASSERT_EQUAL(1, (int)aSequenceTdf101237.getLength());
+
+    Primitive2dXmlDump dumper;
+    xmlDocPtr pDocument = dumper.dumpAndParse(comphelper::sequenceToContainer<Primitive2DContainer>(aSequenceTdf101237));
+
+    CPPUNIT_ASSERT (pDocument);
+
+    assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor", "color", "#ff0000");
+    assertXPath(pDocument, "/primitive2D/transform/polypolygonstroke/line", "color", "#000000");
+    assertXPath(pDocument, "/primitive2D/transform/polypolygonstroke/line", "width", "5");
+
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(Test);
 
 }
diff --git a/svgio/qa/cppunit/data/tdf101237.svg b/svgio/qa/cppunit/data/tdf101237.svg
new file mode 100644
index 0000000..e5afa37
--- /dev/null
+++ b/svgio/qa/cppunit/data/tdf101237.svg
@@ -0,0 +1,11 @@
+<svg version="1.1" baseProfile="basic" id="svg-root"
+  width="100%" height="100%" viewBox="0 0 480 360"
+  xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" fill="none">
+
+  <clipPath id="p.0">
+    <path
+        d="m0 0l437.0 0l0 487.0l-437.0 0l0 -487.0z"
+        clip-rule="nonzero"/>
+  </clipPath>
+  <circle clip-path="url(#p.0)" id="c1" cx="100" cy="100" r="50" style="fill:red" stroke-width="5px" stroke="black"/>
+</svg>
diff --git a/svgio/source/svgreader/svgstyleattributes.cxx b/svgio/source/svgreader/svgstyleattributes.cxx
index 9fc8b23..cc66af5a 100644
--- a/svgio/source/svgreader/svgstyleattributes.cxx
+++ b/svgio/source/svgreader/svgstyleattributes.cxx
@@ -2007,14 +2007,26 @@ namespace svgio
 
                 if(pSvgStyleAttributes)
                 {
-                    return pSvgStyleAttributes->getFill();
+                    const basegfx::BColor* pFill = pSvgStyleAttributes->getFill();
+
+                    if(mbIsClipPathContent)
+                    {
+                        if (pFill)
+                        {
+                            return pFill;
+                        }
+                        else
+                        {
+                            static basegfx::BColor aBlack(0.0, 0.0, 0.0);
+                            return &aBlack;
+                        }
+                    }
+                    else
+                    {
+                        return pFill;
+                    }
                 }
             }
-            else if(mbIsClipPathContent)
-            {
-                static basegfx::BColor aBlack(0.0, 0.0, 0.0);
-                return &aBlack;
-            }
 
             return nullptr;
         }


More information about the Libreoffice-commits mailing list