sw/qa/extras/layout/data/tdf170630.docx |binary sw/qa/extras/layout/layout5.cxx | 28 ++++++++++++++++++++++++++++ sw/source/core/layout/tabfrm.cxx | 17 ++++++++++++++--- 3 files changed, 42 insertions(+), 3 deletions(-)
New commits: commit d4f47f5fcc7f344d2bcabaf8447c64ee2e93a6b9 Author: Mike Kaganski <[email protected]> AuthorDate: Fri Feb 6 11:08:35 2026 +0500 Commit: Miklos Vajna <[email protected]> CommitDate: Mon Feb 9 13:00:56 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]> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/198933 Reviewed-by: Miklos Vajna <[email protected]> Tested-by: Jenkins CollaboraOffice <[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/layout5.cxx b/sw/qa/extras/layout/layout5.cxx index 9095a96684ab..55e1c4aba00a 100644 --- a/sw/qa/extras/layout/layout5.cxx +++ b/sw/qa/extras/layout/layout5.cxx @@ -2416,6 +2416,34 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter5, testTdf170620_float_table_after_keep_with_ assertXPath(pXmlDoc, aP1OuterFlyTab + "/row/cell/txt[2]/anchored/fly", 2); } +CPPUNIT_TEST_FIXTURE(SwLayoutWriter5, 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); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/layout/tabfrm.cxx b/sw/source/core/layout/tabfrm.cxx index e40b38fdc3d1..be2780b21c5d 100644 --- a/sw/source/core/layout/tabfrm.cxx +++ b/sw/source/core/layout/tabfrm.cxx @@ -4854,10 +4854,21 @@ tools::Long CalcHeightWithFlys( const SwFrame *pFrame ) { // #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 {
