tdf#161213: fill can use context-stroke and vice versa

Change-Id: Id127bd4943ff1b67915d1de3ba4fcf93dab21423
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168774
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
This commit is contained in:
Xisco Fauli 2024-06-13 12:09:19 +02:00
parent 27e9fd6726
commit 1a7c927f6f
3 changed files with 32 additions and 0 deletions

View File

@ -654,6 +654,14 @@ CPPUNIT_TEST_FIXTURE(Test, testContextFill)
assertXPath(pDocument, "/primitive2D/transform/transform/polypolygoncolor"_ostr, "color"_ostr, u"#ff0000"_ustr);
}
CPPUNIT_TEST_FIXTURE(Test, testFillContextStroke)
{
xmlDocUniquePtr pDocument = dumpAndParseSvg(u"/svgio/qa/cppunit/data/fillContextStroke.svg");
assertXPath(pDocument, "/primitive2D/transform/polypolygonstroke/line"_ostr, "color"_ostr, u"#ff0000"_ustr);
assertXPath(pDocument, "/primitive2D/transform/transform/polypolygoncolor"_ostr, "color"_ostr, u"#ff0000"_ustr);
}
CPPUNIT_TEST_FIXTURE(Test, testContextStroke)
{
xmlDocUniquePtr pDocument = dumpAndParseSvg(u"/svgio/qa/cppunit/data/contextStroke.svg");

View File

@ -0,0 +1,8 @@
<svg width="100" height="100" xmlns="http://www.w3.org/2000/svg">
<defs>
<marker id="triangle" viewBox="0 0 10 10" refX="5" refY="5" markerWidth="6" markerHeight="6" orient="auto">
<path d="M 0 0 L 10 5 L 0 10 z" fill="context-stroke" />
</marker>
</defs>
<line x1="10" y1="10" x2="90" y2="90" fill="red" stroke="red" marker-end="url(#triangle)" />
</svg>

After

Width:  |  Height:  |  Size: 365 B

View File

@ -1332,6 +1332,10 @@ namespace svgio::svgreader
{
mbContextFill = true;
}
else if(o3tl::equalsIgnoreAsciiCase(o3tl::trim(aContent), u"context-stroke"))
{
mbContextStroke = true;
}
else if(readSvgPaint(aContent, aSvgPaint, aURL, aOpacity))
{
setFill(aSvgPaint);
@ -1381,6 +1385,10 @@ namespace svgio::svgreader
{
mbContextStroke = true;
}
else if(o3tl::equalsIgnoreAsciiCase(o3tl::trim(aContent), u"context-fill"))
{
mbContextFill = true;
}
else if(readSvgPaint(aContent, aSvgPaint, aURL, aOpacity))
{
maStroke = aSvgPaint;
@ -2130,6 +2138,10 @@ namespace svgio::svgreader
{
return getContextFill();
}
else if (mbContextStroke)
{
return getContextStroke();
}
else if (maNodeFillURL.isEmpty())
{
const SvgStyleAttributes* pSvgStyleAttributes = getParentStyle();
@ -2175,6 +2187,10 @@ namespace svgio::svgreader
return &maStroke.getBColor();
}
}
else if (mbContextFill)
{
return getContextFill();
}
else if (mbContextStroke)
{
return getContextStroke();