emfio/qa/cppunit/emf/EmfImportTest.cxx                          |   16 ++++
 emfio/qa/cppunit/emf/data/TestChordWithModifyWorldTransform.emf |binary
 emfio/source/reader/emfreader.cxx                               |   36 
++++------
 3 files changed, 33 insertions(+), 19 deletions(-)

New commits:
commit 6eac9d960f2bb5dae54ef6ca8e7c659e8c79d011
Author:     Bartosz Kosiorek <gan...@poczta.onet.pl>
AuthorDate: Thu May 6 17:43:57 2021 +0200
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Thu May 6 22:21:10 2021 +0200

    tdf#55058 tdf#141982 EMF: Add rotation support for ARC, ARCTO, CHORD, PIE
    
    Change-Id: I5d9b76f0ddd2b7f12604f472986dd95976a8b04d
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115185
    Tested-by: Jenkins
    Reviewed-by: Bartosz Kosiorek <gan...@poczta.onet.pl>
    (cherry picked from commit 6bf2239a189423d087b2536dd7054b21df58ddc4)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115198
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/emfio/qa/cppunit/emf/EmfImportTest.cxx 
b/emfio/qa/cppunit/emf/EmfImportTest.cxx
index 095ff57f4c0b..1f1976c0a2a3 100644
--- a/emfio/qa/cppunit/emf/EmfImportTest.cxx
+++ b/emfio/qa/cppunit/emf/EmfImportTest.cxx
@@ -51,6 +51,7 @@ class Test : public test::BootstrapFixture, public 
XmlTestTools, public unotest:
     void TestTextMapMode();
     void TestEnglishMapMode();
     void TestRectangleWithModifyWorldTransform();
+    void TestChordWithModifyWorldTransform();
     void TestEllipseWithSelectClipPath();
     void TestDrawPolyLine16WithClip();
     void TestFillRegion();
@@ -73,6 +74,7 @@ public:
     CPPUNIT_TEST(TestTextMapMode);
     CPPUNIT_TEST(TestEnglishMapMode);
     CPPUNIT_TEST(TestRectangleWithModifyWorldTransform);
+    CPPUNIT_TEST(TestChordWithModifyWorldTransform);
     CPPUNIT_TEST(TestEllipseWithSelectClipPath);
     CPPUNIT_TEST(TestDrawPolyLine16WithClip);
     CPPUNIT_TEST(TestFillRegion);
@@ -332,6 +334,20 @@ void Test::TestRectangleWithModifyWorldTransform()
     assertXPathContent(pDocument, 
"/primitive2D/metafile/transform/polygonstroke[1]/polygon", "1042,417 1960,946 
2313,1556 1395,1028");
 }
 
+void Test::TestChordWithModifyWorldTransform()
+{
+    // EMF import test with records: CHORD, MODIFYWORLDTRANSFORM, 
EXTCREATEPEN, SELECTOBJECT
+    Primitive2DSequence aSequence = 
parseEmf(u"/emfio/qa/cppunit/emf/data/TestChordWithModifyWorldTransform.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", 
"color", "#ffffff");
+    assertXPath(pDocument, 
"/primitive2D/metafile/transform/polypolygoncolor/polypolygon", "path", "m590 
448-154 93-54 57-21 45 24 67 45 21 224-6 265-97z");
+    assertXPathContent(pDocument, 
"/primitive2D/metafile/transform/polygonstroke/polygon", "590,448 436,541 
382,598 361,643 385,710 430,731 654,725 919,628");
+}
+
 void Test::TestEllipseWithSelectClipPath()
 {
     // EMF import test with records: RECTANGLE, BEGINPATH, ENDPATH, ELLIPSE
diff --git a/emfio/qa/cppunit/emf/data/TestChordWithModifyWorldTransform.emf 
b/emfio/qa/cppunit/emf/data/TestChordWithModifyWorldTransform.emf
new file mode 100644
index 000000000000..991a1f802fae
Binary files /dev/null and 
b/emfio/qa/cppunit/emf/data/TestChordWithModifyWorldTransform.emf differ
diff --git a/emfio/source/reader/emfreader.cxx 
b/emfio/source/reader/emfreader.cxx
index 4691eff85410..9375da294180 100644
--- a/emfio/source/reader/emfreader.cxx
+++ b/emfio/source/reader/emfreader.cxx
@@ -1351,18 +1351,17 @@ namespace emfio
                     break;
 
                     case EMR_ARC :
-                    {
-                        sal_uInt32 nStartX, nStartY, nEndX, nEndY;
-                        mpInputStream->ReadInt32( nX32 ).ReadInt32( nY32 
).ReadInt32( nx32 ).ReadInt32( ny32 ).ReadUInt32( nStartX ).ReadUInt32( nStartY 
).ReadUInt32( nEndX ).ReadUInt32( nEndY );
-                        DrawArc( ReadRectangle( nX32, nY32, nx32, ny32 ), 
Point( nStartX, nStartY ), Point( nEndX, nEndY ) );
-                    }
-                    break;
-
+                    case EMR_ARCTO :
                     case EMR_CHORD :
                     {
                         sal_uInt32 nStartX, nStartY, nEndX, nEndY;
                         mpInputStream->ReadInt32( nX32 ).ReadInt32( nY32 
).ReadInt32( nx32 ).ReadInt32( ny32 ).ReadUInt32( nStartX ).ReadUInt32( nStartY 
).ReadUInt32( nEndX ).ReadUInt32( nEndY );
-                        DrawChord( ReadRectangle( nX32, nY32, nx32, ny32 ), 
Point( nStartX, nStartY ), Point( nEndX, nEndY ) );
+                        tools::Polygon aPoly( ReadRectangle( nX32, nY32, nx32, 
ny32 ), Point( nStartX, nStartY ), Point( nEndX, nEndY ), PolyStyle::Arc );
+                        aPoly.Optimize( PolyOptimizeFlags::EDGES );
+                        if ( nRecType == EMR_CHORD )
+                            DrawPolygon( aPoly, mbRecordPath );
+                        else
+                            DrawPolyLine( aPoly, nRecType == EMR_ARCTO, 
mbRecordPath );
                     }
                     break;
 
@@ -1370,14 +1369,21 @@ namespace emfio
                     {
                         sal_uInt32 nStartX, nStartY, nEndX, nEndY;
                         mpInputStream->ReadInt32( nX32 ).ReadInt32( nY32 
).ReadInt32( nx32 ).ReadInt32( ny32 ).ReadUInt32( nStartX ).ReadUInt32( nStartY 
).ReadUInt32( nEndX ).ReadUInt32( nEndY );
-                        const tools::Rectangle aRect( ReadRectangle( nX32, 
nY32, nx32, ny32 ));
+                        tools::Polygon aPoly;
 
                         // #i73608# OutputDevice deviates from WMF
                         // semantics. start==end means full ellipse here.
                         if( nStartX == nEndX && nStartY == nEndY )
-                            DrawEllipse( aRect );
+                        {
+                            tools::Long dw = (nx32 - nX32) / 2;
+                            tools::Long dh = (ny32 - nY32) / 2;
+                            Point aCenter( nX32 + dw, nY32 + dh );
+                            aPoly = tools::Polygon( aCenter, dw, dh );
+                        }
                         else
-                            DrawPie( aRect, Point( nStartX, nStartY ), Point( 
nEndX, nEndY ) );
+                            aPoly = tools::Polygon( ReadRectangle( nX32, nY32, 
nx32, ny32 ), Point( nStartX, nStartY ), Point( nEndX, nEndY ), PolyStyle::Pie 
);
+                        aPoly.Optimize( PolyOptimizeFlags::EDGES );
+                        DrawPolygon( aPoly, mbRecordPath );
                     }
                     break;
 
@@ -1388,14 +1394,6 @@ namespace emfio
                     }
                     break;
 
-                    case EMR_ARCTO :
-                    {
-                        sal_uInt32 nStartX, nStartY, nEndX, nEndY;
-                        mpInputStream->ReadInt32( nX32 ).ReadInt32( nY32 
).ReadInt32( nx32 ).ReadInt32( ny32 ).ReadUInt32( nStartX ).ReadUInt32( nStartY 
).ReadUInt32( nEndX ).ReadUInt32( nEndY );
-                        DrawArc( ReadRectangle( nX32, nY32, nx32, ny32 ), 
Point( nStartX, nStartY ), Point( nEndX, nEndY ), true );
-                    }
-                    break;
-
                     case EMR_BEGINPATH :
                     {
                         ClearPath();
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to