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 39369c6e67dffe04acc4abb678c1a94526237fd8
Author:     Bartosz Kosiorek <gan...@poczta.onet.pl>
AuthorDate: Tue May 18 17:36:21 2021 +0200
Commit:     Bartosz Kosiorek <gan...@poczta.onet.pl>
CommitDate: Tue May 18 20:42:27 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 <gan...@poczta.onet.pl>

diff --git a/emfio/qa/cppunit/emf/EmfImportTest.cxx 
b/emfio/qa/cppunit/emf/EmfImportTest.cxx
index fceb43b30215..64c7effa1baa 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 TestArcInsideWronglyDefinedRectangle();
     void TestChordWithModifyWorldTransform();
     void TestEllipseWithSelectClipPath();
     void TestEllipseXformIntersectClipRect();
@@ -81,6 +82,7 @@ public:
     CPPUNIT_TEST(TestTextMapMode);
     CPPUNIT_TEST(TestEnglishMapMode);
     CPPUNIT_TEST(TestRectangleWithModifyWorldTransform);
+    CPPUNIT_TEST(TestArcInsideWronglyDefinedRectangle);
     CPPUNIT_TEST(TestChordWithModifyWorldTransform);
     CPPUNIT_TEST(TestEllipseWithSelectClipPath);
     CPPUNIT_TEST(TestEllipseXformIntersectClipRect);
@@ -360,6 +362,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,1460 1800,1530 
1850,1540 1980,1540 2030,1530 2170,1470 2220,1440 2330,1330 2380,1240 2420,1140 
2430,1060 2430,950 2420,930 2410,870 2410,850 2380,770 2290,640 2120,520 
2090,510 2070,510 2040,500 2020,490 1970,480 1860,480 1760,500 1670,540 
1600,580 1520,660 1510,680 1480,720 1460,740 1450,760");
+}
+
 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 292247478aac..88a534660894 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 auto nWidth = rBound.GetWidth();
     const auto nHeight = rBound.GetHeight();
 
-    if( ( nWidth > 1 ) && ( nHeight > 1 ) )
+    if( ( nWidth != 0 ) && ( nHeight != 0 ) )
     {
         const Point aCenter( rBound.Center() );
-        const auto nRadX = o3tl::saturating_sub(aCenter.X(), rBound.Left());
-        const auto nRadY = o3tl::saturating_sub(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 auto nRadX = o3tl::saturating_sub(aCenter.X(), aBoundLeft);
+        const auto nRadY = o3tl::saturating_sub(aCenter.Y(), aBoundTop);
         sal_uInt16  nPoints;
 
         tools::Long nRadXY;
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to