diff options
author | Bartosz Kosiorek <gang65@poczta.onet.pl> | 2021-05-04 13:37:40 +0200 |
---|---|---|
committer | Bartosz Kosiorek <gang65@poczta.onet.pl> | 2021-05-06 12:12:40 +0200 |
commit | 761fdaf26dc9ed7cd0d25a7630576e7800813e2f (patch) | |
tree | 61d4705419ce42b068e5e132917f2ebef026282d /emfio | |
parent | 5f10242591d88f6627d7cd82172551879168f9be (diff) |
tdf#142004 tdf#141982 EMF Import: Add rotation and path support for EMR_ELLIPSE
Previous implementation of EMR_ELLIPSE, doesn't support rotation
and EMR_ELLIPSE was not work with EMR_BEGINPATH, EMR_ENDPATH and EMR_ABORTPATH
The EMR_BEGINPATH opens path bracket construction.
Once path bracket construction is open, an application can begin specifying records to
define the points that lie in the path. Path bracket construction MUST be closed by an
EMR_ABORTPATH or EMR_ENDPATH record.
With this patch all these issue was resolved for EMR_ELLIPSE
Change-Id: I6d352e0ff0326dd788d43272bf1330fa6c777df4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115101
Tested-by: Jenkins
Reviewed-by: Bartosz Kosiorek <gang65@poczta.onet.pl>
Diffstat (limited to 'emfio')
-rw-r--r-- | emfio/qa/cppunit/emf/EmfImportTest.cxx | 24 | ||||
-rw-r--r-- | emfio/qa/cppunit/emf/data/TestEllipseWithSelectClipPath.emf | bin | 0 -> 308 bytes | |||
-rw-r--r-- | emfio/source/reader/emfreader.cxx | 8 |
3 files changed, 29 insertions, 3 deletions
diff --git a/emfio/qa/cppunit/emf/EmfImportTest.cxx b/emfio/qa/cppunit/emf/EmfImportTest.cxx index aa62dcd4b00b..3b08f7fe7d21 100644 --- a/emfio/qa/cppunit/emf/EmfImportTest.cxx +++ b/emfio/qa/cppunit/emf/EmfImportTest.cxx @@ -53,6 +53,7 @@ class Test : public test::BootstrapFixture, public XmlTestTools, public unotest: void TestTextMapMode(); void TestEnglishMapMode(); void TestRectangleWithModifyWorldTransform(); + void TestEllipseWithSelectClipPath(); void TestDrawPolyLine16WithClip(); void TestFillRegion(); void TestCreatePen(); @@ -74,6 +75,7 @@ public: CPPUNIT_TEST(TestTextMapMode); CPPUNIT_TEST(TestEnglishMapMode); CPPUNIT_TEST(TestRectangleWithModifyWorldTransform); + CPPUNIT_TEST(TestEllipseWithSelectClipPath); CPPUNIT_TEST(TestDrawPolyLine16WithClip); CPPUNIT_TEST(TestFillRegion); CPPUNIT_TEST(TestCreatePen); @@ -314,7 +316,6 @@ void Test::TestEnglishMapMode() assertXPathContent(pDocument, "/primitive2D/metafile/transform/mask/polygonhairline[3]/polygon", "12699,1058 16933,1058 16933,2118 15346,2118 15346,6349 14287,6349 14287,2118 12699,2118"); } - void Test::TestRectangleWithModifyWorldTransform() { // Check import of EMF image with records: EXTCREATEPEN, SELECTOBJECT, MODIFYWORLDTRANSFORM, RECTANGLE @@ -333,6 +334,26 @@ void Test::TestRectangleWithModifyWorldTransform() assertXPathContent(pDocument, "/primitive2D/metafile/transform/polygonstroke[1]/polygon", "1042,417 1960,946 2313,1556 1395,1028"); } +void Test::TestEllipseWithSelectClipPath() +{ + // EMF import test with records: RECTANGLE, BEGINPATH, ENDPATH, ELLIPSE + Primitive2DSequence aSequence = parseEmf(u"/emfio/qa/cppunit/emf/data/TestEllipseWithSelectClipPath.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/group/mask/polypolygon", 1); + assertXPath(pDocument, "/primitive2D/metafile/transform/group/mask/polypolygon[1]", "path", "m2790 705-106-106-106-70-318-106-424-70h-706l-35 35-247 35h-142l-318 106-105 70-106 106v141l106 106 105 70 318 106 424 71h706l424-71 318-106 106-70 106-106"); + + assertXPath(pDocument, "/primitive2D/metafile/transform/group/mask/polypolygoncolor", 1); + assertXPath(pDocument, "/primitive2D/metafile/transform/group/mask/polypolygoncolor[1]", "color", "#ffff00"); + assertXPath(pDocument, "/primitive2D/metafile/transform/group/mask/polypolygoncolor[1]/polypolygon[1]", "path", "m353 353h2472v1057h-2472z"); + + assertXPath(pDocument, "/primitive2D/metafile/transform/group/mask/polygonstroke", 1); + assertXPathContent(pDocument, "/primitive2D/metafile/transform/group/mask/polygonstroke[1]/polygon", "353,353 2825,353 2825,1410 353,1410"); +} + void Test::TestDrawPolyLine16WithClip() { // Check import of EMF image with records: @@ -358,7 +379,6 @@ void Test::TestDrawPolyLine16WithClip() assertXPath(pDocument, "/primitive2D/metafile/transform/mask/group[1]/mask/polypolygon", "path", "m2646 0v1322h1323v1322h-1323v1322h-1323v-1322h-1323v-1322h1323v-1322"); assertXPathContent(pDocument, "/primitive2D/metafile/transform/mask/group[1]/mask/polygonstroke/polygon", "0,793 3969,4230"); - } void Test::TestFillRegion() diff --git a/emfio/qa/cppunit/emf/data/TestEllipseWithSelectClipPath.emf b/emfio/qa/cppunit/emf/data/TestEllipseWithSelectClipPath.emf Binary files differnew file mode 100644 index 000000000000..ed0d52401238 --- /dev/null +++ b/emfio/qa/cppunit/emf/data/TestEllipseWithSelectClipPath.emf diff --git a/emfio/source/reader/emfreader.cxx b/emfio/source/reader/emfreader.cxx index 2296855c7603..3f1945bf35a5 100644 --- a/emfio/source/reader/emfreader.cxx +++ b/emfio/source/reader/emfreader.cxx @@ -1334,7 +1334,13 @@ namespace emfio case EMR_ELLIPSE : { mpInputStream->ReadInt32( nX32 ).ReadInt32( nY32 ).ReadInt32( nx32 ).ReadInt32( ny32 ); - DrawEllipse( ReadRectangle( nX32, nY32, nx32, ny32 ) ); + SAL_INFO("emfio", "\t\t Rectangle, left: " << nX32 << ", top: " << nY32 << ", right: " << nx32 << ", bottom: " << ny32); + tools::Long dw = (nx32 - nX32) / 2; + tools::Long dh = (ny32 - nY32) / 2; + Point aCenter( nX32 + dw, nY32 + dh ); + tools::Polygon aPoly( aCenter, dw, dh ); + aPoly.Optimize( PolyOptimizeFlags::EDGES ); + DrawPolygon( aPoly, mbRecordPath ); } break; |