diff options
author | László Németh <nemeth@numbertext.org> | 2023-12-04 15:33:14 +0100 |
---|---|---|
committer | László Németh <nemeth@numbertext.org> | 2023-12-04 21:41:04 +0100 |
commit | 7059a1858ddb044c5f3f0c8e0386d3e1d9dd2b5f (patch) | |
tree | a22b989f61187ba6dc58bc6ca53b18e45972f67c /sw | |
parent | 5b4a705f7477da2b546d0658e46e96f4e69017e4 (diff) |
tdf#119908 tdf#158439 sw smart justify: fix freezing with NBSP
Stop shrinking during underflow, because it resulted
endless layout loop, e.g. when a very short word followed
by a no-break space.
Regression from commit 7d08767b890e723cd502b1c61d250924f695eb98
"tdf#130088 tdf#119908 smart justify: fix DOCX line count + compat opt."
Change-Id: Id832b7fdbc01453a30067995e14e5430b0a15232
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160316
Tested-by: László Németh <nemeth@numbertext.org>
Reviewed-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/qa/extras/ooxmlexport/data/tdf158436.docx | bin | 0 -> 12243 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport14.cxx | 6 | ||||
-rw-r--r-- | sw/source/core/text/guess.cxx | 5 |
3 files changed, 10 insertions, 1 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/tdf158436.docx b/sw/qa/extras/ooxmlexport/data/tdf158436.docx Binary files differnew file mode 100644 index 000000000000..8cdcd21b4c1a --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/tdf158436.docx diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx index d9ef6b8a48d0..0656bb868795 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx @@ -1408,6 +1408,12 @@ DECLARE_OOXMLEXPORT_TEST(testTdf130088, "tdf130088.docx") CPPUNIT_ASSERT_EQUAL(1, getPages()); } +DECLARE_OOXMLEXPORT_TEST(testTdf158436, "tdf158436.docx") +{ + // This resulted freezing + CPPUNIT_ASSERT_EQUAL(1, getPages()); +} + CPPUNIT_TEST_FIXTURE(Test, testHyphenationAuto) { loadAndReload("hyphenation.odt"); diff --git a/sw/source/core/text/guess.cxx b/sw/source/core/text/guess.cxx index 5e66b366c63f..37a2147d0987 100644 --- a/sw/source/core/text/guess.cxx +++ b/sw/source/core/text/guess.cxx @@ -82,7 +82,10 @@ bool SwTextGuess::Guess( const SwTextPortion& rPor, SwTextFormatInfo &rInf, // allow shrinking, i.e. more text in justified lines, depending on the justification algorithm if ( rAdjust == SvxAdjust::Block && rInf.GetTextFrame()->GetDoc().getIDocumentSettingAccess().get( - DocumentSettingId::JUSTIFY_LINES_WITH_SHRINKING)) + DocumentSettingId::JUSTIFY_LINES_WITH_SHRINKING) && + // tdf#158436 avoid shrinking at underflow, e.g. no-break space + // after a very short word resulted endless loop + !rInf.IsUnderflow() ) { // allow up to 2% shrinking of the line nLineWidth = nLineWidth / 0.98 + rInf.X() / 0.98 - rInf.X(); |