drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx | 6 ++ sd/qa/unit/data/pptx/tdf164622.pptx |binary sd/qa/unit/layout-tests.cxx | 34 +++++++++++++ 3 files changed, 40 insertions(+)
New commits: commit d56b5945cb06600fba3f4e507cbbd1d3c3146439 Author: Balazs Varga <balazs.varga.ext...@allotropia.de> AuthorDate: Wed Jan 15 09:53:15 2025 +0100 Commit: Michael Stahl <michael.st...@allotropia.de> CommitDate: Wed Jan 22 10:15:42 2025 +0100 tdf#164622 - SVG: fix broken cropped svg files at metafile export For creating metafile, there mask polygon from MaskPrimitive2D needs to be closed. Otherwise later during the metafile export the we will skipp the rendering of the last points of the polylines. SVG clipping paths: "A clipping path is a set of closed vector path that may consist of an arbitrary number of straight and curved segments." Change-Id: I21487a81b904ec7ec5c6bd2a89b7539aeb86d606 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/180278 Reviewed-by: Armin Le Grand <armin.le.gr...@me.com> Tested-by: Jenkins (cherry picked from commit 0e01a536d8173270d6a4545a861c2b0b1ba4db17) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/180525 Reviewed-by: Michael Stahl <michael.st...@allotropia.de> diff --git a/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx b/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx index d931320718d4..fdb98edceff2 100644 --- a/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx +++ b/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx @@ -2246,6 +2246,12 @@ void VclMetafileProcessor2D::processMaskPrimitive2D( if (aMask.count()) { + // A clipping path is a set of closed vector path that may consist of an arbitrary number + // of straight and curved segments. The region(s) enclosed by the path define(s) the visible area, + // i.e. after applying a clipping path, only those portions of the subsequently drawn graphics that + // fall inside the enclosed area are visible, everything else is cut away. + if (!aMask.isClosed()) + aMask.setClosed(true); // prepare new mask polygon and rescue current one aMask.transform(maCurrentTransformation); const basegfx::B2DPolyPolygon aLastClipPolyPolygon(maClipPolyPolygon); diff --git a/sd/qa/unit/data/pptx/tdf164622.pptx b/sd/qa/unit/data/pptx/tdf164622.pptx new file mode 100644 index 000000000000..2f766518cc11 Binary files /dev/null and b/sd/qa/unit/data/pptx/tdf164622.pptx differ diff --git a/sd/qa/unit/layout-tests.cxx b/sd/qa/unit/layout-tests.cxx index 57baf576c8c5..6fae40d135c7 100644 --- a/sd/qa/unit/layout-tests.cxx +++ b/sd/qa/unit/layout-tests.cxx @@ -424,6 +424,40 @@ CPPUNIT_TEST_FIXTURE(SdLayoutTest, testTdf152906_AdjustToContour) } } +CPPUNIT_TEST_FIXTURE(SdLayoutTest, testTdf164622) +{ + xmlDocUniquePtr pXmlDoc = load("pptx/tdf164622.pptx"); + + // Without the fix, the test fails with: + // - Expected: 8998 + // - Actual : 892 + // - In <>, attribute 'y' of '/metafile/push[1]/push[1]/push[2]/push[1]/clipregion/polygon/point[4]' + assertXPath(pXmlDoc, "/metafile/push[1]/push[1]/push[2]/push[1]/clipregion/polygon/point[1]", + "x", u"7556"); + assertXPath(pXmlDoc, "/metafile/push[1]/push[1]/push[2]/push[1]/clipregion/polygon/point[1]", + "y", u"892"); + + assertXPath(pXmlDoc, "/metafile/push[1]/push[1]/push[2]/push[1]/clipregion/polygon/point[2]", + "x", u"20440"); + assertXPath(pXmlDoc, "/metafile/push[1]/push[1]/push[2]/push[1]/clipregion/polygon/point[2]", + "y", u"892"); + + assertXPath(pXmlDoc, "/metafile/push[1]/push[1]/push[2]/push[1]/clipregion/polygon/point[3]", + "x", u"20440"); + assertXPath(pXmlDoc, "/metafile/push[1]/push[1]/push[2]/push[1]/clipregion/polygon/point[3]", + "y", u"8998"); + + assertXPath(pXmlDoc, "/metafile/push[1]/push[1]/push[2]/push[1]/clipregion/polygon/point[4]", + "x", u"7556"); + assertXPath(pXmlDoc, "/metafile/push[1]/push[1]/push[2]/push[1]/clipregion/polygon/point[4]", + "y", u"8998"); + + assertXPath(pXmlDoc, "/metafile/push[1]/push[1]/push[2]/push[1]/clipregion/polygon/point[5]", + "x", u"7556"); + assertXPath(pXmlDoc, "/metafile/push[1]/push[1]/push[2]/push[1]/clipregion/polygon/point[5]", + "y", u"892"); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */