sw/source/core/layout/calcmove.cxx | 9 ++++++++- sw/source/core/layout/fly.cxx | 13 +++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-)
New commits: commit 4a8041bc4ddadd91aec6038a380ab4ce2279d27a Author: Michael Stahl <[email protected]> AuthorDate: Thu Aug 17 13:30:38 2023 +0200 Commit: Xisco Fauli <[email protected]> CommitDate: Tue Aug 22 20:59:24 2023 +0200 tdf#156728 sw: layout: invalidate fly on header/footer size On page 30 there are at-page anchored shapes Shape22, Shape23 and Shape25. Shape22 and Shape23 are positioned relative to the bottom of the page text area, and that is working; Shape25 is positioned with an offset to the top of the page text area, and that doesn't work. The problem is that the shapes are positioned when the header on the page hasn't been formatted yet, and once the header is formatted, the position of the Shape25 is not invalidated, so it's a header-height too far up. (regression from commit 425a252c3cc5e5a79a533965026dd4af6b8df739) Change-Id: Ic907d98b1bcd4bb544fd1af9bf93ebc7b75bf362 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155762 Tested-by: Jenkins Reviewed-by: Michael Stahl <[email protected]> (cherry picked from commit ee82accbd0d67eaf0f5a164a82b86abd00c3b0c9) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155774 Reviewed-by: Xisco Fauli <[email protected]> diff --git a/sw/source/core/layout/fly.cxx b/sw/source/core/layout/fly.cxx index c2d27eaf2f0e..a06c2a9e7f70 100644 --- a/sw/source/core/layout/fly.cxx +++ b/sw/source/core/layout/fly.cxx @@ -2718,10 +2718,23 @@ void SwLayoutFrame::NotifyLowerObjs( const bool _bUnlockPosOfObjs ) { assert( dynamic_cast<const SwAnchoredDrawObject*>( pObj) && "<SwLayoutFrame::NotifyFlys() - anchored object of unexpected type" ); + // tdf#156728 invalidate fly positioned dependent on header/footer size + bool isPositionedByHF(false); + if (IsHeaderFrame() || IsFooterFrame()) + { + auto const nO(pObj->GetFrameFormat().GetVertOrient().GetRelationOrient()); + if (nO == text::RelOrientation::PAGE_PRINT_AREA + || nO == text::RelOrientation::PAGE_PRINT_AREA_BOTTOM + || nO == text::RelOrientation::PAGE_PRINT_AREA_TOP) + { + isPositionedByHF = true; + } + } // #i26945# - use <pAnchorFrame> to check, if // fly frame is lower of layout frame resp. if fly frame is // at a different page registered as its anchor frame is on. if ( IsAnLower( pAnchorFrame ) || + isPositionedByHF || pAnchorFrame->FindPageFrame() != pPageFrame ) { // #i44016# commit 9b6a4fcc010bdb740a5b3581a47327f45ee05718 Author: Michael Stahl <[email protected]> AuthorDate: Wed Aug 16 16:09:12 2023 +0200 Commit: Xisco Fauli <[email protected]> CommitDate: Tue Aug 22 20:59:13 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 <[email protected]> (cherry picked from commit 169b4d72b28b05e1a14d9b00571f7488200e39c2) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155709 Reviewed-by: Xisco Fauli <[email protected]> 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 ) {
