From a625a9e6858fa1c8c62d6201040d7d36e71a4efa Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Wed, 2 Mar 2022 12:04:32 +0000 Subject: move these two DeleteListeners beside each other MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I815223b88b09d19014bed7c4940873fc12b4854f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130845 Tested-by: Caolán McNamara Reviewed-by: Caolán McNamara --- sw/source/filter/ww8/ww8par2.cxx | 85 +++++++++++++++++++--------------------- 1 file changed, 41 insertions(+), 44 deletions(-) diff --git a/sw/source/filter/ww8/ww8par2.cxx b/sw/source/filter/ww8/ww8par2.cxx index e47f11913548..df34892bc8a9 100644 --- a/sw/source/filter/ww8/ww8par2.cxx +++ b/sw/source/filter/ww8/ww8par2.cxx @@ -169,12 +169,12 @@ sal_uInt32 wwSectionManager::GetWWPageTopMargin() const namespace { - class DeleteListener final : public SvtListener + class SvtDeleteListener final : public SvtListener { private: bool bObjectDeleted; public: - explicit DeleteListener(SvtBroadcaster& rNotifier) + explicit SvtDeleteListener(SvtBroadcaster& rNotifier) : bObjectDeleted(false) { StartListening(rNotifier); @@ -191,6 +191,43 @@ namespace return bObjectDeleted; } }; + + class SwDeleteListener final : public SwClient + { + private: + SwModify* m_pModify; + + virtual void SwClientNotify(const SwModify&, const SfxHint& rHint) override + { + if (rHint.GetId() != SfxHintId::SwLegacyModify) + return; + auto pLegacy = static_cast(&rHint); + if (pLegacy->GetWhich() == RES_OBJECTDYING) + { + m_pModify->Remove(this); + m_pModify = nullptr; + } + } + + public: + SwDeleteListener(SwModify* pModify) + : m_pModify(pModify) + { + m_pModify->Add(this); + } + + bool WasDeleted() const + { + return !m_pModify; + } + + virtual ~SwDeleteListener() override + { + if (!m_pModify) + return; + m_pModify->Remove(this); + } + }; } sal_uInt16 SwWW8ImplReader::End_Footnote() @@ -252,7 +289,7 @@ sal_uInt16 SwWW8ImplReader::End_Footnote() SwFormatFootnote& rFormatFootnote = static_cast(pFN->GetAttr()); - DeleteListener aDeleteListener(rFormatFootnote.GetNotifier()); + SvtDeleteListener aDeleteListener(rFormatFootnote.GetNotifier()); // read content of Ft-/End-Note Read_HdFtFootnoteText( pSttIdx, rDesc.mnStartCp, rDesc.mnLen, rDesc.meType); @@ -2789,46 +2826,6 @@ void WW8TabDesc::MoveOutsideTable() *m_pIo->m_pPaM->GetPoint() = *m_xTmpPos->GetPoint(); } -namespace -{ - class SwTableNodeListener final : public SwClient - { - private: - SwModify* m_pModify; - - virtual void SwClientNotify(const SwModify&, const SfxHint& rHint) override - { - if (rHint.GetId() != SfxHintId::SwLegacyModify) - return; - auto pLegacy = static_cast(&rHint); - if (pLegacy->GetWhich() == RES_OBJECTDYING) - { - m_pModify->Remove(this); - m_pModify = nullptr; - } - } - - public: - SwTableNodeListener(SwModify* pModify) - : m_pModify(pModify) - { - m_pModify->Add(this); - } - - bool WasDeleted() const - { - return !m_pModify; - } - - virtual ~SwTableNodeListener() override - { - if (!m_pModify) - return; - m_pModify->Remove(this); - } - }; -} - void WW8TabDesc::FinishSwTable() { m_pIo->m_xRedlineStack->closeall(*m_pIo->m_pPaM->GetPoint()); @@ -2839,7 +2836,7 @@ void WW8TabDesc::FinishSwTable() m_pIo->m_pLastAnchorPos.reset(); SwTableNode* pTableNode = m_pTable->GetTableNode(); - SwTableNodeListener aListener(pTableNode); + SwDeleteListener aListener(pTableNode); m_pIo->m_xRedlineStack = std::move(mxOldRedlineStack); if (xLastAnchorCursor) -- cgit