sw/qa/core/text/data/floattable-heading-split-footer.docx |binary sw/qa/core/text/widorp.cxx | 5 ++++- sw/source/core/layout/calcmove.cxx | 12 +++++++++++- 3 files changed, 15 insertions(+), 2 deletions(-)
New commits: commit e1522e2b1985f6ebdbf442bdbd55cbc5f2b85dd6 Author: Miklos Vajna <vmik...@collabora.com> AuthorDate: Mon Jul 28 08:46:37 2025 +0200 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Mon Jul 28 17:45:06 2025 +0200 Related: tdf#167222 sw floattable: fix split of fly and its heading text w/ ftn Open the updated bugdoc, which now has a footnote as well: the table goes to page 2 in Word, but to page 3 in Writer. This time what seems to happen is that the footnote container results in less body frame space, so the entire floating table + anchor text moves to page 3 and never moves back, even after the footnote moved to page 3. Fix this by extending SwContentFrame::MakeAll() to be consistent with the SwTextFrameBreak ctor, so it also ignores "don't break" / "keep with next" when that would potentially result in not allowing a page break between the floating table and its anchor text. Change-Id: I3161fb6896909b32996fe83acd8d6772f7b66af6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/188469 Reviewed-by: Miklos Vajna <vmik...@collabora.com> Tested-by: Jenkins diff --git a/sw/qa/core/text/data/floattable-heading-split-footer.docx b/sw/qa/core/text/data/floattable-heading-split-footer.docx index f8c532a03853..225cd11fff6b 100644 Binary files a/sw/qa/core/text/data/floattable-heading-split-footer.docx and b/sw/qa/core/text/data/floattable-heading-split-footer.docx differ diff --git a/sw/qa/core/text/widorp.cxx b/sw/qa/core/text/widorp.cxx index 06d5939a7628..899624fe97d4 100644 --- a/sw/qa/core/text/widorp.cxx +++ b/sw/qa/core/text/widorp.cxx @@ -89,7 +89,8 @@ CPPUNIT_TEST_FIXTURE(Test, testFloattableHeadingSplitFooter) // When loading that document & laying it out: createSwDoc("floattable-heading-split-footer.docx"); - // Then make sure that the floating table is on page 2 and the last heading is on page 3: + // Then make sure that the floating table is on page 2 and the last heading + footnote is on + // page 3: SwDocShell* pDocShell = getSwDocShell(); SwDoc* pDoc = pDocShell->GetDoc(); SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout(); @@ -98,9 +99,11 @@ CPPUNIT_TEST_FIXTURE(Test, testFloattableHeadingSplitFooter) // Without the accompanying fix in place, this test would have failed, the floating table went // to page 3, not to page 2. CPPUNIT_ASSERT(pPage2->GetSortedObjs()); + CPPUNIT_ASSERT(!pPage2->FindFootnoteCont()); // Make sure that page 3 has no floating table and has the heading on the correct page. auto pPage3 = pPage2->GetNext()->DynCastPageFrame(); CPPUNIT_ASSERT(!pPage3->GetSortedObjs()); + CPPUNIT_ASSERT(pPage3->FindFootnoteCont()); SwLayoutFrame* pBody3 = pPage3->FindBodyCont(); SwTextFrame* pPage3Para1 = pBody3->ContainsContent()->DynCastTextFrame(); CPPUNIT_ASSERT_EQUAL(u"page 3"_ustr, pPage3Para1->GetText()); diff --git a/sw/source/core/layout/calcmove.cxx b/sw/source/core/layout/calcmove.cxx index a7a9ddc244ad..2154f4b29164 100644 --- a/sw/source/core/layout/calcmove.cxx +++ b/sw/source/core/layout/calcmove.cxx @@ -1372,7 +1372,17 @@ void SwContentFrame::MakeAll(vcl::RenderContext* /*pRenderContext*/) oNotify->SetBordersJoinedWithPrev(); } - const bool bKeep{!isHiddenNow && IsKeep(rAttrs.GetAttrSet().GetKeep(), GetBreakItem())}; + bool bKeep{!isHiddenNow && IsKeep(rAttrs.GetAttrSet().GetKeep(), GetBreakItem())}; + if (bKeep && IsTextFrame()) + { + auto pTextFrame = DynCastTextFrame(); + if (pTextFrame->HasSplitFlyDrawObjs()) + { + // The SwTextFrameBreak ctor already turns off bKeep for split fly anchors, don't + // change that decision here. + bKeep = false; + } + } std::unique_ptr<SwSaveFootnoteHeight> pSaveFootnote; if ( bFootnote )