svgio/inc/svgstyleattributes.hxx              |   12 ++++++++
 svgio/inc/svgtoken.hxx                        |    1 
 svgio/qa/cppunit/SvgImportTest.cxx            |   17 +++++++++++
 svgio/qa/cppunit/data/tdf159968.svg           |   37 +++++++++++++++++++++++++
 svgio/source/svgreader/svgstyleattributes.cxx |   38 +++++++++++++++++++++++++-
 svgio/source/svgreader/svgtoken.cxx           |    1 
 6 files changed, 105 insertions(+), 1 deletion(-)

New commits:
commit 6eb331934f27993db83a2175d22bdd554a775ad8
Author:     Xisco Fauli <xiscofa...@libreoffice.org>
AuthorDate: Fri Mar 1 16:42:27 2024 +0100
Commit:     Caolán McNamara <caolan.mcnam...@collabora.com>
CommitDate: Mon Mar 4 09:38:39 2024 +0100

    tdf#159968: Support overflow:visible in marker element
    
    Change-Id: I4ea648cf94a4bb321a78843a9898769a69c5630d
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164224
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>
    (cherry picked from commit eaf9befee8073916f6b22dd600e54073504154b7)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164198
    Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com>

diff --git a/svgio/inc/svgstyleattributes.hxx b/svgio/inc/svgstyleattributes.hxx
index 4516773e83a6..bf921f8b1bb0 100644
--- a/svgio/inc/svgstyleattributes.hxx
+++ b/svgio/inc/svgstyleattributes.hxx
@@ -170,6 +170,13 @@ namespace svgio::svgreader
             Central
         };
 
+        enum class Overflow
+        {
+            notset,
+            hidden,
+            visible
+        };
+
         enum class Visibility
         {
             notset,
@@ -207,6 +214,7 @@ namespace svgio::svgreader
             TextAnchor                  maTextAnchor;
             SvgPaint                    maColor;
             SvgNumber                   maOpacity;
+            Overflow                    maOverflow;
             Visibility                  maVisibility;
             OUString               maTitle;
             OUString               maDesc;
@@ -410,6 +418,10 @@ namespace svgio::svgreader
             SvgNumber getOpacity() const;
             void setOpacity(const SvgNumber& rOpacity) { maOpacity = rOpacity; 
}
 
+            /// Overflow
+            Overflow getOverflow() const;
+            void setOverflow(const Overflow aOverflow) { maOverflow = 
aOverflow; }
+
             /// Visibility
             Visibility getVisibility() const;
             void setVisibility(const Visibility aVisibility) { maVisibility = 
aVisibility; }
diff --git a/svgio/inc/svgtoken.hxx b/svgio/inc/svgtoken.hxx
index 3927a27d1db5..26a5d8f5f423 100644
--- a/svgio/inc/svgtoken.hxx
+++ b/svgio/inc/svgtoken.hxx
@@ -112,6 +112,7 @@ namespace svgio::svgreader
             Visibility,
             Title,
             Desc,
+            Overflow,
 
             // AspectRatio and params
             PreserveAspectRatio,
diff --git a/svgio/qa/cppunit/SvgImportTest.cxx 
b/svgio/qa/cppunit/SvgImportTest.cxx
index 0ba32d8cb9f3..326e8f38ffb6 100644
--- a/svgio/qa/cppunit/SvgImportTest.cxx
+++ b/svgio/qa/cppunit/SvgImportTest.cxx
@@ -1950,6 +1950,23 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf156271)
     assertXPath(pDocument, 
"/primitive2D/transform/mask/textsimpleportion[4]"_ostr, "dx1"_ostr, "23");
 }
 
+CPPUNIT_TEST_FIXTURE(Test, testTdf159968)
+{
+    Primitive2DSequence aSequence = 
parseSvg(u"/svgio/qa/cppunit/data/tdf159968.svg");
+    CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aSequence.getLength()));
+
+    drawinglayer::Primitive2dXmlDump dumper;
+    xmlDocUniquePtr pDocument = 
dumper.dumpAndParse(Primitive2DContainer(aSequence));
+
+    CPPUNIT_ASSERT (pDocument);
+
+    // Check no mask is applied to the marker
+    assertXPath(pDocument,
+            
"/primitive2D/transform/transform/transform/transform/polypolygoncolor"_ostr, 
"color"_ostr, "#000000");
+    assertXPath(pDocument,
+            
"/primitive2D/transform/transform/transform/transform/polypolygoncolor/polypolygon/polygon/point"_ostr,
 5);
+}
+
 CPPUNIT_TEST_FIXTURE(Test, testTdf149880)
 {
     Primitive2DSequence aSequence = 
parseSvg(u"/svgio/qa/cppunit/data/tdf149880.svg");
diff --git a/svgio/qa/cppunit/data/tdf159968.svg 
b/svgio/qa/cppunit/data/tdf159968.svg
new file mode 100644
index 000000000000..8c13f0864901
--- /dev/null
+++ b/svgio/qa/cppunit/data/tdf159968.svg
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+
+<svg
+   width="100mm"
+   height="100mm"
+   viewBox="0 0 100 100"
+   version="1.1"
+   id="svg1"
+   xmlns="http://www.w3.org/2000/svg";
+   xmlns:svg="http://www.w3.org/2000/svg";>
+  <defs
+     id="defs1">
+    <marker
+       style="overflow:visible"
+       id="ArrowTriangleStylized"
+       refX="0"
+       refY="0"
+       orient="auto-start-reverse"
+       markerWidth="1"
+       markerHeight="1"
+       viewBox="0 0 1 1"
+       preserveAspectRatio="xMidYMid">
+      <path
+         transform="scale(0.5)"
+         
style="fill:context-stroke;fill-rule:evenodd;stroke:context-stroke;stroke-width:1pt"
+         d="m 6,0 c -3,1 -7,3 -9,5 0,0 0,-4 2,-5 -2,-1 -2,-5 -2,-5 2,2 6,4 9,5 
z"
+         id="path4" />
+    </marker>
+  </defs>
+  <g
+     id="layer1">
+    <path
+       
style="fill:none;stroke:#000000;stroke-width:3;stroke-linecap:butt;stroke-linejoin:miter;stroke-dasharray:none;stroke-opacity:1;marker-end:url(#ArrowTriangleStylized)"
+       d="M 9.7161802,91.253315 84.819628,15.230769"
+       id="path1"/>
+  </g>
+</svg>
diff --git a/svgio/source/svgreader/svgstyleattributes.cxx 
b/svgio/source/svgreader/svgstyleattributes.cxx
index 731df59aeebf..19070989bb55 100644
--- a/svgio/source/svgreader/svgstyleattributes.cxx
+++ b/svgio/source/svgreader/svgstyleattributes.cxx
@@ -850,7 +850,8 @@ namespace svgio::svgreader
                         const basegfx::B2DRange aTargetRange(0.0, 0.0, 
fTargetWidth, fTargetHeight);
                         const SvgAspectRatio& rRatio = 
rMarker.getSvgAspectRatio();
 
-                        if(rRatio.isSet())
+
+                        if(rRatio.isSet() && Overflow::visible != 
rMarker.getSvgStyleAttributes()->getOverflow())
                         {
                             // let mapping be created from SvgAspectRatio
                             rMarkerTransform = 
rRatio.createMapping(aTargetRange, aPrimitiveRange);
@@ -1279,6 +1280,7 @@ namespace svgio::svgreader
             maTextAlign(TextAlign::notset),
             maTextDecoration(TextDecoration::notset),
             maTextAnchor(TextAnchor::notset),
+            maOverflow(Overflow::notset),
             maVisibility(Visibility::notset),
             maFillRule(FillRule::notset),
             maClipRule(FillRule::notset),
@@ -1822,6 +1824,21 @@ namespace svgio::svgreader
                     }
                     break;
                 }
+                case SVGToken::Overflow:
+                {
+                    if(!aContent.isEmpty())
+                    {
+                        if(o3tl::equalsIgnoreAsciiCase(o3tl::trim(aContent), 
u"visible"))
+                        {
+                            setOverflow(Overflow::visible);
+                        }
+                        else 
if(o3tl::equalsIgnoreAsciiCase(o3tl::trim(aContent), u"hidden"))
+                        {
+                            setOverflow(Overflow::hidden);
+                        }
+                    }
+                    break;
+                }
                 case SVGToken::Visibility:
                 {
                     if(!aContent.isEmpty())
@@ -2316,6 +2333,25 @@ namespace svgio::svgreader
             return SvgNumber(1.0);
         }
 
+        Overflow SvgStyleAttributes::getOverflow() const
+        {
+            if(Overflow::notset != maOverflow)
+            {
+                return maOverflow;
+            }
+
+            if(mrOwner.hasLocalCssStyle())
+            {
+                const SvgStyleAttributes* pSvgStyleAttributes = 
getParentStyle();
+                if (pSvgStyleAttributes)
+                {
+                    return pSvgStyleAttributes->getOverflow();
+                }
+            }
+
+            return Overflow::hidden;
+        }
+
         Visibility SvgStyleAttributes::getVisibility() const
         {
             if(Visibility::notset == maVisibility || Visibility::inherit == 
maVisibility)
diff --git a/svgio/source/svgreader/svgtoken.cxx 
b/svgio/source/svgreader/svgtoken.cxx
index fa28c8647cea..968ead048312 100644
--- a/svgio/source/svgreader/svgtoken.cxx
+++ b/svgio/source/svgreader/svgtoken.cxx
@@ -110,6 +110,7 @@ constexpr auto aSVGTokenMap = 
frozen::make_unordered_map<std::u16string_view, SV
     { u"visibility", SVGToken::Visibility },
     { u"title", SVGToken::Title },
     { u"desc", SVGToken::Desc },
+    { u"overflow", SVGToken::Overflow },
     { u"preserveAspectRatio", SVGToken::PreserveAspectRatio },
     { u"defer", SVGToken::Defer },
     { u"none", SVGToken::None },

Reply via email to