Kaydet (Commit) c2d13042 authored tarafından Xisco Fauli's avatar Xisco Fauli Kaydeden (comit) Xisco Faulí

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/23527Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarXisco Faulí <anistenis@gmail.com>
üst ae5bf728
...@@ -53,6 +53,7 @@ class Test : public test::BootstrapFixture, public XmlTestTools ...@@ -53,6 +53,7 @@ class Test : public test::BootstrapFixture, public XmlTestTools
void testRGBColor(); void testRGBColor();
void testRGBAColor(); void testRGBAColor();
void testTdf97936(); void testTdf97936();
void testClipPathAndParentStyle();
Primitive2DSequence parseSvg(const char* aSource); Primitive2DSequence parseSvg(const char* aSource);
...@@ -76,6 +77,7 @@ public: ...@@ -76,6 +77,7 @@ public:
CPPUNIT_TEST(testRGBColor); CPPUNIT_TEST(testRGBColor);
CPPUNIT_TEST(testRGBAColor); CPPUNIT_TEST(testRGBAColor);
CPPUNIT_TEST(testTdf97936); CPPUNIT_TEST(testTdf97936);
CPPUNIT_TEST(testClipPathAndParentStyle);
CPPUNIT_TEST_SUITE_END(); CPPUNIT_TEST_SUITE_END();
}; };
...@@ -403,6 +405,24 @@ void Test::testTdf97936() ...@@ -403,6 +405,24 @@ void Test::testTdf97936()
assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor[2]", "maxx", "60"); assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor[2]", "maxx", "60");
assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor[2]", "maxy", "100"); 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); CPPUNIT_TEST_SUITE_REGISTRATION(Test);
} }
......
This diff was suppressed by a .gitattributes entry.
...@@ -1956,6 +1956,13 @@ namespace svgio ...@@ -1956,6 +1956,13 @@ namespace svgio
{ {
if(mbIsClipPathContent) if(mbIsClipPathContent)
{ {
const SvgStyleAttributes* pSvgStyleAttributes = getParentStyle();
if(pSvgStyleAttributes)
{
return pSvgStyleAttributes->getFill();
}
static basegfx::BColor aBlack(0.0, 0.0, 0.0); static basegfx::BColor aBlack(0.0, 0.0, 0.0);
return &aBlack; return &aBlack;
} }
...@@ -1999,6 +2006,13 @@ namespace svgio ...@@ -1999,6 +2006,13 @@ namespace svgio
{ {
if(mbIsClipPathContent) if(mbIsClipPathContent)
{ {
const SvgStyleAttributes* pSvgStyleAttributes = getParentStyle();
if(pSvgStyleAttributes)
{
return pSvgStyleAttributes->getStroke();
}
return nullptr; return nullptr;
} }
else if(maStroke.isSet()) else if(maStroke.isSet())
...@@ -2041,6 +2055,13 @@ namespace svgio ...@@ -2041,6 +2055,13 @@ namespace svgio
{ {
if(mbIsClipPathContent) if(mbIsClipPathContent)
{ {
const SvgStyleAttributes* pSvgStyleAttributes = getParentStyle();
if(pSvgStyleAttributes)
{
return pSvgStyleAttributes->getSvgGradientNodeFill();
}
return nullptr; return nullptr;
} }
else if(mpSvgGradientNodeFill) else if(mpSvgGradientNodeFill)
...@@ -2064,6 +2085,13 @@ namespace svgio ...@@ -2064,6 +2085,13 @@ namespace svgio
{ {
if(mbIsClipPathContent) if(mbIsClipPathContent)
{ {
const SvgStyleAttributes* pSvgStyleAttributes = getParentStyle();
if(pSvgStyleAttributes)
{
return pSvgStyleAttributes->getSvgGradientNodeStroke();
}
return nullptr; return nullptr;
} }
else if(mpSvgGradientNodeStroke) else if(mpSvgGradientNodeStroke)
...@@ -2087,6 +2115,13 @@ namespace svgio ...@@ -2087,6 +2115,13 @@ namespace svgio
{ {
if(mbIsClipPathContent) if(mbIsClipPathContent)
{ {
const SvgStyleAttributes* pSvgStyleAttributes = getParentStyle();
if(pSvgStyleAttributes)
{
return pSvgStyleAttributes->getSvgPatternNodeFill();
}
return nullptr; return nullptr;
} }
else if(mpSvgPatternNodeFill) else if(mpSvgPatternNodeFill)
...@@ -2110,6 +2145,13 @@ namespace svgio ...@@ -2110,6 +2145,13 @@ namespace svgio
{ {
if(mbIsClipPathContent) if(mbIsClipPathContent)
{ {
const SvgStyleAttributes* pSvgStyleAttributes = getParentStyle();
if(pSvgStyleAttributes)
{
return pSvgStyleAttributes->getSvgPatternNodeStroke();
}
return nullptr; return nullptr;
} }
else if(mpSvgPatternNodeStroke) else if(mpSvgPatternNodeStroke)
...@@ -2133,6 +2175,13 @@ namespace svgio ...@@ -2133,6 +2175,13 @@ namespace svgio
{ {
if(mbIsClipPathContent) if(mbIsClipPathContent)
{ {
const SvgStyleAttributes* pSvgStyleAttributes = getParentStyle();
if(pSvgStyleAttributes)
{
return pSvgStyleAttributes->getStrokeWidth();
}
return SvgNumber(0.0); return SvgNumber(0.0);
} }
else if(maStrokeWidth.isSet()) else if(maStrokeWidth.isSet())
...@@ -2166,6 +2215,13 @@ namespace svgio ...@@ -2166,6 +2215,13 @@ namespace svgio
{ {
if(mbIsClipPathContent) if(mbIsClipPathContent)
{ {
const SvgStyleAttributes* pSvgStyleAttributes = getParentStyle();
if(pSvgStyleAttributes)
{
return pSvgStyleAttributes->getFillOpacity();
}
return SvgNumber(1.0); return SvgNumber(1.0);
} }
else if(maFillOpacity.isSet()) else if(maFillOpacity.isSet())
...@@ -2188,6 +2244,12 @@ namespace svgio ...@@ -2188,6 +2244,12 @@ namespace svgio
{ {
if(mbIsClipPathContent) if(mbIsClipPathContent)
{ {
const SvgStyleAttributes* pSvgStyleAttributes = getParentStyle();
if(pSvgStyleAttributes)
{
return pSvgStyleAttributes->getOpacity();
}
return SvgNumber(1.0); return SvgNumber(1.0);
} }
else if(maOpacity.isSet()) else if(maOpacity.isSet())
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment