sw/inc/calbck.hxx                   |    5 ----
 sw/inc/format.hxx                   |   23 +++++++++++++++++-
 sw/source/core/attr/calbck.cxx      |   35 +++++++++-------------------
 sw/source/core/attr/format.cxx      |   45 ++++++++++++++++++++----------------
 sw/source/core/txtnode/ndtxt.cxx    |    1 
 sw/source/core/txtnode/swfntcch.cxx |    2 -
 6 files changed, 62 insertions(+), 49 deletions(-)

New commits:
commit 8dd78873a9de028c0d9f1f1aee537e85f74d2300
Author:     Bjoern Michaelsen <bjoern.michael...@libreoffice.org>
AuthorDate: Tue Jan 12 01:37:29 2021 +0100
Commit:     Bjoern Michaelsen <bjoern.michael...@libreoffice.org>
CommitDate: Wed Jan 13 18:20:37 2021 +0100

    Move SwFntCache link from SwModify down to SwFormat
    
    - apparently only SwTextFormatColls are ever in the SwFntCache
    - however lots of SwFormat members need to clear the cache
    - so for now, only move it down to SwFormat
    - this should make SwModify less of a kitchen sink
    
    Change-Id: I389fc9f0a9d9b18b5914f24ae62c5d4119bc468f
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109154
    Tested-by: Jenkins
    Reviewed-by: Bjoern Michaelsen <bjoern.michael...@libreoffice.org>

diff --git a/sw/inc/calbck.hxx b/sw/inc/calbck.hxx
index 31df9791291b..b5b6ff9a3e30 100644
--- a/sw/inc/calbck.hxx
+++ b/sw/inc/calbck.hxx
@@ -178,7 +178,6 @@ class SW_DLLPUBLIC SwModify: public SwClient
     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_bInSwFntCache : 1;
 
     SwModify(SwModify const &) = delete;
     SwModify &operator =(const SwModify&) = delete;
@@ -186,7 +185,7 @@ protected:
     virtual void SwClientNotify(const SwModify&, const SfxHint& rHint) 
override;
 public:
     SwModify()
-        : SwClient(), m_pWriterListeners(nullptr), m_bModifyLocked(false), 
m_bInCache(false), m_bInSwFntCache(false)
+        : SwClient(), m_pWriterListeners(nullptr), m_bModifyLocked(false), 
m_bInCache(false)
     {}
 
     // broadcasting mechanism
@@ -204,11 +203,9 @@ public:
     void LockModify()                   { m_bModifyLocked = true;  }
     void UnlockModify()                 { m_bModifyLocked = false; }
     void SetInCache( bool bNew )        { m_bInCache = bNew;       }
-    void SetInSwFntCache( bool bNew )   { m_bInSwFntCache = bNew;  }
     void SetInDocDTOR();
     bool IsModifyLocked() const     { return m_bModifyLocked;  }
     bool IsInCache()      const     { return m_bInCache;       }
-    bool IsInSwFntCache() const     { return m_bInSwFntCache;  }
 
     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 e596a26bb882..96e03b342eec 100644
--- a/sw/inc/format.hxx
+++ b/sw/inc/format.hxx
@@ -22,6 +22,7 @@
 #include "swdllapi.h"
 #include "swatrset.hxx"
 #include "calbck.hxx"
+#include "hintids.hxx"
 #include <memory>
 
 class IDocumentSettingAccess;
@@ -59,7 +60,25 @@ class SW_DLLPUBLIC SwFormat : public sw::BroadcastingModify
     bool   m_bAutoUpdateFormat : 1;/**< TRUE: Set attributes of a whole 
paragraph
                                        at format (UI-side!). */
     bool m_bHidden : 1;
+    bool m_bInSwFntCache : 1;
     std::shared_ptr<SfxGrabBagItem> m_pGrabBagItem; ///< Style InteropGrabBag.
+    void InvalidateInSwFntCache(sal_uInt16 nWhich)
+    {
+        if(isCHRATR(nWhich))
+        {
+            m_bInSwFntCache = false;
+        }
+        else
+        {
+            switch(nWhich)
+            {
+                case RES_OBJECTDYING:
+                case RES_FMT_CHG:
+                case RES_ATTRSET_CHG:
+                    m_bInSwFntCache = false;
+            }
+        }
+    };
 
 protected:
     SwFormat( SwAttrPool& rPool, const char* pFormatNm,
@@ -75,7 +94,9 @@ public:
     SwFormat &operator=(const SwFormat&);
 
     /// for Querying of Writer-functions.
-    sal_uInt16 Which() const { return m_nWhichId; }
+    sal_uInt16 Which() const { return m_nWhichId; };
+    bool IsInSwFntCache() const { return m_bInSwFntCache; };
+    void SetInSwFntCache() { m_bInSwFntCache = true; };
 
     /// Copy attributes even among documents.
     void CopyAttrs( const SwFormat& );
diff --git a/sw/source/core/attr/calbck.cxx b/sw/source/core/attr/calbck.cxx
index 1c86c75fc992..ef6008f3ce77 100644
--- a/sw/source/core/attr/calbck.cxx
+++ b/sw/source/core/attr/calbck.cxx
@@ -17,15 +17,17 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
-#include <frame.hxx>
+#include <algorithm>
+
 #include <format.hxx>
+#include <frame.hxx>
 #include <hintids.hxx>
 #include <hints.hxx>
+#include <osl/diagnose.h>
+#include <sal/log.hxx>
 #include <swcache.hxx>
-#include <swfntcch.hxx>
 #include <tools/debug.hxx>
-#include <sal/log.hxx>
-#include <algorithm>
+
 #ifdef DBG_UTIL
 #include <sal/backtrace.hxx>
 #endif
@@ -156,9 +158,6 @@ SwModify::~SwModify()
     if ( IsInCache() )
         SwFrame::GetCache().Delete( this );
 
-    if ( IsInSwFntCache() )
-        pSwFontCache->Delete( this );
-
     // notify all clients that they shall remove themselves
     SwPtrMsgPoolItem aDyObject( RES_OBJECTDYING, this );
     SwModify::SwClientNotify(*this, sw::LegacyModifyHint(&aDyObject, 
&aDyObject));
@@ -274,21 +273,13 @@ SwClient* SwModify::Remove( SwClient* pDepend )
     return pDepend;
 }
 
-void SwModify::CheckCaching( const sal_uInt16 nWhich )
+void SwModify::CheckCaching(const sal_uInt16 nWhich)
 {
-    if( isCHRATR( nWhich ) )
+    switch(nWhich)
     {
-        SetInSwFntCache( false );
-    }
-    else
-    {
-        switch( nWhich )
-        {
         case RES_OBJECTDYING:
         case RES_FMT_CHG:
         case RES_ATTRSET_CHG:
-            SetInSwFntCache( false );
-            [[fallthrough]];
         case RES_UL_SPACE:
         case RES_LR_SPACE:
         case RES_BOX:
@@ -296,13 +287,11 @@ void SwModify::CheckCaching( const sal_uInt16 nWhich )
         case RES_FRM_SIZE:
         case RES_KEEP:
         case RES_BREAK:
-            if( IsInCache() )
+            if(IsInCache())
             {
-                SwFrame::GetCache().Delete( this );
-                SetInCache( false );
+                SwFrame::GetCache().Delete(this);
+                SetInCache(false);
             }
-            break;
-        }
     }
 }
 
@@ -352,7 +341,7 @@ void SwModify::SwClientNotify(const SwModify&, const 
SfxHint& rHint)
     if(auto pLegacyHint = dynamic_cast<const sw::LegacyModifyHint*>(&rHint))
     {
         DBG_TESTSOLARMUTEX();
-        if(IsInCache() || IsInSwFntCache())
+        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 6e0f55ef8da0..8dd42c7fc935 100644
--- a/sw/source/core/attr/format.cxx
+++ b/sw/source/core/attr/format.cxx
@@ -17,22 +17,23 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
-#include <doc.hxx>
 #include <DocumentSettingManager.hxx> //For SwFmt::getIDocumentSettingAccess()
 #include <IDocumentTimerAccess.hxx>
+#include <doc.hxx>
 #include <fmtcolfunc.hxx>
-#include <frame.hxx>
 #include <format.hxx>
+#include <frame.hxx>
+#include <frmatr.hxx>
 #include <hintids.hxx>
 #include <hints.hxx>
-#include <swcache.hxx>
-#include <frmatr.hxx>
 #include <osl/diagnose.h>
+#include <sal/log.hxx>
 #include <svl/grabbagitem.hxx>
 #include <svx/sdr/attribute/sdrallfillattributeshelper.hxx>
 #include <svx/unobrushitemhelper.hxx>
 #include <svx/xdef.hxx>
-#include <sal/log.hxx>
+#include <swcache.hxx>
+#include <swfntcch.hxx>
 
 using namespace com::sun::star;
 
@@ -49,7 +50,7 @@ SwFormat::SwFormat( SwAttrPool& rPool, const char* pFormatNm,
 {
     m_bAutoUpdateFormat = false; // LAYER_IMPL
     m_bAutoFormat = true;
-    m_bFormatInDTOR = m_bHidden = false;
+    m_bFormatInDTOR = m_bHidden = m_bInSwFntCache = false;
 
     if( pDrvdFrame )
     {
@@ -70,7 +71,7 @@ SwFormat::SwFormat( SwAttrPool& rPool, const OUString& 
rFormatNm,
 {
     m_bAutoUpdateFormat = false; // LAYER_IMPL
     m_bAutoFormat = true;
-    m_bFormatInDTOR = m_bHidden = false;
+    m_bFormatInDTOR = m_bHidden = m_bInSwFntCache = false;
 
     if( pDrvdFrame )
     {
@@ -90,6 +91,7 @@ SwFormat::SwFormat( const SwFormat& rFormat ) :
     m_bFormatInDTOR = false; // LAYER_IMPL
     m_bAutoFormat = rFormat.m_bAutoFormat;
     m_bHidden = rFormat.m_bHidden;
+    m_bInSwFntCache = false;
     m_bAutoUpdateFormat = rFormat.m_bAutoUpdateFormat;
 
     if( auto pDerived = rFormat.DerivedFrom() )
@@ -116,7 +118,7 @@ SwFormat &SwFormat::operator=(const SwFormat& rFormat)
         SwFrame::GetCache().Delete( this );
         SetInCache( false );
     }
-    SetInSwFntCache( false );
+    m_bInSwFntCache = false;
 
     // copy only array with attributes delta
     SwAttrSet aOld( *m_aSet.GetPool(), m_aSet.GetRanges() ),
@@ -183,7 +185,7 @@ void SwFormat::CopyAttrs( const SwFormat& rFormat )
         SwFrame::GetCache().Delete( this );
         SetInCache( false );
     }
-    SetInSwFntCache( false );
+    m_bInSwFntCache = false;
 
     // special treatments for some attributes
     SwAttrSet* pChgSet = const_cast<SwAttrSet*>(&rFormat.m_aSet);
@@ -230,6 +232,8 @@ SwFormat::~SwFormat()
     for(SwClient* pClient = aIter.First(); pClient; pClient = aIter.Next())
         pClient->CheckRegistrationFormat(*this);
     assert(!HasWriterListeners());
+    if(m_bInSwFntCache)
+        pSwFontCache->Delete( this );
 }
 
 void SwFormat::SwClientNotify(const SwModify&, const SfxHint& rHint)
@@ -357,7 +361,7 @@ bool SwFormat::SetDerivedFrom(SwFormat *pDerFrom)
         SwFrame::GetCache().Delete( this );
         SetInCache( false );
     }
-    SetInSwFntCache( false );
+    m_bInSwFntCache = false;
 
     pDerFrom->Add( this );
     m_aSet.SetParent( &pDerFrom->m_aSet );
@@ -458,11 +462,9 @@ SfxItemState 
SwFormat::GetBackgroundState(std::unique_ptr<SvxBrushItem>& rItem)
 
 bool SwFormat::SetFormatAttr( const SfxPoolItem& rAttr )
 {
-    if ( IsInCache() || IsInSwFntCache() )
-    {
-        const sal_uInt16 nWhich = rAttr.Which();
-        CheckCaching( nWhich );
-    }
+    const sal_uInt16 nWhich = rAttr.Which();
+    CheckCaching( nWhich );
+    InvalidateInSwFntCache( nWhich );
 
     bool bRet = false;
 
@@ -547,7 +549,7 @@ bool SwFormat::SetFormatAttr( const SfxItemSet& rSet )
         SwFrame::GetCache().Delete( this );
         SetInCache( false );
     }
-    SetInSwFntCache( false );
+    m_bInSwFntCache = false;
 
     bool bRet = false;
 
@@ -644,11 +646,16 @@ bool SwFormat::ResetFormatAttr( sal_uInt16 nWhich1, 
sal_uInt16 nWhich2 )
     if( !nWhich2 || nWhich2 < nWhich1 )
         nWhich2 = nWhich1; // then set to 1st ID, only this item
 
-    if ( IsInCache() || IsInSwFntCache() )
+    if ( IsInCache() )
     {
         for( sal_uInt16 n = nWhich1; n < nWhich2; ++n )
             CheckCaching( n );
     }
+    if( m_bInSwFntCache )
+    {
+        for( sal_uInt16 n = nWhich1; n < nWhich2; ++n )
+            InvalidateInSwFntCache( n );
+    }
 
     // if Modify is locked then no modifications will be sent
     if( IsModifyLocked() )
@@ -675,7 +682,7 @@ sal_uInt16 SwFormat::ResetAllFormatAttr()
         SwFrame::GetCache().Delete( this );
         SetInCache( false );
     }
-    SetInSwFntCache( false );
+    m_bInSwFntCache = false;
 
     // if Modify is locked then no modifications will be sent
     if( IsModifyLocked() )
@@ -699,7 +706,7 @@ void SwFormat::DelDiffs( const SfxItemSet& rSet )
         SwFrame::GetCache().Delete( this );
         SetInCache( false );
     }
-    SetInSwFntCache( false );
+    m_bInSwFntCache = false;
 
     // if Modify is locked then no modifications will be sent
     if( IsModifyLocked() )
diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx
index 99331779c4c5..64a7f2a5da85 100644
--- a/sw/source/core/txtnode/ndtxt.cxx
+++ b/sw/source/core/txtnode/ndtxt.cxx
@@ -2832,7 +2832,6 @@ void SwTextNode::NumRuleChgd()
         SwFrame::GetCache().Delete( this );
         SetInCache( false );
     }
-    SetInSwFntCache( false );
 
     // Sending "noop" modify in order to cause invalidations of registered
     // <SwTextFrame> instances to get the list style change respectively the 
change
diff --git a/sw/source/core/txtnode/swfntcch.cxx 
b/sw/source/core/txtnode/swfntcch.cxx
index 49783fd25942..100a0e7a7965 100644
--- a/sw/source/core/txtnode/swfntcch.cxx
+++ b/sw/source/core/txtnode/swfntcch.cxx
@@ -60,7 +60,7 @@ SwFontObj *SwFontAccess::Get( )
 
 SwCacheObj *SwFontAccess::NewObj( )
 {
-    const_cast<SwTextFormatColl*>(static_cast<const 
SwTextFormatColl*>(m_pOwner))->SetInSwFntCache( true );
+    const_cast<SwTextFormatColl*>(static_cast<const 
SwTextFormatColl*>(m_pOwner))->SetInSwFntCache();
     return new SwFontObj( m_pOwner, m_pShell );
 }
 
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to