sw/source/core/text/porfld.cxx | 45 +++++++++++++++++++++++++---------------- 1 file changed, 28 insertions(+), 17 deletions(-)
New commits: commit 10abf111105537e1f400600edc2995ded23aed2d Author: Michael Stahl <michael.st...@allotropia.de> AuthorDate: Mon May 15 17:13:37 2023 +0200 Commit: Michael Stahl <michael.st...@allotropia.de> CommitDate: Mon May 15 19:10:52 2023 +0200 sw: fix crashtesting assert on ooo34309-3.odt frmpaint.cxx:804: SwTextFrame::PaintSwFrame: Assertion `!oTaggedLabel' failed. This is even more special, the numbering contains a ' ' space followed by '\t' tab and the space becomes a hook-char and then somehow disappears completely, while the tab becomes a SwTabLeftPortion. So SwFieldPortion::Format() needs to predict that 2 of the SwNumberingPortion follows will be deleted by hook-char magic. (regression from commit 9b38beadf9eaf027b201cdf0ecb2bce5611014dd) Change-Id: Ica2b303f7f098c2b85720d7ae7c5c7bbf078e1b1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151800 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.st...@allotropia.de> diff --git a/sw/source/core/text/porfld.cxx b/sw/source/core/text/porfld.cxx index 1ef148b20a40..6142b0e9539b 100644 --- a/sw/source/core/text/porfld.cxx +++ b/sw/source/core/text/porfld.cxx @@ -390,25 +390,35 @@ bool SwFieldPortion::Format( SwTextFormatInfo &rInf ) // These characters should not be contained in the follow // field portion. They are handled via the HookChar mechanism. const sal_Unicode nNew = !aNew.isEmpty() ? aNew[0] : 0; - switch (nNew) + auto IsHook = [](const sal_Unicode cNew) -> bool { - case CH_BREAK : bFull = true; - [[fallthrough]]; - case ' ' : - case CH_TAB : - case CHAR_HARDHYPHEN: // non-breaking hyphen - case CHAR_SOFTHYPHEN: - case CHAR_HARDBLANK: - case CHAR_ZWSP : - case CHAR_WJ : - case CH_TXTATR_BREAKWORD: - case CH_TXTATR_INWORD: + switch (cNew) { - aNew = aNew.copy( 1 ); - ++nNextOfst; - break; + case CH_BREAK: + case ' ': // ??? why is this one not in ScanPortionEnd? + case CH_TAB: + case CHAR_HARDHYPHEN: // non-breaking hyphen + case CHAR_SOFTHYPHEN: + case CHAR_HARDBLANK: + case CHAR_ZWSP: + case CHAR_WJ: + case CH_TXTATR_BREAKWORD: + case CH_TXTATR_INWORD: + { + return true; + } + default: + return false; + } + }; + if (IsHook(nNew)) + { + if (nNew == CH_BREAK) + { + bFull = true; } - default: ; + aNew = aNew.copy(1); + ++nNextOfst; } // Even if there is no more text left for a follow field, @@ -424,7 +434,8 @@ bool SwFieldPortion::Format( SwTextFormatInfo &rInf ) // anyway so make sure pField doesn't have a stale flag pField->SetFollow( true ); } - if (pField->Compress()) + if (pField->Compress() && !std::all_of(std::u16string_view(aNew).begin(), + std::u16string_view(aNew).end(), IsHook)) { // empty pField will be deleted in SwLineLayout::CalcLine() // anyway so make sure this one doesn't have a stale flag SetHasFollow( true );