sw/source/core/inc/flyfrms.hxx | 1 + sw/source/core/layout/flycnt.cxx | 4 ++++ sw/source/core/text/itrform2.cxx | 37 +++++++++++++++++++++++++++++++++++++ 3 files changed, 42 insertions(+)
New commits: commit 6275bd9db475cb984ac153d06ed1ddadfa2fadb7 Author: Miklos Vajna <vmik...@collabora.com> AuthorDate: Tue Feb 7 08:23:50 2023 +0100 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Tue Feb 7 10:41:21 2023 +0000 sw: handle split flys in SwTextFormatter::FormatLine() One workaround in SwFrame::GetNextFlyLeaf() is to assume that there is always a next frame after the fly's anchor when we split the fly. An alternative to this is to split the fly's anchor as well, so we always have a next such frame. When this happens, we hit various problems, the first is that once we have 2 flys after the split, we try to move the first fly to page 2 as well. The reason for this appears to be that SwTextFormatter::FormatLine() sets the height of the line in the fly's anchor to 1 twip larger than the available space. Disable this tweak when the only reason that text frame is on the page to serve as an anchor. We definitely don't want to move it to the next page, arguing it's too large. Towards an initial layout for multi-page fly frames. Change-Id: Ia7b7a93ff78af640366fb49e30e910e5f4e0e0a2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146602 Reviewed-by: Miklos Vajna <vmik...@collabora.com> Tested-by: Jenkins diff --git a/sw/source/core/inc/flyfrms.hxx b/sw/source/core/inc/flyfrms.hxx index 39f9c1dbf2f5..608e04ff8f11 100644 --- a/sw/source/core/inc/flyfrms.hxx +++ b/sw/source/core/inc/flyfrms.hxx @@ -179,6 +179,7 @@ public: SwFlyAtContentFrame( SwFlyFrameFormat*, SwFrame*, SwFrame *pAnchor, bool bFollow = false ); SwFlyAtContentFrame(SwFlyAtContentFrame& rPrecede); + ~SwFlyAtContentFrame(); void SetAbsPos( const Point &rNew ); diff --git a/sw/source/core/layout/flycnt.cxx b/sw/source/core/layout/flycnt.cxx index 2d4c9a373796..2fcd1723d0fc 100644 --- a/sw/source/core/layout/flycnt.cxx +++ b/sw/source/core/layout/flycnt.cxx @@ -90,6 +90,10 @@ SwFlyAtContentFrame::SwFlyAtContentFrame(SwFlyAtContentFrame& rPrecede) rPrecede.SetFollow(this); } +SwFlyAtContentFrame::~SwFlyAtContentFrame() +{ +} + // #i28701# void SwFlyAtContentFrame::SwClientNotify(const SwModify& rMod, const SfxHint& rHint) diff --git a/sw/source/core/text/itrform2.cxx b/sw/source/core/text/itrform2.cxx index 91f73ed87825..48ad43bde8ef 100644 --- a/sw/source/core/text/itrform2.cxx +++ b/sw/source/core/text/itrform2.cxx @@ -1932,6 +1932,43 @@ TextFrameIndex SwTextFormatter::FormatLine(TextFrameIndex const nStartPos) m_pCurr->SetLen(TextFrameIndex(0)); m_pCurr->Height( GetFrameRstHeight() + 1, false ); m_pCurr->SetRealHeight( GetFrameRstHeight() + 1 ); + + if (m_pFrame) + { + // Don't oversize the line in case of split flys, so we don't try to move the anchor + // of a precede fly forward. + bool bHasNonLastFlySplitAnchored = false; + SwSortedObjs* pSortedObjs = m_pFrame->GetDrawObjs(); + if (pSortedObjs) + { + for (const auto& pSortedObj : *pSortedObjs) + { + SwFlyFrame* pFlyFrame = pSortedObj->DynCastFlyFrame(); + if (!pFlyFrame) + { + continue; + } + + if (!pFlyFrame->IsFlySplitAllowed()) + { + continue; + } + + auto pFlyAtContentFrame = static_cast<SwFlyAtContentFrame*>(pFlyFrame); + if (pFlyAtContentFrame->GetFollow()) + { + bHasNonLastFlySplitAnchored = true; + break; + } + } + } + + if (bHasNonLastFlySplitAnchored) + { + m_pCurr->SetRealHeight( GetFrameRstHeight() ); + } + } + m_pCurr->Width(0); m_pCurr->Truncate(); return nStartPos;