summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXisco Fauli <xiscofauli@libreoffice.org>2024-03-01 16:42:27 +0100
committerXisco Fauli <xiscofauli@libreoffice.org>2024-03-01 21:46:01 +0100
commita661f9a2e0a05de1705a8e9d930c148a1416be29 (patch)
tree617569dc2ac5875284b4c9ace15221fd334dcc7f
parent948cd8b9f62e28883b691084a9bb83177422defd (diff)
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 <xiscofauli@libreoffice.org>
-rw-r--r--svgio/inc/svgstyleattributes.hxx12
-rw-r--r--svgio/inc/svgtoken.hxx1
-rw-r--r--svgio/qa/cppunit/SvgImportTest.cxx17
-rw-r--r--svgio/qa/cppunit/data/tdf159968.svg37
-rw-r--r--svgio/source/svgreader/svgstyleattributes.cxx38
-rw-r--r--svgio/source/svgreader/svgtoken.cxx1
6 files changed, 105 insertions, 1 deletions
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 8ad390f0b4a5..613b75049335 100644
--- a/svgio/inc/svgtoken.hxx
+++ b/svgio/inc/svgtoken.hxx
@@ -113,6 +113,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 99541f0b63b7..708ab7dcc970 100644
--- a/svgio/qa/cppunit/SvgImportTest.cxx
+++ b/svgio/qa/cppunit/SvgImportTest.cxx
@@ -2013,6 +2013,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 e2088be449b3..cdebccbd2526 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 14c27a396631..2edcd528793e 100644
--- a/svgio/source/svgreader/svgtoken.cxx
+++ b/svgio/source/svgreader/svgtoken.cxx
@@ -111,6 +111,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 },