diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2023-01-21 08:04:47 +0300 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2023-01-21 11:38:14 +0000 |
commit | c31267e23603c77e3a3335fa431bb9b74448d5b2 (patch) | |
tree | 37dfc4a283241d89a6a54a5257ec88acc5eefc30 | |
parent | 6b6d1dc7bc402d1d966e506b91729c1c1cafb8d1 (diff) |
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.kaganski@collabora.com>
-rw-r--r-- | sw/qa/extras/ooxmlexport/data/tdf153128.docx | bin | 0 -> 13425 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport18.cxx | 15 | ||||
-rw-r--r-- | sw/source/core/text/porlay.cxx | 8 |
3 files changed, 20 insertions, 3 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/tdf153128.docx b/sw/qa/extras/ooxmlexport/data/tdf153128.docx Binary files differnew file mode 100644 index 000000000000..97f08827d956 --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/tdf153128.docx 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: |