sw/qa/core/layout/data/bad-split-section.odt |binary sw/qa/core/layout/layact.cxx | 22 ++++++++++++++++++++++ sw/source/core/inc/sectfrm.hxx | 2 +- sw/source/core/layout/layact.cxx | 4 ++-- 4 files changed, 25 insertions(+), 3 deletions(-)
New commits: commit f9a08c15e3a8fb078c1707d67a998f8c4d670e5a Author: Miklos Vajna <vmik...@collabora.com> AuthorDate: Mon Apr 8 06:36:37 2024 +0200 Commit: Michael Stahl <michael.st...@allotropia.de> CommitDate: Mon Apr 15 09:41:17 2024 +0200 tdf#160067 sw floattable: fix missing move bwd of paras in split section frame The last (5th) paragraph in the index was on page 2, even if page 1 still had space for it. This is a regression from commit 397d72e582c725d162c7e0b819dc6c0bb62e42b0 (Related: tdf#158986 sw floattable: fix unexpected page break with sections, 2024-02-23), in case SwLayAction::FormatLayout() doesn't calc its lower content frames then this bugdoc is good, but the old bugdoc moves its floating table to the next page, which would be bad. Fix the problem by making the condition for this "calc lower in FormatLayout()" action more strict: only do this for content frames which are in sections, followed by sections. Note that probably a cleaner way would be to completely stop calculating content frames in SwLayAction::FormatLayout() and only do that in FormatContent(), but then it's not clear how to re-fix tdf#158986, and at least this resolves the regression. Change-Id: Id671b3b68d8af8ad1cca3399a9aa028de58df3a0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165878 Reviewed-by: Miklos Vajna <vmik...@collabora.com> Tested-by: Jenkins (cherry picked from commit 607fcac441c7f3a7d3c169c19039e581d707f2bb) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165841 Reviewed-by: Michael Stahl <michael.st...@allotropia.de> diff --git a/sw/qa/core/layout/data/bad-split-section.odt b/sw/qa/core/layout/data/bad-split-section.odt new file mode 100644 index 000000000000..6dbd07802dfd Binary files /dev/null and b/sw/qa/core/layout/data/bad-split-section.odt differ diff --git a/sw/qa/core/layout/layact.cxx b/sw/qa/core/layout/layact.cxx index 8923d6b0e89a..9de0c9ebfa43 100644 --- a/sw/qa/core/layout/layact.cxx +++ b/sw/qa/core/layout/layact.cxx @@ -21,6 +21,7 @@ #include <sortedobjs.hxx> #include <tabfrm.hxx> #include <wrtsh.hxx> +#include <sectfrm.hxx> namespace { @@ -108,6 +109,27 @@ CPPUNIT_TEST_FIXTURE(Test, testSplitFlyInSection) CPPUNIT_ASSERT(pPage2); CPPUNIT_ASSERT(!pPage2->GetSortedObjs()); } + +CPPUNIT_TEST_FIXTURE(Test, testBadSplitSection) +{ + // Given a document with a section, containing 5 paragraphs: + createSwDoc("bad-split-section.odt"); + + // When laying out that document: + SwDoc* pDoc = getSwDoc(); + SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout(); + + // Then make sure the entire section is on page 1: + auto pPage = pLayout->Lower()->DynCastPageFrame(); + CPPUNIT_ASSERT(pPage); + auto pBody = pPage->FindBodyCont(); + CPPUNIT_ASSERT(pBody); + auto pSection = dynamic_cast<SwSectionFrame*>(pBody->GetLastLower()); + CPPUNIT_ASSERT(pSection); + // Without the fix in place, it would have failed, the section was split between page 1 and page + // 2. + CPPUNIT_ASSERT(!pSection->GetFollow()); +} } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/inc/sectfrm.hxx b/sw/source/core/inc/sectfrm.hxx index 69158b335863..3debf367f05a 100644 --- a/sw/source/core/inc/sectfrm.hxx +++ b/sw/source/core/inc/sectfrm.hxx @@ -46,7 +46,7 @@ namespace o3tl { template<> struct typed_flags<SwSectionFrameInvFlags> : is_typed_flags<SwSectionFrameInvFlags, 0x0011> {}; } -class SwSectionFrame final: public SwLayoutFrame, public SwFlowFrame +class SW_DLLPUBLIC SwSectionFrame final: public SwLayoutFrame, public SwFlowFrame , public SvtListener // TODO? { SwSection* m_pSection; diff --git a/sw/source/core/layout/layact.cxx b/sw/source/core/layout/layact.cxx index 1a0a1260a135..ad437f98527f 100644 --- a/sw/source/core/layout/layact.cxx +++ b/sw/source/core/layout/layact.cxx @@ -1439,9 +1439,9 @@ bool SwLayAction::FormatLayout( OutputDevice *pRenderContext, SwLayoutFrame *pLa PopFormatLayout(); } } - else if (pLay->IsSctFrame() && pLow->IsTextFrame() && pLow == pLay->GetLastLower()) + else if (pLay->IsSctFrame() && pLay->GetNext() && pLay->GetNext()->IsSctFrame() && pLow->IsTextFrame() && pLow == pLay->GetLastLower()) { - // else: only calc the last text lower of sections + // else: only calc the last text lower of sections, followed by sections pLow->OptCalc(); }