sw/source/core/inc/SwUndoPageDesc.hxx  |    2 ++
 sw/source/core/undo/SwUndoPageDesc.cxx |   12 ++++++++++++
 2 files changed, 14 insertions(+)

New commits:
commit b39c4353fecc168c6752aacd74e2b483c0000e05
Author:     Caolán McNamara <caol...@redhat.com>
AuthorDate: Thu Jan 26 15:05:36 2023 +0000
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Fri Jan 27 08:38:30 2023 +0000

    tdf#153220 exit header/footer edit mode, if active, on undo header/footer
    
    Change-Id: Ibe97a9239bff03b7bcffc11c02b6bdff840c4481
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146194
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/sw/source/core/inc/SwUndoPageDesc.hxx 
b/sw/source/core/inc/SwUndoPageDesc.hxx
index c8d88f6cbd04..ab90a3a65b5f 100644
--- a/sw/source/core/inc/SwUndoPageDesc.hxx
+++ b/sw/source/core/inc/SwUndoPageDesc.hxx
@@ -34,6 +34,8 @@ class SwUndoPageDesc final : public SwUndo
     // To avoid duplication of (header/footer)content nodes for simple page 
desc changes
     void ExchangeContentNodes( SwPageDesc& rSource, SwPageDesc &rDest );
 
+    // tdf#153220 use to Exit HeaderFooter EditMode
+    void ExitHeaderFooterEdit();
 public:
     SwUndoPageDesc(const SwPageDesc & aOld, const SwPageDesc & aNew,
                    SwDoc * pDoc);
diff --git a/sw/source/core/undo/SwUndoPageDesc.cxx 
b/sw/source/core/undo/SwUndoPageDesc.cxx
index 0ec97951ed85..eec1300d5e67 100644
--- a/sw/source/core/undo/SwUndoPageDesc.cxx
+++ b/sw/source/core/undo/SwUndoPageDesc.cxx
@@ -18,6 +18,7 @@
  */
 
 #include <doc.hxx>
+#include <editsh.hxx>
 #include <IDocumentUndoRedo.hxx>
 #include <swundo.hxx>
 #include <pagedesc.hxx>
@@ -216,12 +217,22 @@ void SwUndoPageDesc::ExchangeContentNodes( SwPageDesc& 
rSource, SwPageDesc &rDes
     pNewFormat->SetFormatAttr( SwFormatContent() );
 }
 
+void SwUndoPageDesc::ExitHeaderFooterEdit()
+{
+    SwEditShell* pESh = m_pDoc->GetEditShell();
+    if (!pESh)
+        return;
+    if (pESh->IsHeaderFooterEdit())
+        pESh->ToggleHeaderFooterEdit();
+}
+
 void SwUndoPageDesc::UndoImpl(::sw::UndoRedoContext &)
 {
     // Move (header/footer)content node responsibility from new page 
descriptor to old one again.
     if( m_bExchange )
         ExchangeContentNodes( m_aNew.m_PageDesc, m_aOld.m_PageDesc );
     m_pDoc->ChgPageDesc(m_aOld.GetName(), m_aOld);
+    ExitHeaderFooterEdit();
 }
 
 void SwUndoPageDesc::RedoImpl(::sw::UndoRedoContext &)
@@ -230,6 +241,7 @@ void SwUndoPageDesc::RedoImpl(::sw::UndoRedoContext &)
     if( m_bExchange )
         ExchangeContentNodes( m_aOld.m_PageDesc, m_aNew.m_PageDesc );
     m_pDoc->ChgPageDesc(m_aNew.GetName(), m_aNew);
+    ExitHeaderFooterEdit();
 }
 
 SwRewriter SwUndoPageDesc::GetRewriter() const

Reply via email to