sw/source/core/text/porfld.cxx | 6 +++++- sw/source/core/text/porlin.cxx | 3 +++ 2 files changed, 8 insertions(+), 1 deletion(-)
New commits: commit 6c0105307efa15837e9e5287103995312f373b67 Author: Michael Stahl <michael.st...@allotropia.de> AuthorDate: Wed Mar 8 13:10:55 2023 +0100 Commit: Michael Stahl <michael.st...@allotropia.de> CommitDate: Fri Mar 10 10:57:07 2023 +0000 sw: fix stale SwNumberPortion follow flag Somehow a SwNumberPortion can be split into 2 SwNumberPortions and the 2nd one ends up with a '\t' character that is then removed from the portion and via some HookChar thing converted to a SwTabLeftPortion. To add further insult, the SwTabLeftPortion is inserted between the first SwNumberPortion and the empty SwNumberPortion, and then SwLineLayout::CalcLine() deletes the empty one but the first one still has the m_bHasFollow flag set. Change-Id: Ic902ed7f35d7faf168bef636b869e5cd9e2435ec Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148555 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 dbe62d49e6bb..e0737d4f948d 100644 --- a/sw/source/core/text/porfld.cxx +++ b/sw/source/core/text/porfld.cxx @@ -420,7 +420,11 @@ bool SwFieldPortion::Format( SwTextFormatInfo &rInf ) pField->SetFont( std::make_unique<SwFont>( *rInf.GetFont() ) ); } pField->SetFollow( true ); - SetHasFollow( true ); + if (pField->Compress()) + { // empty pField will be deleted in SwLineLayout::CalcLine() + // anyway so make sure this one doesn't have a stale flag + SetHasFollow( true ); + } // For a newly created field, nNextOffset contains the Offset // of its start of the original string diff --git a/sw/source/core/text/porlin.cxx b/sw/source/core/text/porlin.cxx index c7b6b17279b3..4421f107f27f 100644 --- a/sw/source/core/text/porlin.cxx +++ b/sw/source/core/text/porlin.cxx @@ -202,6 +202,9 @@ SwLinePortion *SwLinePortion::Cut( SwLinePortion *pVictim ) { SwLinePortion *pPrev = pVictim->FindPrevPortion( this ); OSL_ENSURE( pPrev, "SwLinePortion::Cut(): can't cut" ); + // note: if pVictim is a follow then clearing pPrev's m_bHasFollow here is + // tricky because it could be that the HookChar inserted a tab portion + // between 2 field portions pPrev->SetNextPortion( pVictim->GetNextPortion() ); pVictim->SetNextPortion(nullptr); return pVictim;