summaryrefslogtreecommitdiff
path: root/svx/qa
diff options
context:
space:
mode:
authorRegina Henschel <rb.henschel@t-online.de>2020-06-07 23:54:20 +0200
committerRegina Henschel <rb.henschel@t-online.de>2020-06-08 13:36:06 +0200
commit91f06123298bb8870cd6fa4e19d3aea9909f8e5b (patch)
treeb0656191fafdd1184227ace31c21c11fd9be1e7d /svx/qa
parent1027f7a0e1c10d957de34e27af16a4d0e825ffb2 (diff)
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@t-online.de>
Diffstat (limited to 'svx/qa')
-rw-r--r--svx/qa/unit/customshapes.cxx33
-rw-r--r--svx/qa/unit/data/tdf103474_commandT_CaseZeroHeight.odpbin0 -> 12833 bytes
2 files changed, 33 insertions, 0 deletions
diff --git a/svx/qa/unit/customshapes.cxx b/svx/qa/unit/customshapes.cxx
index ce2f06c42bfe..3a422fce3687 100644
--- a/svx/qa/unit/customshapes.cxx
+++ b/svx/qa/unit/customshapes.cxx
@@ -663,6 +663,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
--- /dev/null
+++ b/svx/qa/unit/data/tdf103474_commandT_CaseZeroHeight.odp
Binary files differ