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@libreoffice.org>
Reviewed-by: Xisco Faulí <anistenis@gmail.com>
This commit is contained in:
Xisco Fauli
2016-08-30 16:21:52 +02:00
committed by Xisco Faulí
parent 93d7fc90b5
commit 75003438e4
3 changed files with 49 additions and 6 deletions

View File

@@ -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);
}

View File

@@ -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>

After

Width:  |  Height:  |  Size: 451 B

View File

@@ -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;
}