summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--svgio/inc/svgstyleattributes.hxx2
-rw-r--r--svgio/qa/cppunit/SvgImportTest.cxx17
-rw-r--r--svgio/qa/cppunit/data/ShapeWithClipPathAndCssStyle.svg13
-rw-r--r--svgio/source/svgreader/svgstyleattributes.cxx27
4 files changed, 53 insertions, 6 deletions
diff --git a/svgio/inc/svgstyleattributes.hxx b/svgio/inc/svgstyleattributes.hxx
index 87c17647eeb8..8489430b7546 100644
--- a/svgio/inc/svgstyleattributes.hxx
+++ b/svgio/inc/svgstyleattributes.hxx
@@ -411,7 +411,7 @@ namespace svgio::svgreader
const OUString& getDesc() const { return maDesc; }
// ClipPathXLink content
- OUString const & getClipPathXLink() const;
+ OUString getClipPathXLink() const;
const SvgClipPathNode* accessClipPathXLink() const;
// MaskXLink content
diff --git a/svgio/qa/cppunit/SvgImportTest.cxx b/svgio/qa/cppunit/SvgImportTest.cxx
index 13f135460017..4724b3a6c8eb 100644
--- a/svgio/qa/cppunit/SvgImportTest.cxx
+++ b/svgio/qa/cppunit/SvgImportTest.cxx
@@ -59,6 +59,7 @@ class Test : public test::BootstrapFixture, public XmlTestTools
void testNoneColor();
void testTdf97936();
void testTdf149893();
+ void testShapeWithClipPathAndCssStyle();
void testClipPathAndParentStyle();
void testClipPathAndStyle();
void testShapeWithClipPath();
@@ -101,6 +102,7 @@ public:
CPPUNIT_TEST(testNoneColor);
CPPUNIT_TEST(testTdf97936);
CPPUNIT_TEST(testTdf149893);
+ CPPUNIT_TEST(testShapeWithClipPathAndCssStyle);
CPPUNIT_TEST(testClipPathAndParentStyle);
CPPUNIT_TEST(testClipPathAndStyle);
CPPUNIT_TEST(testShapeWithClipPath);
@@ -598,6 +600,21 @@ void Test::testTdf149893()
assertXPath(pDocument, "/primitive2D/transform/polypolygoncolor", "color", "#008000");
}
+void Test::testShapeWithClipPathAndCssStyle()
+{
+ // tdf#97539: Check there is a mask and 3 polygons
+ Primitive2DSequence aSequenceClipPathAndStyle = parseSvg(u"/svgio/qa/cppunit/data/ShapeWithClipPathAndCssStyle.svg");
+ CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aSequenceClipPathAndStyle.getLength()));
+
+ drawinglayer::Primitive2dXmlDump dumper;
+ xmlDocUniquePtr pDocument = dumper.dumpAndParse(Primitive2DContainer(aSequenceClipPathAndStyle));
+
+ CPPUNIT_ASSERT (pDocument);
+
+ assertXPath(pDocument, "/primitive2D/transform/mask/polypolygon/polygon", 2);
+ assertXPath(pDocument, "/primitive2D/transform/mask/polypolygoncolor/polypolygon/polygon", 1);
+}
+
void Test::testClipPathAndParentStyle()
{
//Check that fill color, stroke color and stroke-width are inherited from use element
diff --git a/svgio/qa/cppunit/data/ShapeWithClipPathAndCssStyle.svg b/svgio/qa/cppunit/data/ShapeWithClipPathAndCssStyle.svg
new file mode 100644
index 000000000000..4b6455c64930
--- /dev/null
+++ b/svgio/qa/cppunit/data/ShapeWithClipPathAndCssStyle.svg
@@ -0,0 +1,13 @@
+<?xml version="1.0"?>
+<svg width="120" height="120"
+ viewPort="0 0 120 120" version="1.1"
+ xmlns="http://www.w3.org/2000/svg">
+
+ <clipPath id="myClip">
+ <rect x="30" y="30" width="20" height="20"/>
+ <rect x="70" y="70" width="20" height="20"/>
+ </clipPath>
+
+ <rect x="10" y="10" width="100" height="100" style="fill:#00D000"
+ clip-path="url(#myClip)"/>
+</svg>
diff --git a/svgio/source/svgreader/svgstyleattributes.cxx b/svgio/source/svgreader/svgstyleattributes.cxx
index 822ea4c65994..6b676cd952f7 100644
--- a/svgio/source/svgreader/svgstyleattributes.cxx
+++ b/svgio/source/svgreader/svgstyleattributes.cxx
@@ -1196,11 +1196,10 @@ namespace svgio::svgreader
}
const SvgClipPathNode* pClip = accessClipPathXLink();
- while(pClip)
+ if(pClip)
{
// #i124852# transform may be needed when SvgUnits::userSpaceOnUse
pClip->apply(aSource, pTransform);
- pClip = pClip->getSvgStyleAttributes()->accessClipPathXLink();
}
if(!aSource.empty()) // test again, applied clipPath may have lead to empty geometry
@@ -1278,7 +1277,7 @@ namespace svgio::svgreader
maClipRule(FillRule::nonzero),
maBaselineShift(BaselineShift::Baseline),
maBaselineShiftNumber(0),
- maResolvingParent(30, 0),
+ maResolvingParent(31, 0),
mbIsClipPathContent(SVGToken::ClipPathNode == mrOwner.getType()),
mbStrokeDasharraySet(false)
{
@@ -2812,9 +2811,27 @@ namespace svgio::svgreader
return nullptr;
}
- OUString const & SvgStyleAttributes::getClipPathXLink() const
+ OUString SvgStyleAttributes::getClipPathXLink() const
{
- return maClipPathXLink;
+ if(!maClipPathXLink.isEmpty())
+ {
+ return maClipPathXLink;
+ }
+
+ if(getCssStyleParent())
+ {
+ const SvgStyleAttributes* pSvgStyleAttributes = getParentStyle();
+
+ if (pSvgStyleAttributes && maResolvingParent[30] < nStyleDepthLimit)
+ {
+ ++maResolvingParent[30];
+ auto ret = pSvgStyleAttributes->getClipPathXLink();
+ --maResolvingParent[30];
+ return ret;
+ }
+ }
+
+ return OUString();
}
const SvgClipPathNode* SvgStyleAttributes::accessClipPathXLink() const