diff options
author | Regina Henschel <rb.henschel@t-online.de> | 2021-12-16 19:47:05 +0100 |
---|---|---|
committer | Xisco Fauli <xiscofauli@libreoffice.org> | 2021-12-17 11:57:06 +0100 |
commit | e9d927b0a0ab56a7abdb7afad3c0fcc0c0c51e44 (patch) | |
tree | e9b7d4d257e99f67b16dacdf22f17bd5c9552b94 /svx | |
parent | f4ba4c014c74d1735288fe356878d6a2effab21f (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>
(cherry picked from commit b9c159361abd79862b30412c433fb355d63299e2)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126969
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'svx')
-rw-r--r-- | svx/qa/unit/customshapes.cxx | 48 | ||||
-rw-r--r-- | svx/qa/unit/data/tdf145904_center_Zminus2000.odt | bin | 0 -> 9602 bytes | |||
-rw-r--r-- | svx/qa/unit/data/tdf145956_Origin.odp | bin | 0 -> 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 Binary files differnew file mode 100644 index 000000000000..9a19f4cbdd6a --- /dev/null +++ b/svx/qa/unit/data/tdf145904_center_Zminus2000.odt diff --git a/svx/qa/unit/data/tdf145956_Origin.odp b/svx/qa/unit/data/tdf145956_Origin.odp Binary files differnew file mode 100644 index 000000000000..7bba1dadd8e7 --- /dev/null +++ b/svx/qa/unit/data/tdf145956_Origin.odp |