summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRegina Henschel <rb.henschel@t-online.de>2021-12-16 19:47:05 +0100
committerRegina Henschel <rb.henschel@t-online.de>2021-12-17 01:32:38 +0100
commitb9c159361abd79862b30412c433fb355d63299e2 (patch)
treed8865fa2a2bb04935ed0775aa40729cc51661e84
parentdc54785f153a7fe8fecc1e21b0ef7c6549e2d0d0 (diff)
tdf#145904,tdf#145956 unit test extrusion of shapes
These tests belongs to commit 453c5b6, improve extrusion of custom shapes. Change-Id: I3b89a887d72b6814540a659dfa088f1550a1d47b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126962 Tested-by: Jenkins Reviewed-by: Regina Henschel <rb.henschel@t-online.de>
-rw-r--r--svx/qa/unit/customshapes.cxx48
-rw-r--r--svx/qa/unit/data/tdf145904_center_Zminus2000.odtbin0 -> 9602 bytes
-rw-r--r--svx/qa/unit/data/tdf145956_Origin.odpbin0 -> 28073 bytes
3 files changed, 48 insertions, 0 deletions
diff --git a/svx/qa/unit/customshapes.cxx b/svx/qa/unit/customshapes.cxx
index 84a18fc77b4d..ca6ece320afa 100644
--- a/svx/qa/unit/customshapes.cxx
+++ b/svx/qa/unit/customshapes.cxx
@@ -127,6 +127,54 @@ void lcl_AssertRectEqualWithTolerance(std::string_view sInfo, const tools::Recta
std::abs(rExpected.GetHeight() - rActual.GetHeight()) <= nTolerance);
}
+CPPUNIT_TEST_FIXTURE(CustomshapesTest, testTdf145956_Origin_Relative_BoundRect)
+{
+ // The ViewPoint is relative to point Origin. The coordinates of point Origin are fractions of
+ // the actual (2D) bounding rectangle of the shape, including rotation around z-axis and flip.
+ // Error (among others) was, that the unrotated snap rectangle was used.
+
+ // Load document
+ OUString aURL = m_directories.getURLFromSrc(sDataDirectory) + "tdf145956_Origin.odp";
+ mxComponent = loadFromDesktop(aURL, "com.sun.star.presentation.PresentationDocument");
+
+ // The shape is extruded with 10cm. viewpoint="(0cm 0cm 25cm)", origin="0 0".
+ uno::Reference<drawing::XShape> xShape(getShape(0));
+ uno::Reference<beans::XPropertySet> xPropSet(xShape, uno::UNO_QUERY);
+ CPPUNIT_ASSERT_MESSAGE("Could not get the properties", xPropSet.is());
+ awt::Rectangle aBoundRect;
+ xPropSet->getPropertyValue(UNO_NAME_MISC_OBJ_BOUNDRECT) >>= aBoundRect;
+ sal_Int32 nActualTop = aBoundRect.Y;
+
+ // Without the fix it would have failed with top = 9462.
+ // The tolerance 10 is estimated and can be adjusted if required for HiDPI.
+ CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("top", 10448, nActualTop, 10);
+}
+
+CPPUNIT_TEST_FIXTURE(CustomshapesTest, testTdf145904_Extrusion_CenterZ_odt)
+{
+ // The Z-component of the extrusion rotation center specifies the position in Hmm.
+ // Error (among others) was, that the value was interpreted as Twips.
+
+ // Load document
+ OUString aURL = m_directories.getURLFromSrc(sDataDirectory) + "tdf145904_center_Zminus2000.odt";
+ mxComponent = loadFromDesktop(aURL, "com.sun.star.text.TextDocument");
+
+ // The shape is extruded and tilt left 60deg. The rotation center is at -2000Hmm on the z-axis.
+ // That is a position behind the back face of the extruded shape.
+ uno::Reference<drawing::XShape> xShape(getShape(0));
+ uno::Reference<beans::XPropertySet> xPropSet(xShape, uno::UNO_QUERY);
+ CPPUNIT_ASSERT_MESSAGE("Could not get the properties", xPropSet.is());
+ awt::Rectangle aBoundRect;
+ xPropSet->getPropertyValue(UNO_NAME_MISC_OBJ_BOUNDRECT) >>= aBoundRect;
+ awt::Point aAnchorPosition;
+ xPropSet->getPropertyValue("AnchorPosition") >>= aAnchorPosition;
+ sal_Int32 nActualLeft = aBoundRect.X - aAnchorPosition.X;
+
+ // Without the fix it would have failed with left = 7731.
+ // The tolerance 10 is estimated and can be adjusted if required for HiDPI.
+ CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("left", 3501, nActualLeft, 10);
+}
+
CPPUNIT_TEST_FIXTURE(CustomshapesTest, testTdf145904_Extrusion_CenterY_odt)
{
// The X- and Y-component of the extrusion rotation center specify the position as fraction of
diff --git a/svx/qa/unit/data/tdf145904_center_Zminus2000.odt b/svx/qa/unit/data/tdf145904_center_Zminus2000.odt
new file mode 100644
index 000000000000..9a19f4cbdd6a
--- /dev/null
+++ b/svx/qa/unit/data/tdf145904_center_Zminus2000.odt
Binary files differ
diff --git a/svx/qa/unit/data/tdf145956_Origin.odp b/svx/qa/unit/data/tdf145956_Origin.odp
new file mode 100644
index 000000000000..7bba1dadd8e7
--- /dev/null
+++ b/svx/qa/unit/data/tdf145956_Origin.odp
Binary files differ