From 64bacd4f2bd9c8e10e8c9a0b7d18516c77260df3 Mon Sep 17 00:00:00 2001 From: Regina Henschel Date: Fri, 15 Oct 2021 02:00:30 +0200 Subject: tdf#145111 evaluate nVertDiff for HORZADJUST_LEFT too In case of ScaleX=true in property TextPath, SDRTEXTVERTADJUST is evaluated and should shift the Fontwork text. That did not work for 'LeftTop' and 'LeftBottom'. Error was that in case of SDRTEXTHORZADJUST_LEFT the vertical shift was not considered. Change-Id: I4edb47515c4bf40e17b4054c3a10220df8468028 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123613 Tested-by: Jenkins Reviewed-by: Regina Henschel --- svx/qa/unit/customshapes.cxx | 38 ++++++++++++++++++++++++++ svx/qa/unit/data/tdf145111_TL_BL_Fontwork.odp | Bin 0 -> 13908 bytes 2 files changed, 38 insertions(+) create mode 100644 svx/qa/unit/data/tdf145111_TL_BL_Fontwork.odp (limited to 'svx/qa') diff --git a/svx/qa/unit/customshapes.cxx b/svx/qa/unit/customshapes.cxx index c2d30cef2c0b..5c4ea6914288 100644 --- a/svx/qa/unit/customshapes.cxx +++ b/svx/qa/unit/customshapes.cxx @@ -127,6 +127,44 @@ void lcl_AssertRectEqualWithTolerance(std::string_view sInfo, const tools::Recta std::abs(rExpected.GetHeight() - rActual.GetHeight()) <= nTolerance); } +CPPUNIT_TEST_FIXTURE(CustomshapesTest, testTdf145111_anchor_in_Fontwork) +{ + // The tested positions depend on dpi. + if (!IsDefaultDPI()) + return; + + // tdf#145004 In case ScaleX is true in property TextPath, SDRTEXTVERTADJUST is + // evaluated and should shift the Fontwork text. That did not work for + // 'Top-Left' and 'Bottom-Left'. + + // Load document + OUString aURL = m_directories.getURLFromSrc(sDataDirectory) + "tdf145111_TL_BL_Fontwork.odp"; + mxComponent = loadFromDesktop(aURL, "com.sun.star.comp.presentation.PresentationDocument"); + + { + // First shape has anchor set to Top-Left, which shifts Fontwork text down. + uno::Reference xShape(getShape(0)); + SdrObjCustomShape& rSdrCustomShape( + static_cast(*SdrObject::getSdrObjectFromXShape(xShape))); + + // Without the fix in place top was 2295, but should be 2916 for 96dpi. + // Was 2184, should be 2886 for 120dpi. + tools::Rectangle aBoundRect(rSdrCustomShape.GetCurrentBoundRect()); + CPPUNIT_ASSERT_DOUBLES_EQUAL(tools::Long(2916), aBoundRect.Top(), 5); + } + { + // Second shape has anchor set to Bottom-Left, which shifts Fontwork text up. + uno::Reference xShape(getShape(1)); + SdrObjCustomShape& rSdrCustomShape( + static_cast(*SdrObject::getSdrObjectFromXShape(xShape))); + + // Without the fix in place top was 10294, but should be 9519 for 96dpi. + // Was 10184, should be 9481 for 120dpi. + tools::Rectangle aBoundRect(rSdrCustomShape.GetCurrentBoundRect()); + CPPUNIT_ASSERT_DOUBLES_EQUAL(tools::Long(9519), aBoundRect.Top(), 5); + } +} + CPPUNIT_TEST_FIXTURE(CustomshapesTest, testTdf145004_gap_by_ScaleX) { if (!IsDefaultDPI()) diff --git a/svx/qa/unit/data/tdf145111_TL_BL_Fontwork.odp b/svx/qa/unit/data/tdf145111_TL_BL_Fontwork.odp new file mode 100644 index 000000000000..257023cfad0a Binary files /dev/null and b/svx/qa/unit/data/tdf145111_TL_BL_Fontwork.odp differ -- cgit