diff options
-rw-r--r-- | sw/qa/core/layout/data/bad-split-section.odt | bin | 0 -> 29305 bytes | |||
-rw-r--r-- | sw/qa/core/layout/layact.cxx | 22 | ||||
-rw-r--r-- | sw/source/core/inc/sectfrm.hxx | 2 | ||||
-rw-r--r-- | sw/source/core/layout/layact.cxx | 4 |
4 files changed, 25 insertions, 3 deletions
diff --git a/sw/qa/core/layout/data/bad-split-section.odt b/sw/qa/core/layout/data/bad-split-section.odt Binary files differnew file mode 100644 index 000000000000..6dbd07802dfd --- /dev/null +++ b/sw/qa/core/layout/data/bad-split-section.odt 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..9dbf9f4df9cc 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 SAL_DLLPUBLIC_RTTI 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 5add4e40a8a7..a7933214f5c7 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(); } |