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

Xisco Fauli anistenis at gmail.com
Tue Mar 29 08:01:20 UTC 2016


 svgio/qa/cppunit/SvgImportTest.cxx            |   21 ++++
 svgio/qa/cppunit/data/ClipPathAndStyle.svg    |   13 ++
 svgio/source/svgreader/svgstyleattributes.cxx |  128 ++++----------------------
 3 files changed, 54 insertions(+), 108 deletions(-)

New commits:
commit 3041df16f8315859ddf22075eac8f9ad4fa37b8e
Author: Xisco Fauli <anistenis at gmail.com>
Date:   Mon Mar 28 19:24:29 2016 +0200

    SVGIO: Don't inherit style attributes from parent if the...
    
    ... shapes define their own attributes.
    
    Partially revert commit c2d130425cc876cceb96cc7e47636426a9e48fa8
    
    Change-Id: Iee98003f4ff63575a28818b091ab77431337192f
    Reviewed-on: https://gerrit.libreoffice.org/23571
    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 c4b681b..046d905 100644
--- a/svgio/qa/cppunit/SvgImportTest.cxx
+++ b/svgio/qa/cppunit/SvgImportTest.cxx
@@ -54,6 +54,7 @@ class Test : public test::BootstrapFixture, public XmlTestTools
     void testRGBAColor();
     void testTdf97936();
     void testClipPathAndParentStyle();
+    void testClipPathAndStyle();
 
     Primitive2DSequence parseSvg(const char* aSource);
 
@@ -78,6 +79,7 @@ public:
     CPPUNIT_TEST(testRGBAColor);
     CPPUNIT_TEST(testTdf97936);
     CPPUNIT_TEST(testClipPathAndParentStyle);
+    CPPUNIT_TEST(testClipPathAndStyle);
     CPPUNIT_TEST_SUITE_END();
 };
 
@@ -423,6 +425,25 @@ void Test::testClipPathAndParentStyle()
     assertXPath(pDocument, "/primitive2D/transform/polypolygonstroke/line", "width", "5");
 
 }
+
+void Test::testClipPathAndStyle()
+{
+    //Check that fill color, stroke color and stroke-width are inherited from use element
+    //when the element is within a clipPath element
+    Primitive2DSequence aSequenceClipPathAndStyle = parseSvg("/svgio/qa/cppunit/data/ClipPathAndStyle.svg");
+    CPPUNIT_ASSERT_EQUAL(1, (int)aSequenceClipPathAndStyle.getLength());
+
+    Primitive2dXmlDump dumper;
+    xmlDocPtr pDocument = dumper.dumpAndParse(comphelper::sequenceToContainer<Primitive2DContainer>(aSequenceClipPathAndStyle));
+
+    CPPUNIT_ASSERT (pDocument);
+
+    assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor", "color", "#ccccff");
+    assertXPath(pDocument, "/primitive2D/transform/polypolygonstroke/line", "color", "#0000cc");
+    assertXPath(pDocument, "/primitive2D/transform/polypolygonstroke/line", "width", "2");
+
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(Test);
 
 }
diff --git a/svgio/qa/cppunit/data/ClipPathAndStyle.svg b/svgio/qa/cppunit/data/ClipPathAndStyle.svg
new file mode 100644
index 0000000..29814fa
--- /dev/null
+++ b/svgio/qa/cppunit/data/ClipPathAndStyle.svg
@@ -0,0 +1,13 @@
+<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"
+                      style="stroke: #0000cc;
+                     stroke-width: 2px;
+                     fill  : #ccccff;"/>
+      </clipPath>
+
+  <use xlink:href="#c1" style="fill:red" stroke-width="5px" stroke="black"/>
+
+</svg>
\ No newline at end of file
diff --git a/svgio/source/svgreader/svgstyleattributes.cxx b/svgio/source/svgreader/svgstyleattributes.cxx
index 6b768f0..e04999d 100644
--- a/svgio/source/svgreader/svgstyleattributes.cxx
+++ b/svgio/source/svgreader/svgstyleattributes.cxx
@@ -1954,19 +1954,7 @@ namespace svgio
 
         const basegfx::BColor* SvgStyleAttributes::getFill() const
         {
-            if(mbIsClipPathContent)
-            {
-                const SvgStyleAttributes* pSvgStyleAttributes = getParentStyle();
-
-                if(pSvgStyleAttributes)
-                {
-                    return pSvgStyleAttributes->getFill();
-                }
-
-                static basegfx::BColor aBlack(0.0, 0.0, 0.0);
-                return &aBlack;
-            }
-            else if((SVGTokenMarker == mrOwner.getType()) && !maFill.isSet())
+            if((SVGTokenMarker == mrOwner.getType()) && !maFill.isSet())
             {
                 const SvgStyleAttributes* pSvgStyleAttributes = getParentStyle();
 
@@ -1998,24 +1986,18 @@ namespace svgio
                     return pSvgStyleAttributes->getFill();
                 }
             }
+            else if(mbIsClipPathContent)
+            {
+                static basegfx::BColor aBlack(0.0, 0.0, 0.0);
+                return &aBlack;
+            }
 
             return nullptr;
         }
 
         const basegfx::BColor* SvgStyleAttributes::getStroke() const
         {
-            if(mbIsClipPathContent)
-            {
-                const SvgStyleAttributes* pSvgStyleAttributes = getParentStyle();
-
-                if(pSvgStyleAttributes)
-                {
-                    return pSvgStyleAttributes->getStroke();
-                }
-
-                return nullptr;
-            }
-            else if(maStroke.isSet())
+            if(maStroke.isSet())
             {
                 if(maStroke.isCurrent())
                 {
@@ -2053,18 +2035,7 @@ namespace svgio
 
         const SvgGradientNode* SvgStyleAttributes::getSvgGradientNodeFill() const
         {
-            if(mbIsClipPathContent)
-            {
-                const SvgStyleAttributes* pSvgStyleAttributes = getParentStyle();
-
-                if(pSvgStyleAttributes)
-                {
-                    return pSvgStyleAttributes->getSvgGradientNodeFill();
-                }
-
-                return nullptr;
-            }
-            else if(mpSvgGradientNodeFill)
+            if(mpSvgGradientNodeFill)
             {
                 return mpSvgGradientNodeFill;
             }
@@ -2083,18 +2054,7 @@ namespace svgio
 
         const SvgGradientNode* SvgStyleAttributes::getSvgGradientNodeStroke() const
         {
-            if(mbIsClipPathContent)
-            {
-                const SvgStyleAttributes* pSvgStyleAttributes = getParentStyle();
-
-                if(pSvgStyleAttributes)
-                {
-                    return pSvgStyleAttributes->getSvgGradientNodeStroke();
-                }
-
-                return nullptr;
-            }
-            else if(mpSvgGradientNodeStroke)
+            if(mpSvgGradientNodeStroke)
             {
                 return mpSvgGradientNodeStroke;
             }
@@ -2113,18 +2073,7 @@ namespace svgio
 
         const SvgPatternNode* SvgStyleAttributes::getSvgPatternNodeFill() const
         {
-            if(mbIsClipPathContent)
-            {
-                const SvgStyleAttributes* pSvgStyleAttributes = getParentStyle();
-
-                if(pSvgStyleAttributes)
-                {
-                    return pSvgStyleAttributes->getSvgPatternNodeFill();
-                }
-
-                return nullptr;
-            }
-            else if(mpSvgPatternNodeFill)
+            if(mpSvgPatternNodeFill)
             {
                 return mpSvgPatternNodeFill;
             }
@@ -2143,18 +2092,7 @@ namespace svgio
 
         const SvgPatternNode* SvgStyleAttributes::getSvgPatternNodeStroke() const
         {
-            if(mbIsClipPathContent)
-            {
-                const SvgStyleAttributes* pSvgStyleAttributes = getParentStyle();
-
-                if(pSvgStyleAttributes)
-                {
-                    return pSvgStyleAttributes->getSvgPatternNodeStroke();
-                }
-
-                return nullptr;
-            }
-            else if(mpSvgPatternNodeStroke)
+            if(mpSvgPatternNodeStroke)
             {
                 return mpSvgPatternNodeStroke;
             }
@@ -2173,18 +2111,7 @@ namespace svgio
 
         SvgNumber SvgStyleAttributes::getStrokeWidth() const
         {
-            if(mbIsClipPathContent)
-            {
-                const SvgStyleAttributes* pSvgStyleAttributes = getParentStyle();
-
-                if(pSvgStyleAttributes)
-                {
-                    return pSvgStyleAttributes->getStrokeWidth();
-                }
-
-                return SvgNumber(0.0);
-            }
-            else if(maStrokeWidth.isSet())
+            if(maStrokeWidth.isSet())
             {
                 return maStrokeWidth;
             }
@@ -2196,6 +2123,11 @@ namespace svgio
                 return pSvgStyleAttributes->getStrokeWidth();
             }
 
+            if(mbIsClipPathContent)
+            {
+                return SvgNumber(0.0);
+            }
+
             // default is 1
             return SvgNumber(1.0);
         }
@@ -2213,18 +2145,7 @@ namespace svgio
 
         SvgNumber SvgStyleAttributes::getFillOpacity() const
         {
-            if(mbIsClipPathContent)
-            {
-                const SvgStyleAttributes* pSvgStyleAttributes = getParentStyle();
-
-                if(pSvgStyleAttributes)
-                {
-                    return pSvgStyleAttributes->getFillOpacity();
-                }
-
-                return SvgNumber(1.0);
-            }
-            else if(maFillOpacity.isSet())
+            if(maFillOpacity.isSet())
             {
                 return maFillOpacity;
             }
@@ -2242,17 +2163,7 @@ namespace svgio
 
         SvgNumber SvgStyleAttributes::getOpacity() const
         {
-            if(mbIsClipPathContent)
-            {
-                const SvgStyleAttributes* pSvgStyleAttributes = getParentStyle();
-
-                if(pSvgStyleAttributes)
-                {
-                    return pSvgStyleAttributes->getOpacity();
-                }
-                return SvgNumber(1.0);
-            }
-            else if(maOpacity.isSet())
+            if(maOpacity.isSet())
             {
                 return maOpacity;
             }
@@ -2910,3 +2821,4 @@ namespace svgio
 } // end of namespace svgio
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
+


More information about the Libreoffice-commits mailing list