From 304cc248f15d795bc9fe8b751b0d98841b8ff5d1 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Thu, 30 May 2024 08:10:13 +0200 Subject: [PATCH] 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 f86d1482bef285f90079b5130e410646db96cf58 (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: - layout loop control for layout action 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 Tested-by: Jenkins --- sw/CppunitTest_sw_core_text.mk | 1 + .../data/clearing-break-wrap-through.docx | Bin 0 -> 13056 bytes sw/qa/core/text/txtfly.cxx | 52 ++++++++++++++++++ sw/source/core/text/txtfly.cxx | 7 +++ 4 files changed, 60 insertions(+) create mode 100644 sw/qa/core/text/data/clearing-break-wrap-through.docx create mode 100644 sw/qa/core/text/txtfly.cxx 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 0000000000000000000000000000000000000000..c96e8c27da5e1a8a32091e74d3d649fec676175b GIT binary patch literal 13056 zcmeHu1y>!*()LDz6WrZBxCeK4cXxLS7M$P^oZ#;6?(Xg`0YY&7cFw)$9(m9D{=mJn zR@d6oJx@*VnX0bp?q}qsz`#)f5CA9u06+xT%$u>+1OWgD-vIz904Pu`Av;@V6I*9J zWe0HDC@|9AWsKY_Z0QQIB{M3KA1M}*i$6~m*P5^B&0-XuE3 zV@OOdP}P^X!M4{96i@{fkXRUNVlw8t4QADW!0DA#YiOi;H?mU+A z)}dp~!LmJWCl8iZ(!=v69Iinua(DR#HY%;lCoHxAjK{OSI%(nyW|NRNHsAR1h7MMr zZ0^ATfVVd=fc#%v5{fA%jf3Emn?0t%7>mc0yc z{1<^Qfz#~@E8Up6vh+q%tC-7>P+AhwD631Bi?1&qmzF?vjt#^{XJ+H4Je|@-UA7W* zF0qqT;KSRY7anwbwVvAC0f|9v`Hb!h_B(KC2e+m#BP0@3BY_bbXyKFC5V7~6$>Uup z`_#g>`-QL;#8i`WMx?d5nGPz8cgdfazojtFFIb9ec|n%&h;#(wwM<}rf-&W*{>n@j z6Wy~>qtmB+65qu1#ggiV7TcPEo-94qunY$KvTgdrGqj@^8(H)9 zF#G_EkL`j;qfT$z4kukl;3qIJ{ox+~V90{fZC8iQh9$iNhASfs000Sq3vjb@G^RJU zGjg#3#;sogOGOzP0Jiy{YWl0VxWfWKz>k2Q25t;|g7xZJPH7ydpEgro5a2GTwpw{y zxE*HlQidB+3RXXk3SyFjT97>~=yi%A>m$Q;Pp}{eEM90kJ5NyfKDS8~*AfYm)26j{ zLvFf=2Wuo7mo`6LOr}MIor(w5ASxuqHn&pDygVOYbn@Do5%r!X7>|I2N>4Q4POhs{ z@&5c6W)w&KKqOP8A187GW?DR$L)qQ8%7o;}!*?kY0UI2aKzIRTfHI;Gr@S$ z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/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())