[Libreoffice-commits] core.git: Branch 'libreoffice-7-0' - sw/qa sw/source

Miklos Vajna (via logerrit) logerrit at kemper.freedesktop.org
Tue Jun 16 11:20:06 UTC 2020


 sw/qa/core/layout/data/continuous-endnotes-move-backwards.doc |binary
 sw/qa/core/layout/layout.cxx                                  |   17 +++++++++
 sw/source/core/layout/ftnfrm.cxx                              |   18 ++++++++++
 3 files changed, 35 insertions(+)

New commits:
commit b67ee7ed04fb081c21205ada72c0843af92de28c
Author:     Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Mon Jun 15 21:04:56 2020 +0200
Commit:     Miklos Vajna <vmiklos at collabora.com>
CommitDate: Tue Jun 16 13:19:35 2020 +0200

    tdf#133145 sw ContinuousEndnotes: fix moving endnotes to a previous page
    
    Regression from commit 4814e8caa5f06c4fe438dfd7d7315e4a2410ea18
    (tdf#124601 sw: add ContinuousEndnotes layout compat option,
    2019-09-30), the problem was that SwFrame::GetPrevFootnoteLeaf() did not
    take the new compat flag into account when determining the previous
    footnote page for endnotes.
    
    Do the same pattern here as the cases already handled in the above
    commit, just try to get the "last but one" and not the "last" page,
    since we try to move these endnotes to a previous page.
    
    (cherry picked from commit 35bb0594b2d977312ef06fc5262cc7592bc13d0f)
    
    Change-Id: I77841a3a0fb68f054941184ee2a8aca0707d2a9c
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96432
    Tested-by: Jenkins
    Reviewed-by: Miklos Vajna <vmiklos at collabora.com>

diff --git a/sw/qa/core/layout/data/continuous-endnotes-move-backwards.doc b/sw/qa/core/layout/data/continuous-endnotes-move-backwards.doc
new file mode 100644
index 000000000000..3ee6c56aa370
Binary files /dev/null and b/sw/qa/core/layout/data/continuous-endnotes-move-backwards.doc differ
diff --git a/sw/qa/core/layout/layout.cxx b/sw/qa/core/layout/layout.cxx
index cfc13640c471..ccf2b5cd513a 100644
--- a/sw/qa/core/layout/layout.cxx
+++ b/sw/qa/core/layout/layout.cxx
@@ -129,6 +129,23 @@ CPPUNIT_TEST_FIXTURE(SwCoreLayoutTest, testTablesMoveBackwards)
     assertXPath(pLayout, "//page", 1);
 }
 
+CPPUNIT_TEST_FIXTURE(SwCoreLayoutTest, testContinuousEndnotesMoveBackwards)
+{
+    // Load a document with the ContinuousEndnotes flag turned on.
+    load(DATA_DIRECTORY, "continuous-endnotes-move-backwards.doc");
+    xmlDocUniquePtr pLayout = parseLayoutDump();
+    // We have 2 pages.
+    assertXPath(pLayout, "/root/page", 2);
+    // No endnote container on page 1.
+    // Without the accompanying fix in place, this test would have failed with:
+    // - Expected: 0
+    // - Actual  : 1
+    // i.e. there were unexpected endnotes on page 1.
+    assertXPath(pLayout, "/root/page[1]/ftncont", 0);
+    // All endnotes are in a container on page 2.
+    assertXPath(pLayout, "/root/page[2]/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 1b143e7d7b87..8ddd9747f840 100644
--- a/sw/source/core/layout/ftnfrm.cxx
+++ b/sw/source/core/layout/ftnfrm.cxx
@@ -750,13 +750,31 @@ SwLayoutFrame *SwFrame::GetPrevFootnoteLeaf( MakePageType eMakeFootnote )
     {
         bool bEndn = pFootnote->GetAttr()->GetFootnote().IsEndNote();
         SwFrame* pTmpRef = nullptr;
+        const IDocumentSettingAccess& rSettings
+            = pFootnote->GetAttrSet()->GetDoc()->getIDocumentSettingAccess();
         if( bEndn && pFootnote->IsInSct() )
         {
             SwSectionFrame* pSect = pFootnote->FindSctFrame();
             if( pSect->IsEndnAtEnd() )
+                // Endnotes at the end of the section.
                 pTmpRef = pSect->FindLastContent( SwFindMode::LastCnt );
         }
+        else if (bEndn && rSettings.get(DocumentSettingId::CONTINUOUS_ENDNOTES))
+        {
+            // Endnotes at the end of the document.
+            SwPageFrame* pPage = getRootFrame()->GetLastPage();
+            assert(pPage);
+            SwFrame* pPrevPage = pPage->GetPrev();
+            if (pPrevPage)
+            {
+                // Have a last but one page, use that since we try to get a preceding frame.
+                assert(pPrevPage->IsPageFrame());
+                pPage = static_cast<SwPageFrame*>(pPrevPage);
+            }
+            pTmpRef = pPage->FindLastBodyContent();
+        }
         if( !pTmpRef )
+            // Endnotes on a separate page.
             pTmpRef = pFootnote->GetRef();
         SwFootnoteBossFrame* pStop = pTmpRef->FindFootnoteBossFrame( !bEndn );
 


More information about the Libreoffice-commits mailing list