diff options
author | Bjoern Michaelsen <bjoern.michaelsen@libreoffice.org> | 2020-12-05 23:44:44 +0100 |
---|---|---|
committer | Bjoern Michaelsen <bjoern.michaelsen@libreoffice.org> | 2020-12-06 01:54:39 +0100 |
commit | a0f97e40ce078b044893061933c329c103f91269 (patch) | |
tree | 6bbeba938eb9c7bd90eb7c8db31701ddcb0bf9d4 /sw | |
parent | 5ffcd52801b5986652b644c1ff6fb37906f30da6 (diff) |
SwFormatPageDesc: Modify no more
Change-Id: Id0f428ba8426f3ce32ceca3e14687e3b83999509
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107267
Tested-by: Jenkins
Reviewed-by: Bjoern Michaelsen <bjoern.michaelsen@libreoffice.org>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/inc/fmtpdsc.hxx | 1 | ||||
-rw-r--r-- | sw/source/core/layout/atrfrm.cxx | 90 |
2 files changed, 39 insertions, 52 deletions
diff --git a/sw/inc/fmtpdsc.hxx b/sw/inc/fmtpdsc.hxx index de54dd585f1e..f66eb3db4128 100644 --- a/sw/inc/fmtpdsc.hxx +++ b/sw/inc/fmtpdsc.hxx @@ -38,7 +38,6 @@ class SW_DLLPUBLIC SwFormatPageDesc : public SfxPoolItem, public SwClient sw::BroadcastingModify* m_pDefinedIn; /**< Points to the object in which the attribute was set (ContentNode/Format). */ protected: - virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew ) override; virtual void SwClientNotify( const SwModify&, const SfxHint& rHint ) override; public: diff --git a/sw/source/core/layout/atrfrm.cxx b/sw/source/core/layout/atrfrm.cxx index 6828c53cfdf4..5e3d0b89e75c 100644 --- a/sw/source/core/layout/atrfrm.cxx +++ b/sw/source/core/layout/atrfrm.cxx @@ -669,32 +669,50 @@ SwFormatPageDesc* SwFormatPageDesc::Clone( SfxItemPool* ) const return new SwFormatPageDesc( *this ); } -void SwFormatPageDesc::SwClientNotify( const SwModify& rModify, const SfxHint& rHint ) +void SwFormatPageDesc::SwClientNotify(const SwModify&, const SfxHint& rHint) { - SwClient::SwClientNotify(rModify, rHint); - const SwPageDescHint* pHint = dynamic_cast<const SwPageDescHint*>(&rHint); - if ( !pHint ) - return; - - // mba: shouldn't that be broadcasted also? - SwFormatPageDesc aDfltDesc( pHint->GetPageDesc() ); - SwPageDesc* pDesc = pHint->GetPageDesc(); - const sw::BroadcastingModify* pMod = GetDefinedIn(); - if ( pMod ) + if(auto pLegacy = dynamic_cast<const sw::LegacyModifyHint*>(&rHint)) { - if( auto pContentNode = dynamic_cast<const SwContentNode*>( pMod) ) - const_cast<SwContentNode*>(pContentNode)->SetAttr( aDfltDesc ); - else if( auto pFormat = dynamic_cast<const SwFormat*>( pMod) ) - const_cast<SwFormat*>(pFormat)->SetFormatAttr( aDfltDesc ); - else + if(m_pDefinedIn && RES_OBJECTDYING == pLegacy->GetWhich()) { - OSL_FAIL( "What kind of sw::BroadcastingModify is this?" ); - RegisterToPageDesc( *pDesc ); + //The Pagedesc where I'm registered dies, therefore I unregister + //from that format. During this I get deleted! + if(typeid(SwFormat) == typeid(m_pDefinedIn)) + { + bool const bResult = static_cast<SwFormat*>(m_pDefinedIn)->ResetFormatAttr(RES_PAGEDESC); + SAL_WARN_IF(!bResult, "sw.core", "FormatPageDesc not deleted in format."); + } + else if(typeid(SwContentNode) == typeid(m_pDefinedIn)) + { + bool const bResult = static_cast<SwContentNode*>(m_pDefinedIn)->ResetAttr(RES_PAGEDESC); + SAL_WARN_IF(!bResult, "sw.core", "FormatPageDesc not deleted in content node."); + } + else + SAL_WARN("sw.core", "SwFormatPageDesc defined in object of unknown type"); } } - else - // there could be an Undo-copy - RegisterToPageDesc( *pDesc ); + else if (const SwPageDescHint* pHint = dynamic_cast<const SwPageDescHint*>(&rHint)) + { + // mba: shouldn't that be broadcasted also? + SwFormatPageDesc aDfltDesc(pHint->GetPageDesc()); + SwPageDesc* pDesc = pHint->GetPageDesc(); + const sw::BroadcastingModify* pMod = GetDefinedIn(); + if(pMod) + { + if(auto pContentNode = dynamic_cast<const SwContentNode*>(pMod)) + const_cast<SwContentNode*>(pContentNode)->SetAttr(aDfltDesc); + else if(auto pFormat = dynamic_cast<const SwFormat*>(pMod)) + const_cast<SwFormat*>(pFormat)->SetFormatAttr( aDfltDesc ); + else + { + SAL_WARN("sw.core", "What kind of sw::BroadcastingModify is this?"); + RegisterToPageDesc(*pDesc); + } + } + else + // there could be an Undo-copy + RegisterToPageDesc(*pDesc); + } } void SwFormatPageDesc::RegisterToPageDesc( SwPageDesc& rDesc ) @@ -702,36 +720,6 @@ void SwFormatPageDesc::RegisterToPageDesc( SwPageDesc& rDesc ) rDesc.Add( this ); } -void SwFormatPageDesc::Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew ) -{ - if( !m_pDefinedIn ) - return; - - const sal_uInt16 nWhichId = pOld ? pOld->Which() : pNew ? pNew->Which() : 0; - switch( nWhichId ) - { - case RES_OBJECTDYING: - //The Pagedesc where I'm registered dies, therefore I unregister - //from that format. During this I get deleted! - if( typeid(SwFormat) == typeid( m_pDefinedIn )) - { - bool const bResult = - static_cast<SwFormat*>(m_pDefinedIn)->ResetFormatAttr(RES_PAGEDESC); - OSL_ENSURE( bResult, "FormatPageDesc not deleted" ); - } - else if( typeid(SwContentNode) == typeid( m_pDefinedIn )) - { - bool const bResult = static_cast<SwContentNode*>(m_pDefinedIn) - ->ResetAttr(RES_PAGEDESC); - OSL_ENSURE( bResult, "FormatPageDesc not deleted" ); - } - break; - - default: - /* do nothing */; - } -} - bool SwFormatPageDesc::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const { // here we convert always! |