sw/source/core/text/portxt.cxx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
New commits: commit 41d3574263d90f1872ff0bad74618761e84d0f61 Author: László Németh <nem...@numbertext.org> AuthorDate: Tue May 13 18:49:06 2025 +0200 Commit: László Németh <nem...@numbertext.org> CommitDate: Wed May 14 13:46:04 2025 +0200 tdf#126154 sw word spacing: fix greedy shrinking regression Fix failing unit test file:///home/sberg/lo/core//sw/qa/extras/layout/data//tdf126154_minimum_shrinking.fodt: /home/sberg/lo/core/test/source/xmltesttools.cxx:169:(anonymous namespace)::testTdf126154_minimum_shrinking::TestBody equality assertion failed - Expected: ,, , , , , , , , Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vesti bulum - Actual : ,, , , , , , , , Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vesti bulum c - In <>, attribute 'portion' of '/root/page[1]/body/txt[18]/SwParaPortion/SwLineLayout[1]' incorrect value. Regression since commit 01d1037262070ae4ab37868bb47f6ac258433618 "tdf#126154 tdf#149420 tdf#165984 sw: fix hyphenation zones with portions". Notes: Instead of the desired word spacing, an extra shrinking was applied, when minimum and maximum word spacing is specified, despite that there was no hyphenation with the desired word spacing. The first Guess() call is for the original line breaking with 100% word spacing (specified in the font, no shrinking or expanding yet), detecting also the possible space count in the line. The second Guess() call is for both the custom desired and maximum word spacing. The third Guess() call is for the minimum word spacing. No need for the third call, if 1) The desired word spacing is 100% (as in the first Guess() call, and 2) There was no hyphenation in the first Guess() call (minimum word spacing is used only for avoid hyphenation, yet). Change-Id: Ia2e689800f4bdf94512e8b47bc42d6e77c3723ec Reviewed-on: https://gerrit.libreoffice.org/c/core/+/185299 Tested-by: László Németh <nem...@numbertext.org> Reviewed-by: László Németh <nem...@numbertext.org> diff --git a/sw/source/core/text/portxt.cxx b/sw/source/core/text/portxt.cxx index be365fef2d64..df577062e712 100644 --- a/sw/source/core/text/portxt.cxx +++ b/sw/source/core/text/portxt.cxx @@ -420,6 +420,8 @@ bool SwTextPortion::Format_( SwTextFormatInfo &rInf ) } else { + bool bOrigHyphenated = pGuess->HyphWord().is() && + pGuess->BreakPos() > rInf.GetLineStart(); if ( bWordSpacing || bWordSpacingMaximum ) { pGuess.emplace(); @@ -428,7 +430,13 @@ bool SwTextPortion::Format_( SwTextFormatInfo &rInf ) // if both maximum word spacing or minimum word spacing can disable // hyphenation, prefer the last one if ( bWordSpacingMinimum && ( bWordSpacingMaximum || - ( pGuess->HyphWord().is() && pGuess->BreakPos() > rInf.GetLineStart() ) ) ) + ( pGuess->HyphWord().is() && pGuess->BreakPos() > rInf.GetLineStart() ) ) && + // if the desired word spacing is 100% (!bWordSpacing), and it was possible + // to break the line without hyphenation in the first run (where maximum + // word spacing was not used), no need to check minimum word spacing + // FIXME: avoid too much shrinking, if desired word spacing is not 100% + ( bWordSpacing || bOrigHyphenated ) + ) { std::optional<SwTextGuess> pGuess2(std::in_place); SwTwips nOldExtraSpace = rInf.GetExtraSpace();