diff options
-rw-r--r-- | sw/inc/txtatr.hxx | 4 | ||||
-rw-r--r-- | sw/source/core/txtnode/thints.cxx | 3 | ||||
-rw-r--r-- | sw/source/core/txtnode/txtatr2.cxx | 56 |
3 files changed, 25 insertions, 38 deletions
diff --git a/sw/inc/txtatr.hxx b/sw/inc/txtatr.hxx index cf425589387a..dae1a61b1723 100644 --- a/sw/inc/txtatr.hxx +++ b/sw/inc/txtatr.hxx @@ -80,10 +80,10 @@ public: }; -class SW_DLLPUBLIC SwTextRuby final: public SwTextAttrNesting, public SwClient +class SW_DLLPUBLIC SwTextRuby final: public SwTextAttrNesting, public SvtListener { SwTextNode* m_pTextNode; - virtual void SwClientNotify(const SwModify&, const SfxHint&) override; + virtual void Notify(const SfxHint&) override; public: SwTextRuby( const SfxPoolItemHolder& rAttr, diff --git a/sw/source/core/txtnode/thints.cxx b/sw/source/core/txtnode/thints.cxx index f288b8d1a162..5cb27e549181 100644 --- a/sw/source/core/txtnode/thints.cxx +++ b/sw/source/core/txtnode/thints.cxx @@ -229,7 +229,8 @@ void SwTextRuby::InitRuby(SwTextNode & rNode) ChgTextNode(&rNode); SwCharFormat * const pFormat( rNode.GetDoc().getIDocumentStylePoolAccess().GetCharFormatFromPool(RES_POOLCHR_RUBYTEXT) ); - pFormat->Add(*this); + EndListeningAll(); + StartListening(pFormat->GetNotifier()); } /** diff --git a/sw/source/core/txtnode/txtatr2.cxx b/sw/source/core/txtnode/txtatr2.cxx index 219664f76d86..c6cb5b64141c 100644 --- a/sw/source/core/txtnode/txtatr2.cxx +++ b/sw/source/core/txtnode/txtatr2.cxx @@ -257,7 +257,6 @@ SwTextRuby::SwTextRuby( sal_Int32 nEnd ) : SwTextAttr( rAttr, nStart ) , SwTextAttrNesting( rAttr, nStart, nEnd ) - , SwClient( nullptr ) , m_pTextNode( nullptr ) { SwFormatRuby& rSwFormatRuby(static_cast<SwFormatRuby&>(GetAttr())); @@ -268,41 +267,29 @@ SwTextRuby::~SwTextRuby() { } -void SwTextRuby::SwClientNotify(const SwModify&, const SfxHint& rHint) +void SwTextRuby::Notify(const SfxHint& rHint) { if(lcl_CheckAutoFormatHint(rHint, m_pTextNode)) return; - if (rHint.GetId() == SfxHintId::SwFormatChange) - { - if(!m_pTextNode) - return; - SwUpdateAttr aUpdateAttr(GetStart(), *GetEnd(), RES_UPDATEATTR_FMT_CHG); - m_pTextNode->TriggerNodeUpdate(sw::UpdateAttrHint(&aUpdateAttr, &aUpdateAttr)); - } - else if (rHint.GetId() == SfxHintId::SwAttrSetChange) + sal_uInt16 nWhich = 0; + switch(rHint.GetId()) { - if(!m_pTextNode) - return; - SwUpdateAttr aUpdateAttr(GetStart(), *GetEnd(), RES_UPDATEATTR_ATTRSET_CHG); - m_pTextNode->TriggerNodeUpdate(sw::UpdateAttrHint(&aUpdateAttr, &aUpdateAttr)); - } - else if (rHint.GetId() == SfxHintId::SwObjectDying) - { - if(!m_pTextNode) - return; - SwUpdateAttr aUpdateAttr(GetStart(), *GetEnd(), RES_UPDATEATTR_OBJECTDYING); - m_pTextNode->TriggerNodeUpdate(sw::UpdateAttrHint(&aUpdateAttr, &aUpdateAttr)); - } - else if (rHint.GetId() == SfxHintId::SwLegacyModify) - { - auto pLegacy = static_cast<const sw::LegacyModifyHint*>(&rHint); - const auto nWhich = pLegacy->GetWhich(); - assert( isCHRATR(nWhich) && "SwTextRuby::SwClientNotify(): unknown legacy hint"); - if(!m_pTextNode) - return; - SwUpdateAttr aUpdateAttr(GetStart(), *GetEnd(), nWhich); - m_pTextNode->TriggerNodeUpdate(sw::UpdateAttrHint(&aUpdateAttr, &aUpdateAttr)); + case SfxHintId::SwAttrSetChange: nWhich = RES_UPDATEATTR_ATTRSET_CHG; break; + case SfxHintId::SwFormatChange: nWhich = RES_UPDATEATTR_FMT_CHG; break; + case SfxHintId::SwObjectDying: nWhich = RES_UPDATEATTR_OBJECTDYING; break; + case SfxHintId::SwLegacyModify: + { + auto pLegacy = static_cast<const sw::LegacyModifyHint*>(&rHint); + nWhich = pLegacy->GetWhich(); + assert( isCHRATR(nWhich) && "SwTextRuby::SwClientNotify(): unknown legacy hint"); + break; + } + default: break; } + if(!m_pTextNode || !nWhich) + return; + SwUpdateAttr aUpdateAttr(GetStart(), *GetEnd(), nWhich); + m_pTextNode->TriggerNodeUpdate(sw::UpdateAttrHint(&aUpdateAttr, &aUpdateAttr)); } SwCharFormat* SwTextRuby::GetCharFormat() @@ -339,10 +326,9 @@ SwCharFormat* SwTextRuby::GetCharFormat() } } - if( pRet ) - pRet->Add(*this); - else - EndListeningAll(); + EndListeningAll(); + if(pRet) + StartListening(pRet->GetNotifier()); return pRet; } |