summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sw/qa/core/layout/data/floattable-deleted-anchor.docxbin0 -> 41531 bytes
-rw-r--r--sw/qa/core/layout/flycnt.cxx25
-rw-r--r--sw/source/core/text/frmform.cxx13
3 files changed, 37 insertions, 1 deletions
diff --git a/sw/qa/core/layout/data/floattable-deleted-anchor.docx b/sw/qa/core/layout/data/floattable-deleted-anchor.docx
new file mode 100644
index 000000000000..cab5b68ff94d
--- /dev/null
+++ b/sw/qa/core/layout/data/floattable-deleted-anchor.docx
Binary files differ
diff --git a/sw/qa/core/layout/flycnt.cxx b/sw/qa/core/layout/flycnt.cxx
index bd3e98a38a62..1ad1443dd392 100644
--- a/sw/qa/core/layout/flycnt.cxx
+++ b/sw/qa/core/layout/flycnt.cxx
@@ -737,6 +737,31 @@ CPPUNIT_TEST_FIXTURE(Test, testSplitFlyTableRowKeep)
auto pCell3 = dynamic_cast<SwCellFrame*>(pRow3->GetLower());
CPPUNIT_ASSERT(pCell3->GetFollowCell());
}
+
+CPPUNIT_TEST_FIXTURE(Test, testSplitFlyDeletedAnchor)
+{
+ // Given a document with a floating table that spans over 3 pages:
+ createSwDoc("floattable-deleted-anchor.docx");
+
+ // When laying out that document:
+ calcLayout();
+
+ // Then make sure that there are 3 anchors for the 3 pages:
+ SwDoc* pDoc = getSwDoc();
+ SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout();
+ auto pPage1 = dynamic_cast<SwPageFrame*>(pLayout->Lower());
+ CPPUNIT_ASSERT(pPage1);
+ SwFrame* pBody1 = pPage1->GetLower();
+ CPPUNIT_ASSERT(pBody1);
+ auto pAnchor1 = dynamic_cast<SwTextFrame*>(pBody1->GetLower()->GetNext());
+ CPPUNIT_ASSERT(pAnchor1);
+ SwTextFrame* pAnchor2 = pAnchor1->GetFollow();
+ CPPUNIT_ASSERT(pAnchor2);
+ SwTextFrame* pAnchor3 = pAnchor2->GetFollow();
+ // Without the accompanying fix in place, this test would have failed, the fly frame on the 3rd
+ // page was anchored to a text frame on the 2nd page, leading to a negative frame height.
+ CPPUNIT_ASSERT(pAnchor3);
+}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/text/frmform.cxx b/sw/source/core/text/frmform.cxx
index 2f3024f1bb0a..912047487a64 100644
--- a/sw/source/core/text/frmform.cxx
+++ b/sw/source/core/text/frmform.cxx
@@ -633,6 +633,13 @@ void SwTextFrame::AdjustFollow_( SwTextFormatter &rLine,
while( GetFollow() && GetFollow()->GetFollow() &&
nNewOfst >= GetFollow()->GetFollow()->GetOffset() )
{
+ if (HasNonLastSplitFlyDrawObj())
+ {
+ // A non-last split fly is anchored to us, don't move content from the last frame to
+ // this one and don't join.
+ return;
+ }
+
JoinFrame();
}
}
@@ -1109,7 +1116,11 @@ void SwTextFrame::FormatAdjust( SwTextFormatter &rLine,
// AdjustFollow might execute JoinFrame() because of this.
// Else, nEnd is the end of the last line in the Master.
TextFrameIndex nOld = nEnd;
- nEnd = rLine.GetEnd();
+ // Make sure content from the last floating table anchor is not shifted to previous anchors.
+ if (!HasNonLastSplitFlyDrawObj())
+ {
+ nEnd = rLine.GetEnd();
+ }
if( GetFollow() )
{
if( nNew && nOld < nEnd )