[Libreoffice-commits] core.git: sw/inc sw/source
Bjoern Michaelsen (via logerrit)
logerrit at kemper.freedesktop.org
Sun Dec 6 00:55:21 UTC 2020
sw/inc/fmtpdsc.hxx | 1
sw/source/core/layout/atrfrm.cxx | 90 ++++++++++++++++-----------------------
2 files changed, 39 insertions(+), 52 deletions(-)
New commits:
commit a0f97e40ce078b044893061933c329c103f91269
Author: Bjoern Michaelsen <bjoern.michaelsen at libreoffice.org>
AuthorDate: Sat Dec 5 23:44:44 2020 +0100
Commit: Bjoern Michaelsen <bjoern.michaelsen at libreoffice.org>
CommitDate: Sun Dec 6 01:54:39 2020 +0100
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 at libreoffice.org>
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!
More information about the Libreoffice-commits
mailing list