svx/qa/unit/customshapes.cxx                            |   38 ++++++++++++++++
 svx/qa/unit/data/tdf145111_TL_BL_Fontwork.odp           |binary
 svx/source/customshapes/EnhancedCustomShapeFontWork.cxx |    2 
 3 files changed, 39 insertions(+), 1 deletion(-)

New commits:
commit 64bacd4f2bd9c8e10e8c9a0b7d18516c77260df3
Author:     Regina Henschel <rb.hensc...@t-online.de>
AuthorDate: Fri Oct 15 02:00:30 2021 +0200
Commit:     Regina Henschel <rb.hensc...@t-online.de>
CommitDate: Sat Oct 16 01:15:21 2021 +0200

    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.hensc...@t-online.de>

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
new file mode 100644
index 000000000000..257023cfad0a
Binary files /dev/null and b/svx/qa/unit/data/tdf145111_TL_BL_Fontwork.odp 
differ
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 )
                     {

Reply via email to