[Libreoffice-commits] core.git: vcl/qa vcl/source
panoskorovesis (via logerrit)
logerrit at kemper.freedesktop.org
Mon Jun 14 12:46:49 UTC 2021
vcl/qa/cppunit/svm/data/clipregion.svm |binary
vcl/qa/cppunit/svm/svmtest.cxx | 96 +++++++++++++++++++++++++++++++--
vcl/source/gdi/mtfxmldump.cxx | 24 ++++++++
3 files changed, 116 insertions(+), 4 deletions(-)
New commits:
commit fff9163cd8ad27d251c06d0e903a71e185009d80
Author: panoskorovesis <panoskorovesis at outlook.com>
AuthorDate: Thu Jun 10 09:41:18 2021 +0300
Commit: Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Mon Jun 14 14:46:06 2021 +0200
Add ClipRegion cppunit test to vcl
The test creates multiple ClipRegions with
different shapes and tests their attributes.
Makefile was edited to support basegfx::B2DPolyPolygon
Change-Id: Iabdf744e1749627b2bc4cbc0c8e933b38552e785
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116959
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>
diff --git a/vcl/qa/cppunit/svm/data/clipregion.svm b/vcl/qa/cppunit/svm/data/clipregion.svm
index aa0d277fee1f..bf8170222c61 100644
Binary files a/vcl/qa/cppunit/svm/data/clipregion.svm and b/vcl/qa/cppunit/svm/data/clipregion.svm differ
diff --git a/vcl/qa/cppunit/svm/svmtest.cxx b/vcl/qa/cppunit/svm/svmtest.cxx
index ec9c80614e22..3fb91f84f006 100644
--- a/vcl/qa/cppunit/svm/svmtest.cxx
+++ b/vcl/qa/cppunit/svm/svmtest.cxx
@@ -23,6 +23,8 @@
#include <bitmap/BitmapWriteAccess.hxx>
+#include <basegfx/polygon/b2dpolypolygon.hxx>
+
#include <config_features.h>
#include <vcl/skia/SkiaHelper.hxx>
@@ -1447,6 +1449,66 @@ void SvmTest::checkClipRegion(const GDIMetaFile& rMetaFile)
{"right", "5"},
{"bottom", "5"},
});
+
+ assertXPathAttrs(pDoc, "/metafile/clipregion[2]/polygon[1]/point[1]", {
+ {"x", "1"},
+ {"y", "8"}
+ });
+
+ assertXPathAttrs(pDoc, "/metafile/clipregion[2]/polygon[1]/point[2]", {
+ {"x", "2"},
+ {"y", "7"}
+ });
+
+ assertXPathAttrs(pDoc, "/metafile/clipregion[2]/polygon[1]/point[3]", {
+ {"x", "3"},
+ {"y", "6"}
+ });
+
+ assertXPathAttrs(pDoc, "/metafile/clipregion[3]/polygon[1]/point[1]", {
+ {"x", "1"},
+ {"y", "8"}
+ });
+
+ assertXPathAttrs(pDoc, "/metafile/clipregion[3]/polygon[1]/point[2]", {
+ {"x", "2"},
+ {"y", "7"}
+ });
+
+ assertXPathAttrs(pDoc, "/metafile/clipregion[3]/polygon[1]/point[3]", {
+ {"x", "3"},
+ {"y", "6"}
+ });
+
+ assertXPathAttrs(pDoc, "/metafile/clipregion[3]/polygon[2]/point[1]", {
+ {"x", "4"},
+ {"y", "9"}
+ });
+
+ assertXPathAttrs(pDoc, "/metafile/clipregion[3]/polygon[2]/point[2]", {
+ {"x", "5"},
+ {"y", "10"}
+ });
+
+ assertXPathAttrs(pDoc, "/metafile/clipregion[3]/polygon[2]/point[3]", {
+ {"x", "6"},
+ {"y", "11"}
+ });
+
+ assertXPathAttrs(pDoc, "/metafile/clipregion[4]/polygon[1]/point[1]", {
+ {"x", "0"},
+ {"y", "1"}
+ });
+
+ assertXPathAttrs(pDoc, "/metafile/clipregion[4]/polygon[1]/point[2]", {
+ {"x", "2"},
+ {"y", "3"}
+ });
+
+ assertXPathAttrs(pDoc, "/metafile/clipregion[4]/polygon[1]/point[3]", {
+ {"x", "4"},
+ {"y", "4"}
+ });
}
void SvmTest::testClipRegion()
@@ -1457,12 +1519,38 @@ void SvmTest::testClipRegion()
vcl::Region aRegion(tools::Rectangle(Point(2, 2), Size(4, 4)));
- // TODO
- // explicit Region(const tools::Polygon& rPolygon);
- // explicit Region(const tools::PolyPolygon& rPolyPoly);
- // explicit Region(const basegfx::B2DPolyPolygon&);
pVirtualDev->SetClipRegion(aRegion);
+ tools::Polygon aPolygon(3);
+ aPolygon.SetPoint(Point(1, 8), 0);
+ aPolygon.SetPoint(Point(2, 7), 1);
+ aPolygon.SetPoint(Point(3, 6), 2);
+
+ vcl::Region aRegion2(aPolygon);
+ pVirtualDev->SetClipRegion(aRegion2);
+
+ tools::Polygon aPolygon1(3);
+ aPolygon1.SetPoint(Point(4, 9), 0);
+ aPolygon1.SetPoint(Point(5, 10), 1);
+ aPolygon1.SetPoint(Point(6, 11), 2);
+
+ tools::PolyPolygon aPolyPolygon(2);
+ aPolyPolygon.Insert(aPolygon);
+ aPolyPolygon.Insert(aPolygon1);
+
+ vcl::Region aRegion3(aPolyPolygon);
+ pVirtualDev->SetClipRegion(aRegion3);
+
+ basegfx::B2DPolygon aB2DPolygon;
+ aB2DPolygon.append(basegfx::B2DPoint(0.0, 1.1));
+ aB2DPolygon.append(basegfx::B2DPoint(2.2, 3.3));
+ aB2DPolygon.append(basegfx::B2DPoint(3.7, 3.8));
+
+ basegfx::B2DPolyPolygon aB2DPolyPolygon(aB2DPolygon);
+
+ vcl::Region aRegion4(aB2DPolyPolygon);
+ pVirtualDev->SetClipRegion(aRegion4);
+
checkClipRegion(writeAndReadStream(aGDIMetaFile));
checkClipRegion(readFile(u"clipregion.svm"));
}
diff --git a/vcl/source/gdi/mtfxmldump.cxx b/vcl/source/gdi/mtfxmldump.cxx
index 8bd21b9d7460..7799a3014f15 100644
--- a/vcl/source/gdi/mtfxmldump.cxx
+++ b/vcl/source/gdi/mtfxmldump.cxx
@@ -1041,6 +1041,30 @@ void MetafileXmlDump::writeXml(const GDIMetaFile& rMetaFile, tools::XmlWriter& r
// dumping the real polypolygon in the future
tools::Rectangle aRectangle = pMetaClipRegionAction->GetRegion().GetBoundRect();
writeRectangle(rWriter, aRectangle);
+
+ vcl::Region aRegion = pMetaClipRegionAction->GetRegion();
+
+ if (aRegion.HasPolyPolygonOrB2DPolyPolygon())
+ {
+ tools::PolyPolygon aPolyPolygon = aRegion.GetAsPolyPolygon();
+
+ for (sal_uInt16 j = 0; j < aPolyPolygon.Count(); ++j)
+ {
+ rWriter.startElement("polygon");
+ tools::Polygon const& rPolygon = aPolyPolygon[j];
+ bool bFlags = rPolygon.HasFlags();
+ for (sal_uInt16 i = 0; i < rPolygon.GetSize(); ++i)
+ {
+ rWriter.startElement("point");
+ writePoint(rWriter, rPolygon[i]);
+ if (bFlags)
+ rWriter.attribute("flags", convertPolygonFlags(rPolygon.GetFlags(i)));
+ rWriter.endElement();
+ }
+ rWriter.endElement();
+ }
+ }
+
rWriter.endElement();
}
break;
More information about the Libreoffice-commits
mailing list