tdf#161318 sw clearing break: ignore wrap-through anchored objects

Import the bugdoc: we expect just a single page for the 2 paragraphs,
but the second paragraph goes to a 2nd page.

What seems to happen since commit
f86d1482be (sw clearing breaks: add DOCX
import, 2022-03-08) is that on one hand, SwTextFly::ForEach() ignores
wrap-through shapes, but at the same time SwTextFly::GetMaxBottom() did
not, and this lead to a loop: the first paragraph kept growing till the
shape was shifted to page 2, but then the same first paragraph was
reduced to just 2 lines, goto 1.

Fix the problem by extending SwTextFly::GetMaxBottom() to also ignore
wrap-though shapes: this is the intention, just clearing breaks were not
tested with wrap-though wrap mode before.

This is a reduced bugdoc, the original one even produced warnings like:
warn:legacy.osl:12034:12034:sw/source/core/layout/flowfrm.cxx:2667: <SwFlowFrame::MoveBwd(..)> - layout loop control for layout action <Move Backward> applied!
without the fix, and these are now gone.

Change-Id: Iaf9849dbf8e1a8e5d625d3c19b99636247804cdd
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168239
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
This commit is contained in:
Miklos Vajna 2024-05-30 08:10:13 +02:00
parent f67e7fc5c7
commit 304cc248f1
4 changed files with 60 additions and 0 deletions

View file

@ -20,6 +20,7 @@ $(eval $(call gb_CppunitTest_add_exception_objects,sw_core_text, \
sw/qa/core/text/porlay \
sw/qa/core/text/porrst \
sw/qa/core/text/text \
sw/qa/core/text/txtfly \
sw/qa/core/text/widorp \
))

Binary file not shown.

View file

@ -0,0 +1,52 @@
/* -*- 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 <pagefrm.hxx>
#include <rootfrm.hxx>
namespace
{
/// Covers sw/source/core/text/txtfly.cxx fixes.
class Test : public SwModelTestBase
{
public:
Test()
: SwModelTestBase("/sw/qa/core/text/data/")
{
}
};
CPPUNIT_TEST_FIXTURE(Test, testClearingBreakWrapThrough)
{
// Given a document with a clearing break, then a shape in the next paragraph:
createSwDoc("clearing-break-wrap-through.docx");
// When laying out that document:
calcLayout();
// Then make sure we layout these 2 paragraphs on a single page, since there is enough space for
// them:
SwDoc* pDoc = getSwDoc();
SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout();
auto pPage = pLayout->Lower()->DynCastPageFrame();
CPPUNIT_ASSERT(pPage);
// Without the accompanying fix in place, this test would have failed, we had an unexpected 2nd
// page.
CPPUNIT_ASSERT(!pPage->GetNext());
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View file

@ -1051,6 +1051,13 @@ SwTwips SwTextFly::GetMaxBottom(const SwBreakPortion& rPortion, const SwTextForm
continue;
}
const SwFormatSurround& rSurround = pAnchoredObj->GetFrameFormat()->GetSurround();
if (rSurround.GetValue() == text::WrapTextMode_THROUGH)
{
// Wrap through has no influence on clearing breaks.
continue;
}
SwRect aRect(pAnchoredObj->GetObjRectWithSpaces());
if (m_pCurrFrame->IsVertical())