svgio/qa/cppunit/SvgImportTest.cxx | 16 ++++++++++++++++ svgio/qa/cppunit/data/ClipPathUsingClipPath.svg | 24 ++++++++++++++++++++++++ svgio/source/svgreader/svgstyleattributes.cxx | 3 ++- 3 files changed, 42 insertions(+), 1 deletion(-)
New commits: commit 6cd06c36b9755cb3a9058ee1572b68e3ef4a3fad Author: Xisco Fauli <xiscofa...@libreoffice.org> AuthorDate: Mon Jul 18 13:21:35 2022 +0200 Commit: Adolfo Jayme Barrientos <fit...@ubuntu.com> CommitDate: Tue Jul 19 06:58:39 2022 +0200 related: tdf#97539: SVGIO: iterate over parent's clippaths This commit reintroduces fb33451a27d8668bc14f5bcfd6ea742fc4c5b84c "tdf#97539: SVGIO: iterate over parent's clippaths" which I reverted it in 82c0a363abbceac6464b62c3571aa3225415c7db "tdf#97539; if parent is css style, look one level up" because I thought it was no longer necessary, but I was wrong. Also add a unittest Change-Id: Ib66ca0afd63e8e52be6677b6965179e092a61aa8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137195 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/+/137208 Reviewed-by: Adolfo Jayme Barrientos <fit...@ubuntu.com> diff --git a/svgio/qa/cppunit/SvgImportTest.cxx b/svgio/qa/cppunit/SvgImportTest.cxx index ff28c43f7a52..d9b803deea33 100644 --- a/svgio/qa/cppunit/SvgImportTest.cxx +++ b/svgio/qa/cppunit/SvgImportTest.cxx @@ -61,6 +61,7 @@ class Test : public test::BootstrapFixture, public XmlTestTools void testShapeWithClipPathAndCssStyle(); void testClipPathAndParentStyle(); void testClipPathAndStyle(); + void testClipPathUsingClipPath(); void testi125329(); void testMaskingPath07b(); void test123926(); @@ -102,6 +103,7 @@ public: CPPUNIT_TEST(testShapeWithClipPathAndCssStyle); CPPUNIT_TEST(testClipPathAndParentStyle); CPPUNIT_TEST(testClipPathAndStyle); + CPPUNIT_TEST(testClipPathUsingClipPath); CPPUNIT_TEST(testi125329); CPPUNIT_TEST(testMaskingPath07b); CPPUNIT_TEST(test123926); @@ -627,6 +629,20 @@ void Test::testClipPathAndStyle() } +void Test::testClipPathUsingClipPath() +{ + Primitive2DSequence aSequenceClipPathAndStyle = parseSvg(u"/svgio/qa/cppunit/data/ClipPathUsingClipPath.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/point", 20); + assertXPath(pDocument, "/primitive2D/transform/mask/mask/polypolygon/polygon/point", 13); +} + void Test::testi125329() { //Check style inherit from * css element diff --git a/svgio/qa/cppunit/data/ClipPathUsingClipPath.svg b/svgio/qa/cppunit/data/ClipPathUsingClipPath.svg new file mode 100644 index 000000000000..5eaa7928cb85 --- /dev/null +++ b/svgio/qa/cppunit/data/ClipPathUsingClipPath.svg @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<svg + xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> +<defs> + +<clipPath id="clip1"> + <polygon id="clip1Shape" points="100,10 40,180 190,60 10,60 160,180 100,10" stroke="blue" /> +</clipPath> + +<clipPath id="clip2"> + <circle id="clip2Shape" cx="100" cy="100" r="65" /> +</clipPath> + + +<clipPath id="clipIntersection" clip-path="url(#clip1)"> + <use x="0" y="0" width="200" height="200" xlink:href="#clip2Shape" /> +</clipPath> + +</defs> + +<rect x="10" y="10" width="180" height="180" fill="red" + clip-path="url(#clipIntersection)" transform="translate(200)" /> + +</svg> diff --git a/svgio/source/svgreader/svgstyleattributes.cxx b/svgio/source/svgreader/svgstyleattributes.cxx index c7240e6fbefc..2d1a04eeb052 100644 --- a/svgio/source/svgreader/svgstyleattributes.cxx +++ b/svgio/source/svgreader/svgstyleattributes.cxx @@ -1195,10 +1195,11 @@ namespace svgio::svgreader } const SvgClipPathNode* pClip = accessClipPathXLink(); - if(pClip) + while(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