diff options
author | Armin Le Grand (allotropia) <armin.le.grand.extern@allotropia.de> | 2024-01-24 17:53:19 +0100 |
---|---|---|
committer | Armin Le Grand <Armin.Le.Grand@me.com> | 2024-01-25 01:58:36 +0100 |
commit | 37f148c58974210707e069f21da2cc2b9ae086dd (patch) | |
tree | 51317de2e9a1e5fdee7221e5b25424573493e5c4 /editeng | |
parent | ce53519f025158f8f64a4e8603c8c6e0dc35473a (diff) |
ITEM: Slight re-design of global Item-Reusage
Unfortunately I had overseen something with derived
classes, but it came now up on CI ASan/UBsan build
with a failing UnitTest - thanks to pointing me at
it.
The ItemInstanceManager at the SfxPoolItems are now
no longer static but constructed instances returned
on-demand.
Also added checks to really use an incarnated/
registered one *only* for that derivation and made
sure this is now correctly supported.
Had to change again, using createItemInstanceManager
to always create instances was less effective than
intended, back to getItemInstanceManager & static
instances in the Item implementations. Also added
some stuff to implCreateItemEntry/implCleanupItemEntry
to be more effective, e.g. direct handling of
slot stuff in latter one. Also some more asserts
and comments. Slot stuff is now handled without
RefCounting, takes some write accesses away...
Change-Id: I6cd69556b416510b5b23549dd042ff3ba155559d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162521
Tested-by: Jenkins
Reviewed-by: Armin Le Grand <Armin.Le.Grand@me.com>
Diffstat (limited to 'editeng')
-rw-r--r-- | editeng/source/items/frmitems.cxx | 8 | ||||
-rw-r--r-- | editeng/source/items/paraitem.cxx | 4 | ||||
-rw-r--r-- | editeng/source/items/textitem.cxx | 58 |
3 files changed, 42 insertions, 28 deletions
diff --git a/editeng/source/items/frmitems.cxx b/editeng/source/items/frmitems.cxx index c3a5836b082a..e84ae2140e33 100644 --- a/editeng/source/items/frmitems.cxx +++ b/editeng/source/items/frmitems.cxx @@ -3980,8 +3980,8 @@ void SvxLineItem::SetLine( const SvxBorderLine* pNew ) ItemInstanceManager* SvxBrushItem::getItemInstanceManager() const { - static DefaultItemInstanceManager aManager; - return &aManager; + static DefaultItemInstanceManager aInstanceManager(typeid(SvxBrushItem).hash_code()); + return &aInstanceManager; } SvxBrushItem::SvxBrushItem(sal_uInt16 _nWhich) @@ -4598,8 +4598,8 @@ void SvxBrushItem::dumpAsXml(xmlTextWriterPtr pWriter) const ItemInstanceManager* SvxFrameDirectionItem::getItemInstanceManager() const { - static DefaultItemInstanceManager aManager; - return &aManager; + static DefaultItemInstanceManager aInstanceManager(typeid(SvxFrameDirectionItem).hash_code()); + return &aInstanceManager; } SvxFrameDirectionItem::SvxFrameDirectionItem( SvxFrameDirection nValue , diff --git a/editeng/source/items/paraitem.cxx b/editeng/source/items/paraitem.cxx index 2a9a514a6461..e080b517eb43 100644 --- a/editeng/source/items/paraitem.cxx +++ b/editeng/source/items/paraitem.cxx @@ -340,8 +340,8 @@ void SvxLineSpacingItem::SetEnumValue( sal_uInt16 nVal ) ItemInstanceManager* SvxAdjustItem::getItemInstanceManager() const { - static DefaultItemInstanceManager aManager; - return &aManager; + static DefaultItemInstanceManager aInstanceManager(typeid(SvxAdjustItem).hash_code()); + return &aInstanceManager; } SvxAdjustItem::SvxAdjustItem(const SvxAdjust eAdjst, const sal_uInt16 nId ) diff --git a/editeng/source/items/textitem.cxx b/editeng/source/items/textitem.cxx index 0bed0a7d077d..77e4c6c9cda0 100644 --- a/editeng/source/items/textitem.cxx +++ b/editeng/source/items/textitem.cxx @@ -168,8 +168,17 @@ namespace { SvxFontItemMap maRegistered; + public: + SvxFontItemInstanceManager() + : ItemInstanceManager(typeid(SvxFontItem).hash_code()) + { + } + + private: static size_t hashCode(const SfxPoolItem&); + // standard interface, accessed exclusively + // by implCreateItemEntry/implCleanupItemEntry virtual const SfxPoolItem* find(const SfxPoolItem&) const override; virtual void add(const SfxPoolItem&) override; virtual void remove(const SfxPoolItem&) override; @@ -209,8 +218,8 @@ namespace ItemInstanceManager* SvxFontItem::getItemInstanceManager() const { - static SvxFontItemInstanceManager aManager; - return &aManager; + static SvxFontItemInstanceManager aInstanceManager; + return &aInstanceManager; } SvxFontItem::SvxFontItem( @@ -439,8 +448,8 @@ void SvxFontItem::dumpAsXml(xmlTextWriterPtr pWriter) const ItemInstanceManager* SvxPostureItem::getItemInstanceManager() const { - static DefaultItemInstanceManager aManager; - return &aManager; + static DefaultItemInstanceManager aInstanceManager(typeid(SvxPostureItem).hash_code()); + return &aInstanceManager; } SvxPostureItem::SvxPostureItem( const FontItalic ePosture, const sal_uInt16 nId ) : @@ -561,8 +570,8 @@ void SvxPostureItem::dumpAsXml(xmlTextWriterPtr pWriter) const ItemInstanceManager* SvxWeightItem::getItemInstanceManager() const { - static DefaultItemInstanceManager aManager; - return &aManager; + static DefaultItemInstanceManager aInstanceManager(typeid(SvxWeightItem).hash_code()); + return &aInstanceManager; } SvxWeightItem::SvxWeightItem( const FontWeight eWght, const sal_uInt16 nId ) : @@ -691,8 +700,8 @@ void SvxWeightItem::dumpAsXml(xmlTextWriterPtr pWriter) const ItemInstanceManager* SvxFontHeightItem::getItemInstanceManager() const { - static DefaultItemInstanceManager aManager; - return &aManager; + static DefaultItemInstanceManager aInstanceManager(typeid(SvxFontHeightItem).hash_code()); + return &aInstanceManager; } SvxFontHeightItem::SvxFontHeightItem( const sal_uInt32 nSz, @@ -1038,12 +1047,6 @@ void SvxFontHeightItem::dumpAsXml(xmlTextWriterPtr pWriter) const // class SvxTextLineItem ------------------------------------------------ -ItemInstanceManager* SvxTextLineItem::getItemInstanceManager() const -{ - static DefaultItemInstanceManager aManager; - return &aManager; -} - SvxTextLineItem::SvxTextLineItem( const FontLineStyle eSt, const sal_uInt16 nId ) : SfxEnumItem(nId, eSt) , maColor(COL_TRANSPARENT) @@ -1196,6 +1199,11 @@ bool SvxTextLineItem::operator==( const SfxPoolItem& rItem ) const // class SvxUnderlineItem ------------------------------------------------ +ItemInstanceManager* SvxUnderlineItem::getItemInstanceManager() const +{ + static DefaultItemInstanceManager aInstanceManager(typeid(SvxUnderlineItem).hash_code()); + return &aInstanceManager; +} SvxUnderlineItem::SvxUnderlineItem( const FontLineStyle eSt, const sal_uInt16 nId ) : SvxTextLineItem( eSt, nId ) @@ -1238,6 +1246,12 @@ OUString SvxUnderlineItem::GetValueTextByPos( sal_uInt16 nPos ) const // class SvxOverlineItem ------------------------------------------------ +ItemInstanceManager* SvxOverlineItem::getItemInstanceManager() const +{ + static DefaultItemInstanceManager aInstanceManager(typeid(SvxOverlineItem).hash_code()); + return &aInstanceManager; +} + SvxOverlineItem::SvxOverlineItem( const FontLineStyle eSt, const sal_uInt16 nId ) : SvxTextLineItem( eSt, nId ) { @@ -1281,8 +1295,8 @@ OUString SvxOverlineItem::GetValueTextByPos( sal_uInt16 nPos ) const ItemInstanceManager* SvxCrossedOutItem::getItemInstanceManager() const { - static DefaultItemInstanceManager aManager; - return &aManager; + static DefaultItemInstanceManager aInstanceManager(typeid(SvxCrossedOutItem).hash_code()); + return &aInstanceManager; } SvxCrossedOutItem::SvxCrossedOutItem( const FontStrikeout eSt, const sal_uInt16 nId ) @@ -2083,8 +2097,8 @@ bool SvxEscapementItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId ) ItemInstanceManager* SvxLanguageItem::getItemInstanceManager() const { - static DefaultItemInstanceManager aManager; - return &aManager; + static DefaultItemInstanceManager aInstanceManager(typeid(SvxLanguageItem).hash_code()); + return &aInstanceManager; } SvxLanguageItem::SvxLanguageItem( const LanguageType eLang, const sal_uInt16 nId ) @@ -2231,8 +2245,8 @@ bool SvxBlinkItem::GetPresentation ItemInstanceManager* SvxEmphasisMarkItem::getItemInstanceManager() const { - static DefaultItemInstanceManager aManager; - return &aManager; + static DefaultItemInstanceManager aInstanceManager(typeid(SvxEmphasisMarkItem).hash_code()); + return &aInstanceManager; } SvxEmphasisMarkItem::SvxEmphasisMarkItem( const FontEmphasisMark nValue, @@ -2671,8 +2685,8 @@ bool SvxCharScaleWidthItem::QueryValue( uno::Any& rVal, sal_uInt8 /*nMemberId*/ ItemInstanceManager* SvxCharReliefItem::getItemInstanceManager() const { - static DefaultItemInstanceManager aManager; - return &aManager; + static DefaultItemInstanceManager aInstanceManager(typeid(SvxCharReliefItem).hash_code()); + return &aInstanceManager; } SvxCharReliefItem::SvxCharReliefItem( FontRelief eValue, |