diff options
author | Bjoern Michaelsen <bjoern.michaelsen@libreoffice.org> | 2021-01-04 00:40:32 +0100 |
---|---|---|
committer | Bjoern Michaelsen <bjoern.michaelsen@libreoffice.org> | 2021-01-05 08:33:46 +0100 |
commit | bf81aa59d86ef749dc37cdd49c6fc745376f857d (patch) | |
tree | e7a8c270e2774e60345b87d378969cd4854f6923 /sw/source | |
parent | 968db0f261e2eb19d09f91c52b0ce920fcbd02d2 (diff) |
SwClientNotifyCall no more
- SwClientNotify calls really shouldnt happen from outside the class in
the future
- the few remaining legacy exceptions have been marked as friend --
admittedly ugly, but it reduces the scope of call being triggered from
anywhere to a welldefined set.
Change-Id: I46d5f755b0cf5de013a4c345a04e2c67447a99aa
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108651
Tested-by: Jenkins
Reviewed-by: Bjoern Michaelsen <bjoern.michaelsen@libreoffice.org>
Diffstat (limited to 'sw/source')
-rw-r--r-- | sw/source/core/attr/calbck.cxx | 22 | ||||
-rw-r--r-- | sw/source/core/attr/format.cxx | 27 |
2 files changed, 26 insertions, 23 deletions
diff --git a/sw/source/core/attr/calbck.cxx b/sw/source/core/attr/calbck.cxx index 25c19a6d2015..11235aeac02a 100644 --- a/sw/source/core/attr/calbck.cxx +++ b/sw/source/core/attr/calbck.cxx @@ -18,6 +18,7 @@ */ #include <frame.hxx> +#include <format.hxx> #include <hintids.hxx> #include <hints.hxx> #include <swcache.hxx> @@ -41,13 +42,13 @@ namespace sw { auto pModifyChanged = CheckRegistration(pLegacyHint->m_pOld); if (pModifyChanged) - m_pToTell->SwClientNotifyCall(rModify, *pModifyChanged); + m_pToTell->SwClientNotify(rModify, *pModifyChanged); } else if (m_pToTell) - m_pToTell->SwClientNotifyCall(rModify, rHint); + m_pToTell->SwClientNotify(rModify, rHint); } else if (m_pToTell) - m_pToTell->SwClientNotifyCall(rModify, rHint); + m_pToTell->SwClientNotify(rModify, rHint); } } @@ -103,6 +104,19 @@ std::unique_ptr<sw::ModifyChangedHint> SwClient::CheckRegistration( const SfxPoo return std::unique_ptr<sw::ModifyChangedHint>(new sw::ModifyChangedHint(pAbove)); } +void SwClient::CheckRegistrationFormat(SwFormat& rOld) +{ + assert(GetRegisteredIn() == &rOld); + auto pNew = rOld.DerivedFrom(); + SAL_INFO("sw.core", "reparenting " << typeid(*this).name() << " at " << this << " from " << typeid(rOld).name() << " at " << &rOld << " to " << typeid(*pNew).name() << " at " << pNew); + assert(pNew); + pNew->Add(this); + const SwFormatChg aOldFormat(&rOld); + const SwFormatChg aNewFormat(pNew); + const sw::LegacyModifyHint aHint(&aOldFormat, &aNewFormat); + SwClientNotify(rOld, aHint); +} + void SwClient::SwClientNotify(const SwModify&, const SfxHint& rHint) { if(auto pLegacyHint = dynamic_cast<const sw::LegacyModifyHint*>(&rHint)) @@ -363,6 +377,6 @@ void sw::ClientNotifyAttrChg(SwModify& rModify, const SwAttrSet& aSet, SwAttrSet const SwAttrSetChg aChgOld(aSet, aOld); const SwAttrSetChg aChgNew(aSet, aNew); const sw::LegacyModifyHint aHint(&aChgOld, &aChgNew); - rModify.SwClientNotifyCall(rModify, aHint); + rModify.SwClientNotify(rModify, aHint); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/attr/format.cxx b/sw/source/core/attr/format.cxx index 13e3f7c48d9a..be7e24e120d7 100644 --- a/sw/source/core/attr/format.cxx +++ b/sw/source/core/attr/format.cxx @@ -215,31 +215,20 @@ SwFormat::~SwFormat() { // This happens at an ObjectDying message. Thus put all dependent // ones on DerivedFrom. - if( !HasWriterListeners() ) + if(!HasWriterListeners()) return; m_bFormatInDTOR = true; - SwFormat* pParentFormat = DerivedFrom(); - if( !pParentFormat ) + if(!DerivedFrom()) { - SAL_WARN( - "sw.core", - "~SwFormat: parent format missing from: " << GetName() ); - } - else - { - SwFormatChg aOldFormat( this ); - SwFormatChg aNewFormat( pParentFormat ); - SwIterator<SwClient,SwFormat> aIter(*this); - for(SwClient* pClient = aIter.First(); pClient && pParentFormat; pClient = aIter.Next()) - { - SAL_INFO("sw.core", "reparenting " << typeid(*pClient).name() << " at " << pClient << " from " << typeid(*this).name() << " at " << this << " to " << typeid(*pParentFormat).name() << " at " << pParentFormat); - pParentFormat->Add( pClient ); - const sw::LegacyModifyHint aHint(&aOldFormat, &aNewFormat); - pClient->SwClientNotifyCall(*this, aHint); - } + SAL_WARN("sw.core", "~SwFormat: format still has clients on death, but parent format is missing: " << GetName()); + return; } + SwIterator<SwClient,SwFormat> aIter(*this); + for(SwClient* pClient = aIter.First(); pClient; pClient = aIter.Next()) + pClient->CheckRegistrationFormat(*this); + assert(!HasWriterListeners()); } void SwFormat::SwClientNotify(const SwModify&, const SfxHint& rHint) |