sw/qa/core/layout/flycnt.cxx | 23 +++++++++++++++++++++++ sw/source/core/layout/flycnt.cxx | 8 ++++++++ 2 files changed, 31 insertions(+)
New commits: commit ef35298643eb5da14bfd704e24ef3bb098b308ee Author: Miklos Vajna <vmik...@collabora.com> AuthorDate: Mon Apr 3 08:15:06 2023 +0200 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Wed Apr 19 16:31:10 2023 +0200 sw floattable: fix removal of empty master flys on master table removal The bugdoc has 2 pages, a floating table covering both pages, row 1 on page 1, row 2 on page 2. Once row 1 was deleted, the text around row 2 moved up to page 1, but row 2 remained on page 2, which is unexpected. What happened is that we correctly deleted the fly of row 1, even moved the text of the anchor on page 2 to page 1, but nobody moved the fly of row 2 to page 1, which is inconsistent. Fix the problem by invalidating the position of the follow in SwFlyAtContentFrame::DelEmpty(), since deleting a master fly potentially creates space for follows, so they can move up. This helps in the 2-page case, the case with more than 2 pages still needs work. (cherry picked from commit 1006fd848ba7c67927472e53df7f3b6f682fadfb) Change-Id: Ida9cc1d586963867e8fc7ee92d4b3f5dfafd3579 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150009 Tested-by: Miklos Vajna <vmik...@collabora.com> Reviewed-by: Miklos Vajna <vmik...@collabora.com> diff --git a/sw/qa/core/layout/flycnt.cxx b/sw/qa/core/layout/flycnt.cxx index 09d08ff14285..34e31371d346 100644 --- a/sw/qa/core/layout/flycnt.cxx +++ b/sw/qa/core/layout/flycnt.cxx @@ -606,6 +606,29 @@ CPPUNIT_TEST_FIXTURE(Test, testSplitFlyRowDelete) CPPUNIT_ASSERT(pPage1); CPPUNIT_ASSERT(!pPage1->GetNext()); } + +CPPUNIT_TEST_FIXTURE(Test, testSplitFly1stRowDelete) +{ + // Given a document with a multi-page floating table: + Create1x2SplitFly(); + + // When deleting the row of A1: + SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell(); + pWrtShell->GotoTable("Table1"); + SwTextNode* pTextNode = pWrtShell->GetCursor()->GetPointNode().GetTextNode(); + // We delete the right row: + CPPUNIT_ASSERT_EQUAL(OUString("A1"), pTextNode->GetText()); + pWrtShell->DeleteRow(); + + // Then make sure we only have 1 page: + 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, the follow fly was still + // on page 2. + CPPUNIT_ASSERT(!pPage1->GetNext()); +} } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/layout/flycnt.cxx b/sw/source/core/layout/flycnt.cxx index c4a283038277..ed7ee1467ef8 100644 --- a/sw/source/core/layout/flycnt.cxx +++ b/sw/source/core/layout/flycnt.cxx @@ -1660,6 +1660,14 @@ void SwFlyAtContentFrame::DelEmpty() { pMaster->SetFollow(GetFollow()); } + + SwFlyAtContentFrame* pFollow = GetFollow(); + if (pFollow) + { + // I'll be deleted, so invalidate the position of my follow, so it can move up. + pFollow->InvalidatePos(); + } + SetFollow(nullptr); {