[Libreoffice-commits] core.git: sw/inc sw/Library_sw.mk sw/source

Bjoern Michaelsen (via logerrit) logerrit at kemper.freedesktop.org
Fri Jan 29 22:11:44 UTC 2021


 sw/Library_sw.mk                         |    1 
 sw/inc/BorderCacheOwner.hxx              |   49 +++++++++++++++++++++++++++++++
 sw/inc/calbck.hxx                        |    7 +---
 sw/inc/format.hxx                        |    6 ++-
 sw/inc/node.hxx                          |    3 +
 sw/source/core/attr/BorderCacheOwner.cxx |   45 ++++++++++++++++++++++++++++
 sw/source/core/attr/calbck.cxx           |   30 ------------------
 sw/source/core/attr/format.cxx           |   47 ++++++-----------------------
 sw/source/core/bastyp/swcache.cxx        |    2 -
 sw/source/core/docnode/node.cxx          |   48 ++++++------------------------
 sw/source/core/inc/frmtool.hxx           |    3 +
 sw/source/core/layout/frmtool.cxx        |   20 ++++++------
 sw/source/core/txtnode/ndtxt.cxx         |   17 +++-------
 sw/source/core/undo/untbl.cxx            |   12 +------
 14 files changed, 146 insertions(+), 144 deletions(-)

New commits:
commit d77552970af7ffb9d06bcd57315979f317e94e2f
Author:     Bjoern Michaelsen <bjoern.michaelsen at libreoffice.org>
AuthorDate: Sat Jan 23 01:09:49 2021 +0100
Commit:     Bjoern Michaelsen <bjoern.michaelsen at libreoffice.org>
CommitDate: Fri Jan 29 23:10:59 2021 +0100

    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 at libreoffice.org>

diff --git a/sw/Library_sw.mk b/sw/Library_sw.mk
index 65f4154bf12e..85fd37e2b150 100644
--- a/sw/Library_sw.mk
+++ b/sw/Library_sw.mk
@@ -124,6 +124,7 @@ $(eval $(call gb_Library_add_exception_objects,sw,\
     sw/source/core/access/acctextframe \
     sw/source/core/access/parachangetrackinginfo \
     sw/source/core/access/textmarkuphelper \
+    sw/source/core/attr/BorderCacheOwner \
     sw/source/core/attr/calbck \
     sw/source/core/attr/cellatr \
     sw/source/core/attr/fmtfollowtextflow \
diff --git a/sw/inc/BorderCacheOwner.hxx b/sw/inc/BorderCacheOwner.hxx
new file mode 100644
index 000000000000..6819aed3a8ca
--- /dev/null
+++ b/sw/inc/BorderCacheOwner.hxx
@@ -0,0 +1,49 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef INCLUDED_SW_INC_CACHEOWNER_HXX
+#define INCLUDED_SW_INC_CACHEOWNER_HXX
+
+#include <sal/types.h>
+#include "swdllapi.h"
+
+class SwBorderAttrs;
+class SwBorderAttrAccess;
+
+namespace sw
+{
+/// Bookkeeping helper for SwCache caching writer borders.
+class SW_DLLPUBLIC BorderCacheOwner
+{
+private:
+    friend SwBorderAttrs;
+    friend SwBorderAttrAccess;
+    bool m_bInCache;
+
+public:
+    BorderCacheOwner()
+        : m_bInCache(false)
+    {
+    }
+    BorderCacheOwner(BorderCacheOwner&)
+        : m_bInCache(false)
+    {
+    }
+    BorderCacheOwner& operator=(const BorderCacheOwner&)
+    {
+        m_bInCache = false;
+        return *this;
+    }
+    ~BorderCacheOwner();
+    bool IsInCache() const { return m_bInCache; }
+    void InvalidateInSwCache(const sal_uInt16);
+};
+}
+#endif
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/inc/calbck.hxx b/sw/inc/calbck.hxx
index b5b6ff9a3e30..32b0d35b4c1d 100644
--- a/sw/inc/calbck.hxx
+++ b/sw/inc/calbck.hxx
@@ -176,8 +176,7 @@ class SW_DLLPUBLIC SwModify: public SwClient
     friend void sw::ClientNotifyAttrChg(SwModify&, const SwAttrSet&, SwAttrSet&, SwAttrSet&);
     template<typename E, typename S, sw::IteratorMode> friend class SwIterator;
     sw::WriterListener* m_pWriterListeners;                // the start of the linked list of clients
-    bool m_bModifyLocked : 1;         // don't broadcast changes now
-    bool m_bInCache   : 1;
+    bool m_bModifyLocked;         // don't broadcast changes now
 
     SwModify(SwModify const &) = delete;
     SwModify &operator =(const SwModify&) = delete;
@@ -185,7 +184,7 @@ protected:
     virtual void SwClientNotify(const SwModify&, const SfxHint& rHint) override;
 public:
     SwModify()
-        : SwClient(), m_pWriterListeners(nullptr), m_bModifyLocked(false), m_bInCache(false)
+        : SwClient(), m_pWriterListeners(nullptr), m_bModifyLocked(false)
     {}
 
     // broadcasting mechanism
@@ -202,10 +201,8 @@ public:
 
     void LockModify()                   { m_bModifyLocked = true;  }
     void UnlockModify()                 { m_bModifyLocked = false; }
-    void SetInCache( bool bNew )        { m_bInCache = bNew;       }
     void SetInDocDTOR();
     bool IsModifyLocked() const     { return m_bModifyLocked;  }
-    bool IsInCache()      const     { return m_bInCache;       }
 
     void CheckCaching( const sal_uInt16 nWhich );
     bool HasOnlyOneListener() const { return m_pWriterListeners && m_pWriterListeners->IsLast(); }
diff --git a/sw/inc/format.hxx b/sw/inc/format.hxx
index f1e301ba50d0..29c3fab36033 100644
--- a/sw/inc/format.hxx
+++ b/sw/inc/format.hxx
@@ -20,9 +20,11 @@
 #define INCLUDED_SW_INC_FORMAT_HXX
 
 #include "swdllapi.h"
-#include "swatrset.hxx"
+
+#include "BorderCacheOwner.hxx"
 #include "calbck.hxx"
 #include "hintids.hxx"
+#include "swatrset.hxx"
 #include <memory>
 
 class IDocumentSettingAccess;
@@ -41,7 +43,7 @@ namespace drawinglayer::attribute {
 }
 
 /// Base class for various Writer styles.
-class SW_DLLPUBLIC SwFormat : public sw::BroadcastingModify
+class SW_DLLPUBLIC SwFormat : public sw::BorderCacheOwner, public sw::BroadcastingModify
 {
     friend class SwFrameFormat;
 
diff --git a/sw/inc/node.hxx b/sw/inc/node.hxx
index c69347fde410..a65b4872c5fd 100644
--- a/sw/inc/node.hxx
+++ b/sw/inc/node.hxx
@@ -23,6 +23,7 @@
 #include <sal/types.h>
 
 #include "swdllapi.h"
+#include "BorderCacheOwner.hxx"
 #include "ndarr.hxx"
 #include "ndtyp.hxx"
 #include "index.hxx"
@@ -77,7 +78,7 @@ namespace drawinglayer::attribute {
 
 /// Base class of the Writer document model elements.
 class SW_DLLPUBLIC SwNode
-    : private BigPtrEntry
+    : public sw::BorderCacheOwner, private BigPtrEntry
 {
     friend class SwNodes;
 
diff --git a/sw/source/core/attr/BorderCacheOwner.cxx b/sw/source/core/attr/BorderCacheOwner.cxx
new file mode 100644
index 000000000000..af13686c5afd
--- /dev/null
+++ b/sw/source/core/attr/BorderCacheOwner.cxx
@@ -0,0 +1,45 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <BorderCacheOwner.hxx>
+
+#include <hintids.hxx>
+#include <frame.hxx>
+#include <swcache.hxx>
+
+using namespace sw;
+
+BorderCacheOwner::~BorderCacheOwner()
+{
+    if (m_bInCache)
+        SwFrame::GetCache().Delete(this);
+}
+
+void BorderCacheOwner::InvalidateInSwCache(const sal_uInt16 nWhich)
+{
+    switch (nWhich)
+    {
+        case RES_OBJECTDYING:
+        case RES_FMT_CHG:
+        case RES_ATTRSET_CHG:
+        case RES_UL_SPACE:
+        case RES_LR_SPACE:
+        case RES_BOX:
+        case RES_SHADOW:
+        case RES_FRM_SIZE:
+        case RES_KEEP:
+        case RES_BREAK:
+            if (m_bInCache)
+            {
+                SwFrame::GetCache().Delete(this);
+                m_bInCache = false;
+            }
+    }
+}
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/attr/calbck.cxx b/sw/source/core/attr/calbck.cxx
index a4fff2809f72..0efc4ada197e 100644
--- a/sw/source/core/attr/calbck.cxx
+++ b/sw/source/core/attr/calbck.cxx
@@ -25,7 +25,6 @@
 #include <hints.hxx>
 #include <osl/diagnose.hxx>
 #include <sal/log.hxx>
-#include <swcache.hxx>
 #include <tools/debug.hxx>
 
 #ifdef DBG_UTIL
@@ -155,9 +154,6 @@ SwModify::~SwModify()
     DBG_TESTSOLARMUTEX();
     OSL_ENSURE( !IsModifyLocked(), "Modify destroyed but locked." );
 
-    if ( IsInCache() )
-        SwFrame::GetCache().Delete( this );
-
     // notify all clients that they shall remove themselves
     SwPtrMsgPoolItem aDyObject( RES_OBJECTDYING, this );
     SwModify::SwClientNotify(*this, sw::LegacyModifyHint(&aDyObject, &aDyObject));
@@ -273,28 +269,6 @@ SwClient* SwModify::Remove( SwClient* pDepend )
     return pDepend;
 }
 
-void SwModify::CheckCaching(const sal_uInt16 nWhich)
-{
-    switch(nWhich)
-    {
-        case RES_OBJECTDYING:
-        case RES_FMT_CHG:
-        case RES_ATTRSET_CHG:
-        case RES_UL_SPACE:
-        case RES_LR_SPACE:
-        case RES_BOX:
-        case RES_SHADOW:
-        case RES_FRM_SIZE:
-        case RES_KEEP:
-        case RES_BREAK:
-            if(IsInCache())
-            {
-                SwFrame::GetCache().Delete(this);
-                SetInCache(false);
-            }
-    }
-}
-
 sw::WriterMultiListener::WriterMultiListener(SwClient& rToTell)
     : m_rToTell(rToTell)
 {}
@@ -338,11 +312,9 @@ sw::ClientIteratorBase* sw::ClientIteratorBase::s_pClientIters = nullptr;
 
 void SwModify::SwClientNotify(const SwModify&, const SfxHint& rHint)
 {
-    if(auto pLegacyHint = dynamic_cast<const sw::LegacyModifyHint*>(&rHint))
+    if(dynamic_cast<const sw::LegacyModifyHint*>(&rHint))
     {
         DBG_TESTSOLARMUTEX();
-        if(IsInCache())
-            CheckCaching(pLegacyHint->GetWhich());
         if(IsModifyLocked())
             return;
 
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
diff --git a/sw/source/core/bastyp/swcache.cxx b/sw/source/core/bastyp/swcache.cxx
index fee19de3e583..a0ce68b033d1 100644
--- a/sw/source/core/bastyp/swcache.cxx
+++ b/sw/source/core/bastyp/swcache.cxx
@@ -327,9 +327,7 @@ void SwCache::Delete(void const*const pOwner, sal_uInt16 const nIndex)
 {
     INCREMENT( m_nDelete );
     if (SwCacheObj *const pObj = Get(pOwner, nIndex, false))
-    {
         DeleteObj(pObj);
-    }
 }
 
 void SwCache::Delete( const void *pOwner )
diff --git a/sw/source/core/docnode/node.cxx b/sw/source/core/docnode/node.cxx
index 2fb5e255148e..7f9bae8a01f2 100644
--- a/sw/source/core/docnode/node.cxx
+++ b/sw/source/core/docnode/node.cxx
@@ -348,6 +348,8 @@ SwNode::SwNode( SwNodes& rNodes, sal_uLong nPos, const SwNodeType nNdType )
 SwNode::~SwNode()
 {
     assert(!m_pAnchoredFlys || GetDoc().IsInDtor()); // must all be deleted
+    InvalidateInSwCache(RES_OBJECTDYING);
+    assert(!IsInCache());
 }
 
 /// Find the TableNode in which it is located.
@@ -1092,6 +1094,7 @@ SwContentNode::~SwContentNode()
 
     if ( mpAttrSet && mbSetModifyAtAttr )
         const_cast<SwAttrSet*>(static_cast<const SwAttrSet*>(mpAttrSet.get()))->SetModifyAtAttr( nullptr );
+    InvalidateInSwCache(RES_OBJECTDYING);
 }
 void SwContentNode::UpdateAttr(const SwUpdateAttr& rUpdate)
 {
@@ -1107,6 +1110,7 @@ void SwContentNode::SwClientNotify( const SwModify&, const SfxHint& rHint)
     if (auto pLegacyHint = dynamic_cast<const sw::LegacyModifyHint*>(&rHint))
     {
         const sal_uInt16 nWhich = pLegacyHint->GetWhich();
+        InvalidateInSwCache(nWhich);
 
         bool bSetParent = false;
         bool bCalcHidden = false;
@@ -1262,11 +1266,7 @@ SwFormatColl *SwContentNode::ChgFormatColl( SwFormatColl *pNewColl )
             SwClientNotify( *this, sw::LegacyModifyHint(&aTmp1, &aTmp2) );
         }
     }
-    if ( IsInCache() )
-    {
-        SwFrame::GetCache().Delete( this );
-        SetInCache( false );
-    }
+    InvalidateInSwCache(RES_ATTRSET_CHG);
     return pOldColl;
 }
 
@@ -1562,11 +1562,7 @@ bool SwContentNode::SetAttr(const SfxPoolItem& rAttr )
 
     OSL_ENSURE( GetpSwAttrSet(), "Why did't we create an AttrSet?");
 
-    if ( IsInCache() )
-    {
-        SwFrame::GetCache().Delete( this );
-        SetInCache( false );
-    }
+    InvalidateInSwCache(RES_ATTRSET_CHG);
 
     bool bRet = false;
     // If Modify is locked, we do not send any Modifys
@@ -1588,11 +1584,7 @@ bool SwContentNode::SetAttr(const SfxPoolItem& rAttr )
 
 bool SwContentNode::SetAttr( const SfxItemSet& rSet )
 {
-    if ( IsInCache() )
-    {
-        SwFrame::GetCache().Delete( this );
-        SetInCache( false );
-    }
+    InvalidateInSwCache(RES_ATTRSET_CHG);
 
     const SfxPoolItem* pFnd = nullptr;
     if( SfxItemState::SET == rSet.GetItemState( RES_AUTO_STYLE, false, &pFnd ) )
@@ -1663,11 +1655,7 @@ bool SwContentNode::ResetAttr( sal_uInt16 nWhich1, sal_uInt16 nWhich2 )
     if( !GetpSwAttrSet() )
         return false;
 
-    if ( IsInCache() )
-    {
-        SwFrame::GetCache().Delete( this );
-        SetInCache( false );
-    }
+    InvalidateInSwCache(RES_ATTRSET_CHG);
 
     // If Modify is locked, do not send out any Modifys
     if( IsModifyLocked() )
@@ -1710,12 +1698,7 @@ bool SwContentNode::ResetAttr( const std::vector<sal_uInt16>& rWhichArr )
     if( !GetpSwAttrSet() )
         return false;
 
-    if ( IsInCache() )
-    {
-        SwFrame::GetCache().Delete( this );
-        SetInCache( false );
-    }
-
+    InvalidateInSwCache(RES_ATTRSET_CHG);
     // If Modify is locked, do not send out any Modifys
     sal_uInt16 nDel = 0;
     if( IsModifyLocked() )
@@ -1743,12 +1726,7 @@ sal_uInt16 SwContentNode::ResetAllAttr()
 {
     if( !GetpSwAttrSet() )
         return 0;
-
-    if ( IsInCache() )
-    {
-        SwFrame::GetCache().Delete( this );
-        SetInCache( false );
-    }
+    InvalidateInSwCache(RES_ATTRSET_CHG);
 
     // If Modify is locked, do not send out any Modifys
     if( IsModifyLocked() )
@@ -1906,11 +1884,7 @@ void SwContentNode::SetCondFormatColl(SwFormatColl* pColl)
         SwFormatChg aTmp2(pColl ? pColl : GetFormatColl());
         CallSwClientNotify(sw::LegacyModifyHint(&aTmp1, &aTmp2));
     }
-    if(IsInCache())
-    {
-        SwFrame::GetCache().Delete(this);
-        SetInCache(false);
-    }
+    InvalidateInSwCache(RES_ATTRSET_CHG);
 }
 
 bool SwContentNode::IsAnyCondition( SwCollCondition& rTmp ) const
diff --git a/sw/source/core/inc/frmtool.hxx b/sw/source/core/inc/frmtool.hxx
index 59e2c25769c7..04a8376d9430 100644
--- a/sw/source/core/inc/frmtool.hxx
+++ b/sw/source/core/inc/frmtool.hxx
@@ -21,6 +21,7 @@
 #define INCLUDED_SW_SOURCE_CORE_INC_FRMTOOL_HXX
 
 #include <swtypes.hxx>
+#include <BorderCacheOwner.hxx>
 #include "frame.hxx"
 #include "txtfrm.hxx"
 #include "swcache.hxx"
@@ -377,7 +378,7 @@ class SwBorderAttrs : public SwCacheObj
     void CalcLineSpacing_();
 
 public:
-    SwBorderAttrs( const sw::BroadcastingModify *pOwner, const SwFrame *pConstructor );
+    SwBorderAttrs( const sw::BorderCacheOwner* pOwner, const SwFrame *pConstructor );
     virtual ~SwBorderAttrs() override;
 
     const SwAttrSet      &GetAttrSet() const { return m_rAttrSet;  }
diff --git a/sw/source/core/layout/frmtool.cxx b/sw/source/core/layout/frmtool.cxx
index 9228b4a8b68e..b0a0e13e9182 100644
--- a/sw/source/core/layout/frmtool.cxx
+++ b/sw/source/core/layout/frmtool.cxx
@@ -2150,8 +2150,8 @@ void MakeFrames( SwDoc *pDoc, const SwNodeIndex &rSttIdx,
     bObjsDirect = true;
 }
 
-SwBorderAttrs::SwBorderAttrs(const sw::BroadcastingModify *pMod, const SwFrame *pConstructor)
-    : SwCacheObj(pMod)
+SwBorderAttrs::SwBorderAttrs(const sw::BorderCacheOwner* pOwner, const SwFrame* pConstructor)
+    : SwCacheObj(pOwner)
     , m_rAttrSet(pConstructor->IsContentFrame()
                     ? pConstructor->IsTextFrame()
                         ? static_cast<const SwTextFrame*>(pConstructor)->GetTextNodeForParaProps()->GetSwAttrSet()
@@ -2206,7 +2206,7 @@ SwBorderAttrs::SwBorderAttrs(const sw::BroadcastingModify *pMod, const SwFrame *
 
 SwBorderAttrs::~SwBorderAttrs()
 {
-    const_cast<sw::BroadcastingModify *>(static_cast<sw::BroadcastingModify const *>(m_pOwner))->SetInCache( false );
+    const_cast<sw::BorderCacheOwner*>(static_cast<sw::BorderCacheOwner const *>(m_pOwner))->m_bInCache = false;
 }
 
 /* All calc methods calculate a safety distance in addition to the values given by the attributes.
@@ -2545,28 +2545,28 @@ void SwBorderAttrs::CalcLineSpacing_()
     m_bLineSpacing = false;
 }
 
-static sw::BroadcastingModify const* GetCacheOwner(SwFrame const& rFrame)
+static sw::BorderCacheOwner const* GetBorderCacheOwner(SwFrame const& rFrame)
 {
     return rFrame.IsContentFrame()
-        ? static_cast<sw::BroadcastingModify const*>(rFrame.IsTextFrame()
+        ? static_cast<sw::BorderCacheOwner const*>(rFrame.IsTextFrame()
         // sw_redlinehide: presumably this caches the border attrs at the model level and can be shared across different layouts so we want the ParaProps node here
             ? static_cast<const SwTextFrame&>(rFrame).GetTextNodeForParaProps()
             : static_cast<const SwNoTextFrame&>(rFrame).GetNode())
-        : static_cast<sw::BroadcastingModify const*>(static_cast<const SwLayoutFrame&>(rFrame).GetFormat());
+        : static_cast<sw::BorderCacheOwner const*>(static_cast<const SwLayoutFrame&>(rFrame).GetFormat());
 }
 
 SwBorderAttrAccess::SwBorderAttrAccess( SwCache &rCach, const SwFrame *pFrame ) :
     SwCacheAccess( rCach,
-        static_cast<void const *>(GetCacheOwner(*pFrame)),
-        GetCacheOwner(*pFrame)->IsInCache()),
+        static_cast<void const *>(GetBorderCacheOwner(*pFrame)),
+        GetBorderCacheOwner(*pFrame)->IsInCache()),
     m_pConstructor( pFrame )
 {
 }
 
 SwCacheObj *SwBorderAttrAccess::NewObj()
 {
-    const_cast<sw::BroadcastingModify *>(static_cast<sw::BroadcastingModify const *>(m_pOwner))->SetInCache( true );
-    return new SwBorderAttrs( static_cast<sw::BroadcastingModify const *>(m_pOwner), m_pConstructor );
+    const_cast<sw::BorderCacheOwner *>(static_cast<sw::BorderCacheOwner const *>(m_pOwner))->m_bInCache = true;
+    return new SwBorderAttrs( static_cast<sw::BorderCacheOwner const *>(m_pOwner), m_pConstructor );
 }
 
 SwBorderAttrs *SwBorderAttrAccess::Get()
diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx
index 5ff9923e6bad..ee3f85c2a04e 100644
--- a/sw/source/core/txtnode/ndtxt.cxx
+++ b/sw/source/core/txtnode/ndtxt.cxx
@@ -255,6 +255,7 @@ SwTextNode::~SwTextNode()
     DelFrames(nullptr); // must be called here while it's still a SwTextNode
     DelFrames_TextNodePart();
     ResetAttr(RES_PAGEDESC);
+    InvalidateInSwCache(RES_OBJECTDYING);
 }
 
 void SwTextNode::FileLoadedInitHints()
@@ -548,11 +549,7 @@ SwTextNode *SwTextNode::SplitContentNode(const SwPosition & rPos,
             }
         }
 
-        if ( IsInCache() )
-        {
-            SwFrame::GetCache().Delete( this );
-            SetInCache( false );
-        }
+        InvalidateInSwCache(RES_ATTRSET_CHG);
 
         if ( HasHints() )
         {
@@ -2977,10 +2974,9 @@ SwTextNode* SwTextNode::MakeNewTextNode( const SwNodeIndex& rPos, bool bNext,
         if ( !aClearWhichIds.empty() )
             bRemoveFromCache = 0 != ClearItemsFromAttrSet( aClearWhichIds );
 
-        if( !bNext && bRemoveFromCache && IsInCache() )
+        if( !bNext && bRemoveFromCache )
         {
-            SwFrame::GetCache().Delete( this );
-            SetInCache( false );
+            InvalidateInSwCache(RES_OBJECTDYING);
         }
     }
     SwNodes& rNds = GetNodes();
@@ -3021,10 +3017,9 @@ SwTextNode* SwTextNode::MakeNewTextNode( const SwNodeIndex& rPos, bool bNext,
         {
             std::vector<sal_uInt16> aClearWhichIds;
             aClearWhichIds.push_back( RES_PARATR_NUMRULE );
-            if ( ClearItemsFromAttrSet( aClearWhichIds ) != 0 && IsInCache() )
+            if ( ClearItemsFromAttrSet( aClearWhichIds ) != 0 )
             {
-                SwFrame::GetCache().Delete( this );
-                SetInCache( false );
+                InvalidateInSwCache(RES_ATTRSET_CHG);
             }
         }
     }
diff --git a/sw/source/core/undo/untbl.cxx b/sw/source/core/undo/untbl.cxx
index a07d8cb7df69..b15a8db09331 100644
--- a/sw/source/core/undo/untbl.cxx
+++ b/sw/source/core/undo/untbl.cxx
@@ -937,11 +937,7 @@ void SaveTable::RestoreAttr( SwTable& rTable, bool bMdfyBox )
     rFormatSet.ClearItem();
     rFormatSet.Put(m_aTableSet);
 
-    if( pFormat->IsInCache() )
-    {
-        SwFrame::GetCache().Delete( pFormat );
-        pFormat->SetInCache( false );
-    }
+    pFormat->InvalidateInSwCache(RES_ATTRSET_CHG);
 
     // for safety, invalidate all TableFrames
     SwIterator<SwTabFrame,SwFormat> aIter( *pFormat );
@@ -994,11 +990,7 @@ void SaveTable::CreateNew( SwTable& rTable, bool bCreateFrames,
     rFormatSet.ClearItem();
     rFormatSet.Put(m_aTableSet);
 
-    if( pFormat->IsInCache() )
-    {
-        SwFrame::GetCache().Delete( pFormat );
-        pFormat->SetInCache( false );
-    }
+    pFormat->InvalidateInSwCache(RES_ATTRSET_CHG);
 
     // SwTableBox must have a format - the SwTableBox takes ownership of it
     SwTableBoxFormat *const pNewFormat(pFormat->GetDoc()->MakeTableBoxFormat());


More information about the Libreoffice-commits mailing list