tdf#146704 sw: fix regression of endnote layout in sections

Endnotes collected at the end of sections moved to a new page.

Regression from commit 4c31b4ef2083087a822c3ae648fd09acc67d2f88
"tdf#139336 sw: fix extra pages of multicolumn sections with footnotes".

Co-authored-by: Tibor Nagy (NISZ)

Change-Id: I36568e33b04ba8024ceef6b3ea84b71fb375e2a4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129896
Tested-by: László Németh <nemeth@numbertext.org>
Reviewed-by: László Németh <nemeth@numbertext.org>
diff --git a/sw/qa/extras/layout/data/tdf146704_EndnoteInSection.odt b/sw/qa/extras/layout/data/tdf146704_EndnoteInSection.odt
new file mode 100644
index 0000000..660dcb7
--- /dev/null
+++ b/sw/qa/extras/layout/data/tdf146704_EndnoteInSection.odt
Binary files differ
diff --git a/sw/qa/extras/layout/layout.cxx b/sw/qa/extras/layout/layout.cxx
index 74638e4..1618b86a 100644
--- a/sw/qa/extras/layout/layout.cxx
+++ b/sw/qa/extras/layout/layout.cxx
@@ -3728,6 +3728,15 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf135035)
    CPPUNIT_ASSERT_GREATER(nParentWidth, nFly3Width);
}

CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf146704_EndnoteInSection)
{
    SwDoc* pDoc = createSwDoc(DATA_DIRECTORY, "tdf146704_EndnoteInSection.odt");
    CPPUNIT_ASSERT(pDoc);
    xmlDocUniquePtr pXmlDoc = parseLayoutDump();
    // Without the fix, the endnote placed to 2. page
    assertXPath(pXmlDoc, "/root/page", 1);
}

CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf139336_ColumnsWithFootnoteDoNotOccupyEntirePage)
{
    SwDoc* pDoc
diff --git a/sw/source/core/layout/findfrm.cxx b/sw/source/core/layout/findfrm.cxx
index 445d3e2..d100e24 100644
--- a/sw/source/core/layout/findfrm.cxx
+++ b/sw/source/core/layout/findfrm.cxx
@@ -458,8 +458,9 @@ SwFootnoteBossFrame* SwFrame::FindFootnoteBossFrame( bool bFootnotes )
    //         similar case can be reached with a page break + FootnoteAtEnd setting
    SwSectionFrame* pSectframe = pRet->FindSctFrame();
    bool bMoveToPageFrame = false;
    // tdf146704: only if it is really a footnote, not an endnote.
    // tdf54465: compatibility flag to make old odt files keep these full page sections.
    if (pSectframe
    if (bFootnotes && pSectframe
        && pSectframe->GetFormat()->getIDocumentSettingAccess().get(
            DocumentSettingId::FOOTNOTE_IN_COLUMN_TO_PAGEEND))
    {