[Libreoffice-commits] core.git: Branch 'libreoffice-7-0' - svx/qa svx/source

Regina Henschel (via logerrit) logerrit at kemper.freedesktop.org
Wed Jun 10 19:53:27 UTC 2020


 svx/qa/unit/customshapes.cxx                           |   33 +++++++++++++++++
 svx/qa/unit/data/tdf103474_commandT_CaseZeroHeight.odp |binary
 svx/source/customshapes/EnhancedCustomShape2d.cxx      |    2 +
 3 files changed, 35 insertions(+)

New commits:
commit a7eef5557060504e6e185e8cd8d9acaf6431cd16
Author:     Regina Henschel <rb.henschel at t-online.de>
AuthorDate: Sun Jun 7 23:54:20 2020 +0200
Commit:     Xisco Fauli <xiscofauli at libreoffice.org>
CommitDate: Wed Jun 10 21:52:56 2020 +0200

    tdf#103474 handle quarter angles before using atan2
    
    sin(basegfx::deg2rad(fEAngleDeg)) does not result in 0 for
    fEAngleDeg=180 because of rounding errors and therefore
    atan2 later in the code gives wrong angle.
    Because the corresponding circle angle is the same as the ellipse
    angle for 0°, 90°, 180° and 270°, these angles are now handled
    before using atan2.
    
    Change-Id: Iae2a4d188b837ff787f2af4d79f874ba21c9aa2f
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95772
    Tested-by: Jenkins
    Reviewed-by: Regina Henschel <rb.henschel at t-online.de>
    (cherry picked from commit 91f06123298bb8870cd6fa4e19d3aea9909f8e5b)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95819
    Reviewed-by: Xisco Fauli <xiscofauli at libreoffice.org>

diff --git a/svx/qa/unit/customshapes.cxx b/svx/qa/unit/customshapes.cxx
index a21652113ef8..b99bc0c1d576 100644
--- a/svx/qa/unit/customshapes.cxx
+++ b/svx/qa/unit/customshapes.cxx
@@ -671,6 +671,39 @@ CPPUNIT_TEST_FIXTURE(CustomshapesTest, testTdf129532_MatrixFlipV)
     }
     CPPUNIT_ASSERT_EQUAL(OUString(), sErrors);
 }
+
+CPPUNIT_TEST_FIXTURE(CustomshapesTest, testTdf103474_commandT_CaseZeroHeight)
+{
+    // tdf103474 custom shape with command T to create quater ellipses in a bracket,
+    // corner case where the ellipse has zero height.
+    // Error was, that the calculation of the circle angle from the ellipse
+    // angle results in a wrong angle for the case 180° and height zero.
+    const OUString sFileName("tdf103474_commandT_CaseZeroHeight.odp");
+    OUString sURL = m_directories.getURLFromSrc(sDataDirectory) + sFileName;
+    mxComponent = loadFromDesktop(sURL, "com.sun.star.comp.presentation.PresentationDocument");
+    CPPUNIT_ASSERT_MESSAGE("Could not load document", mxComponent.is());
+    uno::Reference<drawing::XShape> xShape(getShape(0));
+    // The end points of the straight line segment should have the same x-coordinate of left
+    // of shape, and different y-coordinates, one top and the other bottom of the shape.
+    SdrObjCustomShape& rSdrObjCustomShape(
+        static_cast<SdrObjCustomShape&>(*GetSdrObjectFromXShape(xShape)));
+    EnhancedCustomShape2d aCustomShape2d(rSdrObjCustomShape);
+    SdrPathObj* pPathObj = static_cast<SdrPathObj*>(aCustomShape2d.CreateLineGeometry());
+    CPPUNIT_ASSERT_MESSAGE("Could not convert to SdrPathObj", pPathObj);
+    const basegfx::B2DPolyPolygon aPolyPolygon(pPathObj->GetPathPoly());
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("count polygons", static_cast<sal_uInt32>(1),
+                                 aPolyPolygon.count());
+    const basegfx::B2DPolygon aPolygon(aPolyPolygon.getB2DPolygon(0));
+    // Get the middle points of the polygon. They are the endpoints of the
+    // straight line segment regardless of the quarter ellipse parts, because
+    // the shape is symmetric.
+    const basegfx::B2DPoint aStart(aPolygon.getB2DPoint(aPolygon.count() / 2 - 1));
+    const basegfx::B2DPoint aEnd(aPolygon.getB2DPoint(aPolygon.count() / 2));
+    CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("aStart x-coordinate", 13999.0, aStart.getX(), 1.0);
+    CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("aEnd x-coordinate", 13999.0, aEnd.getX(), 1.0);
+    CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("aStart y-coordinate", 9999.0, aStart.getY(), 1.0);
+    CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("aEnd y-coordinate", 1999.0, aEnd.getY(), 1.0);
+}
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/qa/unit/data/tdf103474_commandT_CaseZeroHeight.odp b/svx/qa/unit/data/tdf103474_commandT_CaseZeroHeight.odp
new file mode 100644
index 000000000000..54a4377cab8f
Binary files /dev/null and b/svx/qa/unit/data/tdf103474_commandT_CaseZeroHeight.odp differ
diff --git a/svx/source/customshapes/EnhancedCustomShape2d.cxx b/svx/source/customshapes/EnhancedCustomShape2d.cxx
index 7bf8383ab8f6..8b570edd809e 100644
--- a/svx/source/customshapes/EnhancedCustomShape2d.cxx
+++ b/svx/source/customshapes/EnhancedCustomShape2d.cxx
@@ -1997,6 +1997,8 @@ static double lcl_getNormalizedCircleAngleRad(const double fWR, const double fHR
     double fEAngleDeg(fmod(fEllipseAngleDeg, 360.0));
     if (fEAngleDeg < 0.0)
         fEAngleDeg += 360.0;
+    if (fEAngleDeg == 0.0 || fEAngleDeg == 90.0 || fEAngleDeg == 180.0 || fEAngleDeg == 270.0)
+        return basegfx::deg2rad(fEAngleDeg);
     const double fX(fHR * cos(basegfx::deg2rad(fEAngleDeg)));
     const double fY(fWR * sin(basegfx::deg2rad(fEAngleDeg)));
     if (fX != 0.0 || fY != 0.0)


More information about the Libreoffice-commits mailing list