From c950f16a2bfec74b757bb32bc869b01faee6dac1 Mon Sep 17 00:00:00 2001 From: Mike Kaganski Date: Thu, 13 Apr 2023 23:50:07 +0300 Subject: tdf#138124: do not reset IsFootnoteDone status in line layout Similar to IsNumDone Change-Id: I64c713148b613ca1db4a30cde13bec5a6744accc Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150378 Tested-by: Jenkins Reviewed-by: Mike Kaganski Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150434 Reviewed-by: Xisco Fauli (cherry picked from commit 16fca224a398b562d009fb562493fd5460bb3dc5) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150718 Reviewed-by: Miklos Vajna Tested-by: Michael Stahl Reviewed-by: Michael Stahl --- sw/qa/extras/layout/data/wideBoxInFootnote.fodt | 24 ++++++++++++++++++++ sw/qa/extras/layout/layout2.cxx | 29 +++++++++++++++++++++++++ sw/source/core/text/itrform2.cxx | 2 ++ 3 files changed, 55 insertions(+) create mode 100644 sw/qa/extras/layout/data/wideBoxInFootnote.fodt (limited to 'sw') diff --git a/sw/qa/extras/layout/data/wideBoxInFootnote.fodt b/sw/qa/extras/layout/data/wideBoxInFootnote.fodt new file mode 100644 index 000000000000..f63eaa6fa621 --- /dev/null +++ b/sw/qa/extras/layout/data/wideBoxInFootnote.fodt @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + 1 + + + + + + + \ No newline at end of file diff --git a/sw/qa/extras/layout/layout2.cxx b/sw/qa/extras/layout/layout2.cxx index 1e72bd335227..bd939bc5d661 100644 --- a/sw/qa/extras/layout/layout2.cxx +++ b/sw/qa/extras/layout/layout2.cxx @@ -18,6 +18,7 @@ #include #include #include +#include #include #include @@ -2744,6 +2745,34 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf153136) // CPPUNIT_ASSERT_GREATER(large, height); } +CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf138124) +{ + // When the only portion after the footnote number is a FlyCnt, and it doesn't fit into + // the page width, it should be moved to the next line without the footnote number, and + // not loop, nor OOM, nor fail assertions. + + createSwDoc("wideBoxInFootnote.fodt"); + Scheduler::ProcessEventsToIdle(); + + // Without the fix in place, the layout would loop, creating new FootnoteNum portions + // indefinitely, until OOM. + // If the footnote paragraph had no orphan control, then the loop would finally end, + // but an assertion in SwTextPainter::DrawTextLine would fail during paint. + + xmlDocUniquePtr pXml = parseLayoutDump(); + assertXPath(pXml, "/root/page", 1); + assertXPath(pXml, "/root/page/ftncont/ftn/txt/anchored", 1); + + // And finally, if there were no assertion in SwTextPainter::DrawTextLine, it would have + // produced multiple lines with FootnoteNum portions, failing the following check like + // - Expected: 1 + // - Actual : 49 + + assertXPath(pXml, + "/root/page/ftncont/ftn/txt//SwFieldPortion[@type='PortionType::FootnoteNum']", 1); + assertXPath(pXml, "/root/page/ftncont/ftn/txt//SwLinePortion[@type='PortionType::FlyCnt']", 1); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/text/itrform2.cxx b/sw/source/core/text/itrform2.cxx index 91f73ed87825..ea420b0a0b30 100644 --- a/sw/source/core/text/itrform2.cxx +++ b/sw/source/core/text/itrform2.cxx @@ -1914,6 +1914,7 @@ TextFrameIndex SwTextFormatter::FormatLine(TextFrameIndex const nStartPos) // These values must not be reset by FormatReset(); const bool bOldNumDone = GetInfo().IsNumDone(); + const bool bOldFootnoteDone = GetInfo().IsFootnoteDone(); const bool bOldArrowDone = GetInfo().IsArrowDone(); const bool bOldErgoDone = GetInfo().IsErgoDone(); @@ -1921,6 +1922,7 @@ TextFrameIndex SwTextFormatter::FormatLine(TextFrameIndex const nStartPos) FormatReset( GetInfo() ); GetInfo().SetNumDone( bOldNumDone ); + GetInfo().SetFootnoteDone(bOldFootnoteDone); GetInfo().SetArrowDone( bOldArrowDone ); GetInfo().SetErgoDone( bOldErgoDone ); -- cgit