summaryrefslogtreecommitdiff
path: root/sw/source/core/attr/format.cxx
diff options
context:
space:
mode:
authorBjoern Michaelsen <bjoern.michaelsen@libreoffice.org>2021-01-23 01:09:49 +0100
committerBjoern Michaelsen <bjoern.michaelsen@libreoffice.org>2021-01-29 23:10:59 +0100
commitd77552970af7ffb9d06bcd57315979f317e94e2f (patch)
tree9ba78f893f57efc2ab0f8d542abb70032c240ee3 /sw/source/core/attr/format.cxx
parentc6ff20f1c101372be46a2583ec0c83ff021690a9 (diff)
remove SwCache bookkeeping from SwModify
- only very few classes (SwNode, SwFormat) are the "owners" of SwBorderAttrs in the SwCache - this bookkeeping should not be in such a fundamental class of writer - also: encapsulate most of the interaction with the cache in the new sw::BorderCacheOwner. This is mostly to protect the innocent user: * As interacting with the SwCache directly is very errorprone, because its glorious idea of using void* of the "owners" as keys to the entries. * In C++, reinterpret_cast<void*>(this) might be different along the class heirachy. This might easily slip under the radar of a casual user. Change-Id: I0da774b47885abf52f63aab8d93ebbf41dcf8040 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110112 Tested-by: Jenkins Reviewed-by: Bjoern Michaelsen <bjoern.michaelsen@libreoffice.org>
Diffstat (limited to 'sw/source/core/attr/format.cxx')
-rw-r--r--sw/source/core/attr/format.cxx47
1 files changed, 11 insertions, 36 deletions
diff --git a/sw/source/core/attr/format.cxx b/sw/source/core/attr/format.cxx
index 4c29d313424a..9224a61f2ab2 100644
--- a/sw/source/core/attr/format.cxx
+++ b/sw/source/core/attr/format.cxx
@@ -79,6 +79,7 @@ SwFormat::SwFormat( SwAttrPool& rPool, const OUString& rFormatNm,
}
SwFormat::SwFormat( const SwFormat& rFormat ) :
+ sw::BorderCacheOwner(),
m_aFormatName( rFormat.m_aFormatName ),
m_aSet( rFormat.m_aSet ),
m_nWhichId( rFormat.m_nWhichId ),
@@ -110,11 +111,7 @@ SwFormat &SwFormat::operator=(const SwFormat& rFormat)
m_nPoolHelpId = rFormat.GetPoolHelpId();
m_nPoolHlpFileId = rFormat.GetPoolHlpFileId();
- if ( IsInCache() )
- {
- SwFrame::GetCache().Delete( this );
- SetInCache( false );
- }
+ InvalidateInSwCache(RES_OBJECTDYING);
// copy only array with attributes delta
SwAttrSet aOld( *m_aSet.GetPool(), m_aSet.GetRanges() ),
@@ -176,11 +173,7 @@ void SwFormat::SetName( const OUString& rNewName, bool bBroadcast )
void SwFormat::CopyAttrs( const SwFormat& rFormat )
{
// copy only array with attributes delta
- if ( IsInCache() )
- {
- SwFrame::GetCache().Delete( this );
- SetInCache( false );
- }
+ InvalidateInSwCache(RES_ATTRSET_CHG);
InvalidateInSwFntCache(RES_ATTRSET_CHG);
// special treatments for some attributes
@@ -239,6 +232,7 @@ void SwFormat::SwClientNotify(const SwModify&, const SfxHint& rHint)
std::unique_ptr<SwAttrSetChg> pOldClientChg, pNewClientChg;
auto pDependsHint = std::make_unique<sw::LegacyModifyHint>(pLegacy->m_pOld, pLegacy->m_pNew);
const sal_uInt16 nWhich = pLegacy->GetWhich();
+ InvalidateInSwCache(nWhich);
switch(nWhich)
{
case 0:
@@ -352,11 +346,7 @@ bool SwFormat::SetDerivedFrom(SwFormat *pDerFrom)
|| (Which()==RES_FLYFRMFMT && pDerFrom->Which()==RES_FRMFMT)
);
- if ( IsInCache() )
- {
- SwFrame::GetCache().Delete( this );
- SetInCache( false );
- }
+ InvalidateInSwCache(RES_ATTRSET_CHG);
InvalidateInSwFntCache(RES_ATTRSET_CHG);
pDerFrom->Add( this );
@@ -460,7 +450,7 @@ bool SwFormat::SetFormatAttr( const SfxPoolItem& rAttr )
{
const sal_uInt16 nWhich = rAttr.Which();
InvalidateInSwFntCache( nWhich );
- CheckCaching( nWhich );
+ InvalidateInSwCache( nWhich );
bool bRet = false;
@@ -540,11 +530,7 @@ bool SwFormat::SetFormatAttr( const SfxItemSet& rSet )
if( !rSet.Count() )
return false;
- if ( IsInCache() )
- {
- SwFrame::GetCache().Delete( this );
- SetInCache( false );
- }
+ InvalidateInSwCache(RES_ATTRSET_CHG);
InvalidateInSwFntCache(RES_ATTRSET_CHG);
bool bRet = false;
@@ -644,11 +630,8 @@ bool SwFormat::ResetFormatAttr( sal_uInt16 nWhich1, sal_uInt16 nWhich2 )
for( sal_uInt16 n = nWhich1; n < nWhich2; ++n )
InvalidateInSwFntCache( n );
- if ( IsInCache() )
- {
- for( sal_uInt16 n = nWhich1; n < nWhich2; ++n )
- CheckCaching( n );
- }
+ for( sal_uInt16 n = nWhich1; n < nWhich2 && IsInCache(); ++n )
+ InvalidateInSwCache( n );
// if Modify is locked then no modifications will be sent
if( IsModifyLocked() )
@@ -670,11 +653,7 @@ sal_uInt16 SwFormat::ResetAllFormatAttr()
if( !m_aSet.Count() )
return 0;
- if ( IsInCache() )
- {
- SwFrame::GetCache().Delete( this );
- SetInCache( false );
- }
+ InvalidateInSwCache(RES_ATTRSET_CHG);
InvalidateInSwFntCache(RES_ATTRSET_CHG);
// if Modify is locked then no modifications will be sent
@@ -694,11 +673,7 @@ void SwFormat::DelDiffs( const SfxItemSet& rSet )
if( !m_aSet.Count() )
return;
- if ( IsInCache() )
- {
- SwFrame::GetCache().Delete( this );
- SetInCache( false );
- }
+ InvalidateInSwCache(RES_ATTRSET_CHG);
InvalidateInSwFntCache(RES_ATTRSET_CHG);
// if Modify is locked then no modifications will be sent