sw/source/core/inc/pagefrm.hxx    |    1 +
 sw/source/core/inc/sectfrm.hxx    |    4 ++++
 sw/source/core/layout/findfrm.cxx |   23 +++++++++++++++++++++++
 sw/source/core/layout/sectfrm.cxx |    1 +
 4 files changed, 29 insertions(+)

New commits:
commit 8bae684c93bd23bbe98707ba9cf75d1a39427131
Author:     Miklos Vajna <vmik...@collabora.com>
AuthorDate: Thu May 9 08:20:21 2024 +0200
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Thu May 9 09:35:03 2024 +0200

    tdf#160984 sw continuous endnotes: add a way to find the endnote section 
start
    
    Existing code with endnotes on separate page at the end of the document
    works by searching for a current or next page that is an endnote page in
    SwFootnoteBossFrame::AppendFootnote(), and in case none is found, then
    an endnote page is created.
    
    Add similar infrastructure for the inline endnotes case: here we want to
    find the first page that has an endnotes section, which also requires
    being able to tell if a section is an endnotes one.
    
    The newly introduced SwPageFrame::GetEndNoteSection() is not yet used in
    SwFootnoteBossFrame::AppendFootnote(), though.
    
    Change-Id: Ib08267f9bf6c7b06576624e3fa8e90e8b8b1b232
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167371
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>
    Tested-by: Jenkins

diff --git a/sw/source/core/inc/pagefrm.hxx b/sw/source/core/inc/pagefrm.hxx
index 23d77b1c8f74..be55221b2bef 100644
--- a/sw/source/core/inc/pagefrm.hxx
+++ b/sw/source/core/inc/pagefrm.hxx
@@ -204,6 +204,7 @@ public:
     bool IsEndNotePage() const                      { return m_bEndNotePage; }
     void SetFootnotePage( bool b )                       { m_bFootnotePage = 
b; }
     void SetEndNotePage( bool b )                   { m_bEndNotePage = b; }
+    SwSectionFrame* GetEndNoteSection();
 
     sal_uInt16 GetPhyPageNum() const        { return m_nPhyPageNum;}
     void SetPhyPageNum( sal_uInt16 nNum )   { m_nPhyPageNum = nNum;}
diff --git a/sw/source/core/inc/sectfrm.hxx b/sw/source/core/inc/sectfrm.hxx
index 9dbf9f4df9cc..12646d08ebad 100644
--- a/sw/source/core/inc/sectfrm.hxx
+++ b/sw/source/core/inc/sectfrm.hxx
@@ -52,6 +52,8 @@ class SAL_DLLPUBLIC_RTTI SwSectionFrame final: public 
SwLayoutFrame, public SwFl
     SwSection* m_pSection;
     bool m_bFootnoteAtEnd; // footnotes at the end of section
     bool m_bEndnAtEnd; // endnotes at the end of section
+    /// If this is a section for endnotes, then the SwSection is not backed by 
an SwSectionNode.
+    bool m_bEndNoteSection = false;
     bool m_bContentLock; // content locked
     bool m_bOwnFootnoteNum; // special numbering of footnotes
     bool m_bFootnoteLock; // ftn, don't leave this section bwd
@@ -171,6 +173,8 @@ public:
 
     void SetFootnoteLock( bool bNew ) { m_bFootnoteLock = bNew; }
     bool IsFootnoteLock() const { return m_bFootnoteLock; }
+    void SetEndNoteSection(bool bEndNoteSection) { m_bEndNoteSection = 
bEndNoteSection; }
+    bool IsEndNoteSection() const { return m_bEndNoteSection; }
 };
 
 inline const SwSectionFrame *SwSectionFrame::GetFollow() const
diff --git a/sw/source/core/layout/findfrm.cxx 
b/sw/source/core/layout/findfrm.cxx
index a86a7afefc87..60ca1fe7d326 100644
--- a/sw/source/core/layout/findfrm.cxx
+++ b/sw/source/core/layout/findfrm.cxx
@@ -65,6 +65,29 @@ SwContentFrame *SwPageFrame::FindLastBodyContent()
     return pRet;
 }
 
+SwSectionFrame* SwPageFrame::GetEndNoteSection()
+{
+    SwLayoutFrame* pBody = FindBodyCont();
+    if (!pBody)
+    {
+        return nullptr;
+    }
+
+    SwFrame* pLast = pBody->GetLastLower();
+    if (!pLast || !pLast->IsSctFrame())
+    {
+        return nullptr;
+    }
+
+    auto pLastSection = static_cast<SwSectionFrame*>(pLast);
+    if (!pLastSection->IsEndNoteSection())
+    {
+        return nullptr;
+    }
+
+    return pLastSection;
+}
+
 /**
  * Checks if the frame contains one or more ContentFrame's anywhere in his
  * subsidiary structure; if so the first found ContentFrame is returned.
diff --git a/sw/source/core/layout/sectfrm.cxx 
b/sw/source/core/layout/sectfrm.cxx
index 3967a1f56442..78278da9cb38 100644
--- a/sw/source/core/layout/sectfrm.cxx
+++ b/sw/source/core/layout/sectfrm.cxx
@@ -94,6 +94,7 @@ SwSectionFrame::SwSectionFrame( SwSectionFrame &rSect, bool 
bMaster ) :
     m_bOwnFootnoteNum( false ),
     m_bFootnoteLock( false )
 {
+    m_bEndNoteSection = rSect.m_bEndNoteSection;
     StartListening(rSect.GetFormat()->GetNotifier());
 
     mnFrameType = SwFrameType::Section;

Reply via email to