summaryrefslogtreecommitdiff
path: root/svgio
diff options
context:
space:
mode:
authorXisco Fauli <xiscofauli@libreoffice.org>2023-07-05 14:36:06 +0200
committerXisco Fauli <xiscofauli@libreoffice.org>2023-07-05 17:09:09 +0200
commit88e3e855006e18e146a0619311629c44788a2d71 (patch)
tree72cd75fd617a5016fc8782ffee094052ab3229f2 /svgio
parentb8d2abeff262b25ff1b7d4204cdd844ac595d847 (diff)
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 <xiscofauli@libreoffice.org> Change-Id: Ie699f40ea813d2ba5dc031008d56e2fce73a5715 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154034 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'svgio')
-rw-r--r--svgio/qa/cppunit/SvgImportTest.cxx38
-rw-r--r--svgio/qa/cppunit/data/tdf156168.svg34
-rw-r--r--svgio/source/svgreader/svgnode.cxx4
3 files changed, 74 insertions, 2 deletions
diff --git a/svgio/qa/cppunit/SvgImportTest.cxx b/svgio/qa/cppunit/SvgImportTest.cxx
index c2dad58de2de..8e301469394b 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 d87c76d81e20..bbf0f2342d22 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)