summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sw/qa/core/layout/data/floattable-anchor-keep-with-next.docxbin0 -> 12225 bytes
-rw-r--r--sw/qa/core/layout/flycnt.cxx25
-rw-r--r--sw/source/core/layout/flowfrm.cxx11
3 files changed, 36 insertions, 0 deletions
diff --git a/sw/qa/core/layout/data/floattable-anchor-keep-with-next.docx b/sw/qa/core/layout/data/floattable-anchor-keep-with-next.docx
new file mode 100644
index 000000000000..a0930900d884
--- /dev/null
+++ b/sw/qa/core/layout/data/floattable-anchor-keep-with-next.docx
Binary files differ
diff --git a/sw/qa/core/layout/flycnt.cxx b/sw/qa/core/layout/flycnt.cxx
index efc29670c244..5ed28f38aa5a 100644
--- a/sw/qa/core/layout/flycnt.cxx
+++ b/sw/qa/core/layout/flycnt.cxx
@@ -921,6 +921,31 @@ CPPUNIT_TEST_FIXTURE(Test, testSplitFlyNextLeafInSection)
// Then this never returned, the loop in SwFrame::GetNextFlyLeaf() never finished.
calcLayout();
}
+
+CPPUNIT_TEST_FIXTURE(Test, testSplitFlyAnchorKeepWithNext)
+{
+ // Given a document with 2 pages, a split floating table on both pages:
+ createSwDoc("floattable-anchor-keep-with-next.docx");
+
+ // When calculating the layout:
+ calcLayout();
+
+ // Then make sure the pages have the expected amount of anchored objects:
+ SwDoc* pDoc = getSwDoc();
+ SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout();
+ auto pPage1 = dynamic_cast<SwPageFrame*>(pLayout->Lower());
+ CPPUNIT_ASSERT(pPage1);
+ // Without the accompanying fix in place, this test would have failed, page 1 had no floating
+ // table, it was entirely on page 2.
+ CPPUNIT_ASSERT(pPage1->GetSortedObjs());
+ const SwSortedObjs& rPage1Objs = *pPage1->GetSortedObjs();
+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), rPage1Objs.size());
+ auto pPage2 = dynamic_cast<SwPageFrame*>(pPage1->GetNext());
+ CPPUNIT_ASSERT(pPage2);
+ CPPUNIT_ASSERT(pPage2->GetSortedObjs());
+ const SwSortedObjs& rPage2Objs = *pPage2->GetSortedObjs();
+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), rPage2Objs.size());
+}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/layout/flowfrm.cxx b/sw/source/core/layout/flowfrm.cxx
index cb47267f1195..41b6b8fff953 100644
--- a/sw/source/core/layout/flowfrm.cxx
+++ b/sw/source/core/layout/flowfrm.cxx
@@ -248,6 +248,17 @@ bool SwFlowFrame::IsKeep(SvxFormatKeepItem const& rKeep,
( !m_rThis.IsInTab() || m_rThis.IsTabFrame() ) &&
rKeep.GetValue() && !IsNextContentFullPage(m_rThis));
+ if (bKeep && m_rThis.IsTextFrame())
+ {
+ auto& rTextFrame = static_cast<SwTextFrame&>(m_rThis);
+ if (rTextFrame.HasNonLastSplitFlyDrawObj())
+ {
+ // Allow split for the non-last anchors of a split fly, even if rKeep.GetValue() is
+ // true.
+ bKeep = false;
+ }
+ }
+
OSL_ENSURE( !bCheckIfLastRowShouldKeep || m_rThis.IsTabFrame(),
"IsKeep with bCheckIfLastRowShouldKeep should only be used for tabfrms" );