summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2023-04-13 23:50:07 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2023-04-14 19:34:28 +0200
commit46cf6d3f899fbab7524085597483feeb6f5d6cd9 (patch)
treed09a3898c7a3b0cfa2c92dbc64eceadf44a9b812
parent25d0ae95d6e7695a33cb67b1cb3626c338cf92a9 (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>
-rw-r--r--sw/qa/extras/layout/data/wideBoxInFootnote.fodt24
-rw-r--r--sw/qa/extras/layout/layout3.cxx28
-rw-r--r--sw/source/core/text/itrform2.cxx2
3 files changed, 54 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/layout3.cxx b/sw/qa/extras/layout/layout3.cxx
index 62cb65e2ccd3..824e51b4c710 100644
--- a/sw/qa/extras/layout/layout3.cxx
+++ b/sw/qa/extras/layout/layout3.cxx
@@ -1574,6 +1574,34 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter3, testTdf54465_ColumnsWithFootnoteDoNotOccup
assertXPath(pXmlDoc, "/root/page", 1);
}
+CPPUNIT_TEST_FIXTURE(SwLayoutWriter3, 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 a6a8229721d0..f4cbe364ebe6 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 );