emfio/qa/cppunit/emf/EmfImportTest.cxx | 36 +++++++++++++++++++++++++++- emfio/qa/cppunit/emf/data/TestRoundRect.emf |binary emfio/source/reader/emfreader.cxx | 5 ++- 3 files changed, 38 insertions(+), 3 deletions(-)
New commits: commit 2a416c0c4a1635af8be5b1167fd1f06bdc4a2466 Author: Bartosz Kosiorek <gan...@poczta.onet.pl> AuthorDate: Tue May 11 17:24:20 2021 +0200 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Tue May 11 22:34:34 2021 +0200 tdf#141982 tdf#142139 Add rotation and line width support to ROUNDRECT With this commit the ROUNDRECT is able to change line width and transformation (including rotation) is supported. Change-Id: Ic303a74adf0fd0dd452353f250a13140603d492e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115429 Tested-by: Jenkins Reviewed-by: Bartosz Kosiorek <gan...@poczta.onet.pl> (cherry picked from commit f11ed681df15728abe6a0b6b7b1612f190aa1707) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115282 Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> diff --git a/emfio/qa/cppunit/emf/EmfImportTest.cxx b/emfio/qa/cppunit/emf/EmfImportTest.cxx index 8dc864fb657e..52fab033941a 100644 --- a/emfio/qa/cppunit/emf/EmfImportTest.cxx +++ b/emfio/qa/cppunit/emf/EmfImportTest.cxx @@ -56,6 +56,7 @@ class Test : public test::BootstrapFixture, public XmlTestTools, public unotest: void TestEllipseXformIntersectClipRect(); void TestDrawPolyLine16WithClip(); void TestFillRegion(); + void TestRoundRect(); void TestCreatePen(); void TestPdfInEmf(); @@ -80,6 +81,7 @@ public: CPPUNIT_TEST(TestEllipseXformIntersectClipRect); CPPUNIT_TEST(TestDrawPolyLine16WithClip); CPPUNIT_TEST(TestFillRegion); + CPPUNIT_TEST(TestRoundRect); CPPUNIT_TEST(TestCreatePen); CPPUNIT_TEST(TestPdfInEmf); CPPUNIT_TEST_SUITE_END(); @@ -414,7 +416,7 @@ void Test::TestDrawPolyLine16WithClip() void Test::TestFillRegion() { - // Check import of EMF image with records: CREATEBRUSHINDIRECT, FILLRGN. The SETICMMODE is also used. + // EMF import with records: CREATEBRUSHINDIRECT, FILLRGN. The SETICMMODE is also used. Primitive2DSequence aSequence = parseEmf(u"/emfio/qa/cppunit/emf/data/TestFillRegion.emf"); CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aSequence.getLength())); drawinglayer::Primitive2dXmlDump dumper; @@ -434,6 +436,38 @@ void Test::TestFillRegion() assertXPath(pDocument, "/primitive2D/metafile/transform/mask/polygonhairline[1]", "color", "#000000"); } +void Test::TestRoundRect() +{ + // EMF import with records: CREATEPEN, ROUNDRECT. + Primitive2DSequence aSequence = parseEmf(u"/emfio/qa/cppunit/emf/data/TestRoundRect.emf"); + CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(aSequence.getLength())); + drawinglayer::Primitive2dXmlDump dumper; + xmlDocUniquePtr pDocument = dumper.dumpAndParse(comphelper::sequenceToContainer<Primitive2DContainer>(aSequence)); + CPPUNIT_ASSERT (pDocument); + + assertXPath(pDocument, "/primitive2D/metafile/transform/polypolygoncolor", 2); + assertXPath(pDocument, "/primitive2D/metafile/transform/polypolygoncolor[1]/polypolygon", + "path", "m100 100h4000v2000h-4000z"); + assertXPath(pDocument, "/primitive2D/metafile/transform/polypolygoncolor[1]", + "color", "#ffffff"); + + assertXPath(pDocument, "/primitive2D/metafile/transform/polygonstroke", 2); + assertXPathContent(pDocument, "/primitive2D/metafile/transform/polygonstroke[1]/polygon", + "100,100 4100,100 4100,2100 100,2100"); + assertXPath(pDocument, "/primitive2D/metafile/transform/polygonstroke[1]/line", + "color", "#ff0000"); + + assertXPath(pDocument, "/primitive2D/metafile/transform/polypolygoncolor[2]/polypolygon", + "path", "m4090 2650-10-50-10-30-50-90-100-110-20-10-30-20-20-20-30-20-90-40-100-30-170-30h-2730l-140 20-130 40-90 40-30 20-20 20-30 20-20 10-100 110-50 90-10 30-10 50v1090l10 50 10 30 50 90 100 110 20 10 30 20 20 20 30 20 90 40 100 30 170 30h2730l140-20 130-40 90-40 30-20 20-20 30-20 20-10 100-110 50-90 10-30 10-50z"); + assertXPath(pDocument, "/primitive2D/metafile/transform/polypolygoncolor[2]", + "color", "#ffffff"); + + assertXPathContent(pDocument, "/primitive2D/metafile/transform/polygonstroke[2]/polygon", + "4090,2650 4080,2600 4070,2570 4020,2480 3920,2370 3900,2360 3870,2340 3850,2320 3820,2300 3730,2260 3630,2230 3460,2200 730,2200 590,2220 460,2260 370,2300 340,2320 320,2340 290,2360 270,2370 170,2480 120,2570 110,2600 100,2650 100,3740 110,3790 120,3820 170,3910 270,4020 290,4030 320,4050 340,4070 370,4090 460,4130 560,4160 730,4190 3460,4190 3600,4170 3730,4130 3820,4090 3850,4070 3870,4050 3900,4030 3920,4020 4020,3910 4070,3820 4080,3790 4090,3740"); + assertXPath(pDocument, "/primitive2D/metafile/transform/polygonstroke[2]/line", + "color", "#ff0000"); +} + void Test::TestCreatePen() { // Check import of EMF image with records: RESTOREDC, SAVEDC, MOVETOEX, LINETO, POLYLINE16, EXTTEXTOUTW with DxBuffer diff --git a/emfio/qa/cppunit/emf/data/TestRoundRect.emf b/emfio/qa/cppunit/emf/data/TestRoundRect.emf new file mode 100644 index 000000000000..6e13cda83fae Binary files /dev/null and b/emfio/qa/cppunit/emf/data/TestRoundRect.emf differ diff --git a/emfio/source/reader/emfreader.cxx b/emfio/source/reader/emfreader.cxx index 9375da294180..2ef29fd98dcc 100644 --- a/emfio/source/reader/emfreader.cxx +++ b/emfio/source/reader/emfreader.cxx @@ -1345,8 +1345,9 @@ namespace emfio case EMR_ROUNDRECT : { mpInputStream->ReadInt32( nX32 ).ReadInt32( nY32 ).ReadInt32( nx32 ).ReadInt32( ny32 ).ReadUInt32( nW ).ReadUInt32( nH ); - Size aSize( Size( nW, nH ) ); - DrawRoundRect( ReadRectangle( nX32, nY32, nx32, ny32 ), aSize ); + tools::Polygon aRoundRectPoly( ReadRectangle( nX32, nY32, nx32, ny32 ), nW, nH ); + aRoundRectPoly.Optimize( PolyOptimizeFlags::EDGES ); + DrawPolygon( aRoundRectPoly, mbRecordPath ); } break; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits