svgio/qa/cppunit/SvgImportTest.cxx            |   18 ++++++++++++++++++
 svgio/qa/cppunit/data/tdf155819.svg           |   15 +++++++++++++++
 svgio/source/svgreader/svgstyleattributes.cxx |    5 +++--
 3 files changed, 36 insertions(+), 2 deletions(-)

New commits:
commit d3f0a59f3c47095d4b1d8c01b1316a7dc7f5467d
Author:     Xisco Fauli <xiscofa...@libreoffice.org>
AuthorDate: Wed Jun 14 01:10:50 2023 +0200
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Wed Jun 14 08:08:28 2023 +0200

    tdf#155819: check marker property comes from a style sheet
    
    Since 242b7d0162d55be0945ca849c3de841fbf6cb475
    "svgio: simplify code" where bIsInStyleSheet was replaced by
    getCssStyleParent() incorrectly
    
    Change-Id: I48632e9374f4615e32d18a141aeabec2936e6ec8
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153031
    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 ad5852127551..559af49af695 100644
--- a/svgio/qa/cppunit/SvgImportTest.cxx
+++ b/svgio/qa/cppunit/SvgImportTest.cxx
@@ -135,6 +135,24 @@ CPPUNIT_TEST_FIXTURE(Test, testSymbol)
     assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor", "color", 
"#00d000");
 }
 
+CPPUNIT_TEST_FIXTURE(Test, testTdf155819)
+{
+    Primitive2DSequence aSequence = 
parseSvg(u"/svgio/qa/cppunit/data/tdf155819.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/polypolygonstroke/line", 1);
+    assertXPath(pDocument, 
"/primitive2D/transform/polypolygonstroke/polypolygon", 1);
+    // Without the fix in place, this test would have failed with
+    // - Expected: 4
+    // - Actual  : 0
+    assertXPath(pDocument, "/primitive2D/transform/transform", 4);
+}
+
 CPPUNIT_TEST_FIXTURE(Test, testFilterLuminanceToAlpha)
 {
     Primitive2DSequence aSequenceTdf132246 = 
parseSvg(u"/svgio/qa/cppunit/data/filterLuminanceToAlpha.svg");
diff --git a/svgio/qa/cppunit/data/tdf155819.svg 
b/svgio/qa/cppunit/data/tdf155819.svg
new file mode 100644
index 000000000000..30c2da4d1a5a
--- /dev/null
+++ b/svgio/qa/cppunit/data/tdf155819.svg
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<svg xmlns="http://www.w3.org/2000/svg"; viewBox="0 0 100 100">
+  <style>
+    path {
+      fill: none;
+      stroke-width: 4px;
+      marker: url(#diamond);
+    }
+  </style>
+  <path d="M 10,50 v -20 h 40 v -20" stroke="red"/>
+  <marker id="diamond" markerWidth="12" markerHeight="12" refX="6" refY="6" 
markerUnits="userSpaceOnUse">
+    <circle cx="6" cy="6" r="3"
+            fill="white" stroke="context-stroke" stroke-width="2"/>
+  </marker>
+</svg>
diff --git a/svgio/source/svgreader/svgstyleattributes.cxx 
b/svgio/source/svgreader/svgstyleattributes.cxx
index 99267c762dc5..5f3a3f4aea8a 100644
--- a/svgio/source/svgreader/svgstyleattributes.cxx
+++ b/svgio/source/svgreader/svgstyleattributes.cxx
@@ -1151,7 +1151,7 @@ namespace svgio::svgreader
             if(SVGToken::Path == mrOwner.getType() ||         // path
                 SVGToken::Polygon == mrOwner.getType() ||     // polygon, 
polyline
                 SVGToken::Line == mrOwner.getType() ||        // line
-                getCssStyleParent())
+                SVGToken::Style == mrOwner.getType())        // tdf#150323
             {
                 // try to add markers
                 add_markers(rPath, rTarget, pHelpPointIndices);
@@ -1894,7 +1894,8 @@ namespace svgio::svgreader
                 }
                 case SVGToken::Marker:
                 {
-                    if(getCssStyleParent())
+                    // tdf#155819: Using the marker property from a style 
sheet is equivalent to using all three (start, mid, end).
+                    if(mrOwner.getType() == SVGToken::Style)
                     {
                         readLocalUrl(aContent, maMarkerEndXLink);
                         maMarkerStartXLink = maMarkerMidXLink = 
maMarkerEndXLink;

Reply via email to