summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--editeng/source/items/frmitems.cxx184
-rw-r--r--editeng/source/items/paraitem.cxx19
-rw-r--r--editeng/source/items/textitem.cxx167
-rw-r--r--include/editeng/adjustitem.hxx5
-rw-r--r--include/editeng/boxitem.hxx3
-rw-r--r--include/editeng/brushitem.hxx3
-rw-r--r--include/editeng/charreliefitem.hxx3
-rw-r--r--include/editeng/colritem.hxx2
-rw-r--r--include/editeng/crossedoutitem.hxx3
-rw-r--r--include/editeng/emphasismarkitem.hxx3
-rw-r--r--include/editeng/escapementitem.hxx2
-rw-r--r--include/editeng/fhgtitem.hxx5
-rw-r--r--include/editeng/fontitem.hxx5
-rw-r--r--include/editeng/frmdiritem.hxx3
-rw-r--r--include/editeng/langitem.hxx3
-rw-r--r--include/editeng/lrspitem.hxx38
-rw-r--r--include/editeng/postitem.hxx3
-rw-r--r--include/editeng/protitem.hxx8
-rw-r--r--include/editeng/rsiditem.hxx2
-rw-r--r--include/editeng/shaditem.hxx8
-rw-r--r--include/editeng/sizeitem.hxx2
-rw-r--r--include/editeng/udlnitem.hxx6
-rw-r--r--include/editeng/ulspitem.hxx12
-rw-r--r--include/editeng/wghtitem.hxx3
-rw-r--r--include/svl/cintitem.hxx8
-rw-r--r--include/svl/custritm.hxx2
-rw-r--r--include/svl/eitem.hxx16
-rw-r--r--include/svl/flagitem.hxx2
-rw-r--r--include/svl/globalnameitem.hxx2
-rw-r--r--include/svl/grabbagitem.hxx10
-rw-r--r--include/svl/ilstitem.hxx2
-rw-r--r--include/svl/imageitm.hxx6
-rw-r--r--include/svl/int64item.hxx2
-rw-r--r--include/svl/intitem.hxx2
-rw-r--r--include/svl/poolitem.hxx104
-rw-r--r--include/svl/ptitem.hxx2
-rw-r--r--include/svl/rectitem.hxx2
-rw-r--r--include/svl/rngitem.hxx2
-rw-r--r--include/svl/visitem.hxx2
-rw-r--r--include/svx/algitem.hxx2
-rw-r--r--include/svx/chrtitem.hxx2
-rw-r--r--include/svx/e3ditem.hxx2
-rw-r--r--include/svx/grfcrop.hxx2
-rw-r--r--include/svx/postattr.hxx8
-rw-r--r--include/svx/sdasitm.hxx2
-rw-r--r--include/svx/svxgraphicitem.hxx2
-rw-r--r--svl/source/items/cenumitm.cxx77
-rw-r--r--svl/source/items/custritm.cxx7
-rw-r--r--svl/source/items/globalnameitem.cxx16
-rw-r--r--svl/source/items/globalpool.cxx335
-rw-r--r--svl/source/items/grabbagitem.cxx17
-rw-r--r--svl/source/items/ilstitem.cxx15
-rw-r--r--svl/source/items/imageitm.cxx16
-rw-r--r--svl/source/items/poolitem.cxx16
-rw-r--r--svl/source/items/ptitem.cxx15
-rw-r--r--svl/source/items/rectitem.cxx17
-rw-r--r--svx/inc/sxlayitm.hxx1
-rw-r--r--svx/inc/sxmfsitm.hxx4
-rw-r--r--svx/source/dialog/svxgraphicitem.cxx10
-rw-r--r--svx/source/items/algitem.cxx15
-rw-r--r--svx/source/items/chrtitem.cxx12
-rw-r--r--svx/source/items/customshapeitem.cxx11
-rw-r--r--svx/source/items/e3ditem.cxx14
-rw-r--r--svx/source/items/grfitem.cxx15
-rw-r--r--svx/source/items/postattr.cxx24
-rw-r--r--svx/source/svdraw/svdattr.cxx6
-rw-r--r--sw/inc/fmtfsize.hxx4
-rw-r--r--sw/inc/fmtornt.hxx8
-rw-r--r--sw/inc/paratr.hxx1
-rw-r--r--sw/source/core/layout/atrfrm.cxx89
-rw-r--r--sw/source/core/para/paratr.cxx6
71 files changed, 648 insertions, 779 deletions
diff --git a/editeng/source/items/frmitems.cxx b/editeng/source/items/frmitems.cxx
index fb52f89c055b..0ecf0b6afed1 100644
--- a/editeng/source/items/frmitems.cxx
+++ b/editeng/source/items/frmitems.cxx
@@ -173,7 +173,6 @@ bool SvxSizeItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
bool SvxSizeItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
{
- ASSERT_CHANGE_REFCOUNTED_ITEM;
bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
nMemberId &= ~CONVERT_TWIPS;
@@ -229,19 +228,6 @@ SvxSizeItem::SvxSizeItem( const sal_uInt16 nId ) :
}
-bool SvxSizeItem::isHashable() const
-{
- return true;
-}
-
-size_t SvxSizeItem::hashCode() const
-{
- std::size_t seed = 0;
- o3tl::hash_combine(seed, m_aSize.Width());
- o3tl::hash_combine(seed, m_aSize.Height());
- return seed;
-}
-
bool SvxSizeItem::operator==( const SfxPoolItem& rAttr ) const
{
assert(SfxPoolItem::operator==(rAttr));
@@ -621,7 +607,6 @@ bool SvxLeftMarginItem::QueryValue(uno::Any& rVal, sal_uInt8 nMemberId) const
bool SvxLeftMarginItem::PutValue(const uno::Any& rVal, sal_uInt8 nMemberId)
{
- ASSERT_CHANGE_REFCOUNTED_ITEM;
bool bConvert = 0 != (nMemberId & CONVERT_TWIPS);
nMemberId &= ~CONVERT_TWIPS;
@@ -658,19 +643,6 @@ bool SvxLeftMarginItem::PutValue(const uno::Any& rVal, sal_uInt8 nMemberId)
return true;
}
-bool SvxLeftMarginItem::isHashable() const
-{
- return true;
-}
-
-size_t SvxLeftMarginItem::hashCode() const
-{
- std::size_t seed = 0;
- o3tl::hash_combine(seed, m_nLeftMargin);
- o3tl::hash_combine(seed, m_nPropLeftMargin);
- return seed;
-}
-
bool SvxLeftMarginItem::operator==(const SfxPoolItem& rAttr) const
{
assert(SfxPoolItem::operator==(rAttr));
@@ -812,7 +784,6 @@ bool SvxTextLeftMarginItem::QueryValue(uno::Any& rVal, sal_uInt8 nMemberId) cons
bool SvxTextLeftMarginItem::PutValue(const uno::Any& rVal, sal_uInt8 nMemberId)
{
- ASSERT_CHANGE_REFCOUNTED_ITEM;
bool bConvert = 0 != (nMemberId & CONVERT_TWIPS);
nMemberId &= ~CONVERT_TWIPS;
@@ -849,19 +820,6 @@ bool SvxTextLeftMarginItem::PutValue(const uno::Any& rVal, sal_uInt8 nMemberId)
return true;
}
-bool SvxTextLeftMarginItem::isHashable() const
-{
- return true;
-}
-
-size_t SvxTextLeftMarginItem::hashCode() const
-{
- std::size_t seed = 0;
- o3tl::hash_combine(seed, m_nTextLeftMargin);
- o3tl::hash_combine(seed, m_nPropLeftMargin);
- return seed;
-}
-
bool SvxTextLeftMarginItem::operator==(const SfxPoolItem& rAttr) const
{
assert(SfxPoolItem::operator==(rAttr));
@@ -997,7 +955,6 @@ bool SvxFirstLineIndentItem::QueryValue(uno::Any& rVal, sal_uInt8 nMemberId) con
bool SvxFirstLineIndentItem::PutValue(const uno::Any& rVal, sal_uInt8 nMemberId)
{
- ASSERT_CHANGE_REFCOUNTED_ITEM;
bool bConvert = 0 != (nMemberId & CONVERT_TWIPS);
nMemberId &= ~CONVERT_TWIPS;
@@ -1038,20 +995,6 @@ bool SvxFirstLineIndentItem::PutValue(const uno::Any& rVal, sal_uInt8 nMemberId)
return true;
}
-bool SvxFirstLineIndentItem::isHashable() const
-{
- return true;
-}
-
-size_t SvxFirstLineIndentItem::hashCode() const
-{
- std::size_t seed = 0;
- o3tl::hash_combine(seed, m_nFirstLineOffset);
- o3tl::hash_combine(seed, m_nPropFirstLineOffset);
- o3tl::hash_combine(seed, m_bAutoFirst);
- return seed;
-}
-
bool SvxFirstLineIndentItem::operator==(const SfxPoolItem& rAttr) const
{
assert(SfxPoolItem::operator==(rAttr));
@@ -1196,7 +1139,6 @@ bool SvxRightMarginItem::QueryValue(uno::Any& rVal, sal_uInt8 nMemberId) const
bool SvxRightMarginItem::PutValue(const uno::Any& rVal, sal_uInt8 nMemberId)
{
- ASSERT_CHANGE_REFCOUNTED_ITEM;
bool bConvert = 0 != (nMemberId & CONVERT_TWIPS);
nMemberId &= ~CONVERT_TWIPS;
@@ -1233,19 +1175,6 @@ bool SvxRightMarginItem::PutValue(const uno::Any& rVal, sal_uInt8 nMemberId)
return true;
}
-bool SvxRightMarginItem::isHashable() const
-{
- return true;
-}
-
-size_t SvxRightMarginItem::hashCode() const
-{
- std::size_t seed = 0;
- o3tl::hash_combine(seed, m_nRightMargin);
- o3tl::hash_combine(seed, m_nPropRightMargin);
- return seed;
-}
-
bool SvxRightMarginItem::operator==(const SfxPoolItem& rAttr) const
{
assert(SfxPoolItem::operator==(rAttr));
@@ -1371,7 +1300,6 @@ bool SvxGutterLeftMarginItem::QueryValue(uno::Any& rVal, sal_uInt8 nMemberId) co
bool SvxGutterLeftMarginItem::PutValue(const uno::Any& rVal, sal_uInt8 nMemberId)
{
- ASSERT_CHANGE_REFCOUNTED_ITEM;
bool bConvert = 0 != (nMemberId & CONVERT_TWIPS);
nMemberId &= ~CONVERT_TWIPS;
@@ -1395,18 +1323,6 @@ bool SvxGutterLeftMarginItem::PutValue(const uno::Any& rVal, sal_uInt8 nMemberId
return true;
}
-bool SvxGutterLeftMarginItem::isHashable() const
-{
- return true;
-}
-
-size_t SvxGutterLeftMarginItem::hashCode() const
-{
- std::size_t seed = 0;
- o3tl::hash_combine(seed, m_nGutterMargin);
- return seed;
-}
-
bool SvxGutterLeftMarginItem::operator==(const SfxPoolItem& rAttr) const
{
assert(SfxPoolItem::operator==(rAttr));
@@ -1494,7 +1410,6 @@ bool SvxGutterRightMarginItem::QueryValue(uno::Any& /*rVal*/, sal_uInt8 nMemberI
bool SvxGutterRightMarginItem::PutValue(const uno::Any& /*rVal*/, sal_uInt8 nMemberId)
{
- ASSERT_CHANGE_REFCOUNTED_ITEM;
//bool bConvert = 0 != (nMemberId & CONVERT_TWIPS);
nMemberId &= ~CONVERT_TWIPS;
@@ -1514,18 +1429,6 @@ bool SvxGutterRightMarginItem::PutValue(const uno::Any& /*rVal*/, sal_uInt8 nMem
}
-bool SvxGutterRightMarginItem::isHashable() const
-{
- return true;
-}
-
-size_t SvxGutterRightMarginItem::hashCode() const
-{
- std::size_t seed = 0;
- o3tl::hash_combine(seed, m_nRightGutterMargin);
- return seed;
-}
-
bool SvxGutterRightMarginItem::operator==(const SfxPoolItem& rAttr) const
{
assert(SfxPoolItem::operator==(rAttr));
@@ -1586,28 +1489,6 @@ boost::property_tree::ptree SvxGutterRightMarginItem::dumpAsJSON() const
}
-bool SvxLRSpaceItem::isHashable() const
-{
- return true;
-}
-
-size_t SvxLRSpaceItem::hashCode() const
-{
- std::size_t seed = 0;
- o3tl::hash_combine(seed, nFirstLineOffset);
- o3tl::hash_combine(seed, m_nGutterMargin);
- o3tl::hash_combine(seed, m_nRightGutterMargin);
- o3tl::hash_combine(seed, nLeftMargin);
- o3tl::hash_combine(seed, nRightMargin);
- o3tl::hash_combine(seed, nPropFirstLineOffset);
- o3tl::hash_combine(seed, nPropLeftMargin);
- o3tl::hash_combine(seed, nPropRightMargin);
- o3tl::hash_combine(seed, bAutoFirst);
- o3tl::hash_combine(seed, bExplicitZeroMarginValRight);
- o3tl::hash_combine(seed, bExplicitZeroMarginValLeft);
- return seed;
-}
-
bool SvxLRSpaceItem::operator==( const SfxPoolItem& rAttr ) const
{
assert(SfxPoolItem::operator==(rAttr));
@@ -1832,7 +1713,6 @@ bool SvxULSpaceItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
bool SvxULSpaceItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
{
- ASSERT_CHANGE_REFCOUNTED_ITEM;
bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
nMemberId &= ~CONVERT_TWIPS;
sal_Int32 nVal = 0;
@@ -1893,22 +1773,6 @@ bool SvxULSpaceItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
}
-bool SvxULSpaceItem::isHashable() const
-{
- return true;
-}
-
-size_t SvxULSpaceItem::hashCode() const
-{
- std::size_t seed = 0;
- o3tl::hash_combine(seed, nUpper);
- o3tl::hash_combine(seed, nLower);
- o3tl::hash_combine(seed, bContext);
- o3tl::hash_combine(seed, nPropUpper);
- o3tl::hash_combine(seed, nPropLower);
- return seed;
-}
-
bool SvxULSpaceItem::operator==( const SfxPoolItem& rAttr ) const
{
assert(SfxPoolItem::operator==(rAttr));
@@ -2079,20 +1943,6 @@ bool SvxOpaqueItem::GetPresentation
}
-bool SvxProtectItem::isHashable() const
-{
- return true;
-}
-
-size_t SvxProtectItem::hashCode() const
-{
- std::size_t seed = 0;
- o3tl::hash_combine(seed, bCntnt);
- o3tl::hash_combine(seed, bSize);
- o3tl::hash_combine(seed, bPos);
- return seed;
-}
-
bool SvxProtectItem::operator==( const SfxPoolItem& rAttr ) const
{
assert(SfxPoolItem::operator==(rAttr));
@@ -2125,7 +1975,6 @@ bool SvxProtectItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
bool SvxProtectItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
{
- ASSERT_CHANGE_REFCOUNTED_ITEM;
nMemberId &= ~CONVERT_TWIPS;
bool bVal( Any2Bool(rVal) );
switch(nMemberId)
@@ -2294,20 +2143,6 @@ bool SvxShadowItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
}
-bool SvxShadowItem::isHashable() const
-{
- return true;
-}
-
-size_t SvxShadowItem::hashCode() const
-{
- std::size_t seed = 0;
- o3tl::hash_combine(seed, static_cast<sal_Int32>(aShadowColor));
- o3tl::hash_combine(seed, nWidth);
- o3tl::hash_combine(seed, eLocation);
- return seed;
-}
-
bool SvxShadowItem::operator==( const SfxPoolItem& rAttr ) const
{
assert(SfxPoolItem::operator==(rAttr));
@@ -2523,6 +2358,7 @@ static bool CompareBorderLine(const std::unique_ptr<SvxBorderLine> & pBrd1, cons
return *pBrd1 == *pBrd2;
}
+
bool SvxBoxItem::operator==( const SfxPoolItem& rAttr ) const
{
assert(SfxPoolItem::operator==(rAttr));
@@ -3427,6 +3263,12 @@ SvxBoxInfoItem::SvxBoxInfoItem(const sal_uInt16 nId)
ResetFlags();
}
+ItemInstanceManager* SvxBoxItem::getItemInstanceManager() const
+{
+ static DefaultItemInstanceManager aInstanceManager(typeid(SvxBoxItem).hash_code());
+ return &aInstanceManager;
+}
+
SvxBoxInfoItem::SvxBoxInfoItem( const SvxBoxInfoItem& rCopy )
: SfxPoolItem(rCopy)
, mpHorizontalLine(rCopy.mpHorizontalLine ? new SvxBorderLine(*rCopy.mpHorizontalLine) : nullptr)
@@ -4141,6 +3983,12 @@ void SvxLineItem::SetLine( const SvxBorderLine* pNew )
pLine.reset( pNew ? new SvxBorderLine( *pNew ) : nullptr );
}
+ItemInstanceManager* SvxBrushItem::getItemInstanceManager() const
+{
+ static DefaultItemInstanceManager aInstanceManager(typeid(SvxBrushItem).hash_code());
+ return &aInstanceManager;
+}
+
SvxBrushItem::SvxBrushItem(sal_uInt16 _nWhich)
: SfxPoolItem(_nWhich, SfxItemType::SvxBrushItemType)
, aColor(COL_TRANSPARENT)
@@ -4752,6 +4600,12 @@ void SvxBrushItem::dumpAsXml(xmlTextWriterPtr pWriter) const
(void)xmlTextWriterEndElement(pWriter);
}
+ItemInstanceManager* SvxFrameDirectionItem::getItemInstanceManager() const
+{
+ static DefaultItemInstanceManager aInstanceManager(typeid(SvxFrameDirectionItem).hash_code());
+ return &aInstanceManager;
+}
+
SvxFrameDirectionItem::SvxFrameDirectionItem( SvxFrameDirection nValue ,
sal_uInt16 _nWhich )
: SfxEnumItem<SvxFrameDirection>( _nWhich, SfxItemType::SvxFrameDirectionItemType, nValue )
diff --git a/editeng/source/items/paraitem.cxx b/editeng/source/items/paraitem.cxx
index c75f236f8246..06ab7170341d 100644
--- a/editeng/source/items/paraitem.cxx
+++ b/editeng/source/items/paraitem.cxx
@@ -50,7 +50,6 @@
#include <editeng/memberids.h>
#include <editeng/itemtype.hxx>
#include <editeng/eerdll.hxx>
-#include <o3tl/hash_combine.hxx>
using namespace ::com::sun::star;
@@ -340,6 +339,12 @@ void SvxLineSpacingItem::SetEnumValue( sal_uInt16 nVal )
// class SvxAdjustItem ---------------------------------------------------
+ItemInstanceManager* SvxAdjustItem::getItemInstanceManager() const
+{
+ static DefaultItemInstanceManager aInstanceManager(typeid(SvxAdjustItem).hash_code());
+ return &aInstanceManager;
+}
+
SvxAdjustItem::SvxAdjustItem(const SvxAdjust eAdjst, const sal_uInt16 nId )
: SfxEnumItemInterface( nId, SfxItemType::SvxAdjustItemType ),
bOneBlock( false ), bLastCenter( false ), bLastBlock( false )
@@ -347,18 +352,6 @@ SvxAdjustItem::SvxAdjustItem(const SvxAdjust eAdjst, const sal_uInt16 nId )
SetAdjust( eAdjst );
}
-bool SvxAdjustItem::isHashable() const { return true; }
-
-size_t SvxAdjustItem::hashCode() const
-{
- std::size_t seed(0);
- o3tl::hash_combine(seed, GetAdjust());
- o3tl::hash_combine(seed, bOneBlock);
- o3tl::hash_combine(seed, bLastCenter);
- o3tl::hash_combine(seed, bLastBlock);
- return seed;
-}
-
bool SvxAdjustItem::operator==( const SfxPoolItem& rAttr ) const
{
assert(SfxPoolItem::operator==(rAttr));
diff --git a/editeng/source/items/textitem.cxx b/editeng/source/items/textitem.cxx
index e0082b0a4968..65b83fbff620 100644
--- a/editeng/source/items/textitem.cxx
+++ b/editeng/source/items/textitem.cxx
@@ -159,21 +159,30 @@ bool SvxFontListItem::GetPresentation
// class SvxFontItem -----------------------------------------------------
-bool SvxFontItem::isHashable() const
+namespace
{
- return true;
+ class SvxFontItemInstanceManager : public TypeSpecificItemInstanceManager<SvxFontItem>
+ {
+ protected:
+ virtual size_t hashCode(const SfxPoolItem& rItem) const override
+ {
+ const SvxFontItem& rFontItem(static_cast<const SvxFontItem&>(rItem));
+ std::size_t seed(0);
+ o3tl::hash_combine(seed, rItem.Which());
+ o3tl::hash_combine(seed, rFontItem.GetFamilyName().hashCode());
+ o3tl::hash_combine(seed, rFontItem.GetStyleName().hashCode());
+ o3tl::hash_combine(seed, rFontItem.GetFamily());
+ o3tl::hash_combine(seed, rFontItem.GetPitch());
+ o3tl::hash_combine(seed, rFontItem.GetCharSet());
+ return seed;
+ }
+ };
}
-size_t SvxFontItem::hashCode() const
+ItemInstanceManager* SvxFontItem::getItemInstanceManager() const
{
- std::size_t seed(0);
- o3tl::hash_combine(seed, Which());
- o3tl::hash_combine(seed, GetFamilyName().hashCode());
- o3tl::hash_combine(seed, GetStyleName().hashCode());
- o3tl::hash_combine(seed, GetFamily());
- o3tl::hash_combine(seed, GetPitch());
- o3tl::hash_combine(seed, GetCharSet());
- return seed;
+ static SvxFontItemInstanceManager aInstanceManager;
+ return &aInstanceManager;
}
SvxFontItem::SvxFontItem(
@@ -234,7 +243,6 @@ bool SvxFontItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
bool SvxFontItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId)
{
- ASSERT_CHANGE_REFCOUNTED_ITEM;
nMemberId &= ~CONVERT_TWIPS;
switch(nMemberId)
{
@@ -401,6 +409,28 @@ void SvxFontItem::dumpAsXml(xmlTextWriterPtr pWriter) const
// class SvxPostureItem --------------------------------------------------
+namespace
+{
+ class SvxPostureItemInstanceManager : public TypeSpecificItemInstanceManager<SvxPostureItem>
+ {
+ protected:
+ virtual size_t hashCode(const SfxPoolItem& rItem) const override
+ {
+ auto const & rPostureItem = static_cast<const SvxPostureItem&>(rItem);
+ std::size_t seed(0);
+ o3tl::hash_combine(seed, rPostureItem.Which());
+ o3tl::hash_combine(seed, rPostureItem. GetEnumValue());
+ return seed;
+ }
+ };
+}
+
+ItemInstanceManager* SvxPostureItem::getItemInstanceManager() const
+{
+ static SvxPostureItemInstanceManager aInstanceManager;
+ return &aInstanceManager;
+}
+
SvxPostureItem::SvxPostureItem( const FontItalic ePosture, const sal_uInt16 nId ) :
SfxEnumItem( nId, SfxItemType::SvxPostureItemType, ePosture )
{
@@ -465,7 +495,6 @@ bool SvxPostureItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
bool SvxPostureItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
{
- ASSERT_CHANGE_REFCOUNTED_ITEM;
nMemberId &= ~CONVERT_TWIPS;
switch( nMemberId )
{
@@ -518,6 +547,12 @@ void SvxPostureItem::dumpAsXml(xmlTextWriterPtr pWriter) const
// class SvxWeightItem ---------------------------------------------------
+ItemInstanceManager* SvxWeightItem::getItemInstanceManager() const
+{
+ static DefaultItemInstanceManager aInstanceManager(typeid(SvxWeightItem).hash_code());
+ return &aInstanceManager;
+}
+
SvxWeightItem::SvxWeightItem( const FontWeight eWght, const sal_uInt16 nId ) :
SfxEnumItem( nId, SfxItemType::SvxWeightItemType, eWght )
{
@@ -642,18 +677,28 @@ void SvxWeightItem::dumpAsXml(xmlTextWriterPtr pWriter) const
// class SvxFontHeightItem -----------------------------------------------
-bool SvxFontHeightItem::isHashable() const
+namespace
{
- return true;
+ class SvxFontHeightItemInstanceManager : public TypeSpecificItemInstanceManager<SvxFontHeightItem>
+ {
+ protected:
+ virtual size_t hashCode(const SfxPoolItem& rItem) const override
+ {
+ auto const & rFontHeightItem = static_cast<const SvxFontHeightItem&>(rItem);
+ std::size_t seed(0);
+ o3tl::hash_combine(seed, rFontHeightItem.Which());
+ o3tl::hash_combine(seed, rFontHeightItem.GetHeight());
+ o3tl::hash_combine(seed, rFontHeightItem.GetProp());
+ o3tl::hash_combine(seed, rFontHeightItem.GetPropUnit());
+ return seed;
+ }
+ };
}
-size_t SvxFontHeightItem::hashCode() const
+ItemInstanceManager* SvxFontHeightItem::getItemInstanceManager() const
{
- std::size_t seed(0);
- o3tl::hash_combine(seed, GetHeight());
- o3tl::hash_combine(seed, GetProp());
- o3tl::hash_combine(seed, GetPropUnit());
- return seed;
+ static SvxFontHeightItemInstanceManager aInstanceManager;
+ return &aInstanceManager;
}
SvxFontHeightItem::SvxFontHeightItem( const sal_uInt32 nSz,
@@ -817,7 +862,6 @@ static sal_uInt32 lcl_GetRealHeight_Impl(sal_uInt32 nHeight, sal_uInt16 nProp, M
bool SvxFontHeightItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
{
- ASSERT_CHANGE_REFCOUNTED_ITEM;
bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
nMemberId &= ~CONVERT_TWIPS;
switch( nMemberId )
@@ -1150,6 +1194,12 @@ 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, SfxItemType::SvxUnderlineItemType )
{
@@ -1191,6 +1241,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, SfxItemType::SvxOverlineItemType )
{
@@ -1232,6 +1288,12 @@ OUString SvxOverlineItem::GetValueTextByPos( sal_uInt16 nPos ) const
// class SvxCrossedOutItem -----------------------------------------------
+ItemInstanceManager* SvxCrossedOutItem::getItemInstanceManager() const
+{
+ static DefaultItemInstanceManager aInstanceManager(typeid(SvxCrossedOutItem).hash_code());
+ return &aInstanceManager;
+}
+
SvxCrossedOutItem::SvxCrossedOutItem( const FontStrikeout eSt, const sal_uInt16 nId )
: SfxEnumItem( nId, SfxItemType::SvxCrossedOutItemType, eSt )
{
@@ -1468,16 +1530,6 @@ SvxColorItem::~SvxColorItem()
{
}
-bool SvxColorItem::isHashable() const { return true; }
-
-size_t SvxColorItem::hashCode() const
-{
- std::size_t seed(0);
- o3tl::hash_combine(seed, static_cast<sal_Int32>(mColor));
- o3tl::hash_combine(seed, maComplexColor);
- return seed;
-}
-
bool SvxColorItem::operator==( const SfxPoolItem& rAttr ) const
{
assert(SfxPoolItem::operator==(rAttr));
@@ -1906,16 +1958,6 @@ SvxEscapementItem::SvxEscapementItem( const short _nEsc,
{
}
-bool SvxEscapementItem::isHashable() const { return true; }
-
-size_t SvxEscapementItem::hashCode() const
-{
- std::size_t seed(0);
- o3tl::hash_combine(seed, nEsc);
- o3tl::hash_combine(seed, nProp);
- return seed;
-}
-
bool SvxEscapementItem::operator==( const SfxPoolItem& rAttr ) const
{
assert(SfxPoolItem::operator==(rAttr));
@@ -2049,6 +2091,12 @@ bool SvxEscapementItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
// class SvxLanguageItem -------------------------------------------------
+ItemInstanceManager* SvxLanguageItem::getItemInstanceManager() const
+{
+ static DefaultItemInstanceManager aInstanceManager(typeid(SvxLanguageItem).hash_code());
+ return &aInstanceManager;
+}
+
SvxLanguageItem::SvxLanguageItem( const LanguageType eLang, const sal_uInt16 nId )
: SvxLanguageItem_Base( nId , SfxItemType::SvxLanguageItemType, eLang )
{
@@ -2191,6 +2239,12 @@ bool SvxBlinkItem::GetPresentation
// class SvxEmphaisMarkItem ---------------------------------------------------
+ItemInstanceManager* SvxEmphasisMarkItem::getItemInstanceManager() const
+{
+ static DefaultItemInstanceManager aInstanceManager(typeid(SvxEmphasisMarkItem).hash_code());
+ return &aInstanceManager;
+}
+
SvxEmphasisMarkItem::SvxEmphasisMarkItem( const FontEmphasisMark nValue,
TypedWhichId<SvxEmphasisMarkItem> nId )
: SfxUInt16Item( nId, static_cast<sal_uInt16>(nValue), SfxItemType::SvxEmphasisMarkItemType )
@@ -2626,6 +2680,12 @@ bool SvxCharScaleWidthItem::QueryValue( uno::Any& rVal, sal_uInt8 /*nMemberId*/
|* class SvxCharReliefItem
*************************************************************************/
+ItemInstanceManager* SvxCharReliefItem::getItemInstanceManager() const
+{
+ static DefaultItemInstanceManager aInstanceManager(typeid(SvxCharReliefItem).hash_code());
+ return &aInstanceManager;
+}
+
SvxCharReliefItem::SvxCharReliefItem( FontRelief eValue,
const sal_uInt16 nId )
: SfxEnumItem( nId, SfxItemType::SvxCharReliefItemType, eValue )
@@ -2909,6 +2969,28 @@ void GetDefaultFonts( SvxFontItem& rLatin, SvxFontItem& rAsian, SvxFontItem& rCo
// class SvxRsidItem -----------------------------------------------------
+namespace
+{
+ class SvxRsidItemInstanceManager : public TypeSpecificItemInstanceManager<SvxRsidItem>
+ {
+ protected:
+ virtual size_t hashCode(const SfxPoolItem& rItem) const override
+ {
+ auto const & rRsidItem = static_cast<const SvxRsidItem&>(rItem);
+ std::size_t seed(0);
+ o3tl::hash_combine(seed, rRsidItem.Which());
+ o3tl::hash_combine(seed, rRsidItem.GetValue());
+ return seed;
+ }
+ };
+}
+
+ItemInstanceManager* SvxRsidItem::getItemInstanceManager() const
+{
+ static SvxRsidItemInstanceManager aInstanceManager;
+ return &aInstanceManager;
+}
+
bool SvxRsidItem::QueryValue( uno::Any& rVal, sal_uInt8 ) const
{
rVal <<= GetValue();
@@ -2917,7 +2999,6 @@ bool SvxRsidItem::QueryValue( uno::Any& rVal, sal_uInt8 ) const
bool SvxRsidItem::PutValue( const uno::Any& rVal, sal_uInt8 )
{
- ASSERT_CHANGE_REFCOUNTED_ITEM;
sal_uInt32 nRsid = 0;
if( !( rVal >>= nRsid ) )
return false;
diff --git a/include/editeng/adjustitem.hxx b/include/editeng/adjustitem.hxx
index 006bede075d7..c660598abfc7 100644
--- a/include/editeng/adjustitem.hxx
+++ b/include/editeng/adjustitem.hxx
@@ -44,6 +44,9 @@ class EDITENG_DLLPUBLIC SvxAdjustItem final : public SfxEnumItemInterface
bool bLastCenter : 1;
bool bLastBlock : 1;
+protected:
+ virtual ItemInstanceManager* getItemInstanceManager() const override;
+
public:
static SfxPoolItem* CreateDefault();
@@ -51,8 +54,6 @@ public:
const sal_uInt16 nId );
// "pure virtual Methods" from SfxPoolItem
- virtual bool isHashable() const override;
- virtual size_t hashCode() const override;
virtual bool operator==( const SfxPoolItem& ) const override;
virtual bool QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const override;
diff --git a/include/editeng/boxitem.hxx b/include/editeng/boxitem.hxx
index 6ceff99268c3..7afb8f2bf821 100644
--- a/include/editeng/boxitem.hxx
+++ b/include/editeng/boxitem.hxx
@@ -73,6 +73,9 @@ class EDITENG_DLLPUBLIC SvxBoxItem final : public SfxPoolItem
void tryMigrateComplexColor(SvxBoxItemLine eLine);
+protected:
+ virtual ItemInstanceManager* getItemInstanceManager() const override;
+
public:
static SfxPoolItem* CreateDefault();
diff --git a/include/editeng/brushitem.hxx b/include/editeng/brushitem.hxx
index 8412634a1157..6897e319a3b6 100644
--- a/include/editeng/brushitem.hxx
+++ b/include/editeng/brushitem.hxx
@@ -54,6 +54,9 @@ class EDITENG_DLLPUBLIC SvxBrushItem final : public SfxPoolItem
void ApplyGraphicTransparency_Impl();
+protected:
+ virtual ItemInstanceManager* getItemInstanceManager() const override;
+
public:
static SfxPoolItem* CreateDefault();
diff --git a/include/editeng/charreliefitem.hxx b/include/editeng/charreliefitem.hxx
index 78b57fa7df00..910adcf11e24 100644
--- a/include/editeng/charreliefitem.hxx
+++ b/include/editeng/charreliefitem.hxx
@@ -33,6 +33,9 @@
class EDITENG_DLLPUBLIC SvxCharReliefItem final : public SfxEnumItem<FontRelief>
{
+protected:
+ virtual ItemInstanceManager* getItemInstanceManager() const override;
+
public:
static SfxPoolItem* CreateDefault();
diff --git a/include/editeng/colritem.hxx b/include/editeng/colritem.hxx
index 220d7964ad2c..15c352ebff25 100644
--- a/include/editeng/colritem.hxx
+++ b/include/editeng/colritem.hxx
@@ -43,8 +43,6 @@ public:
virtual ~SvxColorItem() override;
// "pure virtual Methods" from SfxPoolItem
- virtual bool isHashable() const override;
- virtual size_t hashCode() const override;
virtual bool operator==(const SfxPoolItem& rPoolItem) const override;
virtual bool QueryValue(css::uno::Any& rVal, sal_uInt8 nMemberId = 0) const override;
virtual bool PutValue(const css::uno::Any& rVal, sal_uInt8 nMemberId) override;
diff --git a/include/editeng/crossedoutitem.hxx b/include/editeng/crossedoutitem.hxx
index 5d8b18fe2650..259eb412e1e1 100644
--- a/include/editeng/crossedoutitem.hxx
+++ b/include/editeng/crossedoutitem.hxx
@@ -31,6 +31,9 @@
class EDITENG_DLLPUBLIC SvxCrossedOutItem final : public SfxEnumItem<FontStrikeout>
{
+protected:
+ virtual ItemInstanceManager* getItemInstanceManager() const override;
+
public:
static SfxPoolItem* CreateDefault();
diff --git a/include/editeng/emphasismarkitem.hxx b/include/editeng/emphasismarkitem.hxx
index e0fd74cf4400..94d48e4b8d9c 100644
--- a/include/editeng/emphasismarkitem.hxx
+++ b/include/editeng/emphasismarkitem.hxx
@@ -32,6 +32,9 @@
class EDITENG_DLLPUBLIC SvxEmphasisMarkItem final : public SfxUInt16Item
{
+protected:
+ virtual ItemInstanceManager* getItemInstanceManager() const override;
+
public:
static SfxPoolItem* CreateDefault();
diff --git a/include/editeng/escapementitem.hxx b/include/editeng/escapementitem.hxx
index 87afbcdd9e88..d889d7bc309e 100644
--- a/include/editeng/escapementitem.hxx
+++ b/include/editeng/escapementitem.hxx
@@ -51,8 +51,6 @@ public:
const sal_uInt16 nId );
// "pure virtual Methods" from SfxPoolItem
- virtual bool isHashable() const override;
- virtual size_t hashCode() const override;
virtual bool operator==( const SfxPoolItem& ) const override;
virtual bool GetPresentation( SfxItemPresentation ePres,
MapUnit eCoreMetric,
diff --git a/include/editeng/fhgtitem.hxx b/include/editeng/fhgtitem.hxx
index 342419e4e359..bdde8c6f0afd 100644
--- a/include/editeng/fhgtitem.hxx
+++ b/include/editeng/fhgtitem.hxx
@@ -44,6 +44,9 @@ class EDITENG_DLLPUBLIC SvxFontHeightItem final : public SfxPoolItem
friend void Create_legacy_direct_set(SvxFontHeightItem& rItem, sal_uInt32 nH, sal_uInt16 nP, MapUnit eP);
void legacy_direct_set(sal_uInt32 nH, sal_uInt16 nP, MapUnit eP) { nHeight = nH; nProp = nP; ePropUnit = eP; }
+protected:
+ virtual ItemInstanceManager* getItemInstanceManager() const override;
+
public:
static SfxPoolItem* CreateDefault();
@@ -51,8 +54,6 @@ public:
const sal_uInt16 nId );
// "pure virtual Methods" from SfxPoolItem
- virtual bool isHashable() const override;
- virtual size_t hashCode() const override;
virtual bool operator==( const SfxPoolItem& ) const override;
virtual bool QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const override;
virtual bool PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId ) override;
diff --git a/include/editeng/fontitem.hxx b/include/editeng/fontitem.hxx
index 82d19ca40490..f892178c521e 100644
--- a/include/editeng/fontitem.hxx
+++ b/include/editeng/fontitem.hxx
@@ -34,6 +34,9 @@ class EDITENG_DLLPUBLIC SvxFontItem final : public SfxPoolItem
FontPitch ePitch;
rtl_TextEncoding eTextEncoding;
+protected:
+ virtual ItemInstanceManager* getItemInstanceManager() const override;
+
public:
static SfxPoolItem* CreateDefault();
@@ -45,8 +48,6 @@ public:
const sal_uInt16 nId);
// "pure virtual Methods" from SfxPoolItem
- virtual bool isHashable() const override;
- virtual size_t hashCode() const override;
virtual bool operator==(const SfxPoolItem& rItem) const override;
virtual SvxFontItem* Clone(SfxItemPool *pPool = nullptr) const override;
virtual bool QueryValue(css::uno::Any& rVal, sal_uInt8 nMemberId = 0) const override;
diff --git a/include/editeng/frmdiritem.hxx b/include/editeng/frmdiritem.hxx
index 7bb6dc09950d..e2bba96b8974 100644
--- a/include/editeng/frmdiritem.hxx
+++ b/include/editeng/frmdiritem.hxx
@@ -30,6 +30,9 @@
class EDITENG_DLLPUBLIC SvxFrameDirectionItem final : public SfxEnumItem<SvxFrameDirection>
{
+protected:
+ virtual ItemInstanceManager* getItemInstanceManager() const override;
+
public:
SvxFrameDirectionItem( SvxFrameDirection nValue, sal_uInt16 nWhich );
virtual ~SvxFrameDirectionItem() override;
diff --git a/include/editeng/langitem.hxx b/include/editeng/langitem.hxx
index c84aebf3b33c..4ebef0837a6c 100644
--- a/include/editeng/langitem.hxx
+++ b/include/editeng/langitem.hxx
@@ -40,6 +40,9 @@ protected:
class EDITENG_DLLPUBLIC SvxLanguageItem final : public SvxLanguageItem_Base
{
+protected:
+ virtual ItemInstanceManager* getItemInstanceManager() const override;
+
public:
static SfxPoolItem* CreateDefault();
diff --git a/include/editeng/lrspitem.hxx b/include/editeng/lrspitem.hxx
index 998ea71fbb84..edab3ef23d73 100644
--- a/include/editeng/lrspitem.hxx
+++ b/include/editeng/lrspitem.hxx
@@ -68,8 +68,6 @@ public:
SvxLeftMarginItem(SvxLeftMarginItem const &) = default; // SfxPoolItem copy function dichotomy
// "pure virtual Methods" from SfxPoolItem
- virtual bool isHashable() const override;
- virtual size_t hashCode() const override;
virtual bool operator==(const SfxPoolItem&) const override;
virtual bool QueryValue(css::uno::Any& rVal, sal_uInt8 nMemberId = 0) const override;
@@ -112,8 +110,6 @@ public:
SvxTextLeftMarginItem(SvxTextLeftMarginItem const &) = default; // SfxPoolItem copy function dichotomy
// "pure virtual Methods" from SfxPoolItem
- virtual bool isHashable() const override;
- virtual size_t hashCode() const override;
virtual bool operator==(const SfxPoolItem&) const override;
virtual bool QueryValue(css::uno::Any& rVal, sal_uInt8 nMemberId = 0) const override;
@@ -149,19 +145,17 @@ public:
void SetTextFirstLineOffset(const short nF, const sal_uInt16 nProp = 100);
short GetTextFirstLineOffset() const { return m_nFirstLineOffset; }
void SetPropTextFirstLineOffset(const sal_uInt16 nProp)
- { ASSERT_CHANGE_REFCOUNTED_ITEM; m_nPropFirstLineOffset = nProp; }
+ { m_nPropFirstLineOffset = nProp; }
sal_uInt16 GetPropTextFirstLineOffset() const
{ return m_nPropFirstLineOffset; }
void SetTextFirstLineOffsetValue(const short nValue)
- { ASSERT_CHANGE_REFCOUNTED_ITEM; m_nFirstLineOffset = nValue; }
+ { m_nFirstLineOffset = nValue; }
explicit SvxFirstLineIndentItem(const sal_uInt16 nId);
SvxFirstLineIndentItem(const short nOffset, const sal_uInt16 nId);
SvxFirstLineIndentItem(SvxFirstLineIndentItem const &) = default; // SfxPoolItem copy function dichotomy
// "pure virtual Methods" from SfxPoolItem
- virtual bool isHashable() const override;
- virtual size_t hashCode() const override;
virtual bool operator==(const SfxPoolItem&) const override;
virtual bool QueryValue(css::uno::Any& rVal, sal_uInt8 nMemberId = 0) const override;
@@ -201,8 +195,6 @@ public:
SvxRightMarginItem(SvxRightMarginItem const &) = default; // SfxPoolItem copy function dichotomy
// "pure virtual Methods" from SfxPoolItem
- virtual bool isHashable() const override;
- virtual size_t hashCode() const override;
virtual bool operator==(const SfxPoolItem&) const override;
virtual bool QueryValue(css::uno::Any& rVal, sal_uInt8 nMemberId = 0) const override;
@@ -229,15 +221,13 @@ private:
tools::Long m_nGutterMargin = 0;
public:
- void SetGutterMargin(const tools::Long nGutterMargin) { ASSERT_CHANGE_REFCOUNTED_ITEM; m_nGutterMargin = nGutterMargin; }
+ void SetGutterMargin(const tools::Long nGutterMargin) { m_nGutterMargin = nGutterMargin; }
tools::Long GetGutterMargin() const { return m_nGutterMargin; }
explicit SvxGutterLeftMarginItem(const sal_uInt16 nId);
SvxGutterLeftMarginItem(SvxGutterLeftMarginItem const &) = default; // SfxPoolItem copy function dichotomy
// "pure virtual Methods" from SfxPoolItem
- virtual bool isHashable() const override;
- virtual size_t hashCode() const override;
virtual bool operator==(const SfxPoolItem&) const override;
virtual bool QueryValue(css::uno::Any& rVal, sal_uInt8 nMemberId = 0) const override;
@@ -270,8 +260,6 @@ public:
SvxGutterRightMarginItem(SvxGutterRightMarginItem const &) = default; // SfxPoolItem copy function dichotomy
// "pure virtual Methods" from SfxPoolItem
- virtual bool isHashable() const override;
- virtual size_t hashCode() const override;
virtual bool operator==(const SfxPoolItem&) const override;
virtual bool QueryValue(css::uno::Any& rVal, sal_uInt8 nMemberId = 0) const override;
@@ -317,8 +305,6 @@ public:
SvxLRSpaceItem(SvxLRSpaceItem const &) = default; // SfxPoolItem copy function dichotomy
// "pure virtual Methods" from SfxPoolItem
- virtual bool isHashable() const override;
- virtual size_t hashCode() const override;
virtual bool operator==( const SfxPoolItem& ) const override;
virtual bool QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const override;
@@ -340,15 +326,15 @@ public:
// Query/direct setting of the absolute values
tools::Long GetLeft() const { return nLeftMargin; }
tools::Long GetRight() const { return nRightMargin;}
- void SetLeftValue( const tools::Long nL ) { ASSERT_CHANGE_REFCOUNTED_ITEM; assert(nFirstLineOffset == 0); nLeftMargin = nL; }
- void SetRightValue( const tools::Long nR ) { ASSERT_CHANGE_REFCOUNTED_ITEM; nRightMargin = nR; }
+ void SetLeftValue( const tools::Long nL ) { assert(nFirstLineOffset == 0); nLeftMargin = nL; }
+ void SetRightValue( const tools::Long nR ) { nRightMargin = nR; }
bool IsAutoFirst() const { return bAutoFirst; }
- void SetAutoFirst( const bool bNew ) { ASSERT_CHANGE_REFCOUNTED_ITEM; bAutoFirst = bNew; }
+ void SetAutoFirst( const bool bNew ) { bAutoFirst = bNew; }
bool IsExplicitZeroMarginValRight() const { return bExplicitZeroMarginValRight; }
bool IsExplicitZeroMarginValLeft() const { return bExplicitZeroMarginValLeft; }
- void SetExplicitZeroMarginValRight( const bool eR ) { ASSERT_CHANGE_REFCOUNTED_ITEM; bExplicitZeroMarginValRight = eR; }
- void SetExplicitZeroMarginValLeft( const bool eL ) { ASSERT_CHANGE_REFCOUNTED_ITEM; bExplicitZeroMarginValLeft = eL; }
+ void SetExplicitZeroMarginValRight( const bool eR ) { bExplicitZeroMarginValRight = eR; }
+ void SetExplicitZeroMarginValLeft( const bool eL ) { bExplicitZeroMarginValLeft = eL; }
sal_uInt16 GetPropLeft() const { return nPropLeftMargin; }
sal_uInt16 GetPropRight() const { return nPropRightMargin;}
@@ -359,14 +345,14 @@ public:
void SetTextFirstLineOffset(const short nF, const sal_uInt16 nProp = 100);
short GetTextFirstLineOffset() const { return nFirstLineOffset; }
void SetPropTextFirstLineOffset( const sal_uInt16 nProp )
- { ASSERT_CHANGE_REFCOUNTED_ITEM; nPropFirstLineOffset = nProp; }
+ { nPropFirstLineOffset = nProp; }
sal_uInt16 GetPropTextFirstLineOffset() const
{ return nPropFirstLineOffset; }
void SetTextFirstLineOffsetValue( const short nValue )
- { ASSERT_CHANGE_REFCOUNTED_ITEM; nFirstLineOffset = nValue; }
- void SetGutterMargin(const tools::Long nGutterMargin) { ASSERT_CHANGE_REFCOUNTED_ITEM; m_nGutterMargin = nGutterMargin; }
+ { nFirstLineOffset = nValue; }
+ void SetGutterMargin(const tools::Long nGutterMargin) { m_nGutterMargin = nGutterMargin; }
tools::Long GetGutterMargin() const { return m_nGutterMargin; }
- void SetRightGutterMargin(const tools::Long nRightGutterMargin) { ASSERT_CHANGE_REFCOUNTED_ITEM; m_nRightGutterMargin = nRightGutterMargin; }
+ void SetRightGutterMargin(const tools::Long nRightGutterMargin) { m_nRightGutterMargin = nRightGutterMargin; }
tools::Long GetRightGutterMargin() const { return m_nRightGutterMargin; }
void dumpAsXml(xmlTextWriterPtr pWriter) const override;
diff --git a/include/editeng/postitem.hxx b/include/editeng/postitem.hxx
index 93ed44b6b794..392a9627feb6 100644
--- a/include/editeng/postitem.hxx
+++ b/include/editeng/postitem.hxx
@@ -32,6 +32,9 @@
class EDITENG_DLLPUBLIC SvxPostureItem final : public SfxEnumItem<FontItalic>
{
+protected:
+ virtual ItemInstanceManager* getItemInstanceManager() const override;
+
public:
static SfxPoolItem* CreateDefault();
diff --git a/include/editeng/protitem.hxx b/include/editeng/protitem.hxx
index 18ad76fcf3ac..0c3b473700d1 100644
--- a/include/editeng/protitem.hxx
+++ b/include/editeng/protitem.hxx
@@ -43,8 +43,6 @@ public:
SvxProtectItem(SvxProtectItem const &) = default; // SfxPoolItem copy function dichotomy
// "pure virtual Methods" from SfxPoolItem
- virtual bool isHashable() const override;
- virtual size_t hashCode() const override;
virtual bool operator==( const SfxPoolItem& ) const override;
virtual bool GetPresentation( SfxItemPresentation ePres,
@@ -58,9 +56,9 @@ public:
bool IsContentProtected() const { return bCntnt; }
bool IsSizeProtected() const { return bSize; }
bool IsPosProtected() const { return bPos; }
- void SetContentProtect( bool bNew ) { ASSERT_CHANGE_REFCOUNTED_ITEM; bCntnt = bNew; }
- void SetSizeProtect ( bool bNew ) { ASSERT_CHANGE_REFCOUNTED_ITEM; bSize = bNew; }
- void SetPosProtect ( bool bNew ) { ASSERT_CHANGE_REFCOUNTED_ITEM; bPos = bNew; }
+ void SetContentProtect( bool bNew ) { bCntnt = bNew; }
+ void SetSizeProtect ( bool bNew ) { bSize = bNew; }
+ void SetPosProtect ( bool bNew ) { bPos = bNew; }
virtual bool QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const override;
virtual bool PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId ) override;
diff --git a/include/editeng/rsiditem.hxx b/include/editeng/rsiditem.hxx
index 5c91006dcb9b..9e9cf18767ee 100644
--- a/include/editeng/rsiditem.hxx
+++ b/include/editeng/rsiditem.hxx
@@ -33,6 +33,8 @@ public:
void dumpAsXml(xmlTextWriterPtr pWriter) const override;
+protected:
+ virtual ItemInstanceManager* getItemInstanceManager() const override;
};
#endif // INCLUDED_EDITENG_RSIDITEM_HXX
diff --git a/include/editeng/shaditem.hxx b/include/editeng/shaditem.hxx
index 9d15e5ea56e5..bed848215985 100644
--- a/include/editeng/shaditem.hxx
+++ b/include/editeng/shaditem.hxx
@@ -48,8 +48,6 @@ public:
const SvxShadowLocation eLoc = SvxShadowLocation::NONE );
// "pure virtual Methods" from SfxPoolItem
- virtual bool isHashable() const override;
- virtual size_t hashCode() const override;
virtual bool operator==( const SfxPoolItem& ) const override;
virtual bool QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const override;
virtual bool PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId ) override;
@@ -64,13 +62,13 @@ public:
virtual bool HasMetrics() const override;
const Color& GetColor() const { return aShadowColor;}
- void SetColor( const Color &rNew ) { ASSERT_CHANGE_REFCOUNTED_ITEM; aShadowColor = rNew; }
+ void SetColor( const Color &rNew ) { aShadowColor = rNew; }
sal_uInt16 GetWidth() const { return nWidth; }
SvxShadowLocation GetLocation() const { return eLocation; }
- void SetWidth( sal_uInt16 nNew ) { ASSERT_CHANGE_REFCOUNTED_ITEM; nWidth = nNew; }
- void SetLocation( SvxShadowLocation eNew ) { ASSERT_CHANGE_REFCOUNTED_ITEM; eLocation = eNew; }
+ void SetWidth( sal_uInt16 nNew ) { nWidth = nNew; }
+ void SetLocation( SvxShadowLocation eNew ) { eLocation = eNew; }
// Calculate width of the shadow on the page.
sal_uInt16 CalcShadowSpace( SvxShadowItemSide nShadow ) const;
diff --git a/include/editeng/sizeitem.hxx b/include/editeng/sizeitem.hxx
index 7e10873496f3..172099985fac 100644
--- a/include/editeng/sizeitem.hxx
+++ b/include/editeng/sizeitem.hxx
@@ -42,8 +42,6 @@ public:
SvxSizeItem( const sal_uInt16 nId, const Size& rSize, SfxItemType eItemType = SfxItemType::SvxSizeItemType);
// "pure virtual Methods" from SfxPoolItem
- virtual bool isHashable() const override;
- virtual size_t hashCode() const override;
virtual bool operator==( const SfxPoolItem& ) const override;
virtual bool QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const override;
virtual bool PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId ) override;
diff --git a/include/editeng/udlnitem.hxx b/include/editeng/udlnitem.hxx
index 47c8fea73ca7..ec0f35d54ae6 100644
--- a/include/editeng/udlnitem.hxx
+++ b/include/editeng/udlnitem.hxx
@@ -88,6 +88,9 @@ public:
class EDITENG_DLLPUBLIC SvxUnderlineItem final : public SvxTextLineItem
{
+protected:
+ virtual ItemInstanceManager* getItemInstanceManager() const override;
+
public:
static SfxPoolItem* CreateDefault();
@@ -104,6 +107,9 @@ public:
class EDITENG_DLLPUBLIC SvxOverlineItem final : public SvxTextLineItem
{
+protected:
+ virtual ItemInstanceManager* getItemInstanceManager() const override;
+
public:
static SfxPoolItem* CreateDefault();
diff --git a/include/editeng/ulspitem.hxx b/include/editeng/ulspitem.hxx
index 5c26ce2eb6a8..b0131ab9904d 100644
--- a/include/editeng/ulspitem.hxx
+++ b/include/editeng/ulspitem.hxx
@@ -46,8 +46,6 @@ public:
const sal_uInt16 nId );
// "pure virtual Methods" from SfxPoolItem
- virtual bool isHashable() const override;
- virtual size_t hashCode() const override;
virtual bool operator==( const SfxPoolItem& ) const override;
virtual bool QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const override;
@@ -65,11 +63,11 @@ public:
inline void SetUpper( const sal_uInt16 nU, const sal_uInt16 nProp = 100 );
inline void SetLower( const sal_uInt16 nL, const sal_uInt16 nProp = 100 );
- void SetUpperValue( const sal_uInt16 nU ) { ASSERT_CHANGE_REFCOUNTED_ITEM; nUpper = nU; }
- void SetLowerValue( const sal_uInt16 nL ) { ASSERT_CHANGE_REFCOUNTED_ITEM; nLower = nL; }
- void SetContextValue( const bool bC ) { ASSERT_CHANGE_REFCOUNTED_ITEM; bContext = bC; }
- void SetPropUpper( const sal_uInt16 nU ) { ASSERT_CHANGE_REFCOUNTED_ITEM; nPropUpper = nU; }
- void SetPropLower( const sal_uInt16 nL ) { ASSERT_CHANGE_REFCOUNTED_ITEM; nPropLower = nL; }
+ void SetUpperValue( const sal_uInt16 nU ) { nUpper = nU; }
+ void SetLowerValue( const sal_uInt16 nL ) { nLower = nL; }
+ void SetContextValue( const bool bC ) { bContext = bC; }
+ void SetPropUpper( const sal_uInt16 nU ) { nPropUpper = nU; }
+ void SetPropLower( const sal_uInt16 nL ) { nPropLower = nL; }
sal_uInt16 GetUpper() const { return nUpper; }
sal_uInt16 GetLower() const { return nLower; }
diff --git a/include/editeng/wghtitem.hxx b/include/editeng/wghtitem.hxx
index 121cfcf318a6..f8beb7c7a62f 100644
--- a/include/editeng/wghtitem.hxx
+++ b/include/editeng/wghtitem.hxx
@@ -32,6 +32,9 @@
class EDITENG_DLLPUBLIC SvxWeightItem final : public SfxEnumItem<FontWeight>
{
+protected:
+ virtual ItemInstanceManager* getItemInstanceManager() const override;
+
public:
static SfxPoolItem* CreateDefault();
diff --git a/include/svl/cintitem.hxx b/include/svl/cintitem.hxx
index c10be9ccb8f9..d9c0f273f260 100644
--- a/include/svl/cintitem.hxx
+++ b/include/svl/cintitem.hxx
@@ -33,8 +33,6 @@ public:
CntByteItem(sal_uInt16 which, sal_uInt8 nTheValue, SfxItemType eItemType = SfxItemType::CntByteItemType):
SfxPoolItem(which, eItemType), m_nValue(nTheValue) {}
- virtual bool isHashable() const override final { return true; }
- virtual size_t hashCode() const override final { return m_nValue; }
virtual bool operator ==(const SfxPoolItem & rItem) const override;
virtual bool GetPresentation(SfxItemPresentation,
@@ -66,8 +64,6 @@ public:
SfxPoolItem(which, eItemType), m_nValue(nTheValue)
{}
- virtual bool isHashable() const override final { return true; }
- virtual size_t hashCode() const override final { return m_nValue; }
virtual bool operator ==(const SfxPoolItem & rItem) const override;
virtual bool GetPresentation(SfxItemPresentation,
@@ -100,8 +96,6 @@ public:
SfxPoolItem(which, eItemType), m_nValue(nTheValue)
{}
- virtual bool isHashable() const override final { return true; }
- virtual size_t hashCode() const override final { return m_nValue; }
virtual bool operator ==(const SfxPoolItem & rItem) const override;
virtual bool GetPresentation(SfxItemPresentation,
@@ -134,8 +128,6 @@ public:
SfxPoolItem(which, eItemType), m_nValue(nTheValue)
{}
- virtual bool isHashable() const override final { return true; }
- virtual size_t hashCode() const override final { return m_nValue; }
virtual bool operator ==(const SfxPoolItem & rItem) const override;
virtual bool GetPresentation(SfxItemPresentation,
diff --git a/include/svl/custritm.hxx b/include/svl/custritm.hxx
index 309c0ebfe48a..118fd0963f15 100644
--- a/include/svl/custritm.hxx
+++ b/include/svl/custritm.hxx
@@ -39,8 +39,6 @@ public:
SfxPoolItem(which, eItemType), m_aValue(std::move(aTheValue))
{}
- // not all of the subclasses of this are hashable, so we only define the shared hashCode function here
- virtual size_t hashCode() const override;
virtual bool operator ==(const SfxPoolItem & rItem) const override;
virtual bool GetPresentation(SfxItemPresentation,
diff --git a/include/svl/eitem.hxx b/include/svl/eitem.hxx
index 141e292ceaad..f6fb22bfeb7d 100644
--- a/include/svl/eitem.hxx
+++ b/include/svl/eitem.hxx
@@ -62,16 +62,6 @@ public:
return SfxEnumItemInterface::operator==(other) &&
m_nValue == static_cast<const SfxEnumItem<EnumT> &>(other).m_nValue;
}
-
- virtual bool isHashable() const override final
- {
- return true;
- }
-
- virtual size_t hashCode() const override final
- {
- return GetEnumValue();
- }
};
class SVL_DLLPUBLIC SfxBoolItem
@@ -79,6 +69,9 @@ class SVL_DLLPUBLIC SfxBoolItem
{
bool m_bValue;
+protected:
+ virtual ItemInstanceManager* getItemInstanceManager() const override;
+
public:
static SfxPoolItem* CreateDefault();
@@ -88,9 +81,6 @@ public:
, m_bValue(bValue)
{ }
- virtual bool isHashable() const override;
- virtual size_t hashCode() const override;
-
bool GetValue() const { return m_bValue; }
void SetValue(bool const bTheValue);
diff --git a/include/svl/flagitem.hxx b/include/svl/flagitem.hxx
index f9967af78b9c..ac32bab18ca9 100644
--- a/include/svl/flagitem.hxx
+++ b/include/svl/flagitem.hxx
@@ -36,8 +36,6 @@ public:
virtual sal_uInt8 GetFlagCount() const;
- virtual bool isHashable() const override { return true; }
- virtual size_t hashCode() const override final { return nVal; }
virtual bool operator==( const SfxPoolItem& ) const override;
virtual SfxFlagItem* Clone( SfxItemPool *pPool = nullptr ) const override;
diff --git a/include/svl/globalnameitem.hxx b/include/svl/globalnameitem.hxx
index 36824d3a39e4..edbb56273232 100644
--- a/include/svl/globalnameitem.hxx
+++ b/include/svl/globalnameitem.hxx
@@ -39,8 +39,6 @@ public:
SfxGlobalNameItem & operator =(SfxGlobalNameItem const &) = delete; // due to SfxPoolItem
SfxGlobalNameItem & operator =(SfxGlobalNameItem &&) = delete; // due to SfxPoolItem
- virtual bool isHashable() const override;
- virtual size_t hashCode() const override;
virtual bool operator==( const SfxPoolItem& ) const override;
virtual SfxGlobalNameItem* Clone( SfxItemPool *pPool = nullptr ) const override;
const SvGlobalName& GetValue() const { return m_aName; }
diff --git a/include/svl/grabbagitem.hxx b/include/svl/grabbagitem.hxx
index d14bde539620..77a619aec4c1 100644
--- a/include/svl/grabbagitem.hxx
+++ b/include/svl/grabbagitem.hxx
@@ -33,14 +33,8 @@ public:
const std::map<OUString, css::uno::Any>& GetGrabBag() const { return m_aMap; }
- std::map<OUString, css::uno::Any>& GetGrabBag()
- {
- ASSERT_CHANGE_REFCOUNTED_ITEM;
- return m_aMap;
- }
-
- virtual bool isHashable() const override;
- virtual size_t hashCode() const override;
+ std::map<OUString, css::uno::Any>& GetGrabBag() { return m_aMap; }
+
bool operator==(const SfxPoolItem& rItem) const override;
SfxGrabBagItem* Clone(SfxItemPool* pPool = nullptr) const override;
diff --git a/include/svl/ilstitem.hxx b/include/svl/ilstitem.hxx
index 53f2a6204b64..bb49d18c9dbb 100644
--- a/include/svl/ilstitem.hxx
+++ b/include/svl/ilstitem.hxx
@@ -44,8 +44,6 @@ public:
const std::vector< sal_Int32 >& GetList() const { return m_aList; }
- virtual bool isHashable() const override;
- virtual size_t hashCode() const override;
virtual bool operator==( const SfxPoolItem& ) const override;
virtual SfxIntegerListItem* Clone( SfxItemPool *pPool = nullptr ) const override;
virtual bool PutValue ( const css::uno::Any& rVal, sal_uInt8 nMemberId ) override;
diff --git a/include/svl/imageitm.hxx b/include/svl/imageitm.hxx
index d5c871ed8c4c..f06eb7fd6902 100644
--- a/include/svl/imageitm.hxx
+++ b/include/svl/imageitm.hxx
@@ -34,15 +34,13 @@ public:
virtual ~SfxImageItem() override;
virtual SfxImageItem* Clone( SfxItemPool* pPool = nullptr ) const override;
- virtual bool isHashable() const override;
- virtual size_t hashCode() const override;
virtual bool operator==( const SfxPoolItem& ) const override;
virtual bool QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const override;
virtual bool PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId ) override;
- void SetRotation( Degree10 nValue ) { ASSERT_CHANGE_REFCOUNTED_ITEM; mnAngle = nValue; }
+ void SetRotation( Degree10 nValue ) { mnAngle = nValue; }
Degree10 GetRotation() const { return mnAngle; }
- void SetMirrored( bool bSet ) { ASSERT_CHANGE_REFCOUNTED_ITEM; mbMirrored = bSet; }
+ void SetMirrored( bool bSet ) { mbMirrored = bSet; }
bool IsMirrored() const { return mbMirrored; }
private:
diff --git a/include/svl/int64item.hxx b/include/svl/int64item.hxx
index 0dd33e0a735c..70a502c645a8 100644
--- a/include/svl/int64item.hxx
+++ b/include/svl/int64item.hxx
@@ -27,8 +27,6 @@ public:
SfxInt64Item & operator =(SfxInt64Item const &) = delete; // due to SfxPoolItem;
SfxInt64Item & operator =(SfxInt64Item &&) = delete; // due to SfxPoolItem
- virtual bool isHashable() const override { return true; }
- virtual size_t hashCode() const override { return mnValue; }
virtual bool operator== ( const SfxPoolItem& rItem ) const override;
virtual bool GetPresentation(
diff --git a/include/svl/intitem.hxx b/include/svl/intitem.hxx
index 82fa80f12d09..0d3adcf0a750 100644
--- a/include/svl/intitem.hxx
+++ b/include/svl/intitem.hxx
@@ -50,8 +50,6 @@ public:
SfxPoolItem(which, eItemType), m_nValue(nTheValue)
{}
- virtual bool isHashable() const override { return true; }
- virtual size_t hashCode() const override { return m_nValue; }
virtual bool operator ==(const SfxPoolItem & rItem) const override;
virtual bool GetPresentation(SfxItemPresentation,
diff --git a/include/svl/poolitem.hxx b/include/svl/poolitem.hxx
index 8be865c4e9b0..c993039afa7b 100644
--- a/include/svl/poolitem.hxx
+++ b/include/svl/poolitem.hxx
@@ -523,6 +523,7 @@ SVL_DLLPUBLIC void listAllocatedSfxPoolItems();
class SfxItemPool;
class SfxItemSet;
typedef struct _xmlTextWriter* xmlTextWriterPtr;
+class ItemInstanceManager;
class SVL_DLLPUBLIC SfxPoolItem
{
@@ -579,6 +580,15 @@ protected:
void setIsSetItem() { m_bIsSetItem = true; }
void setNonShareable() { m_bShareable = false; }
+ // access ItemInstanceManager for this Item, default
+ // is nullptr. If you overload this it is expected that
+ // you return a ptr to a static, Item-local managed
+ // instance that exists the whole office lifetime. This
+ // usually means to have a static instance directly in the
+ // implementation of the overloaded function (just grep
+ // for examples)
+ virtual ItemInstanceManager* getItemInstanceManager() const;
+
public:
inline void AddRef(sal_uInt32 n = 1) const
{
@@ -691,14 +701,100 @@ public:
virtual void dumpAsXml(xmlTextWriterPtr pWriter) const;
virtual boost::property_tree::ptree dumpAsJSON() const;
- // Only return true from isHashable() if hashCode is implemented.
- virtual bool isHashable() const;
- virtual size_t hashCode() const;
-
private:
SfxPoolItem& operator=( const SfxPoolItem& ) = delete;
};
+// basic Interface definition
+class SVL_DLLPUBLIC ItemInstanceManager
+{
+ // allow *only* ItemSetTooling to access
+ friend SfxPoolItem const* implCreateItemEntry(SfxItemPool&, SfxPoolItem const*, bool);
+ friend void implCleanupItemEntry(SfxPoolItem const*);
+
+ // Define for which class to register (usually typeid().hash_code()).
+ std::size_t m_aClassHash;
+
+public:
+ ItemInstanceManager(const std::size_t aClassHash)
+ : m_aClassHash(aClassHash)
+ {
+ }
+ virtual ~ItemInstanceManager() = default;
+
+ std::size_t getClassHash() const { return m_aClassHash; }
+
+private:
+ // standard interface, accessed exclusively
+ // by implCreateItemEntry/implCleanupItemEntry
+ virtual const SfxPoolItem* find(const SfxPoolItem&) const = 0;
+ virtual void add(const SfxPoolItem&) = 0;
+ virtual void remove(const SfxPoolItem&) = 0;
+};
+
+// offering a default implementation that can be use for
+// each SfxPoolItem (except when !isShareable()). It just
+// uses an unordered_set holding ptrs to SfxPoolItems added
+// and SfxPoolItem::operator== to linearly search for one.
+// Thus this is not the fastest, but as fast as old 'poooled'
+// stuff - better use an intelligent, pro-Item implementation
+// that does e.g. hashing or whatever might be feasible for
+// that specific Item (see other derivations)
+class SVL_DLLPUBLIC DefaultItemInstanceManager : public ItemInstanceManager
+{
+ std::unordered_map<sal_uInt16, std::unordered_set<const SfxPoolItem*>> maRegistered;
+
+public:
+ DefaultItemInstanceManager(const std::size_t aClassHash)
+ : ItemInstanceManager(aClassHash)
+ {
+ }
+
+private:
+ virtual const SfxPoolItem* find(const SfxPoolItem&) const override;
+ virtual void add(const SfxPoolItem&) override;
+ virtual void remove(const SfxPoolItem&) override;
+};
+
+/**
+ Utility template to reduce boilerplate code when creating item instance managers
+ for specific PoolItem subclasses.
+*/
+template<class T>
+class TypeSpecificItemInstanceManager : public ItemInstanceManager
+{
+public:
+ TypeSpecificItemInstanceManager()
+ : ItemInstanceManager(typeid(T).hash_code())
+ {
+ }
+
+ // standard interface, accessed exclusively
+ // by implCreateItemEntry/implCleanupItemEntry
+ virtual const SfxPoolItem* find(const SfxPoolItem& rItem) const override final
+ {
+ auto aHit(maRegistered.find(hashCode(rItem)));
+ if (aHit != maRegistered.end())
+ return aHit->second;
+ return nullptr;
+ }
+ virtual void add(const SfxPoolItem& rItem) override final
+ {
+ maRegistered.insert({hashCode(rItem), &rItem});
+ }
+ virtual void remove(const SfxPoolItem& rItem) override final
+ {
+ maRegistered.erase(hashCode(rItem));
+ }
+
+protected:
+ virtual size_t hashCode(const SfxPoolItem&) const = 0;
+
+private:
+ std::unordered_map<size_t, const SfxPoolItem*> maRegistered;
+};
+
+
inline bool IsStaticDefaultItem(const SfxPoolItem *pItem )
{
return pItem && pItem->isStaticDefault();
diff --git a/include/svl/ptitem.hxx b/include/svl/ptitem.hxx
index 66a47fd992e1..90db98bbc869 100644
--- a/include/svl/ptitem.hxx
+++ b/include/svl/ptitem.hxx
@@ -41,8 +41,6 @@ public:
OUString &rText,
const IntlWrapper& ) const override;
- virtual bool isHashable() const override;
- virtual size_t hashCode() const override;
virtual bool operator==( const SfxPoolItem& ) const override;
virtual SfxPointItem* Clone( SfxItemPool *pPool = nullptr ) const override;
diff --git a/include/svl/rectitem.hxx b/include/svl/rectitem.hxx
index ff7dce5fb3aa..26c2acd37b65 100644
--- a/include/svl/rectitem.hxx
+++ b/include/svl/rectitem.hxx
@@ -40,8 +40,6 @@ public:
OUString &rText,
const IntlWrapper& ) const override;
- virtual bool isHashable() const override;
- virtual size_t hashCode() const override;
virtual bool operator==( const SfxPoolItem& ) const override;
virtual SfxRectangleItem* Clone( SfxItemPool *pPool = nullptr ) const override;
diff --git a/include/svl/rngitem.hxx b/include/svl/rngitem.hxx
index bb606b7149af..8e41184749b1 100644
--- a/include/svl/rngitem.hxx
+++ b/include/svl/rngitem.hxx
@@ -34,8 +34,6 @@ private:
sal_uInt16 nTo;
public:
SfxRangeItem( sal_uInt16 nWID, sal_uInt16 nFrom, sal_uInt16 nTo );
- virtual bool isHashable() const override { return true; }
- virtual size_t hashCode() const override { return (static_cast<size_t>(nFrom) << 16) | nTo; }
virtual bool operator==( const SfxPoolItem& ) const override;
virtual bool GetPresentation( SfxItemPresentation ePres,
MapUnit eCoreMetric,
diff --git a/include/svl/visitem.hxx b/include/svl/visitem.hxx
index 04d76365cda8..8a458bbf2f6c 100644
--- a/include/svl/visitem.hxx
+++ b/include/svl/visitem.hxx
@@ -36,8 +36,6 @@ public:
m_nValue.bVisible = bVisible;
}
- virtual bool isHashable() const override { return true; }
- virtual size_t hashCode() const override { return static_cast<size_t>(m_nValue.bVisible); }
virtual bool operator ==(const SfxPoolItem & rItem) const override;
virtual bool GetPresentation(SfxItemPresentation, MapUnit, MapUnit,
diff --git a/include/svx/algitem.hxx b/include/svx/algitem.hxx
index 450a349f0e53..d0245403360d 100644
--- a/include/svx/algitem.hxx
+++ b/include/svx/algitem.hxx
@@ -77,8 +77,6 @@ public:
MapUnit ePresMetric,
OUString &rText, const IntlWrapper& ) const override;
- virtual bool isHashable() const override;
- virtual size_t hashCode() const override;
virtual bool operator==( const SfxPoolItem& ) const override;
virtual SvxMarginItem* Clone( SfxItemPool *pPool = nullptr ) const override;
diff --git a/include/svx/chrtitem.hxx b/include/svx/chrtitem.hxx
index 9cff3a00a0e1..eb6d42fde640 100644
--- a/include/svx/chrtitem.hxx
+++ b/include/svx/chrtitem.hxx
@@ -142,8 +142,6 @@ public:
MapUnit ePresMetric,
OUString &rText, const IntlWrapper&) const override;
- virtual bool isHashable() const override;
- virtual size_t hashCode() const override;
virtual bool operator == (const SfxPoolItem&) const override;
virtual SvxDoubleItem* Clone(SfxItemPool *pPool = nullptr) const override;
diff --git a/include/svx/e3ditem.hxx b/include/svx/e3ditem.hxx
index 61f3dddd85c7..bad0e95c89f5 100644
--- a/include/svx/e3ditem.hxx
+++ b/include/svx/e3ditem.hxx
@@ -34,8 +34,6 @@ public:
SvxB3DVectorItem( const SvxB3DVectorItem& );
virtual ~SvxB3DVectorItem() override;
- virtual bool isHashable() const override;
- virtual size_t hashCode() const override;
virtual bool operator==( const SfxPoolItem& ) const override;
virtual SvxB3DVectorItem* Clone( SfxItemPool *pPool = nullptr ) const override;
diff --git a/include/svx/grfcrop.hxx b/include/svx/grfcrop.hxx
index b7e9f8dbd400..354ee8b16c44 100644
--- a/include/svx/grfcrop.hxx
+++ b/include/svx/grfcrop.hxx
@@ -43,8 +43,6 @@ public:
SvxGrfCrop & operator =(SvxGrfCrop &&) = delete; // due to SfxPoolItem
// "pure virtual methods" from SfxPoolItem
- virtual bool isHashable() const override;
- virtual size_t hashCode() const override;
virtual bool operator==( const SfxPoolItem& ) const override;
virtual bool GetPresentation( SfxItemPresentation ePres,
MapUnit eCoreMetric,
diff --git a/include/svx/postattr.hxx b/include/svx/postattr.hxx
index 22ede7dffc92..af980a3e5b9e 100644
--- a/include/svx/postattr.hxx
+++ b/include/svx/postattr.hxx
@@ -39,8 +39,6 @@ public:
OUString &rText, const IntlWrapper& ) const override;
virtual SvxPostItAuthorItem* Clone( SfxItemPool *pPool = nullptr ) const override;
-
- virtual bool isHashable() const override; // hashCode is defined in CntUnencodedStringItem
};
@@ -61,8 +59,6 @@ public:
OUString &rText, const IntlWrapper& ) const override;
virtual SvxPostItDateItem* Clone( SfxItemPool *pPool = nullptr ) const override;
-
- virtual bool isHashable() const override; // hashCode is defined in CntUnencodedStringItem
};
/** The text of a note
@@ -83,8 +79,6 @@ public:
OUString &rText, const IntlWrapper& ) const override;
virtual SvxPostItTextItem* Clone( SfxItemPool *pPool = nullptr ) const override;
-
- virtual bool isHashable() const override; // hashCode is defined in CntUnencodedStringItem
};
@@ -99,8 +93,6 @@ public:
SvxPostItIdItem( TypedWhichId<SvxPostItIdItem> nWhich );
virtual SvxPostItIdItem* Clone( SfxItemPool *pPool = nullptr ) const override;
-
- virtual bool isHashable() const override; // hashCode is defined in CntUnencodedStringItem
};
#endif
diff --git a/include/svx/sdasitm.hxx b/include/svx/sdasitm.hxx
index 6ec62db34e00..7821bbd2e0a8 100644
--- a/include/svx/sdasitm.hxx
+++ b/include/svx/sdasitm.hxx
@@ -69,8 +69,6 @@ private:
SdrCustomShapeGeometryItem & operator =(SdrCustomShapeGeometryItem const &) = delete; // due to SfxPoolItem
SdrCustomShapeGeometryItem & operator =(SdrCustomShapeGeometryItem &&) = delete; // due to SfxPoolItem
- virtual bool isHashable() const override;
- virtual size_t hashCode() const override;
SAL_DLLPRIVATE virtual bool operator==( const SfxPoolItem& ) const override;
SAL_DLLPRIVATE virtual bool GetPresentation(SfxItemPresentation ePresentation,
diff --git a/include/svx/svxgraphicitem.hxx b/include/svx/svxgraphicitem.hxx
index 47f8d1b59354..6d78b0980baa 100644
--- a/include/svx/svxgraphicitem.hxx
+++ b/include/svx/svxgraphicitem.hxx
@@ -31,8 +31,6 @@ class SVX_DLLPUBLIC SvxGraphicItem final : public SfxPoolItem
public:
SvxGraphicItem( Graphic aGraphic);
- virtual bool isHashable() const override;
- virtual size_t hashCode() const override;
virtual bool operator==( const SfxPoolItem& ) const override;
virtual SvxGraphicItem* Clone( SfxItemPool *pPool = nullptr ) const override;
diff --git a/svl/source/items/cenumitm.cxx b/svl/source/items/cenumitm.cxx
index 2ff149592fd0..e5e53e18d0b7 100644
--- a/svl/source/items/cenumitm.cxx
+++ b/svl/source/items/cenumitm.cxx
@@ -83,14 +83,83 @@ bool SfxEnumItemInterface::GetBoolValue() const
void SfxEnumItemInterface::SetBoolValue(bool)
{}
-bool SfxBoolItem::isHashable() const
+typedef std::unordered_map<sal_uInt16, std::pair<const SfxPoolItem*, const SfxPoolItem*>> SfxBoolItemMap;
+
+namespace
{
- return true;
+ class SfxBoolItemInstanceManager : public ItemInstanceManager
+ {
+ SfxBoolItemMap maRegistered;
+
+ public:
+ SfxBoolItemInstanceManager()
+ : ItemInstanceManager(typeid(SfxBoolItem).hash_code())
+ {
+ }
+
+ private:
+ // 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;
+ };
+
+ const SfxPoolItem* SfxBoolItemInstanceManager::find(const SfxPoolItem& rItem) const
+ {
+ SfxBoolItemMap::const_iterator aHit(maRegistered.find(rItem.Which()));
+ if (aHit == maRegistered.end())
+ return nullptr;
+
+ const SfxBoolItem& rSfxBoolItem(static_cast<const SfxBoolItem&>(rItem));
+ if (rSfxBoolItem.GetValue())
+ return aHit->second.first;
+ return aHit->second.second;
+ }
+
+ void SfxBoolItemInstanceManager::add(const SfxPoolItem& rItem)
+ {
+ SfxBoolItemMap::iterator aHit(maRegistered.find(rItem.Which()));
+ const SfxBoolItem& rSfxBoolItem(static_cast<const SfxBoolItem&>(rItem));
+
+ if (aHit == maRegistered.end())
+ {
+ if (rSfxBoolItem.GetValue())
+ maRegistered.insert({rItem.Which(), std::make_pair(&rItem, nullptr)});
+ else
+ maRegistered.insert({rItem.Which(), std::make_pair(nullptr, &rItem)});
+ }
+ else
+ {
+ if (rSfxBoolItem.GetValue())
+ aHit->second.first = &rItem;
+ else
+ aHit->second.second = &rItem;
+ }
+ }
+
+ void SfxBoolItemInstanceManager::remove(const SfxPoolItem& rItem)
+ {
+ SfxBoolItemMap::iterator aHit(maRegistered.find(rItem.Which()));
+ const SfxBoolItem& rSfxBoolItem(static_cast<const SfxBoolItem&>(rItem));
+
+ if (aHit != maRegistered.end())
+ {
+ if (rSfxBoolItem.GetValue())
+ aHit->second.first = nullptr;
+ else
+ aHit->second.second = nullptr;
+
+ if (aHit->second.first == nullptr && aHit->second.second == nullptr)
+ maRegistered.erase(aHit);
+ }
+ }
}
-size_t SfxBoolItem::hashCode() const
+ItemInstanceManager* SfxBoolItem::getItemInstanceManager() const
{
- return size_t(GetValue());
+ static SfxBoolItemInstanceManager aInstanceManager;
+ return &aInstanceManager;
}
void SfxBoolItem::SetValue(bool const bTheValue)
diff --git a/svl/source/items/custritm.cxx b/svl/source/items/custritm.cxx
index 4cd125f1b37f..e814662ec77c 100644
--- a/svl/source/items/custritm.cxx
+++ b/svl/source/items/custritm.cxx
@@ -23,12 +23,6 @@
#include <unotools/intlwrapper.hxx>
#include <svl/custritm.hxx>
-// not all of the subclasses are hashable, so we only define the shared hashcode function here
-size_t CntUnencodedStringItem::hashCode() const
-{
- return m_aValue.hashCode();
-}
-
// virtual
bool CntUnencodedStringItem::operator ==(const SfxPoolItem & rItem) const
{
@@ -58,7 +52,6 @@ bool CntUnencodedStringItem::QueryValue(css::uno::Any& rVal, sal_uInt8) const
bool CntUnencodedStringItem::PutValue(const css::uno::Any& rVal,
sal_uInt8)
{
- ASSERT_CHANGE_REFCOUNTED_ITEM;
OUString aTheValue;
if (rVal >>= aTheValue)
{
diff --git a/svl/source/items/globalnameitem.cxx b/svl/source/items/globalnameitem.cxx
index 311b5f4389fc..6cd1ece098ee 100644
--- a/svl/source/items/globalnameitem.cxx
+++ b/svl/source/items/globalnameitem.cxx
@@ -26,7 +26,6 @@
#include <comphelper/processfactory.hxx>
#include <svl/globalnameitem.hxx>
-#include <o3tl/hash_combine.hxx>
SfxPoolItem* SfxGlobalNameItem::CreateDefault() { return new SfxGlobalNameItem; }
@@ -47,20 +46,6 @@ SfxGlobalNameItem::~SfxGlobalNameItem()
{
}
-bool SfxGlobalNameItem::isHashable() const
-{
- return true;
-}
-
-size_t SfxGlobalNameItem::hashCode() const
-{
- std::size_t seed = 0;
- o3tl::hash_combine(seed, m_aName.GetCLSID().Data1);
- o3tl::hash_combine(seed, m_aName.GetCLSID().Data2);
- o3tl::hash_combine(seed, m_aName.GetCLSID().Data3);
- return seed;
-}
-
bool SfxGlobalNameItem::operator==( const SfxPoolItem& rItem ) const
{
return SfxPoolItem::operator==(rItem) &&
@@ -75,7 +60,6 @@ SfxGlobalNameItem* SfxGlobalNameItem::Clone(SfxItemPool *) const
// virtual
bool SfxGlobalNameItem::PutValue( const css::uno::Any& rVal, sal_uInt8 )
{
- ASSERT_CHANGE_REFCOUNTED_ITEM;
css::uno::Reference < css::script::XTypeConverter > xConverter
( css::script::Converter::create( ::comphelper::getProcessComponentContext() ));
css::uno::Sequence< sal_Int8 > aSeq;
diff --git a/svl/source/items/globalpool.cxx b/svl/source/items/globalpool.cxx
index d2de3b40bc16..ba16d3874429 100644
--- a/svl/source/items/globalpool.cxx
+++ b/svl/source/items/globalpool.cxx
@@ -19,15 +19,12 @@
#include <svl/itemset.hxx>
#include <svl/itempool.hxx>
-#include <svl/poolitem.hxx>
#include <svl/setitem.hxx>
#include <sal/log.hxx>
-#include <o3tl/sorted_vector.hxx>
-#include <unordered_map>
-#include <unordered_set>
-#include <memory>
-// Classes that implement global SfxPoolItem sharing.
+static bool g_bDisableItemInstanceManager(getenv("SVL_DISABLE_ITEM_INSTANCE_MANAGER"));
+static bool g_bShareImmediately(getenv("SVL_SHARE_ITEMS_GLOBALLY_INSTANTLY"));
+#define NUMBER_OF_UNSHARED_INSTANCES (50)
#ifdef DBG_UTIL
@@ -80,118 +77,173 @@ void listSfxPoolItemsWithHighestUsage(sal_uInt16 nNum)
#endif
-namespace
+void DefaultItemInstanceManager::add(const SfxPoolItem& rItem)
{
-// basic Interface definition
-struct ItemInstanceManager
+ maRegistered[rItem.Which()].insert(&rItem);
+}
+
+void DefaultItemInstanceManager::remove(const SfxPoolItem& rItem)
{
- virtual ~ItemInstanceManager() {}
- // standard interface, accessed exclusively
- // by implCreateItemEntry/implCleanupItemEntry
- virtual const SfxPoolItem* find(const SfxPoolItem&) const = 0;
- virtual bool add(const SfxPoolItem&) = 0;
- virtual void remove(const SfxPoolItem&) = 0;
-};
+ maRegistered[rItem.Which()].erase(&rItem);
+}
-// offering a default implementation that can be use for
-// each SfxPoolItem (except when !isShareable()). It just
-// uses an unordered_set holding ptrs to SfxPoolItems added
-// and SfxPoolItem::operator== to linearly search for one.
-// Thus this is not the fastest, but as fast as old 'poooled'
-// stuff - better use an intelligent, pro-Item implementation
-// that does e.g. hashing or whatever might be feasible for
-// that specific Item (see other derivations)
-struct DefaultItemInstanceManager : public ItemInstanceManager
+// Class that implements global Item sharing. It uses rtti to
+// associate every Item-derivation with a possible incarnation
+// of a DefaultItemInstanceManager. This is the default, it will
+// give direct implementations at the Items that overload
+// getItemInstanceManager() preference. These are expected to
+// return static instances of a derived implementation of a
+// ItemInstanceManager.
+// All in all there are now the following possibilities to support
+// this for individual Item derivations:
+// (1) Do nothing:
+// In that case, if the Item is shareable, the new mechanism
+// will kick in: It will start sharing the Item globally,
+// but not immediately: After a defined amount of allowed
+// non-shared occurrences (look for NUMBER_OF_UNSHARED_INSTANCES)
+// an instance of the default ItemInstanceManager, a
+// DefaultItemInstanceManager, will be incarnated and used.
+// NOTE: Mixing shared/unshared instances is not a problem (we
+// might even implement a kind of 're-hash' when this kicks in,
+// but is not really needed).
+// (2) Overload getItemInstanceManager for SfxPoolItem in a class
+// derived from SfxPoolItem and...
+// (2a) Return a static incarnation of DefaultItemInstanceManager to
+// immediately start global sharing of that Item derivation.
+// (2b) Implement and return your own implementation and static
+// incarnation of ItemInstanceManager to do something better/
+// faster that the default implementation can do. Example:
+// SvxFontItem, uses hashing now.
+// There are two supported ENVVARs to use:
+// (a) SVL_DISABLE_ITEM_INSTANCE_MANAGER:
+// This disables the mechanism of global Item sharing completely.
+// This can be used to test/check speed/memory needs compared with
+// using it, but also may come in handy to check if evtl. errors/
+// regressions have to do with it.
+// (b) SVL_SHARE_ITEMS_GLOBALLY_INSTANTLY:
+// This internally forces the NUMBER_OF_UNSHARED_INSTANCES to be
+// ignored and start sharing ALL Item derivations instantly.
+class InstanceManagerHelper
{
- // This workload is very read-heavy, and we want to scan the candidates often, so
- // a vector-based data structure is faster.
- o3tl::sorted_vector<const SfxPoolItem*> maRegistered;
+ typedef std::unordered_map<std::size_t, std::pair<sal_uInt16, DefaultItemInstanceManager*>>
+ managerTypeMap;
+ managerTypeMap maManagerPerType;
- virtual const SfxPoolItem* find(const SfxPoolItem& rItem) const override
- {
- for (const auto& rCandidate : maRegistered)
- if (*rCandidate == rItem)
- return rCandidate;
- return nullptr;
- }
- virtual bool add(const SfxPoolItem& rItem) override
- {
- return maRegistered.insert(&rItem).second;
- }
- virtual void remove(const SfxPoolItem& rItem) override
+public:
+ InstanceManagerHelper() {}
+ ~InstanceManagerHelper()
{
- bool bSuccess = maRegistered.erase(&rItem);
- assert(bSuccess && "removing item but it is already gone");
- (void)bSuccess;
+ for (auto& rCandidate : maManagerPerType)
+ if (nullptr != rCandidate.second.second)
+ delete rCandidate.second.second;
}
-};
-struct HashableItemInstanceManager : public ItemInstanceManager
-{
- struct ItemHash
- {
- size_t operator()(const SfxPoolItem* pItem) const { return pItem->hashCode(); }
- };
- struct ItemEqual
+ ItemInstanceManager* getOrCreateItemInstanceManager(const SfxPoolItem& rItem)
{
- bool operator()(const SfxPoolItem* lhs, const SfxPoolItem* rhs) const
- {
- return *lhs == *rhs;
- }
- };
- std::unordered_set<const SfxPoolItem*, ItemHash, ItemEqual> maRegistered;
+ // deactivated?
+ if (g_bDisableItemInstanceManager)
+ return nullptr;
- virtual const SfxPoolItem* find(const SfxPoolItem& rItem) const override
- {
- auto it = maRegistered.find(&rItem);
- if (it == maRegistered.end())
+ // Item cannot be shared?
+ if (!rItem.isShareable())
return nullptr;
- return *it;
- }
- virtual bool add(const SfxPoolItem& rItem) override
- {
- return maRegistered.insert(&rItem).second;
- }
- virtual void remove(const SfxPoolItem& rItem) override
- {
- auto it = maRegistered.find(&rItem);
- if (it != maRegistered.end())
+
+ // Prefer getting an ItemInstanceManager directly from
+ // the Item: These are the extra implemented (and thus
+ // hopefully fastest) incarnations
+ ItemInstanceManager* pManager(rItem.getItemInstanceManager());
+
+ // Check for correct hash, there may be derivations of that class.
+ // Note that Managers from the Items are *not* added to local list,
+ // they are expected to be static instances at the Items
+ const std::size_t aHash(typeid(rItem).hash_code());
+ if (nullptr != pManager && pManager->getClassHash() == aHash)
+ return pManager;
+
+ // check local memory for existing entry
+ managerTypeMap::iterator aHit(maManagerPerType.find(aHash));
+
+ // no instance yet
+ if (aHit == maManagerPerType.end())
{
- if (&rItem != *it)
+ // create a default one to start usage-counting
+ if (g_bShareImmediately)
{
- SAL_WARN("svl", "erasing wrong object, hash/operator== methods likely bad "
- << typeid(rItem).name());
- assert(false && "erasing wrong object, hash/operator== methods likely bad");
+ // create, insert locally and immediately start sharing
+ DefaultItemInstanceManager* pNew(new DefaultItemInstanceManager(aHash));
+ maManagerPerType.insert({ aHash, std::make_pair(0, pNew) });
+ return pNew;
}
- maRegistered.erase(it);
+
+ // start countdown from NUMBER_OF_UNSHARED_INSTANCES until zero is reached
+ maManagerPerType.insert(
+ { aHash, std::make_pair(NUMBER_OF_UNSHARED_INSTANCES, nullptr) });
+ return nullptr;
}
- else
+
+ // if there is already an ItemInstanceManager incarnated, return it
+ if (nullptr != aHit->second.second)
+ return aHit->second.second;
+
+ if (aHit->second.first > 0)
{
- SAL_WARN("svl",
- "removing item but its already gone, hash/operator== methods likely bad "
- << typeid(rItem).name());
- assert(false
- && "removing item but its already gone, hash/operator== methods likely bad");
+ // still not the needed number of hits, countdown & return nullptr
+ aHit->second.first--;
+ return nullptr;
}
+
+ // here the countdown is zero and there is not yet a ItemInstanceManager
+ // incarnated. Do so, register and return it
+ assert(nullptr == aHit->second.second);
+ DefaultItemInstanceManager* pNew(new DefaultItemInstanceManager(aHash));
+ aHit->second.second = pNew;
+
+ return pNew;
}
-};
-struct PairHash
-{
- size_t operator()(const std::pair<SfxItemType, sal_uInt16>& rKey) const
+ ItemInstanceManager* getExistingItemInstanceManager(const SfxPoolItem& rItem)
{
- return (static_cast<unsigned int>(rKey.first) << 16) | rKey.second;
+ // deactivated?
+ if (g_bDisableItemInstanceManager)
+ return nullptr;
+
+ // Item cannot be shared?
+ if (!rItem.isShareable())
+ return nullptr;
+
+ // Prefer getting an ItemInstanceManager directly from
+ // the Item: These are the extra implemented (and thus
+ // hopefully fastest) incarnations
+ ItemInstanceManager* pManager(rItem.getItemInstanceManager());
+
+ // Check for correct hash, there may be derivations of that class.
+ // Note that Managers from the Items are *not* added to local list,
+ // they are expected to be static instances at the Items
+ const std::size_t aHash(typeid(rItem).hash_code());
+ if (nullptr != pManager && pManager->getClassHash() == aHash)
+ return pManager;
+
+ // check local memory for existing entry
+ managerTypeMap::iterator aHit(maManagerPerType.find(aHash));
+
+ if (aHit == maManagerPerType.end())
+ // no instance yet, return nullptr
+ return nullptr;
+
+ // if there is already a ItemInstanceManager incarnated, return it
+ if (nullptr != aHit->second.second)
+ return aHit->second.second;
+
+ // count-up needed number of hits again if item is released
+ if (aHit->second.first < NUMBER_OF_UNSHARED_INSTANCES)
+ aHit->second.first++;
+
+ return nullptr;
}
};
-}
-// The single static instance that takes over that global Item sharing
-// Maps SfxItemPool sub-classes to a set of shared items.
-//
-// Noting that the WhichId is part of the key, to simply the implementation of the hashCode() overrides
-// in SfxPoolItem sub-classes.
-static std::unordered_map<std::pair<SfxItemType, sal_uInt16>, std::unique_ptr<ItemInstanceManager>,
- PairHash>
- gInstanceManagerMap;
+
+// the single static instance that takes over that global Item sharing
+static InstanceManagerHelper aInstanceManagerHelper;
SfxPoolItem const* implCreateItemEntry(SfxItemPool& rPool, SfxPoolItem const* pSource,
bool bPassingOwnership)
@@ -274,38 +326,30 @@ SfxPoolItem const* implCreateItemEntry(SfxItemPool& rPool, SfxPoolItem const* pS
return pSource;
}
- // Item cannot be shared?
- SfxItemType nSourceItemType(pSource->ItemType());
- if (pSource->isShareable())
+ // try to get an ItemInstanceManager for global Item instance sharing
+ ItemInstanceManager* pManager(aInstanceManagerHelper.getOrCreateItemInstanceManager(*pSource));
+
+ // check if we can globally share the Item using an ItemInstanceManager
+ while (nullptr != pManager)
{
- // check if we can globally share the Item using the ItemInstanceManager
- auto itemsetIt = gInstanceManagerMap.find({ nSourceItemType, pSource->Which() });
- if (itemsetIt != gInstanceManagerMap.end())
- {
- ItemInstanceManager& rItemManager = *(itemsetIt->second);
- const SfxPoolItem* pAlternative = rItemManager.find(*pSource);
- if (pAlternative)
- {
- SAL_WARN_IF(typeid(*pAlternative) != typeid(*pSource), "svl",
- "wrong item from pool, expected " << typeid(*pSource).name()
- << " but got "
- << typeid(*pAlternative).name());
- assert(typeid(*pAlternative) == typeid(*pSource) && "wrong item from pool");
- // Here we do *not* need to check if it is an SfxSetItem
- // and cannot be shared if they are in/use another pool:
- // The SfxItemSet::operator== will check for SfxItemPools
- // being equal, thus when found in global share the Pool
- // cannot be equal
-
- // need to delete evtl. handed over ownership change Item
- if (bPassingOwnership)
- delete pSource;
-
- // If we get here we can share the Item
- pAlternative->AddRef();
- return pAlternative;
- }
- }
+ const SfxPoolItem* pAlternative(pManager->find(*pSource));
+ if (nullptr == pAlternative)
+ // no already globally shared one found, done
+ break;
+
+ // Here we do *not* need to check if it is an SfxSetItem
+ // and cannot be shared if they are in/use another pool:
+ // The SfxItemSet::operator== will check for SfxItemPools
+ // being equal, thus when found in global share the Pool
+ // cannot be equal
+
+ // need to delete evtl. handed over ownership change Item
+ if (bPassingOwnership)
+ delete pSource;
+
+ // If we get here we can share the Item
+ pAlternative->AddRef();
+ return pAlternative;
}
// check if the handed over and to be directly used item is a
@@ -348,30 +392,8 @@ SfxPoolItem const* implCreateItemEntry(SfxItemPool& rPool, SfxPoolItem const* pS
// check if we should register this Item for the global
// ItemInstanceManager mechanism (only for shareable Items)
- if (pSource->isShareable())
- {
- ItemInstanceManager* pManager;
- std::pair<SfxItemType, sal_uInt16> aManagerKey{ nSourceItemType, pSource->Which() };
- auto it1 = gInstanceManagerMap.find(aManagerKey);
- if (it1 != gInstanceManagerMap.end())
- pManager = it1->second.get();
- else
- {
- if (pSource->isHashable())
- gInstanceManagerMap.insert(
- { aManagerKey, std::make_unique<HashableItemInstanceManager>() });
- else
- gInstanceManagerMap.insert(
- { aManagerKey, std::make_unique<DefaultItemInstanceManager>() });
- it1 = gInstanceManagerMap.find(aManagerKey);
- assert(it1 != gInstanceManagerMap.end());
- pManager = it1->second.get();
- }
-
- bool bSuccess = pManager->add(*pSource);
- assert(bSuccess && "failed to add item to pool");
- (void)bSuccess;
- }
+ if (nullptr != pManager)
+ pManager->add(*pSource);
return pSource;
}
@@ -417,14 +439,13 @@ void implCleanupItemEntry(const SfxPoolItem* pSource)
return;
}
+ // try to get an ItemInstanceManager for global Item instance sharing
+ ItemInstanceManager* pManager(aInstanceManagerHelper.getExistingItemInstanceManager(*pSource));
+
// check if we should/can remove this Item from the global
// ItemInstanceManager mechanism
- auto itemsetIt = gInstanceManagerMap.find({ pSource->ItemType(), pSource->Which() });
- if (itemsetIt != gInstanceManagerMap.end())
- {
- auto& rInstanceManager = *(itemsetIt->second);
- rInstanceManager.remove(*pSource);
- }
+ if (nullptr != pManager)
+ pManager->remove(*pSource);
// decrease RefCnt before deleting (destructor asserts for it and that's
// good to find other errors)
diff --git a/svl/source/items/grabbagitem.cxx b/svl/source/items/grabbagitem.cxx
index d16dc097296a..89c0c0336903 100644
--- a/svl/source/items/grabbagitem.cxx
+++ b/svl/source/items/grabbagitem.cxx
@@ -13,8 +13,6 @@
#include <sal/log.hxx>
#include <com/sun/star/beans/PropertyValue.hpp>
#include <com/sun/star/uno/Sequence.hxx>
-#include <comphelper/anytohash.hxx>
-#include <o3tl/hash_combine.hxx>
using namespace com::sun::star;
@@ -30,20 +28,6 @@ SfxGrabBagItem::SfxGrabBagItem(sal_uInt16 nWhich)
SfxGrabBagItem::~SfxGrabBagItem() = default;
-bool SfxGrabBagItem::isHashable() const { return true; }
-
-size_t SfxGrabBagItem::hashCode() const
-{
- std::size_t seed = 0;
- for (const auto& pair : m_aMap)
- {
- o3tl::hash_combine(seed, pair.first);
- if (auto oVal = comphelper::anyToHash(pair.second))
- o3tl::hash_combine(seed, *oVal);
- }
- return seed;
-}
-
bool SfxGrabBagItem::operator==(const SfxPoolItem& rItem) const
{
return SfxPoolItem::operator==(rItem)
@@ -57,7 +41,6 @@ SfxGrabBagItem* SfxGrabBagItem::Clone(SfxItemPool* /*pPool*/) const
bool SfxGrabBagItem::PutValue(const uno::Any& rVal, sal_uInt8 /*nMemberId*/)
{
- ASSERT_CHANGE_REFCOUNTED_ITEM;
uno::Sequence<beans::PropertyValue> aValue;
if (rVal >>= aValue)
{
diff --git a/svl/source/items/ilstitem.cxx b/svl/source/items/ilstitem.cxx
index 90a9c3686d80..adbc324c46ee 100644
--- a/svl/source/items/ilstitem.cxx
+++ b/svl/source/items/ilstitem.cxx
@@ -23,7 +23,6 @@
#include <comphelper/sequence.hxx>
#include <svl/ilstitem.hxx>
-#include <o3tl/hash_combine.hxx>
SfxPoolItem* SfxIntegerListItem::CreateDefault() { return new SfxIntegerListItem; }
@@ -49,19 +48,6 @@ SfxIntegerListItem::~SfxIntegerListItem()
{
}
-bool SfxIntegerListItem::isHashable() const
-{
- return true;
-}
-
-size_t SfxIntegerListItem::hashCode() const
-{
- std::size_t seed = 0;
- for (auto const & i : m_aList)
- o3tl::hash_combine(seed, i);
- return seed;
-}
-
bool SfxIntegerListItem::operator==( const SfxPoolItem& rPoolItem ) const
{
if ( !SfxPoolItem::operator==(rPoolItem) )
@@ -78,7 +64,6 @@ SfxIntegerListItem* SfxIntegerListItem::Clone( SfxItemPool * ) const
bool SfxIntegerListItem::PutValue ( const css::uno::Any& rVal, sal_uInt8 )
{
- ASSERT_CHANGE_REFCOUNTED_ITEM;
css::uno::Reference < css::script::XTypeConverter > xConverter
( css::script::Converter::create(::comphelper::getProcessComponentContext()) );
css::uno::Any aNew;
diff --git a/svl/source/items/imageitm.cxx b/svl/source/items/imageitm.cxx
index 4b5ee5eccc32..7020054d6889 100644
--- a/svl/source/items/imageitm.cxx
+++ b/svl/source/items/imageitm.cxx
@@ -20,7 +20,6 @@
#include <svl/imageitm.hxx>
#include <com/sun/star/uno/Sequence.hxx>
-#include <o3tl/hash_combine.hxx>
SfxPoolItem* SfxImageItem::CreateDefault() { return new SfxImageItem; }
@@ -45,20 +44,6 @@ SfxImageItem* SfxImageItem::Clone( SfxItemPool* ) const
return new SfxImageItem( *this );
}
-bool SfxImageItem::isHashable() const
-{
- return true;
-}
-
-size_t SfxImageItem::hashCode() const
-{
- std::size_t seed = 0;
- o3tl::hash_combine(seed, GetValue());
- o3tl::hash_combine(seed, mnAngle.get());
- o3tl::hash_combine(seed, mbMirrored);
- return seed;
-}
-
bool SfxImageItem::operator==( const SfxPoolItem& rItem ) const
{
if (!SfxInt16Item::operator==(rItem))
@@ -79,7 +64,6 @@ bool SfxImageItem::QueryValue( css::uno::Any& rVal, sal_uInt8 ) const
bool SfxImageItem::PutValue( const css::uno::Any& rVal, sal_uInt8 )
{
- ASSERT_CHANGE_REFCOUNTED_ITEM;
css::uno::Sequence< css::uno::Any > aSeq;
if (( rVal >>= aSeq ) && ( aSeq.getLength() == 4 ))
{
diff --git a/svl/source/items/poolitem.cxx b/svl/source/items/poolitem.cxx
index ebc2d08636a9..709d7aa64a83 100644
--- a/svl/source/items/poolitem.cxx
+++ b/svl/source/items/poolitem.cxx
@@ -501,14 +501,20 @@ void listAllocatedSfxPoolItems()
}
#endif
-bool SfxPoolItem::isHashable() const { return false; }
-
-size_t SfxPoolItem::hashCode() const
+const SfxPoolItem* DefaultItemInstanceManager::find(const SfxPoolItem& rItem) const
{
- assert(false && "not implemented");
- return 0;
+ auto it = maRegistered.find(rItem.Which());
+ if (it == maRegistered.end())
+ return nullptr;
+ for (const auto& rCandidate : it->second)
+ if (*rCandidate == rItem)
+ return rCandidate;
+
+ return nullptr;
}
+ItemInstanceManager* SfxPoolItem::getItemInstanceManager() const { return nullptr; }
+
SfxPoolItem::SfxPoolItem(sal_uInt16 const nWhich, SfxItemType eType)
: m_nRefCount(0)
, m_nWhich(nWhich)
diff --git a/svl/source/items/ptitem.cxx b/svl/source/items/ptitem.cxx
index 120786b4b047..71ac1205b682 100644
--- a/svl/source/items/ptitem.cxx
+++ b/svl/source/items/ptitem.cxx
@@ -27,7 +27,6 @@
#include <svl/poolitem.hxx>
#include <svl/memberid.h>
-#include <o3tl/hash_combine.hxx>
using namespace ::com::sun::star;
@@ -62,19 +61,6 @@ bool SfxPointItem::GetPresentation
}
-bool SfxPointItem::isHashable() const
-{
- return true;
-}
-
-size_t SfxPointItem::hashCode() const
-{
- std::size_t seed = 0;
- o3tl::hash_combine(seed, aVal.X());
- o3tl::hash_combine(seed, aVal.Y());
- return seed;
-}
-
bool SfxPointItem::operator==( const SfxPoolItem& rItem ) const
{
assert(SfxPoolItem::operator==(rItem));
@@ -112,7 +98,6 @@ bool SfxPointItem::QueryValue( uno::Any& rVal,
bool SfxPointItem::PutValue( const uno::Any& rVal,
sal_uInt8 nMemberId )
{
- ASSERT_CHANGE_REFCOUNTED_ITEM;
bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
nMemberId &= ~CONVERT_TWIPS;
bool bRet = false;
diff --git a/svl/source/items/rectitem.cxx b/svl/source/items/rectitem.cxx
index c2c4774d7920..cd9eecdf672a 100644
--- a/svl/source/items/rectitem.cxx
+++ b/svl/source/items/rectitem.cxx
@@ -25,7 +25,6 @@
#include <svl/poolitem.hxx>
#include <svl/memberid.h>
-#include <o3tl/hash_combine.hxx>
SfxPoolItem* SfxRectangleItem::CreateDefault() { return new SfxRectangleItem; }
@@ -61,21 +60,6 @@ bool SfxRectangleItem::GetPresentation
}
-bool SfxRectangleItem::isHashable() const
-{
- return true;
-}
-
-size_t SfxRectangleItem::hashCode() const
-{
- std::size_t seed = 0;
- o3tl::hash_combine(seed, maVal.Top());
- o3tl::hash_combine(seed, maVal.Left());
- o3tl::hash_combine(seed, maVal.Bottom());
- o3tl::hash_combine(seed, maVal.Right());
- return seed;
-}
-
bool SfxRectangleItem::operator==( const SfxPoolItem& rItem ) const
{
assert(SfxPoolItem::operator==(rItem));
@@ -115,7 +99,6 @@ bool SfxRectangleItem::QueryValue( css::uno::Any& rVal,
bool SfxRectangleItem::PutValue( const css::uno::Any& rVal,
sal_uInt8 nMemberId )
{
- ASSERT_CHANGE_REFCOUNTED_ITEM;
bool bRet = false;
nMemberId &= ~CONVERT_TWIPS;
css::awt::Rectangle aValue;
diff --git a/svx/inc/sxlayitm.hxx b/svx/inc/sxlayitm.hxx
index e2d753ba9be6..6891f5f4c345 100644
--- a/svx/inc/sxlayitm.hxx
+++ b/svx/inc/sxlayitm.hxx
@@ -39,7 +39,6 @@ public:
SdrLayerNameItem(const OUString& rStr)
: SfxStringItem(SDRATTR_LAYERNAME, rStr, SfxItemType::SdrLayerNameItemType) {}
virtual SdrLayerNameItem* Clone(SfxItemPool* pPool=nullptr) const override;
- virtual bool isHashable() const override; // hashCode is defined in CntUnencodedStringItem
};
#endif
diff --git a/svx/inc/sxmfsitm.hxx b/svx/inc/sxmfsitm.hxx
index 70b126cfa0fe..f3d6f0facf9d 100644
--- a/svx/inc/sxmfsitm.hxx
+++ b/svx/inc/sxmfsitm.hxx
@@ -31,10 +31,6 @@ public:
{
return new SdrMeasureFormatStringItem(*this);
}
- virtual bool isHashable() const override // hashCode is defined in CntUnencodedStringItem
- {
- return true;
- }
};
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/dialog/svxgraphicitem.cxx b/svx/source/dialog/svxgraphicitem.cxx
index d0ef1111ab08..eb5458c3284e 100644
--- a/svx/source/dialog/svxgraphicitem.cxx
+++ b/svx/source/dialog/svxgraphicitem.cxx
@@ -27,16 +27,6 @@ SvxGraphicItem::SvxGraphicItem( Graphic _aGraphic )
}
-bool SvxGraphicItem::isHashable() const
-{
- return true;
-}
-
-size_t SvxGraphicItem::hashCode() const
-{
- return aGraphic.GetChecksum();
-}
-
bool SvxGraphicItem::operator==( const SfxPoolItem& rItem) const
{
return SfxPoolItem::operator==(rItem) && static_cast<const SvxGraphicItem&>(rItem).aGraphic == aGraphic;
diff --git a/svx/source/items/algitem.cxx b/svx/source/items/algitem.cxx
index 6343b878b687..afcfc2c724f8 100644
--- a/svx/source/items/algitem.cxx
+++ b/svx/source/items/algitem.cxx
@@ -217,21 +217,6 @@ bool SvxMarginItem::GetPresentation
}
-bool SvxMarginItem::isHashable() const
-{
- return true;
-}
-
-size_t SvxMarginItem::hashCode() const
-{
- std::size_t seed = 0;
- o3tl::hash_combine(seed, nLeftMargin);
- o3tl::hash_combine(seed, nTopMargin);
- o3tl::hash_combine(seed, nRightMargin);
- o3tl::hash_combine(seed, nBottomMargin);
- return seed;
-}
-
bool SvxMarginItem::operator==( const SfxPoolItem& rItem ) const
{
assert(SfxPoolItem::operator==(rItem));
diff --git a/svx/source/items/chrtitem.cxx b/svx/source/items/chrtitem.cxx
index 253d4f259aec..11a299cfab01 100644
--- a/svx/source/items/chrtitem.cxx
+++ b/svx/source/items/chrtitem.cxx
@@ -120,18 +120,6 @@ bool SvxDoubleItem::GetPresentation
return true;
}
-bool SvxDoubleItem::isHashable() const
-{
- return true;
-}
-
-size_t SvxDoubleItem::hashCode() const
-{
- std::size_t seed = 0;
- o3tl::hash_combine(seed, fVal);
- return seed;
-}
-
bool SvxDoubleItem::operator == (const SfxPoolItem& rItem) const
{
assert(SfxPoolItem::operator==(rItem));
diff --git a/svx/source/items/customshapeitem.cxx b/svx/source/items/customshapeitem.cxx
index 4479296227ae..be40036d3445 100644
--- a/svx/source/items/customshapeitem.cxx
+++ b/svx/source/items/customshapeitem.cxx
@@ -226,17 +226,6 @@ SdrCustomShapeGeometryItem::~SdrCustomShapeGeometryItem()
{
}
-bool SdrCustomShapeGeometryItem::isHashable() const
-{
- return true;
-}
-
-size_t SdrCustomShapeGeometryItem::hashCode() const
-{
- UpdateHash();
- return m_aHashState == HashState::Valid ? m_aHash : 0;
-}
-
bool SdrCustomShapeGeometryItem::operator==( const SfxPoolItem& rCmp ) const
{
if( !SfxPoolItem::operator==( rCmp ))
diff --git a/svx/source/items/e3ditem.cxx b/svx/source/items/e3ditem.cxx
index 7e947a7670e7..05a2ff8bcb2c 100644
--- a/svx/source/items/e3ditem.cxx
+++ b/svx/source/items/e3ditem.cxx
@@ -43,20 +43,6 @@ SvxB3DVectorItem::SvxB3DVectorItem( const SvxB3DVectorItem& rItem ) :
{
}
-bool SvxB3DVectorItem::isHashable() const
-{
- return true;
-}
-
-size_t SvxB3DVectorItem::hashCode() const
-{
- std::size_t seed = 0;
- o3tl::hash_combine(seed, aVal.getX());
- o3tl::hash_combine(seed, aVal.getY());
- o3tl::hash_combine(seed, aVal.getZ());
- return seed;
-}
-
bool SvxB3DVectorItem::operator==( const SfxPoolItem &rItem ) const
{
assert(SfxPoolItem::operator==(rItem));
diff --git a/svx/source/items/grfitem.cxx b/svx/source/items/grfitem.cxx
index 8a8510aad8d4..b87f021a6f5f 100644
--- a/svx/source/items/grfitem.cxx
+++ b/svx/source/items/grfitem.cxx
@@ -42,21 +42,6 @@ SvxGrfCrop::~SvxGrfCrop()
{
}
-bool SvxGrfCrop::isHashable() const
-{
- return true;
-}
-
-size_t SvxGrfCrop::hashCode() const
-{
- std::size_t seed = 0;
- o3tl::hash_combine(seed, m_nLeft);
- o3tl::hash_combine(seed, m_nRight);
- o3tl::hash_combine(seed, m_nTop);
- o3tl::hash_combine(seed, m_nBottom);
- return seed;
-}
-
bool SvxGrfCrop::operator==( const SfxPoolItem& rAttr ) const
{
assert(SfxPoolItem::operator==(rAttr));
diff --git a/svx/source/items/postattr.cxx b/svx/source/items/postattr.cxx
index f04541bf67e2..09c3f606c03b 100644
--- a/svx/source/items/postattr.cxx
+++ b/svx/source/items/postattr.cxx
@@ -65,12 +65,6 @@ SvxPostItAuthorItem* SvxPostItAuthorItem::Clone( SfxItemPool * ) const
return new SvxPostItAuthorItem( *this );
}
-// hashCode is defined in CntUnencodedStringItem
-bool SvxPostItAuthorItem::isHashable() const
-{
- return true;
-}
-
SvxPostItDateItem::SvxPostItDateItem( TypedWhichId<SvxPostItDateItem> _nWhich )
: SfxStringItem(_nWhich, SfxItemType::SvxPostItDateItemType)
{
@@ -110,12 +104,6 @@ SvxPostItDateItem* SvxPostItDateItem::Clone( SfxItemPool * ) const
return new SvxPostItDateItem( *this );
}
-// hashCode is defined in CntUnencodedStringItem
-bool SvxPostItDateItem::isHashable() const
-{
- return true;
-}
-
SvxPostItTextItem::SvxPostItTextItem( TypedWhichId<SvxPostItTextItem> _nWhich )
{
SetWhich( _nWhich );
@@ -153,12 +141,6 @@ SvxPostItTextItem* SvxPostItTextItem::Clone( SfxItemPool * ) const
return new SvxPostItTextItem( *this );
}
-// hashCode is defined in CntUnencodedStringItem
-bool SvxPostItTextItem::isHashable() const
-{
- return true;
-}
-
SvxPostItIdItem::SvxPostItIdItem( TypedWhichId<SvxPostItIdItem> _nWhich )
{
SetWhich( _nWhich );
@@ -169,10 +151,4 @@ SvxPostItIdItem* SvxPostItIdItem::Clone( SfxItemPool * ) const
return new SvxPostItIdItem( *this );
}
-// hashCode is defined in CntUnencodedStringItem
-bool SvxPostItIdItem::isHashable() const
-{
- return true;
-}
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/svdraw/svdattr.cxx b/svx/source/svdraw/svdattr.cxx
index 93fbfe261fcf..cb6c197dfcd4 100644
--- a/svx/source/svdraw/svdattr.cxx
+++ b/svx/source/svdraw/svdattr.cxx
@@ -2171,10 +2171,4 @@ SdrLayerNameItem* SdrLayerNameItem::Clone(SfxItemPool* /*pPool*/) const
return new SdrLayerNameItem(*this);
}
-// hashCode is defined in CntUnencodedStringItem
-bool SdrLayerNameItem::isHashable() const
-{
- return true;
-}
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/inc/fmtfsize.hxx b/sw/inc/fmtfsize.hxx
index fae54e25729b..4607d2c83579 100644
--- a/sw/inc/fmtfsize.hxx
+++ b/sw/inc/fmtfsize.hxx
@@ -112,8 +112,8 @@ public:
void dumpAsXml(xmlTextWriterPtr pWriter) const override;
- virtual bool isHashable() const override;
- virtual size_t hashCode() const override;
+protected:
+ virtual ItemInstanceManager* getItemInstanceManager() const override;
};
inline const SwFormatFrameSize &SwAttrSet::GetFrameSize(bool bInP) const
diff --git a/sw/inc/fmtornt.hxx b/sw/inc/fmtornt.hxx
index 238bd2def862..9e4ef933c97e 100644
--- a/sw/inc/fmtornt.hxx
+++ b/sw/inc/fmtornt.hxx
@@ -67,8 +67,8 @@ public:
void dumpAsXml(xmlTextWriterPtr pWriter) const override;
- virtual bool isHashable() const override;
- virtual size_t hashCode() const override;
+protected:
+ virtual ItemInstanceManager* getItemInstanceManager() const override;
};
/// Defines the horizontal position of a fly frame.
@@ -110,8 +110,8 @@ public:
void dumpAsXml(xmlTextWriterPtr pWriter) const override;
- virtual bool isHashable() const override;
- virtual size_t hashCode() const override;
+protected:
+ virtual ItemInstanceManager* getItemInstanceManager() const override;
};
inline const SwFormatVertOrient &SwAttrSet::GetVertOrient(bool bInP) const
diff --git a/sw/inc/paratr.hxx b/sw/inc/paratr.hxx
index dfe9be3afe70..3a8fd5d03674 100644
--- a/sw/inc/paratr.hxx
+++ b/sw/inc/paratr.hxx
@@ -164,7 +164,6 @@ public:
SwNumRuleItem(SwNumRuleItem const &) = default; // SfxPoolItem copy function dichotomy
/// "pure virtual methods" of SfxPoolItem
- virtual bool isHashable() const override; // hashCode is defined in CntUnencodedStringItem
virtual bool operator==( const SfxPoolItem& ) const override;
virtual SwNumRuleItem* Clone( SfxItemPool *pPool = nullptr ) const override;
virtual bool GetPresentation( SfxItemPresentation ePres,
diff --git a/sw/source/core/layout/atrfrm.cxx b/sw/source/core/layout/atrfrm.cxx
index 9598c8febaa4..878e155ce4ce 100644
--- a/sw/source/core/layout/atrfrm.cxx
+++ b/sw/source/core/layout/atrfrm.cxx
@@ -216,23 +216,32 @@ static void lcl_DelHFFormat( SwClient *pToRemove, SwFrameFormat *pFormat )
delete pFormat;
}
-bool SwFormatFrameSize::isHashable() const
+namespace
{
- return true;
+ class SwFormatFrameSizeInstanceManager : public TypeSpecificItemInstanceManager<SwFormatFrameSize>
+ {
+ protected:
+ virtual size_t hashCode(const SfxPoolItem& rItem) const override
+ {
+ auto const & rFormatItem = static_cast<const SwFormatFrameSize&>(rItem);
+ std::size_t seed(0);
+ o3tl::hash_combine(seed, rFormatItem.GetHeightSizeType());
+ o3tl::hash_combine(seed, rFormatItem.GetWidthSizeType());
+ o3tl::hash_combine(seed, rFormatItem.GetWidthPercent());
+ o3tl::hash_combine(seed, rFormatItem.GetWidthPercentRelation());
+ o3tl::hash_combine(seed, rFormatItem.GetHeightPercent());
+ o3tl::hash_combine(seed, rFormatItem.GetHeightPercentRelation());
+ o3tl::hash_combine(seed, rFormatItem.GetSize().Width());
+ o3tl::hash_combine(seed, rFormatItem.GetSize().Height());
+ return seed;
+ }
+ };
}
-size_t SwFormatFrameSize::hashCode() const
+ItemInstanceManager* SwFormatFrameSize::getItemInstanceManager() const
{
- std::size_t seed(0);
- o3tl::hash_combine(seed, GetHeightSizeType());
- o3tl::hash_combine(seed, GetWidthSizeType());
- o3tl::hash_combine(seed, GetWidthPercent());
- o3tl::hash_combine(seed, GetWidthPercentRelation());
- o3tl::hash_combine(seed, GetHeightPercent());
- o3tl::hash_combine(seed, GetHeightPercentRelation());
- o3tl::hash_combine(seed, GetSize().Width());
- o3tl::hash_combine(seed, GetSize().Height());
- return seed;
+ static SwFormatFrameSizeInstanceManager aInstanceManager;
+ return &aInstanceManager;
}
void SwFormatFrameSize::ScaleMetrics(tools::Long lMult, tools::Long lDiv) {
@@ -332,7 +341,6 @@ bool SwFormatFrameSize::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
bool SwFormatFrameSize::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
{
- ASSERT_CHANGE_REFCOUNTED_ITEM;
bool bConvert = 0 != (nMemberId&CONVERT_TWIPS);
nMemberId &= ~CONVERT_TWIPS;
bool bRet = true;
@@ -1395,18 +1403,27 @@ void SwFormatSurround::dumpAsXml(xmlTextWriterPtr pWriter) const
(void)xmlTextWriterEndElement(pWriter);
}
-bool SwFormatVertOrient::isHashable() const
+namespace
{
- return true;
+ class SwFormatVertOrientInstanceManager : public TypeSpecificItemInstanceManager<SwFormatVertOrient>
+ {
+ protected:
+ virtual size_t hashCode(const SfxPoolItem& rItem) const override
+ {
+ auto const & rFormatItem = static_cast<const SwFormatVertOrient&>(rItem);
+ std::size_t seed(0);
+ o3tl::hash_combine(seed, rFormatItem.GetPos());
+ o3tl::hash_combine(seed, rFormatItem.GetVertOrient());
+ o3tl::hash_combine(seed, rFormatItem.GetRelationOrient());
+ return seed;
+ }
+ };
}
-size_t SwFormatVertOrient::hashCode() const
+ItemInstanceManager* SwFormatVertOrient::getItemInstanceManager() const
{
- std::size_t seed(0);
- o3tl::hash_combine(seed, GetPos());
- o3tl::hash_combine(seed, GetVertOrient());
- o3tl::hash_combine(seed, GetRelationOrient());
- return seed;
+ static SwFormatVertOrientInstanceManager aInstanceManager;
+ return &aInstanceManager;
}
// Partially implemented inline in hxx
@@ -1501,19 +1518,28 @@ void SwFormatVertOrient::dumpAsXml(xmlTextWriterPtr pWriter) const
(void)xmlTextWriterEndElement(pWriter);
}
-bool SwFormatHoriOrient::isHashable() const
+namespace
{
- return true;
+ class SwFormatHoriOrientInstanceManager : public TypeSpecificItemInstanceManager<SwFormatHoriOrient>
+ {
+ protected:
+ virtual size_t hashCode(const SfxPoolItem& rItem) const override
+ {
+ auto const & rFormatItem = static_cast<const SwFormatHoriOrient&>(rItem);
+ std::size_t seed(0);
+ o3tl::hash_combine(seed, rFormatItem.GetPos());
+ o3tl::hash_combine(seed, rFormatItem.GetHoriOrient());
+ o3tl::hash_combine(seed, rFormatItem.GetRelationOrient());
+ o3tl::hash_combine(seed, rFormatItem.IsPosToggle());
+ return seed;
+ }
+ };
}
-size_t SwFormatHoriOrient::hashCode() const
+ItemInstanceManager* SwFormatHoriOrient::getItemInstanceManager() const
{
- std::size_t seed(0);
- o3tl::hash_combine(seed, GetPos());
- o3tl::hash_combine(seed, GetHoriOrient());
- o3tl::hash_combine(seed, GetRelationOrient());
- o3tl::hash_combine(seed, IsPosToggle());
- return seed;
+ static SwFormatHoriOrientInstanceManager aInstanceManager;
+ return &aInstanceManager;
}
// Partially implemented inline in hxx
@@ -1570,7 +1596,6 @@ bool SwFormatHoriOrient::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
bool SwFormatHoriOrient::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
{
- ASSERT_CHANGE_REFCOUNTED_ITEM;
bool bConvert = 0 != (nMemberId&CONVERT_TWIPS);
nMemberId &= ~CONVERT_TWIPS;
bool bRet = true;
diff --git a/sw/source/core/para/paratr.cxx b/sw/source/core/para/paratr.cxx
index 98e80499e44d..0cffb932c57e 100644
--- a/sw/source/core/para/paratr.cxx
+++ b/sw/source/core/para/paratr.cxx
@@ -185,12 +185,6 @@ SwNumRuleItem* SwNumRuleItem::Clone( SfxItemPool * ) const
return new SwNumRuleItem( *this );
}
-// hashCode is defined in CntUnencodedStringItem
-bool SwNumRuleItem::isHashable() const
-{
- return true;
-}
-
bool SwNumRuleItem::operator==( const SfxPoolItem& rAttr ) const
{
assert(SfxPoolItem::operator==(rAttr));