From e9d927b0a0ab56a7abdb7afad3c0fcc0c0c51e44 Mon Sep 17 00:00:00 2001 From: Regina Henschel Date: Thu, 16 Dec 2021 19:47:05 +0100 Subject: 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 (cherry picked from commit b9c159361abd79862b30412c433fb355d63299e2) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126969 Reviewed-by: Xisco Fauli --- svx/qa/unit/customshapes.cxx | 48 +++++++++++++++++++++++ svx/qa/unit/data/tdf145904_center_Zminus2000.odt | Bin 0 -> 9602 bytes svx/qa/unit/data/tdf145956_Origin.odp | Bin 0 -> 28073 bytes 3 files changed, 48 insertions(+) create mode 100644 svx/qa/unit/data/tdf145904_center_Zminus2000.odt create mode 100644 svx/qa/unit/data/tdf145956_Origin.odp (limited to 'svx') 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 xShape(getShape(0)); + uno::Reference 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 xShape(getShape(0)); + uno::Reference 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 Binary files /dev/null and b/svx/qa/unit/data/tdf145904_center_Zminus2000.odt 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 Binary files /dev/null and b/svx/qa/unit/data/tdf145956_Origin.odp differ -- cgit