SwTextRuby: SwClient no more

Change-Id: I2ff5a5af710302dff5de5bc42e514f3838a13655
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/181757
Tested-by: Jenkins
Reviewed-by: Bjoern Michaelsen <bjoern.michaelsen@libreoffice.org>
Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
Bjoern Michaelsen
2025-02-17 21:38:09 +01:00
parent d80dd99db9
commit 7ff861a1ea
3 changed files with 25 additions and 38 deletions
+2 -2
View File
@@ -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,
+2 -1
View File
@@ -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());
}
/**
+21 -35
View File
@@ -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)
sal_uInt16 nWhich = 0;
switch(rHint.GetId())
{
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)
{
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;
}