svgio/qa/cppunit/SvgImportTest.cxx | 38 ++++++++++++++++++++++++++++++++++++ svgio/qa/cppunit/data/tdf156168.svg | 34 ++++++++++++++++++++++++++++++++ svgio/source/svgreader/svgnode.cxx | 4 +-- 3 files changed, 74 insertions(+), 2 deletions(-)
New commits: commit e6ab906ebe9995fb813db7b66df4f9b2def76a1c Author: Xisco Fauli <xiscofa...@libreoffice.org> AuthorDate: Wed Jul 5 14:36:06 2023 +0200 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Wed Jul 5 17:15:25 2023 +0200 tdf#156168: do nothing when there is no concatenation Regression from: tdf#156034: check for css style further up in the hierarchy Change-Id: I92c6673f1249cc4a273c490cdc0496474ce1f0c5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153498 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> Change-Id: Ie699f40ea813d2ba5dc031008d56e2fce73a5715 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154056 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> diff --git a/svgio/qa/cppunit/SvgImportTest.cxx b/svgio/qa/cppunit/SvgImportTest.cxx index a72bb39b993f..788eab52fdf5 100644 --- a/svgio/qa/cppunit/SvgImportTest.cxx +++ b/svgio/qa/cppunit/SvgImportTest.cxx @@ -403,6 +403,44 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf145896) assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor[3]", "color", "#0000ff"); } +CPPUNIT_TEST_FIXTURE(Test, testTdf156168) +{ + Primitive2DSequence aSequence = parseSvg(u"/svgio/qa/cppunit/data/tdf156168.svg"); + CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aSequence.getLength())); + + drawinglayer::Primitive2dXmlDump dumper; + xmlDocUniquePtr pDocument = dumper.dumpAndParse(aSequence); + + CPPUNIT_ASSERT (pDocument); + + assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor", 8); + assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor[1]", "color", "#0000ff"); + assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor[2]", "color", "#0000ff"); + assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor[3]", "color", "#ff0000"); + assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor[4]", "color", "#ff0000"); + assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor[5]", "color", "#000000"); + assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor[6]", "color", "#000000"); + assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor[7]", "color", "#ff0000"); + assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor[8]", "color", "#ff0000"); + + // Without the fix in place, this test would have failed with + // - Expected: 4 + // - Actual : 3 + assertXPath(pDocument, "/primitive2D/transform/polypolygonstroke", 4); + assertXPath(pDocument, "/primitive2D/transform/polypolygonstroke[1]/line", "width", "5"); + + assertXPath(pDocument, "/primitive2D/transform/polypolygonstroke[1]/line", "color", "#00ff00"); + assertXPath(pDocument, "/primitive2D/transform/polypolygonstroke[2]/line", "width", "5"); + + assertXPath(pDocument, "/primitive2D/transform/polypolygonstroke[2]/line", "color", "#00ff00"); + assertXPath(pDocument, "/primitive2D/transform/polypolygonstroke[3]/line", "width", "5"); + + assertXPath(pDocument, "/primitive2D/transform/polypolygonstroke[3]/line", "color", "#00ff00"); + assertXPath(pDocument, "/primitive2D/transform/polypolygonstroke[4]/line", "width", "5"); + + assertXPath(pDocument, "/primitive2D/transform/polypolygonstroke[4]/line", "color", "#00ff00"); +} + CPPUNIT_TEST_FIXTURE(Test, testTdf156034) { Primitive2DSequence aSequence = parseSvg(u"/svgio/qa/cppunit/data/tdf156034.svg"); diff --git a/svgio/qa/cppunit/data/tdf156168.svg b/svgio/qa/cppunit/data/tdf156168.svg new file mode 100644 index 000000000000..2cdbd35afd09 --- /dev/null +++ b/svgio/qa/cppunit/data/tdf156168.svg @@ -0,0 +1,34 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<svg version="1.2" baseProfile="tiny" + width="100%" height="100%" viewBox="0 0 200 500" + xmlns="http://www.w3.org/2000/svg" + xmlns:xlink="http://www.w3.org/1999/xlink" + style="font-family: 'Times New Roman', serif; + font-size:large" > +<title>stroke enabled</title> + + <style type="text/css"> + #MyRed { + fill: red; + } + #MyBlue { + fill: blue; + } + .MyLime { + stroke: lime; + stroke-width: 5; + } + </style> + +<g id="MyBlue"> +<rect x="10" y="0" height="50" width="50"></rect> +<rect x="10" y="60" height="50" width="50" class="MyLime"></rect> +<rect id="MyRed" x="10" y="120" height="50" width="50"></rect> +<rect id="MyRed" x="10" y="180" height="50" width="50" class="MyLime"></rect> +</g> +<rect x="10" y="240" height="50" width="50"></rect> +<rect x="10" y="300" height="50" width="50" class="MyLime"></rect> +<rect id="MyRed" x="10" y="360" height="50" width="50"></rect> +<rect id="MyRed" x="10" y="420" height="50" width="50" class="MyLime"></rect> +</svg> diff --git a/svgio/source/svgreader/svgnode.cxx b/svgio/source/svgreader/svgnode.cxx index 992aaf72bce0..4f82a16ebf1e 100644 --- a/svgio/source/svgreader/svgnode.cxx +++ b/svgio/source/svgreader/svgnode.cxx @@ -120,7 +120,7 @@ namespace { addCssStyle(rDocument, aNewConcatenated); // look further up in the hierarchy - if(pParent && pParent->getId()) + if(!aConcatenated.isEmpty() && pParent && pParent->getId()) { const OUString& rParentId = pParent->getId().value(); addCssStyle(rDocument, "#" + rParentId + aConcatenated); @@ -140,7 +140,7 @@ namespace { addCssStyle(rDocument, aNewConcatenated); // look further up in the hierarchy - if(pParent) + if(!aConcatenated.isEmpty() && pParent) { std::vector <OUString> aParentClasses = parseClass(*pParent); for(const auto &aParentClass : aParentClasses)