sw/qa/extras/layout/data/tdf170630.docx |binary sw/qa/extras/layout/layout6.cxx | 28 ++++++++++++++++++++++++++++ sw/source/core/layout/tabfrm.cxx | 17 ++++++++++++++--- 3 files changed, 42 insertions(+), 3 deletions(-)
New commits: commit e75f74428a0c2eb5d4b318d6b4e520cc3c13c2d0 Author: Mike Kaganski <[email protected]> AuthorDate: Fri Feb 6 11:08:35 2026 +0500 Commit: Mike Kaganski <[email protected]> CommitDate: Fri Feb 6 15:33:41 2026 +0100 tdf#170630: consider not-yet-moved flys in cell height as "too high" As the bugdoc demonstrated, it is not enough to split too high inner floating table: after the split, the follow anchor and follow fly may not cause the outer table to require an own split. This change introduces a shortcut in CalcHeightWithFlys_Impl (used to calculate cell heights considering anchored objects): if a lower is a follow anchor with a follow fly that hasn't yet moved, do not continue calculating accurate cell height, just return a huge height of this lower. This means that cells with such not-yet-moved anchors will never fit, and will always cause their table to be split. After that, the heights will be calculated accurately. Change-Id: Id81e69c08cfa58ffddfa771fa768f78735433d91 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/198811 Tested-by: Jenkins Reviewed-by: Mike Kaganski <[email protected]> diff --git a/sw/qa/extras/layout/data/tdf170630.docx b/sw/qa/extras/layout/data/tdf170630.docx new file mode 100644 index 000000000000..99a8a8eb961d Binary files /dev/null and b/sw/qa/extras/layout/data/tdf170630.docx differ diff --git a/sw/qa/extras/layout/layout6.cxx b/sw/qa/extras/layout/layout6.cxx index c4b430c9c04c..4f88d7392943 100644 --- a/sw/qa/extras/layout/layout6.cxx +++ b/sw/qa/extras/layout/layout6.cxx @@ -2085,6 +2085,34 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter6, testTdf170620_float_table_after_keep_with_ assertXPath(pXmlDoc, aP1OuterFlyTab + "/row/cell/txt[2]/anchored/fly", 2); } +CPPUNIT_TEST_FIXTURE(SwLayoutWriter6, testTdf170630) +{ + // Given a document with a keep-with-next paragraph, followed by floating table containing + // two keep-with-next paragraphs and another floating table which is split across pages: + createSwDoc("tdf170630.docx"); + + // The keep-with-next paragraph and the floating table must start on page 1: + + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); + CPPUNIT_ASSERT(pXmlDoc); + + // Exactly two pages (without the fix, there was only one): + assertXPath(pXmlDoc, "//page", 2); + + // "Keep-with-next paragraph" is on the first page: + assertXPath(pXmlDoc, "//page[1]/body/txt[2]//SwLineLayout", "portion", + u"Keep-with-next paragraph"); + + // Exactly two objects anchored at each page (without the fix, the first page had three: one + // outer, and two inner, where the follow frame never moved forward): + assertXPath(pXmlDoc, "//page[1]/sorted_objs/fly", 2); + assertXPath(pXmlDoc, "//page[2]/sorted_objs/fly", 2); + + // Page 1's paragraph 3 has two anchored flys (without the fix, it was one: the outer table + // never split): + assertXPath(pXmlDoc, "//page[1]/body/txt[3]/anchored/fly", 2); +} + } // end of anonymous namespace CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sw/source/core/layout/tabfrm.cxx b/sw/source/core/layout/tabfrm.cxx index 3867dabec329..23c8337b4e55 100644 --- a/sw/source/core/layout/tabfrm.cxx +++ b/sw/source/core/layout/tabfrm.cxx @@ -4841,10 +4841,21 @@ static tools::Long CalcHeightWithFlys_Impl(const SwFrame* pTmp, const SwFrame* p { // #i26945# - if <pTmp> is follow, the // anchor character frame has to be <pTmp>. - if ( bIsFollow && - pAnchoredObj->FindAnchorCharFrame() != pTmp ) + if (bIsFollow) { - continue; + if (pAnchoredObj->FindAnchorCharFrame() != pTmp) + continue; + + if (SwFlyFrame* pFly = pAnchoredObj->DynCastFlyFrame()) + { + if (pFly->IsSplitButNotYetMovedFollow()) + { + // A follow split fly, that is yet to move forward: upper's height is not + // correct yet - just return a huge value to signal "too large". This will + // eventually force split / move to the next page. + return SAL_MAX_INT32 / 2; // ~19 km + } + } } // #i26945# - consider also drawing objects {
