summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--svgio/qa/cppunit/SvgImportTest.cxx68
-rw-r--r--svgio/qa/cppunit/data/tdf99115.svg40
-rw-r--r--svgio/source/svgreader/svgnode.cxx18
3 files changed, 112 insertions, 14 deletions
diff --git a/svgio/qa/cppunit/SvgImportTest.cxx b/svgio/qa/cppunit/SvgImportTest.cxx
index 8174c068d045..072f8c66abe2 100644
--- a/svgio/qa/cppunit/SvgImportTest.cxx
+++ b/svgio/qa/cppunit/SvgImportTest.cxx
@@ -62,6 +62,7 @@ class Test : public test::BootstrapFixture, public XmlTestTools
void test47446b();
void testMaskText();
void testTdf99994();
+ void testTdf99115();
void testTdf101237();
void testBehaviourWhenWidthAndHeightIsOrIsNotSet();
@@ -92,6 +93,7 @@ public:
CPPUNIT_TEST(test47446b);
CPPUNIT_TEST(testMaskText);
CPPUNIT_TEST(testTdf99994);
+ CPPUNIT_TEST(testTdf99115);
CPPUNIT_TEST(testTdf101237);
CPPUNIT_TEST(testBehaviourWhenWidthAndHeightIsOrIsNotSet);
CPPUNIT_TEST_SUITE_END();
@@ -527,15 +529,15 @@ void Test::testi125329()
CPPUNIT_ASSERT (pDocument);
- assertXPath(pDocument, "/primitive2D/transform/transform/polypolygoncolor", "color", "#c0c0c0"); // rect background color
- assertXPath(pDocument, "/primitive2D/transform/transform/polypolygoncolor", "height", "30"); // rect background height
- assertXPath(pDocument, "/primitive2D/transform/transform/polypolygoncolor", "width", "50"); // rect background width
- assertXPath(pDocument, "/primitive2D/transform/transform/polypolygoncolor", "minx", "15");
- assertXPath(pDocument, "/primitive2D/transform/transform/polypolygoncolor", "miny", "15");
- assertXPath(pDocument, "/primitive2D/transform/transform/polypolygoncolor", "maxx", "65");
- assertXPath(pDocument, "/primitive2D/transform/transform/polypolygoncolor", "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", "height", "30"); // rect background height
+ assertXPath(pDocument, "/primitive2D/transform/transform/objectinfo/polypolygoncolor", "width", "50"); // rect background width
+ assertXPath(pDocument, "/primitive2D/transform/transform/objectinfo/polypolygoncolor", "minx", "15");
+ assertXPath(pDocument, "/primitive2D/transform/transform/objectinfo/polypolygoncolor", "miny", "15");
+ assertXPath(pDocument, "/primitive2D/transform/transform/objectinfo/polypolygoncolor", "maxx", "65");
+ assertXPath(pDocument, "/primitive2D/transform/transform/objectinfo/polypolygoncolor", "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()
@@ -617,6 +619,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()));
+
+ 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 61b0a9138fa9..8651e1f9620f 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