From 481c740ff04bc119fe1822f1a773a10a46d5d3a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= Date: Thu, 26 Jan 2023 15:05:36 +0000 Subject: [PATCH] tdf#153220 exit header/footer edit mode, if active, on undo header/footer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Ibe97a9239bff03b7bcffc11c02b6bdff840c4481 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146178 Tested-by: Jenkins Reviewed-by: Caolán McNamara --- sw/source/core/inc/SwUndoPageDesc.hxx | 2 ++ sw/source/core/undo/SwUndoPageDesc.cxx | 12 ++++++++++++ 2 files changed, 14 insertions(+) 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 +#include #include #include #include @@ -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