diff options
author | Regina Henschel <rb.henschel@t-online.de> | 2021-10-15 02:00:30 +0200 |
---|---|---|
committer | Regina Henschel <rb.henschel@t-online.de> | 2021-10-16 01:15:21 +0200 |
commit | 64bacd4f2bd9c8e10e8c9a0b7d18516c77260df3 (patch) | |
tree | f13526beee4e497da859e0be41e4f6378d73bf25 /svx | |
parent | 7a001d3706bee453db46fb38c80c17bb84fda4af (diff) |
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 <rb.henschel@t-online.de>
Diffstat (limited to 'svx')
-rw-r--r-- | svx/qa/unit/customshapes.cxx | 38 | ||||
-rw-r--r-- | svx/qa/unit/data/tdf145111_TL_BL_Fontwork.odp | bin | 0 -> 13908 bytes | |||
-rw-r--r-- | svx/source/customshapes/EnhancedCustomShapeFontWork.cxx | 2 |
3 files changed, 39 insertions, 1 deletions
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<drawing::XShape> xShape(getShape(0)); + SdrObjCustomShape& rSdrCustomShape( + static_cast<SdrObjCustomShape&>(*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<drawing::XShape> xShape(getShape(1)); + SdrObjCustomShape& rSdrCustomShape( + static_cast<SdrObjCustomShape&>(*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 Binary files differnew file mode 100644 index 000000000000..257023cfad0a --- /dev/null +++ b/svx/qa/unit/data/tdf145111_TL_BL_Fontwork.odp diff --git a/svx/source/customshapes/EnhancedCustomShapeFontWork.cxx b/svx/source/customshapes/EnhancedCustomShapeFontWork.cxx index 669a855388cf..56f67fcb0c89 100644 --- a/svx/source/customshapes/EnhancedCustomShapeFontWork.cxx +++ b/svx/source/customshapes/EnhancedCustomShapeFontWork.cxx @@ -493,7 +493,7 @@ static bool GetFontWorkOutline( else if ( eHorzAdjust == SDRTEXTHORZADJUST_RIGHT ) nHorzDiff = ( rFWData.fHorizontalTextScaling * rTextArea.aBoundRect.GetWidth() - rParagraph.aBoundRect.GetWidth() ); - if (nHorzDiff) + if (nHorzDiff || nVertDiff) { for ( auto& rCharacter : rParagraph.vCharacters ) { |