svgio/qa/cppunit/SvgImportTest.cxx               |   20 +++++++
 svgio/qa/cppunit/data/ClipPathAndParentStyle.svg |   10 +++
 svgio/source/svgreader/svgstyleattributes.cxx    |   62 +++++++++++++++++++++++
 3 files changed, 92 insertions(+)

New commits:
commit c2d130425cc876cceb96cc7e47636426a9e48fa8
Author: Xisco Fauli <aniste...@gmail.com>
Date:   Sat Mar 26 16:23:23 2016 +0100

    SVGIO: Shapes within a clippath element might inherit...
    
    ... fill, stroke, stroke-width and others attributes from
    parent element, like use element
    
    Change-Id: I911bc50409428e81135b81e6dfc82acd1c21d113
    Reviewed-on: https://gerrit.libreoffice.org/23527
    Tested-by: Jenkins <c...@libreoffice.org>
    Reviewed-by: Xisco Faulí <aniste...@gmail.com>

diff --git a/svgio/qa/cppunit/SvgImportTest.cxx 
b/svgio/qa/cppunit/SvgImportTest.cxx
index feea817..c4b681b 100644
--- a/svgio/qa/cppunit/SvgImportTest.cxx
+++ b/svgio/qa/cppunit/SvgImportTest.cxx
@@ -53,6 +53,7 @@ class Test : public test::BootstrapFixture, public 
XmlTestTools
     void testRGBColor();
     void testRGBAColor();
     void testTdf97936();
+    void testClipPathAndParentStyle();
 
     Primitive2DSequence parseSvg(const char* aSource);
 
@@ -76,6 +77,7 @@ public:
     CPPUNIT_TEST(testRGBColor);
     CPPUNIT_TEST(testRGBAColor);
     CPPUNIT_TEST(testTdf97936);
+    CPPUNIT_TEST(testClipPathAndParentStyle);
     CPPUNIT_TEST_SUITE_END();
 };
 
@@ -403,6 +405,24 @@ void Test::testTdf97936()
     assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor[2]", 
"maxx", "60");
     assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor[2]", 
"maxy", "100");
 }
+
+void Test::testClipPathAndParentStyle()
+{
+    //Check that fill color, stroke color and stroke-width are inherited from 
use element
+    //when the element is within a clipPath element
+    Primitive2DSequence aSequenceClipPathAndParentStyle = 
parseSvg("/svgio/qa/cppunit/data/ClipPathAndParentStyle.svg");
+    CPPUNIT_ASSERT_EQUAL(1, (int)aSequenceClipPathAndParentStyle.getLength());
+
+    Primitive2dXmlDump dumper;
+    xmlDocPtr pDocument = 
dumper.dumpAndParse(comphelper::sequenceToContainer<Primitive2DContainer>(aSequenceClipPathAndParentStyle));
+
+    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/ClipPathAndParentStyle.svg 
b/svgio/qa/cppunit/data/ClipPathAndParentStyle.svg
new file mode 100644
index 0000000..d85a959
--- /dev/null
+++ b/svgio/qa/cppunit/data/ClipPathAndParentStyle.svg
@@ -0,0 +1,10 @@
+<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";>
+      <clipPath>
+        <circle id="c1" cx="100" cy="100" r="50"/>
+      </clipPath>
+
+  <use xlink:href="#c1" style="fill:red" stroke-width="5px" stroke="black"/>
+
+</svg>
diff --git a/svgio/source/svgreader/svgstyleattributes.cxx 
b/svgio/source/svgreader/svgstyleattributes.cxx
index b60d84b..6b768f0 100644
--- a/svgio/source/svgreader/svgstyleattributes.cxx
+++ b/svgio/source/svgreader/svgstyleattributes.cxx
@@ -1956,6 +1956,13 @@ namespace svgio
         {
             if(mbIsClipPathContent)
             {
+                const SvgStyleAttributes* pSvgStyleAttributes = 
getParentStyle();
+
+                if(pSvgStyleAttributes)
+                {
+                    return pSvgStyleAttributes->getFill();
+                }
+
                 static basegfx::BColor aBlack(0.0, 0.0, 0.0);
                 return &aBlack;
             }
@@ -1999,6 +2006,13 @@ namespace svgio
         {
             if(mbIsClipPathContent)
             {
+                const SvgStyleAttributes* pSvgStyleAttributes = 
getParentStyle();
+
+                if(pSvgStyleAttributes)
+                {
+                    return pSvgStyleAttributes->getStroke();
+                }
+
                 return nullptr;
             }
             else if(maStroke.isSet())
@@ -2041,6 +2055,13 @@ namespace svgio
         {
             if(mbIsClipPathContent)
             {
+                const SvgStyleAttributes* pSvgStyleAttributes = 
getParentStyle();
+
+                if(pSvgStyleAttributes)
+                {
+                    return pSvgStyleAttributes->getSvgGradientNodeFill();
+                }
+
                 return nullptr;
             }
             else if(mpSvgGradientNodeFill)
@@ -2064,6 +2085,13 @@ namespace svgio
         {
             if(mbIsClipPathContent)
             {
+                const SvgStyleAttributes* pSvgStyleAttributes = 
getParentStyle();
+
+                if(pSvgStyleAttributes)
+                {
+                    return pSvgStyleAttributes->getSvgGradientNodeStroke();
+                }
+
                 return nullptr;
             }
             else if(mpSvgGradientNodeStroke)
@@ -2087,6 +2115,13 @@ namespace svgio
         {
             if(mbIsClipPathContent)
             {
+                const SvgStyleAttributes* pSvgStyleAttributes = 
getParentStyle();
+
+                if(pSvgStyleAttributes)
+                {
+                    return pSvgStyleAttributes->getSvgPatternNodeFill();
+                }
+
                 return nullptr;
             }
             else if(mpSvgPatternNodeFill)
@@ -2110,6 +2145,13 @@ namespace svgio
         {
             if(mbIsClipPathContent)
             {
+                const SvgStyleAttributes* pSvgStyleAttributes = 
getParentStyle();
+
+                if(pSvgStyleAttributes)
+                {
+                    return pSvgStyleAttributes->getSvgPatternNodeStroke();
+                }
+
                 return nullptr;
             }
             else if(mpSvgPatternNodeStroke)
@@ -2133,6 +2175,13 @@ namespace svgio
         {
             if(mbIsClipPathContent)
             {
+                const SvgStyleAttributes* pSvgStyleAttributes = 
getParentStyle();
+
+                if(pSvgStyleAttributes)
+                {
+                    return pSvgStyleAttributes->getStrokeWidth();
+                }
+
                 return SvgNumber(0.0);
             }
             else if(maStrokeWidth.isSet())
@@ -2166,6 +2215,13 @@ namespace svgio
         {
             if(mbIsClipPathContent)
             {
+                const SvgStyleAttributes* pSvgStyleAttributes = 
getParentStyle();
+
+                if(pSvgStyleAttributes)
+                {
+                    return pSvgStyleAttributes->getFillOpacity();
+                }
+
                 return SvgNumber(1.0);
             }
             else if(maFillOpacity.isSet())
@@ -2188,6 +2244,12 @@ namespace svgio
         {
             if(mbIsClipPathContent)
             {
+                const SvgStyleAttributes* pSvgStyleAttributes = 
getParentStyle();
+
+                if(pSvgStyleAttributes)
+                {
+                    return pSvgStyleAttributes->getOpacity();
+                }
                 return SvgNumber(1.0);
             }
             else if(maOpacity.isSet())
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to