summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2019-10-25 17:40:02 +0200
committerMiklos Vajna <vmiklos@collabora.com>2019-10-25 20:24:05 +0200
commit61cf196631a2a846e0d3b8b83c0805cf4d1d14b2 (patch)
treec56b462e947b89821a1577553769f91861c022ce
parentdf9672b1fada6fc847bfa4c8a8f016fb2af6a7b5 (diff)
sw ContinuousEndnotes: fix moving them to the previous page
If you delete the first page of a document, the endnotes remained on an empty last page. Fix this. Change-Id: I70187c4c32490178366e024606926d3cebcaa680 Reviewed-on: https://gerrit.libreoffice.org/81512 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
-rw-r--r--sw/qa/extras/layout/layout.cxx26
-rw-r--r--sw/source/core/text/txtftn.cxx6
2 files changed, 31 insertions, 1 deletions
diff --git a/sw/qa/extras/layout/layout.cxx b/sw/qa/extras/layout/layout.cxx
index c12c55082ee3..d8cef7ef98aa 100644
--- a/sw/qa/extras/layout/layout.cxx
+++ b/sw/qa/extras/layout/layout.cxx
@@ -3361,6 +3361,32 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testContinuousEndnotesInsertPageAtStart)
assertXPath(pXmlDoc, "/root/page[3]/ftncont", 1);
}
+CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testContinuousEndnotesDeletePageAtStart)
+{
+ // Create a new document with CONTINUOUS_ENDNOTES enabled.
+ SwDoc* pDoc = createDoc();
+ pDoc->getIDocumentSettingAccess().set(DocumentSettingId::CONTINUOUS_ENDNOTES, true);
+
+ // Insert a second page, and an endnote on the 2nd page (both the anchor and the endnote is on
+ // the 2nd page).
+ SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+ pWrtShell->InsertPageBreak();
+ pWrtShell->InsertFootnote("endnote", /*bEndNote=*/true, /*bEdit=*/false);
+
+ // Remove the empty page at the start of the document.
+ pWrtShell->SttEndDoc(/*bStart=*/true);
+ pWrtShell->DelRight();
+
+ // Make sure that the endnote is moved from the 2nd page to the 1st one.
+ xmlDocPtr pXmlDoc = parseLayoutDump();
+ // Without the accompanying fix in place, this test would have failed with:
+ // - Expected: 1
+ // - Actual : 2
+ // i.e. the endnote remained on an (otherwise) empty 2nd page.
+ assertXPath(pXmlDoc, "/root/page", 1);
+ assertXPath(pXmlDoc, "/root/page[1]/ftncont", 1);
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/text/txtftn.cxx b/sw/source/core/text/txtftn.cxx
index e9e7046e66fd..27dfe303d58f 100644
--- a/sw/source/core/text/txtftn.cxx
+++ b/sw/source/core/text/txtftn.cxx
@@ -52,6 +52,7 @@
#include <layouter.hxx>
#include <frmtool.hxx>
#include <ndindex.hxx>
+#include <IDocumentSettingAccess.hxx>
using namespace ::com::sun::star;
@@ -578,7 +579,10 @@ void SwTextFrame::ConnectFootnote( SwTextFootnote *pFootnote, const SwTwips nDea
mbFootnote = true;
mbInFootnoteConnect = true; // Just reset!
- const bool bEnd = pFootnote->GetFootnote().IsEndNote();
+ // See if pFootnote is an endnote on a separate endnote page.
+ const IDocumentSettingAccess& rSettings = GetDoc().getIDocumentSettingAccess();
+ bool bContinuousEndnotes = rSettings.get(DocumentSettingId::CONTINUOUS_ENDNOTES);
+ const bool bEnd = pFootnote->GetFootnote().IsEndNote() && !bContinuousEndnotes;
// We want to store this value, because it is needed as a fallback
// in GetFootnoteLine(), if there is no paragraph information available