sw/source/core/doc/docftn.cxx |   31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

New commits:
commit c23c71cef94d19375d741045975a846bac85fefe
Author:     Jim Raykowski <[email protected]>
AuthorDate: Mon Oct 27 22:06:13 2025 -0800
Commit:     Jim Raykowski <[email protected]>
CommitDate: Thu Oct 30 10:27:17 2025 +0100

    Resolves tdf#169129 Feature to switch between footnotes/endnotes does
    
    not change style
    
    Currently when you change a footnote to an endnote or an endnote to a
    footnote, the type is changed but the style is not. This patch makes the
    style change.
    
    Change-Id: I6e32c35c8563230e440152e1d57895a1006e2f92
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/193066
    Tested-by: Heiko Tietze <[email protected]>
    Reviewed-by: Heiko Tietze <[email protected]>
    Tested-by: Jenkins
    Reviewed-by: Jim Raykowski <[email protected]>

diff --git a/sw/source/core/doc/docftn.cxx b/sw/source/core/doc/docftn.cxx
index 232dd420ae46..5d64d6c5ac7b 100644
--- a/sw/source/core/doc/docftn.cxx
+++ b/sw/source/core/doc/docftn.cxx
@@ -445,6 +445,35 @@ void SwDoc::SetEndNoteInfo(const SwEndNoteInfo& rInfo)
 
 }
 
+namespace
+{
+// Change style of all text nodes between start and end node for the 
SwTextFootnote to the
+// style of the type of note it is.
+void lcl_ChgFormatColl(SwDoc* pDoc, SwTextFootnote* pTextFootnote, 
SwUndoChangeFootNote* pUndo)
+{
+    SwTextFormatColl* pChangeToTextFormatColl
+        = pDoc->getIDocumentStylePoolAccess().GetTextCollFromPool(
+            pTextFootnote->GetFootnote().IsEndNote() ? RES_POOLCOLL_ENDNOTE
+                                                     : RES_POOLCOLL_FOOTNOTE);
+
+    SwNodeIndex aNodeIndex(*pTextFootnote->GetStartNode(), 1);
+    while (!aNodeIndex.GetNode().IsEndNode())
+    {
+        if (aNodeIndex.GetNode().IsTextNode())
+        {
+            SwTextNode* pTextNode = aNodeIndex.GetNode().GetTextNode();
+            if (pUndo)
+            {
+                pUndo->GetHistory().AddColl(pTextNode->GetFormatColl(), 
pTextNode->GetIndex(),
+                                            SwNodeType::Text);
+            }
+            pTextNode->ChgFormatColl(pChangeToTextFormatColl);
+        }
+        ++aNodeIndex;
+    }
+}
+}
+
 bool SwDoc::SetCurFootnote( const SwPaM& rPam, const OUString& rNumStr,
                        bool bIsEndNote)
 {
@@ -495,6 +524,7 @@ bool SwDoc::SetCurFootnote( const SwPaM& rPam, const 
OUString& rNumStr,
                 {
                     const_cast<SwFormatFootnote&>(rFootnote).SetEndNote( 
bIsEndNote );
                     bTypeChgd = true;
+                    lcl_ChgFormatColl(this, pTextFootnote, pUndo.get());
                     pTextFootnote->CheckCondColl();
                     //#i11339# dispose UNO wrapper when a footnote is changed 
to an endnote or vice versa
                     
const_cast<SwFormatFootnote&>(rFootnote).InvalidateFootnote();
@@ -529,6 +559,7 @@ bool SwDoc::SetCurFootnote( const SwPaM& rPam, const 
OUString& rNumStr,
                 {
                     const_cast<SwFormatFootnote&>(rFootnote).SetEndNote( 
bIsEndNote );
                     bTypeChgd = true;
+                    lcl_ChgFormatColl(this, pTextFootnote, pUndo.get());
                     pTextFootnote->CheckCondColl();
                 }
             }

Reply via email to