diff --git a/sw/CppunitTest_sw_core_text.mk b/sw/CppunitTest_sw_core_text.mk index 95b69b90113b..8c215dfab4e1 100644 --- a/sw/CppunitTest_sw_core_text.mk +++ b/sw/CppunitTest_sw_core_text.mk @@ -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 \ )) diff --git a/sw/qa/core/text/data/clearing-break-wrap-through.docx b/sw/qa/core/text/data/clearing-break-wrap-through.docx new file mode 100644 index 000000000000..c96e8c27da5e Binary files /dev/null and b/sw/qa/core/text/data/clearing-break-wrap-through.docx differ diff --git a/sw/qa/core/text/txtfly.cxx b/sw/qa/core/text/txtfly.cxx new file mode 100644 index 000000000000..461ed81e2203 --- /dev/null +++ b/sw/qa/core/text/txtfly.cxx @@ -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 + +#include + +#include +#include +#include +#include +#include + +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: */ diff --git a/sw/source/core/text/txtfly.cxx b/sw/source/core/text/txtfly.cxx index 7c4d9a2e160d..45eea8eeee53 100644 --- a/sw/source/core/text/txtfly.cxx +++ b/sw/source/core/text/txtfly.cxx @@ -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())