sw/qa/extras/layout/data/tdf152106.odt |binary sw/qa/extras/layout/layout.cxx | 11 +++++++++++ sw/source/core/layout/fly.cxx | 8 ++++++++ 3 files changed, 19 insertions(+)
New commits: commit 9300c36361426e724b28c25a7729543b316b258b Author: László Németh <nem...@numbertext.org> AuthorDate: Fri Nov 18 14:11:30 2022 +0100 Commit: László Németh <nem...@numbertext.org> CommitDate: Tue Nov 22 08:23:36 2022 +0100 tdf#152106 sw layout: fix freezing of multicol sections with flys Loading documents with multicol sections with flys could freeze Writer. Add loop control for multicol sections to fix it. Regression from commit 8feac9601cfe35ee0966776bab15d122206f154e "tdf#138518 sw: layout: avoid moving flys forward prematurely". Follow-up to ed12269c42f75f553bb8a8770923406f7824e473 "tdf#142080 sw: layout: fix infinite loop in CalcContent()". Change-Id: I06eb3f5a26b2d2ac3999b98a9661112b8bf7738f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142950 Tested-by: Jenkins Reviewed-by: László Németh <nem...@numbertext.org> (cherry picked from commit 6f0736c2981042f90e83cdd71b3f9c91dbe77661) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142922 diff --git a/sw/qa/extras/layout/data/tdf152106.odt b/sw/qa/extras/layout/data/tdf152106.odt new file mode 100644 index 000000000000..49ef5e50b8bd Binary files /dev/null and b/sw/qa/extras/layout/data/tdf152106.odt differ diff --git a/sw/qa/extras/layout/layout.cxx b/sw/qa/extras/layout/layout.cxx index 431bd5a2cca2..9747fd022e30 100644 --- a/sw/qa/extras/layout/layout.cxx +++ b/sw/qa/extras/layout/layout.cxx @@ -1990,6 +1990,17 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, TestTdf142080) "top", OUString::number(nPage9Top + 1460)); } +CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf152106) +{ + // this caused an infinite loop + load(DATA_DIRECTORY, "tdf152106.odt"); + + xmlDocUniquePtr pLayout = parseLayoutDump(); + + // frame on page 3 + assertXPath(pLayout, "/root/page[3]/sorted_objs/fly", 1); +} + CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf128198) { SwDoc* pDoc = createSwDoc(DATA_DIRECTORY, "tdf128198-1.docx"); diff --git a/sw/source/core/layout/fly.cxx b/sw/source/core/layout/fly.cxx index afe143f158a9..9c61e5590e0a 100644 --- a/sw/source/core/layout/fly.cxx +++ b/sw/source/core/layout/fly.cxx @@ -1472,6 +1472,8 @@ void CalcContent( SwLayoutFrame *pLay, bool bNoColl ) // FME 2007-08-30 #i81146# new loop control int nLoopControlRuns = 0; + // tdf#152106 loop control for multi-column sections + int nLoopControlRunsInMultiCol = 0; const int nLoopControlMax = 20; const SwFrame* pLoopControlCond = nullptr; @@ -1624,10 +1626,16 @@ void CalcContent( SwLayoutFrame *pLay, bool bNoColl ) // #i28701# - restart layout process, if // requested by floating screen object formatting if (bRestartLayoutProcess + // tdf#152106 loop control in multi-column sections to avoid of freezing + && nLoopControlRunsInMultiCol < nLoopControlMax // tdf#142080 if it was already on next page, and still is, // ignore restart, as restart could cause infinite loop && (wasFrameLowerOfLay || pLay->IsAnLower(pFrame))) { + bool bIsMultiColumn = pSect && pSect->GetSection() && pSect->Lower() && + pSect->Lower()->IsColumnFrame() && pSect->Lower()->GetNext(); + if ( bIsMultiColumn ) + ++nLoopControlRunsInMultiCol; pFrame = pLay->ContainsAny(); pAgainObj1 = nullptr; pAgainObj2 = nullptr;