summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2023-04-13 23:50:07 +0300
committerMichael Stahl <michael.stahl@allotropia.de>2023-04-21 11:37:11 +0200
commitc950f16a2bfec74b757bb32bc869b01faee6dac1 (patch)
treebe82e65aff5614f97c52024e18100c44f992aa9e /sw
parent47f442ee5c0252a4dffd464b28c5948448cd901a (diff)
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 <mike.kaganski@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150434 Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org> (cherry picked from commit 16fca224a398b562d009fb562493fd5460bb3dc5) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150718 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Michael Stahl <michael.stahl@allotropia.de> Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
Diffstat (limited to 'sw')
-rw-r--r--sw/qa/extras/layout/data/wideBoxInFootnote.fodt24
-rw-r--r--sw/qa/extras/layout/layout2.cxx29
-rw-r--r--sw/source/core/text/itrform2.cxx2
3 files changed, 55 insertions, 0 deletions
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 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<office:document xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" office:version="1.3" office:mimetype="application/vnd.oasis.opendocument.text">
+ <office:automatic-styles>
+ <style:style style:name="P1" style:family="paragraph" style:parent-style-name="Footnote">
+ <style:paragraph-properties fo:orphans="2"/>
+ </style:style>
+ <style:page-layout style:name="pm1">
+ <style:page-layout-properties fo:page-width="21cm" fo:page-height="297mm" style:print-orientation="portrait" fo:margin-top="2cm" fo:margin-bottom="2cm" fo:margin-left="2cm" fo:margin-right="2cm"/>
+ </style:page-layout>
+ </office:automatic-styles>
+ <office:master-styles>
+ <style:master-page style:name="Standard" style:page-layout-name="pm1"/>
+ </office:master-styles>
+ <office:body>
+ <office:text>
+ <text:p><text:note text:note-class="footnote"><text:note-citation>1</text:note-citation>
+ <text:note-body>
+ <text:p text:style-name="P1"><draw:rect text:anchor-type="as-char" svg:width="18cm" svg:height="3mm"/></text:p>
+ </text:note-body>
+ </text:note></text:p>
+ </office:text>
+ </office:body>
+</office:document> \ 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 <unotools/syslocaleoptions.hxx>
#include <editeng/unolingu.hxx>
#include <o3tl/string_view.hxx>
+#include <vcl/scheduler.hxx>
#include <unotxdoc.hxx>
#include <rootfrm.hxx>
@@ -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 );