diff options
author | Caolán McNamara <caolanm@redhat.com> | 2022-03-02 12:04:32 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2022-03-02 16:34:57 +0100 |
commit | a625a9e6858fa1c8c62d6201040d7d36e71a4efa (patch) | |
tree | ecb5ec7f05d155b25a88f3aa8d7fdc61fd3ef2c5 | |
parent | fc6d3381da7555c7144b650d239ce1d88ce9026e (diff) |
move these two DeleteListeners beside each other
Change-Id: I815223b88b09d19014bed7c4940873fc12b4854f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130845
Tested-by: Caolán McNamara <caolanm@redhat.com>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r-- | sw/source/filter/ww8/ww8par2.cxx | 85 |
1 files 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<const sw::LegacyModifyHint*>(&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<SwFormatFootnote&>(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<const sw::LegacyModifyHint*>(&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) |