[Libreoffice-commits] core.git: Branch 'libreoffice-7-1' - emfio/qa tools/source

Bartosz Kosiorek (via logerrit) logerrit at kemper.freedesktop.org
Fri May 21 08:20:26 UTC 2021


 emfio/qa/cppunit/emf/EmfImportTest.cxx                             |   15 ++++++++++
 emfio/qa/cppunit/emf/data/TestArcInsideWronglyDefinedRectangle.emf |binary
 tools/source/generic/poly.cxx                                      |    9 ++++--
 3 files changed, 21 insertions(+), 3 deletions(-)

New commits:
commit 71edc1d1af9691f7b5067579f22d3d8677c1608c
Author:     Bartosz Kosiorek <gang65 at poczta.onet.pl>
AuthorDate: Tue May 18 17:36:21 2021 +0200
Commit:     Xisco Fauli <xiscofauli at libreoffice.org>
CommitDate: Fri May 21 10:19:55 2021 +0200

    tdf#55007 tdf#142263 tdf#142268 EMF Properly display ARC and CHORD
    
    With previous implementation the ARC, ARCTO and CHORD were
    not displayed if the corners of rectangle was switched.
    
    With this patch the shapes are always displayed correctly.
    
    Change-Id: Ie8ac7af812298c0b96c3b5af417117784f128ce1
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115757
    Tested-by: Jenkins
    Reviewed-by: Bartosz Kosiorek <gang65 at poczta.onet.pl>
    (cherry picked from commit 39369c6e67dffe04acc4abb678c1a94526237fd8)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115524
    Reviewed-by: Xisco Fauli <xiscofauli at libreoffice.org>

diff --git a/emfio/qa/cppunit/emf/EmfImportTest.cxx b/emfio/qa/cppunit/emf/EmfImportTest.cxx
index 53be54f34c02..24e2e295e957 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 TestArcInsideWronglyDefinedRectangle();
     void TestChordWithModifyWorldTransform();
     void TestEllipseWithSelectClipPath();
     void TestEllipseXformIntersectClipRect();
@@ -79,6 +80,7 @@ public:
     CPPUNIT_TEST(TestTextMapMode);
     CPPUNIT_TEST(TestEnglishMapMode);
     CPPUNIT_TEST(TestRectangleWithModifyWorldTransform);
+    CPPUNIT_TEST(TestArcInsideWronglyDefinedRectangle);
     CPPUNIT_TEST(TestChordWithModifyWorldTransform);
     CPPUNIT_TEST(TestEllipseWithSelectClipPath);
     CPPUNIT_TEST(TestEllipseXformIntersectClipRect);
@@ -358,6 +360,19 @@ void Test::TestChordWithModifyWorldTransform()
     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::TestArcInsideWronglyDefinedRectangle()
+{
+    // tdf#142268 EMF import test with records: ARC
+    Primitive2DSequence aSequence = parseEmf(u"/emfio/qa/cppunit/emf/data/TestArcInsideWronglyDefinedRectangle.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/polygonhairline", "color", "#000000");
+    assertXPathContent(pDocument, "/primitive2D/metafile/transform/polygonhairline/polygon", "1630,1450 1650,1470 1850,1540 1990,1540 2040,1530 2190,1470 2270,1410 2330,1350 2390,1260 2430,1160 2430,1140 2440,1090 2450,1060 2450,950 2440,930 2430,880 2430,850 2420,820 2360,710 2310,650 2250,590 2110,510 1980,480 1870,480 1770,500 1670,540 1650,560 1630,570 1600,580 1540,640 1460,740 1450,770");
+}
+
 void Test::TestEllipseWithSelectClipPath()
 {
     // EMF import test with records: RECTANGLE, BEGINPATH, ENDPATH, ELLIPSE
diff --git a/emfio/qa/cppunit/emf/data/TestArcInsideWronglyDefinedRectangle.emf b/emfio/qa/cppunit/emf/data/TestArcInsideWronglyDefinedRectangle.emf
new file mode 100644
index 000000000000..3a785fba6cac
Binary files /dev/null and b/emfio/qa/cppunit/emf/data/TestArcInsideWronglyDefinedRectangle.emf differ
diff --git a/tools/source/generic/poly.cxx b/tools/source/generic/poly.cxx
index f4631dfb1d86..8b4727782350 100644
--- a/tools/source/generic/poly.cxx
+++ b/tools/source/generic/poly.cxx
@@ -230,11 +230,14 @@ ImplPolygon::ImplPolygon( const tools::Rectangle& rBound, const Point& rStart, c
     const tools::Long  nWidth = rBound.GetWidth();
     const tools::Long  nHeight = rBound.GetHeight();
 
-    if( ( nWidth > 1 ) && ( nHeight > 1 ) )
+    if( ( nWidth != 0 ) && ( nHeight != 0 ) )
     {
         const Point aCenter( rBound.Center() );
-        const tools::Long  nRadX = aCenter.X() - rBound.Left();
-        const tools::Long  nRadY = aCenter.Y() - rBound.Top();
+        // tdf#142268 Get Top Left corner of rectangle (the rectangle is not always correctly created)
+        const auto aBoundLeft = rBound.Left() < aCenter.X() ? rBound.Left() : rBound.Right();
+        const auto aBoundTop = rBound.Top() < aCenter.Y() ? rBound.Top() : rBound.Bottom();
+        const tools::Long  nRadX = aCenter.X() - aBoundLeft;
+        const tools::Long  nRadY = aCenter.Y() - aBoundTop;
         sal_uInt16  nPoints;
 
         tools::Long nRadXY;


More information about the Libreoffice-commits mailing list