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

Miklos Vajna (via logerrit) logerrit at kemper.freedesktop.org
Wed Jun 17 12:00:46 UTC 2020


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

New commits:
commit 7caa0003b0dc71ed676cc8fa84585c49f8ac5031
Author:     Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Mon Jun 15 21:04:56 2020 +0200
Commit:     Adolfo Jayme Barrientos <fitojb at ubuntu.com>
CommitDate: Wed Jun 17 14:00:15 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)
    
    Conflicts:
            sw/qa/core/layout/layout.cxx
    
    Change-Id: I77841a3a0fb68f054941184ee2a8aca0707d2a9c
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96467
    Tested-by: Jenkins
    Reviewed-by: Adolfo Jayme Barrientos <fitojb at ubuntu.com>

diff --git a/sw/qa/extras/layout/data/continuous-endnotes-move-backwards.doc b/sw/qa/extras/layout/data/continuous-endnotes-move-backwards.doc
new file mode 100644
index 000000000000..3ee6c56aa370
Binary files /dev/null and b/sw/qa/extras/layout/data/continuous-endnotes-move-backwards.doc differ
diff --git a/sw/qa/extras/layout/layout.cxx b/sw/qa/extras/layout/layout.cxx
index e33eaf66e108..4583df8680b8 100644
--- a/sw/qa/extras/layout/layout.cxx
+++ b/sw/qa/extras/layout/layout.cxx
@@ -3810,6 +3810,23 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testBtlrTableRowSpan)
     assertXPathContent(pXmlDoc, "//textarray[1]/text", "USA");
 }
 
+CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testContinuousEndnotesMoveBackwards)
+{
+    // Load a document with the ContinuousEndnotes flag turned on.
+    load(DATA_DIRECTORY, "continuous-endnotes-move-backwards.doc");
+    xmlDocPtr 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 767ead4c6ef1..9573944b71d1 100644
--- a/sw/source/core/layout/ftnfrm.cxx
+++ b/sw/source/core/layout/ftnfrm.cxx
@@ -718,13 +718,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