sw/qa/extras/ooxmlexport/data/tdf153128.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport18.cxx   |   15 +++++++++++++++
 sw/source/core/text/porlay.cxx               |    8 +++++---
 3 files changed, 20 insertions(+), 3 deletions(-)

New commits:
commit ec3691d6d2f38bffcab683865647e6309881d191
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Sat Jan 21 08:04:47 2023 +0300
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Sun Jan 22 08:14:26 2023 +0000

    tdf#153128: do not increase line height, when ignoring whitespace
    
    Since 2006, there is IgnoreTabsAndBlanksForLineCalculation compat flag,
    that handles whitespace-only text portions like in Word, not affecting
    resulting line height.
    
    The implementation, however, did not check if the corrected value is
    no larger than the old one. In the bugdoc, this increased the resulting
    line height.
    
    Change-Id: If855af3e87fd1458d92a36fdbcfa2c681a1075ee
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145919
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>
    (cherry picked from commit c31267e23603c77e3a3335fa431bb9b74448d5b2)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145934
    Tested-by: Mike Kaganski <mike.kagan...@collabora.com>

diff --git a/sw/qa/extras/ooxmlexport/data/tdf153128.docx 
b/sw/qa/extras/ooxmlexport/data/tdf153128.docx
new file mode 100644
index 000000000000..97f08827d956
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf153128.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
index 08add4c0b7d7..16900a7b3a18 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx
@@ -281,6 +281,21 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf153104)
     assertXPath(pXmlNum, numPath + 
"w:lvlOverride[@w:ilvl='1']/w:startOverride", "val", "1");
 }
 
+CPPUNIT_TEST_FIXTURE(Test, testTdf153128)
+{
+    loadAndReload("tdf153128.docx");
+    calcLayout();
+    sal_Int32 nFirstLineHeight
+        = 
parseDump("/root/page/body/txt[1]/SwParaPortion/SwLineLayout/SwParaPortion", 
"height")
+              .toInt32();
+    CPPUNIT_ASSERT_GREATER(sal_Int32(0), nFirstLineHeight);
+
+    // The text height is 1 pt, i.e. 20 twip; without the fix, it would fail 
with
+    // - Expected less than: 30
+    // - Actual  : 414
+    CPPUNIT_ASSERT_LESS(sal_Int32(30), nFirstLineHeight);
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/text/porlay.cxx b/sw/source/core/text/porlay.cxx
index 8705ac6ecbd1..65f2b4de3bae 100644
--- a/sw/source/core/text/porlay.cxx
+++ b/sw/source/core/text/porlay.cxx
@@ -653,14 +653,16 @@ void SwLineLayout::CalcLine( SwTextFormatter &rLine, 
SwTextFormatInfo &rInf )
         }
     }
 
-    // #i3952#
+    // #i3952# Whitespace does not increase line height
     if ( bHasBlankPortion && bHasOnlyBlankPortions )
     {
         sal_uInt16 nTmpAscent = GetAscent();
         sal_uInt16 nTmpHeight = Height();
         rLine.GetAttrHandler().GetDefaultAscentAndHeight( rInf.GetVsh(), 
*rInf.GetOut(), nTmpAscent, nTmpHeight );
-        SetAscent( nTmpAscent );
-        Height( nTmpHeight, false );
+        if (nTmpAscent < GetAscent() || GetAscent() <= 0)
+            SetAscent(nTmpAscent);
+        if (nTmpHeight < Height() || Height() <= 0)
+            Height(nTmpHeight, false);
     }
 
     // Robust:

Reply via email to