From c31267e23603c77e3a3335fa431bb9b74448d5b2 Mon Sep 17 00:00:00 2001 From: Mike Kaganski Date: Sat, 21 Jan 2023 08:04:47 +0300 Subject: 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 --- sw/qa/extras/ooxmlexport/data/tdf153128.docx | Bin 0 -> 13425 bytes sw/qa/extras/ooxmlexport/ooxmlexport18.cxx | 15 +++++++++++++++ sw/source/core/text/porlay.cxx | 8 +++++--- 3 files changed, 20 insertions(+), 3 deletions(-) create mode 100644 sw/qa/extras/ooxmlexport/data/tdf153128.docx 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 5328c19081fb..e27a1f085b11 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx @@ -294,6 +294,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: -- cgit