sw/qa/extras/layout/layout.cxx   |   26 ++++++++++++++++++++++++++
 sw/source/core/layout/ftnfrm.cxx |    7 ++++++-
 2 files changed, 32 insertions(+), 1 deletion(-)

New commits:
commit 14885ae3637d3e0d276e4cce0c1051c0bcf15c47
Author:     Miklos Vajna <vmik...@collabora.com>
AuthorDate: Thu Oct 24 17:05:46 2019 +0200
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Thu Oct 24 17:55:14 2019 +0200

    sw ContinuousEndnotes: fix moving them to the next page
    
    If you insert a page break at the start of the document, the endnotes on
    the old last page were not moved to the new last page. Fix this.
    
    Change-Id: I0d54cc4242648dfd9a268e6189a35c88a19069eb
    Reviewed-on: https://gerrit.libreoffice.org/81459
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>
    Tested-by: Jenkins

diff --git a/sw/qa/extras/layout/layout.cxx b/sw/qa/extras/layout/layout.cxx
index 5adaf5a54492..c12c55082ee3 100644
--- a/sw/qa/extras/layout/layout.cxx
+++ b/sw/qa/extras/layout/layout.cxx
@@ -3335,6 +3335,32 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf124770)
     assertXPath(pXmlDoc, "/root/page/body/txt[1]/LineBreak", 1);
 }
 
+CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testContinuousEndnotesInsertPageAtStart)
+{
+    // 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);
+
+    // Add a new page at the start of the document.
+    pWrtShell->SttEndDoc(/*bStart=*/true);
+    pWrtShell->InsertPageBreak();
+
+    // Make sure that the endnote is moved from the 2nd page to the 3rd one.
+    xmlDocPtr pXmlDoc = parseLayoutDump();
+    assertXPath(pXmlDoc, "/root/page", 3);
+    // Without the accompanying fix in place, this test would have failed with:
+    // - Expected: 1
+    // - Actual  : 0
+    // i.e. the footnote container remained on page 2.
+    assertXPath(pXmlDoc, "/root/page[3]/ftncont", 1);
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/layout/ftnfrm.cxx b/sw/source/core/layout/ftnfrm.cxx
index d4d4e531e798..6711643d438b 100644
--- a/sw/source/core/layout/ftnfrm.cxx
+++ b/sw/source/core/layout/ftnfrm.cxx
@@ -1859,7 +1859,12 @@ void SwFootnoteBossFrame::CollectFootnotes_( const 
SwContentFrame*   _pRef,
 
         // OD 03.04.2003 #108446# - determine, if found footnote has to be 
collected.
         bool bCollectFoundFootnote = false;
-        if ( _pFootnote->GetRef() == _pRef && 
!_pFootnote->GetAttr()->GetFootnote().IsEndNote() )
+        // Ignore endnotes which are on a separate endnote page.
+        bool bEndNote = _pFootnote->GetAttr()->GetFootnote().IsEndNote();
+        const IDocumentSettingAccess& rSettings
+            = _pFootnote->GetAttrSet()->GetDoc()->getIDocumentSettingAccess();
+        bool bContinuousEndnotes = 
rSettings.get(DocumentSettingId::CONTINUOUS_ENDNOTES);
+        if (_pFootnote->GetRef() == _pRef && (!bEndNote || 
bContinuousEndnotes))
         {
             if ( _bCollectOnlyPreviousFootnotes )
             {
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to