tdf#153220 exit header/footer edit mode, if active, on undo header/footer
Change-Id: Ibe97a9239bff03b7bcffc11c02b6bdff840c4481
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146093
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
diff --git a/sw/source/core/inc/SwUndoPageDesc.hxx b/sw/source/core/inc/SwUndoPageDesc.hxx
index c8d88f6..ab90a3a 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 0ec9795..eec1300 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