svgio/qa/cppunit/SvgImportTest.cxx | 68 ++++++++++++++++++++++++++++++++----- svgio/qa/cppunit/data/tdf99115.svg | 40 +++++++++++++++++++++ svgio/source/svgreader/svgnode.cxx | 18 +++++++-- 3 files changed, 112 insertions(+), 14 deletions(-)
New commits: commit 5db4db35de77e9f71ef2dd0a7d63db6b993c9182 Author: Xisco Fauli <xiscofa...@libreoffice.org> AuthorDate: Mon Sep 16 12:54:59 2019 +0200 Commit: Adolfo Jayme Barrientos <fit...@ubuntu.com> CommitDate: Wed Oct 23 19:38:16 2019 +0200 tdf#99115: add Css selector '*' style only if the element... ... is on top of the hierarchy Otherwise, we add it for every element on the hierarchy Adapt unittest from https://bugs.documentfoundation.org/show_bug.cgi?id=100198 Provided by Sam Yygier Change-Id: I72c7ae08f3ce0194eff86697b202d5553810abeb Reviewed-on: https://gerrit.libreoffice.org/78997 Tested-by: Jenkins Reviewed-by: Xisco FaulĂ <xiscofa...@libreoffice.org> (cherry picked from commit 4007ced54d611d1397387f7329a47de5efaca32f) Reviewed-on: https://gerrit.libreoffice.org/79011 Reviewed-by: Adolfo Jayme Barrientos <fit...@ubuntu.com> diff --git a/svgio/qa/cppunit/SvgImportTest.cxx b/svgio/qa/cppunit/SvgImportTest.cxx index f5cfe34d38a1..e6838fc3229e 100644 --- a/svgio/qa/cppunit/SvgImportTest.cxx +++ b/svgio/qa/cppunit/SvgImportTest.cxx @@ -63,6 +63,7 @@ class Test : public test::BootstrapFixture, public XmlTestTools void test47446b(); void testMaskText(); void testTdf99994(); + void testTdf99115(); void testTdf101237(); void testTdf94765(); void testBehaviourWhenWidthAndHeightIsOrIsNotSet(); @@ -95,6 +96,7 @@ public: CPPUNIT_TEST(test47446b); CPPUNIT_TEST(testMaskText); CPPUNIT_TEST(testTdf99994); + CPPUNIT_TEST(testTdf99115); CPPUNIT_TEST(testTdf101237); CPPUNIT_TEST(testTdf94765); CPPUNIT_TEST(testBehaviourWhenWidthAndHeightIsOrIsNotSet); @@ -531,15 +533,15 @@ void Test::testi125329() CPPUNIT_ASSERT (pDocument); - assertXPath(pDocument, "/primitive2D/transform/transform/polypolygoncolor", "color", "#c0c0c0"); // rect background color - assertXPath(pDocument, "/primitive2D/transform/transform/polypolygoncolor/polypolygon", "height", "30"); // rect background height - assertXPath(pDocument, "/primitive2D/transform/transform/polypolygoncolor/polypolygon", "width", "50"); // rect background width - assertXPath(pDocument, "/primitive2D/transform/transform/polypolygoncolor/polypolygon", "minx", "15"); - assertXPath(pDocument, "/primitive2D/transform/transform/polypolygoncolor/polypolygon", "miny", "15"); - assertXPath(pDocument, "/primitive2D/transform/transform/polypolygoncolor/polypolygon", "maxx", "65"); - assertXPath(pDocument, "/primitive2D/transform/transform/polypolygoncolor/polypolygon", "maxy", "45"); - assertXPath(pDocument, "/primitive2D/transform/transform/polypolygonstroke/line", "color", "#008000"); // rect stroke color - assertXPath(pDocument, "/primitive2D/transform/transform/polypolygonstroke/line", "width", "1"); // rect stroke width + assertXPath(pDocument, "/primitive2D/transform/transform/objectinfo/polypolygoncolor", "color", "#c0c0c0"); // rect background color + assertXPath(pDocument, "/primitive2D/transform/transform/objectinfo/polypolygoncolor/polypolygon", "height", "30"); // rect background height + assertXPath(pDocument, "/primitive2D/transform/transform/objectinfo/polypolygoncolor/polypolygon", "width", "50"); // rect background width + assertXPath(pDocument, "/primitive2D/transform/transform/objectinfo/polypolygoncolor/polypolygon", "minx", "15"); + assertXPath(pDocument, "/primitive2D/transform/transform/objectinfo/polypolygoncolor/polypolygon", "miny", "15"); + assertXPath(pDocument, "/primitive2D/transform/transform/objectinfo/polypolygoncolor/polypolygon", "maxx", "65"); + assertXPath(pDocument, "/primitive2D/transform/transform/objectinfo/polypolygoncolor/polypolygon", "maxy", "45"); + assertXPath(pDocument, "/primitive2D/transform/transform/objectinfo/polypolygonstroke/line", "color", "#008000"); // rect stroke color + assertXPath(pDocument, "/primitive2D/transform/transform/objectinfo/polypolygonstroke/line", "width", "1"); // rect stroke width } void Test::testMaskingPath07b() @@ -634,6 +636,54 @@ void Test::testTdf99994() assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", "familyname", "Sans"); } +void Test::testTdf99115() +{ + //Check that styles are resolved correctly where there is a * css selector + Primitive2DSequence aSequenceTdf99115 = parseSvg("/svgio/qa/cppunit/data/tdf99115.svg"); + CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aSequenceTdf99115.getLength())); + + drawinglayer::tools::Primitive2dXmlDump dumper; + xmlDocPtr pDocument = dumper.dumpAndParse(comphelper::sequenceToContainer<Primitive2DContainer>(aSequenceTdf99115) ); + + CPPUNIT_ASSERT (pDocument); + + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", "text", "red 1"); + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", "fontcolor", "#ff0000"); + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[1]", "height", "18"); + + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[2]", "text", "red 2"); + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[2]", "fontcolor", "#ff0000"); + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[2]", "height", "18"); + + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[3]", "text", "red 3"); + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[3]", "fontcolor", "#ff0000"); + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[3]", "height", "18"); + + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[4]", "text", "blue 4"); + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[4]", "fontcolor", "#0000ff"); + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[4]", "height", "18"); + + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[5]", "text", "blue 5"); + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[5]", "fontcolor", "#0000ff"); + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[5]", "height", "18"); + + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[6]", "text", "blue 6"); + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[6]", "fontcolor", "#0000ff"); + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[6]", "height", "18"); + + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[7]", "text", "green 7"); + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[7]", "fontcolor", "#008000"); + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[7]", "height", "18"); + + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[8]", "text", "green 8"); + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[8]", "fontcolor", "#008000"); + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[8]", "height", "18"); + + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[9]", "text", "green 9"); + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[9]", "fontcolor", "#008000"); + assertXPath(pDocument, "/primitive2D/transform/textsimpleportion[9]", "height", "18"); +} + void Test::testTdf101237() { //Check that fill color, stroke color and stroke-width are inherited from use element diff --git a/svgio/qa/cppunit/data/tdf99115.svg b/svgio/qa/cppunit/data/tdf99115.svg new file mode 100644 index 000000000000..6d4b5e9c1b97 --- /dev/null +++ b/svgio/qa/cppunit/data/tdf99115.svg @@ -0,0 +1,40 @@ +<svg xmlns="http://www.w3.org/2000/svg" width="200 px" height="100 px"> +<style type="text/css" id="style1"> +* {font-size:18px;} +#tspan6 {fill:blue} +.c1 {fill:green} +.c2 {fill:red} +#tspan8 {fill:green} +#text9 {fill:green} +</style> +<text id="text1" style="" x="1" y="20" > + <tspan id="tspan1" fill="red">red 1</tspan> +</text> +<text id="text2" style="fill:red" x="1" y="40" > + <tspan id="tspan2">red 2</tspan> +</text> +<text id="text3" style="" x="1" y="60" > + <tspan id="tspan3" style="fill:red">red 3</tspan> +</text> + +<text id="text4" style="fill:red" x="60" y="20" > + <tspan id="tspan4" fill="blue">blue 4</tspan> +</text> +<text id="text5" x="60" y="40" > + <tspan id="tspan5" style="fill:blue" fill="red">blue 5</tspan> +</text> +<text id="text6" style="fill:red" x="60" y="60" > + <tspan id="tspan6">blue 6</tspan> +</text> + +<text id="text7" x="130" y="20" > + <tspan id="tspan7" class="c1" fill="blue">green 7</tspan> +</text> +<text id="text8" x="130" y="40" > + <tspan id="tspan8" class="c2" fill="red">green 8</tspan> +</text> +<text id="text9" x="130" y="60" class="c2"> + <tspan id="tspan9">green 9</tspan> +</text> + +</svg> diff --git a/svgio/source/svgreader/svgnode.cxx b/svgio/source/svgreader/svgnode.cxx index cb30c3111131..ed65f0c0b3cc 100644 --- a/svgio/source/svgreader/svgnode.cxx +++ b/svgio/source/svgreader/svgnode.cxx @@ -174,6 +174,7 @@ namespace svgio // - 'id' CssStyle // - 'class' CssStyle(s) // - type-dependent elements (e..g. 'rect' for all rect elements) + // - Css selector '*' // - local attributes (rOriginal) // - inherited attributes (up the hierarchy) // The first four will be collected in maCssStyleVector for the current element @@ -191,13 +192,20 @@ namespace svgio // check the hierarchy for concatenated patterns of Selectors fillCssStyleVectorUsingHierarchyAndSelectors(rClassStr, *this, OUString()); - // #i125329# find Css selector '*', add as last element if found - const SvgStyleAttributes* pNew = getDocument().findGlobalCssStyleAttributes("*"); + // tdf#99115, Add css selector '*' style only if the element is on top of the hierarchy + // meaning its parent is <svg> + const SvgNode* pParent = this->getParent(); - if(pNew) + if(pParent && pParent->getType() == SVGTokenSvg) { - // add CssStyle for selector '*' if found - maCssStyleVector.push_back(pNew); + // #i125329# find Css selector '*', add as last element if found + const SvgStyleAttributes* pNew = getDocument().findGlobalCssStyleAttributes("*"); + + if(pNew) + { + // add CssStyle for selector '*' if found + maCssStyleVector.push_back(pNew); + } } //local attributes _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits