sw/source/core/layout/calcmove.cxx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
New commits: commit 802d748d9ce5541dc54a0369910a442afeeaa43e Author: Michael Stahl <michael.st...@allotropia.de> AuthorDate: Wed Aug 16 16:09:12 2023 +0200 Commit: Michael Stahl <michael.st...@allotropia.de> CommitDate: Thu Aug 17 10:59:27 2023 +0200 tdf#156727 sw: layout: allow MoveBwd if previous has keep-with-next In the pathological fdo56431-6.odt there are 16 pages of 1-line paragraphs that all have keep-with-next set, and only the first of them has a page break before. The layout temporarily uses 5 pages for the table of content at the start but then everything fits on 4 pages, so page 5 is empty. Now the first text frame on page 6 moves backward despite its keep-with-next, because it hits SwFlowFrame::SetMoveBwdJump(true) in SwFrame::GetPrevLeaf(). The next one however nopes out in SwContentFrame::WouldFit_(). This is because it continues along the sequence of keep-with-next frames until it runs out of space in the new upper; this happens with a frame that's actually on page 7. Ignore keep-with-next in case the previous frame in the new upper also has it set, because it really doesn't mean anything then. (somehow regression from commit 25a252c3cc5e5a79a533965026dd4af6b8df739) Change-Id: I0cfbc8b67bd0b95dfe08054660a2935de923a661 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155741 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.st...@allotropia.de> diff --git a/sw/source/core/layout/calcmove.cxx b/sw/source/core/layout/calcmove.cxx index 820d7834027b..5fb30d5c7afa 100644 --- a/sw/source/core/layout/calcmove.cxx +++ b/sw/source/core/layout/calcmove.cxx @@ -2004,6 +2004,12 @@ bool SwContentFrame::WouldFit_( SwTwips nSpace, pTmpPrev = static_cast<const SwFootnoteFrame*>(pTmpPrev)->Lower(); while ( pTmpPrev && pTmpPrev->GetNext() ) pTmpPrev = pTmpPrev->GetNext(); + + // tdf#156727 if the previous one has keep-with-next, ignore it on this one! + bool const isIgnoreKeep(pTmpPrev && pTmpPrev->IsFlowFrame() + && SwFlowFrame::CastFlowFrame(pTmpPrev)->IsKeep( + pTmpPrev->GetAttrSet()->GetKeep(), pTmpPrev->GetBreakItem())); + do { // #i46181# @@ -2153,7 +2159,8 @@ bool SwContentFrame::WouldFit_( SwTwips nSpace, } } - if (bRet && !bSplit && pFrame->IsKeep(rAttrs.GetAttrSet().GetKeep(), GetBreakItem())) + if (bRet && !bSplit && !isIgnoreKeep + && pFrame->IsKeep(rAttrs.GetAttrSet().GetKeep(), GetBreakItem())) { if( bTstMove ) {