sw/CppunitTest_sw_core_text.mk | 1 sw/qa/core/text/data/floattable-leftover-para-portion.docx |binary sw/qa/core/text/porrst.cxx | 57 +++++++++++++ sw/source/core/text/porrst.cxx | 2 4 files changed, 59 insertions(+), 1 deletion(-)
New commits: commit 2dc53489d6c36a5a04c154d78a9e8ea928407328 Author: Miklos Vajna <vmik...@collabora.com> AuthorDate: Wed Aug 16 09:34:49 2023 +0200 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Tue Aug 22 20:59:36 2023 +0200 tdf#156682 sw floattable: fix missing del of master anchor para por on split Pressing "enter" at the end of B1 in the bugdoc resulted in a split floating table, which had the anchor text duplicated (both on page 1 and page2). What happened is that the master anchor frame didn't have its paragraph portion cleared, the follow anchor frame had a correct frame offset (of 0). Fix the problem in SwTextFrame::FormatEmpty(), similar to what commit 00b9b33334791079c2dc26b1ed4c123450cabf7d (sw: call FormatEmpty() in SwTextFrame::Format() for split fly masters, 2023-02-09), did; here what we want to avoid is setting some properties on the paragraph preventing the deletion of non-last anchor paragraph portions. As a side effect, this also fixes the hang from the bugreport, after pressing "enter" 5 times at the end of B1. Change-Id: I16e6d786f02ad503a0fdff465ecf7716c1c5f8b7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155732 Reviewed-by: Miklos Vajna <vmik...@collabora.com> Tested-by: Jenkins (cherry picked from commit 1cf29168840f84c2e946e2678b99988e83503c96) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155787 Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> diff --git a/sw/CppunitTest_sw_core_text.mk b/sw/CppunitTest_sw_core_text.mk index 477e25b91612..37b2fa566094 100644 --- a/sw/CppunitTest_sw_core_text.mk +++ b/sw/CppunitTest_sw_core_text.mk @@ -17,6 +17,7 @@ $(eval $(call gb_CppunitTest_add_exception_objects,sw_core_text, \ sw/qa/core/text/frmform \ sw/qa/core/text/itratr \ sw/qa/core/text/itrform2 \ + sw/qa/core/text/porrst \ sw/qa/core/text/text \ )) diff --git a/sw/qa/core/text/data/floattable-leftover-para-portion.docx b/sw/qa/core/text/data/floattable-leftover-para-portion.docx new file mode 100644 index 000000000000..51eee56cf003 Binary files /dev/null and b/sw/qa/core/text/data/floattable-leftover-para-portion.docx differ diff --git a/sw/qa/core/text/porrst.cxx b/sw/qa/core/text/porrst.cxx new file mode 100644 index 000000000000..1c343dc0d9f2 --- /dev/null +++ b/sw/qa/core/text/porrst.cxx @@ -0,0 +1,57 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include <swmodeltestbase.hxx> + +#include <memory> + +#include <IDocumentLayoutAccess.hxx> +#include <doc.hxx> +#include <frame.hxx> +#include <layfrm.hxx> +#include <pagefrm.hxx> +#include <rootfrm.hxx> +#include <txtfrm.hxx> + +namespace +{ +/// Covers sw/source/core/text/porrst.cxx fixes. +class Test : public SwModelTestBase +{ +public: + Test() + : SwModelTestBase("/sw/qa/core/text/data/") + { + } +}; + +CPPUNIT_TEST_FIXTURE(Test, testFloattableLeftoverParaPortion) +{ + // Given a document with a multi-page floating table, the anchor of the table has some text: + createSwDoc("floattable-leftover-para-portion.docx"); + + // When laying out that document: + calcLayout(); + + // Then make sure all anchor text goes to the second page: + SwDoc* pDoc = getSwDoc(); + SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout(); + auto pPage = dynamic_cast<SwPageFrame*>(pLayout->Lower()); + CPPUNIT_ASSERT(pPage); + SwFrame* pBody = pPage->FindBodyCont(); + SwFrame* pPara1 = pBody->GetLower(); + auto pPara2 = pPara1->GetNext()->DynCastTextFrame(); + CPPUNIT_ASSERT(pPara2); + // Without the accompanying fix in place, this test would have failed, the first page's anchor + // also had some (duplicated) anchor text. + CPPUNIT_ASSERT(!pPara2->GetPara()); +} +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/text/porrst.cxx b/sw/source/core/text/porrst.cxx index 255318119f87..5c6ea428c1db 100644 --- a/sw/source/core/text/porrst.cxx +++ b/sw/source/core/text/porrst.cxx @@ -413,7 +413,7 @@ bool SwTextFrame::FormatEmpty() // Split fly frames: non-last parts of the anchor want this optimization to clear the old // content. bool bHasNonLastSplitFlyDrawObj = HasNonLastSplitFlyDrawObj(); - if ((HasFollow() && !bHasNonLastSplitFlyDrawObj) || GetMergedPara() || GetTextNodeFirst()->GetpSwpHints() || + if ((HasFollow() && !bHasNonLastSplitFlyDrawObj) || GetMergedPara() || (GetTextNodeFirst()->GetpSwpHints() && !bHasNonLastSplitFlyDrawObj) || nullptr != GetTextNodeForParaProps()->GetNumRule() || GetTextNodeFirst()->HasHiddenCharAttribute(true) || IsInFootnote() || ( HasPara() && GetPara()->IsPrepMustFit() ) )