svx/qa/unit/customshapes.cxx                            |   22 ++++++++++++++++
 svx/qa/unit/data/tdf145004_gap_by_ScaleX.pptx           |binary
 svx/source/customshapes/EnhancedCustomShapeFontWork.cxx |    3 --
 3 files changed, 22 insertions(+), 3 deletions(-)

New commits:
commit 4e1f5b5eaddac6ff4b3028074edc8f6886d64c3f
Author:     Regina Henschel <rb.hensc...@t-online.de>
AuthorDate: Fri Oct 8 22:10:35 2021 +0200
Commit:     Regina Henschel <rb.hensc...@t-online.de>
CommitDate: Wed Oct 13 13:27:58 2021 +0200

    tdf#145004 remove fontwork text padding for case ScaleX=true
    
    The setting ScaleX=true in property TextPath in CustomShapeGeometry
    is used in import of WortArt of kind 'Follow Path' from MS Office. The
    value 'true' means, that the text is not stretched to the path but its
    original font size is used as long as enough place is available.
    
    The method CalculateHorizontalScalingFactor() has increased the
    scaling factor by 10 percent to make a 'padding'. That results in a
    too short text and a gap at start and/or end. The problem is not only
    visible in imported shapes but in user designed Fontwork shapes too.
    PowerPoint has no 'padding'. Currently our own preset Fontwork shapes
    always use ScaleX=false and therefore are not affected.
    
    I have not found any reason for such padding. So this patch removes it.
    
    Change-Id: I7f2c4eb9101be1f13b006d4178ffbe75eb4ed55a
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123295
    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 57ef2ade4b8e..c2d30cef2c0b 100644
--- a/svx/qa/unit/customshapes.cxx
+++ b/svx/qa/unit/customshapes.cxx
@@ -127,6 +127,28 @@ void lcl_AssertRectEqualWithTolerance(std::string_view 
sInfo, const tools::Recta
                            std::abs(rExpected.GetHeight() - 
rActual.GetHeight()) <= nTolerance);
 }
 
+CPPUNIT_TEST_FIXTURE(CustomshapesTest, testTdf145004_gap_by_ScaleX)
+{
+    if (!IsDefaultDPI())
+        return;
+    // tdf#145004 In case property ScaleX=true was set in property 'TextPath' 
an additional
+    // padding was added to the scaling factor. That results in a gap at start 
or/and end of
+    // the text. Such gap should not be there.
+
+    // Load document and get shape. It is a custom shape from pptx import of a 
WordArt of
+    // kind 'Follow Path'.
+    OUString aURL = m_directories.getURLFromSrc(sDataDirectory) + 
"tdf145004_gap_by_ScaleX.pptx";
+    mxComponent = loadFromDesktop(aURL, 
"com.sun.star.comp.presentation.PresentationDocument");
+    uno::Reference<drawing::XShape> xShape(getShape(0));
+    SdrObjCustomShape& rSdrCustomShape(
+        
static_cast<SdrObjCustomShape&>(*SdrObject::getSdrObjectFromXShape(xShape)));
+
+    // Verify width. Without the fix in place the width was 8231, but should 
be 8496 for 96dpi.
+    // Was 8328, should be 8527 for 120dpi.
+    tools::Rectangle aBoundRect(rSdrCustomShape.GetCurrentBoundRect());
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(tools::Long(8496), aBoundRect.GetWidth(), 5);
+}
+
 CPPUNIT_TEST_FIXTURE(CustomshapesTest, testTdf141021ExtrusionNorth)
 {
     // tdf#141021 Setting extrusion direction in projection method 
'perspective' to
diff --git a/svx/qa/unit/data/tdf145004_gap_by_ScaleX.pptx 
b/svx/qa/unit/data/tdf145004_gap_by_ScaleX.pptx
new file mode 100644
index 000000000000..900a89675e2a
Binary files /dev/null and b/svx/qa/unit/data/tdf145004_gap_by_ScaleX.pptx 
differ
diff --git a/svx/source/customshapes/EnhancedCustomShapeFontWork.cxx 
b/svx/source/customshapes/EnhancedCustomShapeFontWork.cxx
index 839c09f6143b..669a855388cf 100644
--- a/svx/source/customshapes/EnhancedCustomShapeFontWork.cxx
+++ b/svx/source/customshapes/EnhancedCustomShapeFontWork.cxx
@@ -242,9 +242,6 @@ static void CalculateHorizontalScalingFactor(
 
     if (nFontSize > 1)
         rFWData.fVerticalTextScaling = static_cast<double>(nFontSize) / 
rFontHeight.GetHeight();
-    // Add some padding
-    if (rFWData.bScaleX)
-        fScalingFactor *= 1.1;
 
     rFWData.fHorizontalTextScaling = fScalingFactor;
 }

Reply via email to