SwFntCache: move down from SwFormat to SwTextFormatCol where possible
Change-Id: Ia5dcc3b1145c6bd65253577499da3bb80d82e926
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109659
Tested-by: Jenkins
Reviewed-by: Bjoern Michaelsen <bjoern.michaelsen@libreoffice.org>
diff --git a/sw/inc/fmtcol.hxx b/sw/inc/fmtcol.hxx
index 07f157f..10a41b9 100644
--- a/sw/inc/fmtcol.hxx
+++ b/sw/inc/fmtcol.hxx
@@ -66,6 +66,8 @@ class SW_DLLPUBLIC SwTextFormatColl
bool mbAssignedToOutlineStyle;
bool m_bInSwFntCache;
SwTextFormatColl *mpNextTextFormatColl;
protected:
@@ -75,6 +77,7 @@ protected:
: SwFormatColl(rPool, pFormatCollName, aTextFormatCollSetRange, pDerFrom, nFormatWh)
, mbStayAssignedToListLevelOfOutlineStyle(false)
, mbAssignedToOutlineStyle(false)
, m_bInSwFntCache(false)
{
mpNextTextFormatColl = this;
}
@@ -85,6 +88,7 @@ protected:
: SwFormatColl(rPool, rFormatCollName, aTextFormatCollSetRange, pDerFrom, nFormatWh)
, mbStayAssignedToListLevelOfOutlineStyle(false)
, mbAssignedToOutlineStyle(false)
, m_bInSwFntCache(false)
{
mpNextTextFormatColl = this;
}
@@ -93,6 +97,7 @@ protected:
virtual void SwClientNotify(const SwModify&, const SfxHint&) override;
public:
virtual ~SwTextFormatColl();
inline void SetNextTextFormatColl(SwTextFormatColl& rNext);
SwTextFormatColl& GetNextTextFormatColl() const { return *mpNextTextFormatColl; }
@@ -138,6 +143,25 @@ public:
if(HasWriterListeners() && !IsModifyLocked())
CallSwClientNotify(sw::LegacyModifyHint(&rDrop, &rDrop));
};
bool IsInSwFntCache() const { return m_bInSwFntCache; };
void SetInSwFntCache() { m_bInSwFntCache = true; };
virtual void InvalidateInSwFntCache(sal_uInt16 nWhich) override
{
if(isCHRATR(nWhich))
{
m_bInSwFntCache = false;
}
else
{
switch(nWhich)
{
case RES_OBJECTDYING:
case RES_FMT_CHG:
case RES_ATTRSET_CHG:
m_bInSwFntCache = false;
}
}
};
};
class SwGrfFormatColl final : public SwFormatColl
diff --git a/sw/inc/format.hxx b/sw/inc/format.hxx
index 96e03b3..f1e301b 100644
--- a/sw/inc/format.hxx
+++ b/sw/inc/format.hxx
@@ -60,25 +60,8 @@ 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;
}
}
};
virtual void InvalidateInSwFntCache(sal_uInt16) {};
protected:
SwFormat( SwAttrPool& rPool, const char* pFormatNm,
@@ -95,8 +78,6 @@ public:
/// for Querying of Writer-functions.
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/format.cxx b/sw/source/core/attr/format.cxx
index cb36ad5..4c29d31 100644
--- a/sw/source/core/attr/format.cxx
+++ b/sw/source/core/attr/format.cxx
@@ -33,7 +33,6 @@
#include <svx/unobrushitemhelper.hxx>
#include <svx/xdef.hxx>
#include <swcache.hxx>
#include <swfntcch.hxx>
using namespace com::sun::star;
@@ -49,7 +48,7 @@ SwFormat::SwFormat( SwAttrPool& rPool, const char* pFormatNm,
{
m_bAutoUpdateFormat = false; // LAYER_IMPL
m_bAutoFormat = true;
m_bFormatInDTOR = m_bHidden = m_bInSwFntCache = false;
m_bFormatInDTOR = m_bHidden = false;
if( pDrvdFrame )
{
@@ -70,7 +69,7 @@ SwFormat::SwFormat( SwAttrPool& rPool, const OUString& rFormatNm,
{
m_bAutoUpdateFormat = false; // LAYER_IMPL
m_bAutoFormat = true;
m_bFormatInDTOR = m_bHidden = m_bInSwFntCache = false;
m_bFormatInDTOR = m_bHidden = false;
if( pDrvdFrame )
{
@@ -90,7 +89,6 @@ 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() )
@@ -117,7 +115,6 @@ SwFormat &SwFormat::operator=(const SwFormat& rFormat)
SwFrame::GetCache().Delete( this );
SetInCache( false );
}
m_bInSwFntCache = false;
// copy only array with attributes delta
SwAttrSet aOld( *m_aSet.GetPool(), m_aSet.GetRanges() ),
@@ -184,7 +181,7 @@ void SwFormat::CopyAttrs( const SwFormat& rFormat )
SwFrame::GetCache().Delete( this );
SetInCache( false );
}
m_bInSwFntCache = false;
InvalidateInSwFntCache(RES_ATTRSET_CHG);
// special treatments for some attributes
SwAttrSet* pChgSet = const_cast<SwAttrSet*>(&rFormat.m_aSet);
@@ -231,8 +228,6 @@ 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)
@@ -362,7 +357,7 @@ bool SwFormat::SetDerivedFrom(SwFormat *pDerFrom)
SwFrame::GetCache().Delete( this );
SetInCache( false );
}
m_bInSwFntCache = false;
InvalidateInSwFntCache(RES_ATTRSET_CHG);
pDerFrom->Add( this );
m_aSet.SetParent( &pDerFrom->m_aSet );
@@ -550,7 +545,7 @@ bool SwFormat::SetFormatAttr( const SfxItemSet& rSet )
SwFrame::GetCache().Delete( this );
SetInCache( false );
}
m_bInSwFntCache = false;
InvalidateInSwFntCache(RES_ATTRSET_CHG);
bool bRet = false;
@@ -647,11 +642,8 @@ bool SwFormat::ResetFormatAttr( sal_uInt16 nWhich1, sal_uInt16 nWhich2 )
if( !nWhich2 || nWhich2 < nWhich1 )
nWhich2 = nWhich1; // then set to 1st ID, only this item
if(m_bInSwFntCache)
{
for( sal_uInt16 n = nWhich1; n < nWhich2; ++n )
InvalidateInSwFntCache( n );
}
for( sal_uInt16 n = nWhich1; n < nWhich2; ++n )
InvalidateInSwFntCache( n );
if ( IsInCache() )
{
for( sal_uInt16 n = nWhich1; n < nWhich2; ++n )
@@ -683,7 +675,7 @@ sal_uInt16 SwFormat::ResetAllFormatAttr()
SwFrame::GetCache().Delete( this );
SetInCache( false );
}
m_bInSwFntCache = false;
InvalidateInSwFntCache(RES_ATTRSET_CHG);
// if Modify is locked then no modifications will be sent
if( IsModifyLocked() )
@@ -707,7 +699,7 @@ void SwFormat::DelDiffs( const SfxItemSet& rSet )
SwFrame::GetCache().Delete( this );
SetInCache( false );
}
m_bInSwFntCache = false;
InvalidateInSwFntCache(RES_ATTRSET_CHG);
// if Modify is locked then no modifications will be sent
if( IsModifyLocked() )
diff --git a/sw/source/core/doc/fmtcol.cxx b/sw/source/core/doc/fmtcol.cxx
index 20d149d..c82a968 100644
--- a/sw/source/core/doc/fmtcol.cxx
+++ b/sw/source/core/doc/fmtcol.cxx
@@ -20,21 +20,23 @@
#include <memory>
#include <libxml/xmlwriter.h>
#include <sal/macros.h>
#include <osl/diagnose.h>
#include <hintids.hxx>
#include <editeng/ulspitem.hxx>
#include <editeng/lrspitem.hxx>
#include <editeng/fhgtitem.hxx>
#include <editeng/lrspitem.hxx>
#include <editeng/ulspitem.hxx>
#include <osl/diagnose.h>
#include <sal/macros.h>
#include <svl/intitem.hxx>
#include <calbck.hxx>
#include <doc.hxx>
#include <fmtcol.hxx>
#include <fmtcolfunc.hxx>
#include <hintids.hxx>
#include <hints.hxx>
#include <node.hxx>
#include <numrule.hxx>
#include <paratr.hxx>
#include <calbck.hxx>
#include <svl/intitem.hxx>
#include <swfntcch.hxx>
namespace TextFormatCollFunc
{
@@ -108,6 +110,11 @@ namespace TextFormatCollFunc
}
} // end of namespace TextFormatCollFunc
SwTextFormatColl::~SwTextFormatColl()
{
if(m_bInSwFntCache)
pSwFontCache->Delete( this );
}
void SwTextFormatColl::SwClientNotify(const SwModify& rModify, const SfxHint& rHint)
{
auto pLegacy = dynamic_cast<const sw::LegacyModifyHint*>(&rHint);