svgio/qa/cppunit/SvgImportTest.cxx            |   24 ++++++++++++++++++++++++
 svgio/qa/cppunit/data/markerInCssStyle.svg    |   14 ++++++++++++++
 svgio/source/svgreader/svgstyleattributes.cxx |    3 ++-
 3 files changed, 40 insertions(+), 1 deletion(-)

New commits:
commit 2e1583b59816296e22b080809b2d9a8ef94b49cf
Author:     Xisco Fauli <xiscofa...@libreoffice.org>
AuthorDate: Wed Aug 10 14:58:28 2022 +0200
Commit:     Adolfo Jayme Barrientos <fit...@ubuntu.com>
CommitDate: Sat Aug 13 19:59:54 2022 +0200

    tdf#150323: also add markers if there is a css style parent
    
    Change-Id: Ia900726ee31b7b19e98122d40b33581c9a60dcc7
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138090
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>
    Signed-off-by: Xisco Fauli <xiscofa...@libreoffice.org>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138139
    Reviewed-by: Adolfo Jayme Barrientos <fit...@ubuntu.com>

diff --git a/svgio/qa/cppunit/SvgImportTest.cxx 
b/svgio/qa/cppunit/SvgImportTest.cxx
index 3fe1b48660ce..2a254b0afd17 100644
--- a/svgio/qa/cppunit/SvgImportTest.cxx
+++ b/svgio/qa/cppunit/SvgImportTest.cxx
@@ -46,6 +46,7 @@ class Test : public test::BootstrapFixture, public 
XmlTestTools
     void testFontsizePercentage();
     void testFontsizeRelative();
     void testMarkerOrient();
+    void testMarkerInCssStyle();
     void testTdf45771();
     void testTdf97941();
     void testTdf104339();
@@ -90,6 +91,7 @@ public:
     CPPUNIT_TEST(testFontsizePercentage);
     CPPUNIT_TEST(testFontsizeRelative);
     CPPUNIT_TEST(testMarkerOrient);
+    CPPUNIT_TEST(testMarkerInCssStyle);
     CPPUNIT_TEST(testTdf45771);
     CPPUNIT_TEST(testTdf97941);
     CPPUNIT_TEST(testTdf104339);
@@ -368,6 +370,28 @@ void Test::testMarkerOrient()
     assertXPath(pDocument, "/primitive2D/transform/transform[2]", "xy33", "1");
 }
 
+void Test::testMarkerInCssStyle()
+{
+    Primitive2DSequence aSequence = 
parseSvg(u"/svgio/qa/cppunit/data/markerInCssStyle.svg");
+    CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aSequence.getLength()));
+
+    drawinglayer::Primitive2dXmlDump dumper;
+    xmlDocUniquePtr pDocument = dumper.dumpAndParse(aSequence);
+
+    CPPUNIT_ASSERT (pDocument);
+
+    // Without the fix in place, this test would have failed with
+    // - Expected: 20
+    // - Actual  : 0
+    assertXPath(pDocument, 
"/primitive2D/transform/transform/polypolygonstroke/line", 20);
+
+    assertXPath(pDocument, 
"/primitive2D/transform/transform[1]/polypolygonstroke/line", "color", 
"#008000");
+    assertXPath(pDocument, 
"/primitive2D/transform/transform[1]/polypolygonstroke/line", "width", "1");
+    assertXPath(pDocument, 
"/primitive2D/transform/transform[1]/polypolygonstroke/line", "linejoin", 
"Miter");
+    assertXPath(pDocument, 
"/primitive2D/transform/transform[1]/polypolygonstroke/line", "miterangle", 
"28");
+    assertXPath(pDocument, 
"/primitive2D/transform/transform[1]/polypolygonstroke/line", "linecap", 
"BUTT");
+}
+
 void Test::testTdf45771()
 {
     //Check text fontsize when using relative units
diff --git a/svgio/qa/cppunit/data/markerInCssStyle.svg 
b/svgio/qa/cppunit/data/markerInCssStyle.svg
new file mode 100644
index 000000000000..a7a8374f6ee3
--- /dev/null
+++ b/svgio/qa/cppunit/data/markerInCssStyle.svg
@@ -0,0 +1,14 @@
+<?xml version="1.0"?>
+<svg width="500" height="500" xmlns="http://www.w3.org/2000/svg"; 
xmlns:xlink="http://www.w3.org/1999/xlink";>
+<defs>
+<marker style="overflow:visible;" id="bip" refX="0" refY="0" orient="auto">
+       <path style="stroke: green" d="M 0,-3 v 6" />
+</marker>
+</defs>
+
+<style>
+path.boundary {stroke: red; fill: #ccc; stroke-width: 3; marker-mid: 
url(#bip); marker-end: url(#bip)}
+</style>
+
+<path class="boundary" d="m 20,20 v 90 90 90 90 90 h 90 90 90 90 90 v -90 -90 
-90 -90 -90 h -90 -90 -90 -90 z" />
+</svg>
diff --git a/svgio/source/svgreader/svgstyleattributes.cxx 
b/svgio/source/svgreader/svgstyleattributes.cxx
index 156fadc7c689..da44e3bbb292 100644
--- a/svgio/source/svgreader/svgstyleattributes.cxx
+++ b/svgio/source/svgreader/svgstyleattributes.cxx
@@ -1148,7 +1148,8 @@ namespace svgio::svgreader
             // Svg supports markers for path, polygon, polyline and line
             if(SVGToken::Path == mrOwner.getType() ||         // path
                 SVGToken::Polygon == mrOwner.getType() ||     // polygon, 
polyline
-                SVGToken::Line == mrOwner.getType())          // line
+                SVGToken::Line == mrOwner.getType() ||        // line
+                getCssStyleParent())
             {
                 // try to add markers
                 add_markers(rPath, rTarget, pHelpPointIndices);

Reply via email to