summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--editeng/source/items/frmitems.cxx184
-rw-r--r--editeng/source/items/paraitem.cxx7
-rw-r--r--editeng/source/items/textitem.cxx147
-rw-r--r--include/editeng/adjustitem.hxx3
-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/crossedoutitem.hxx3
-rw-r--r--include/editeng/emphasismarkitem.hxx3
-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/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--svl/source/items/cenumitm.cxx77
-rw-r--r--svl/source/items/custritm.cxx1
-rw-r--r--svl/source/items/globalnameitem.cxx16
-rw-r--r--svl/source/items/globalpool.cxx325
-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--sw/inc/fmtfsize.hxx4
-rw-r--r--sw/inc/fmtornt.hxx8
-rw-r--r--sw/source/core/layout/atrfrm.cxx89
49 files changed, 584 insertions, 648 deletions
diff --git a/editeng/source/items/frmitems.cxx b/editeng/source/items/frmitems.cxx
index 0d39a8c4d9ad..c6470a8f120e 100644
--- a/editeng/source/items/frmitems.cxx
+++ b/editeng/source/items/frmitems.cxx
@@ -173,6 +173,7 @@ 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;
@@ -228,6 +229,19 @@ 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));
@@ -607,6 +621,7 @@ 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;
@@ -643,6 +658,19 @@ 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));
@@ -784,6 +812,7 @@ 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;
@@ -820,6 +849,19 @@ 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));
@@ -955,6 +997,7 @@ 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;
@@ -995,6 +1038,20 @@ 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));
@@ -1139,6 +1196,7 @@ 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;
@@ -1175,6 +1233,19 @@ 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));
@@ -1300,6 +1371,7 @@ 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;
@@ -1323,6 +1395,18 @@ 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));
@@ -1410,6 +1494,7 @@ 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;
@@ -1429,6 +1514,18 @@ 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));
@@ -1489,6 +1586,28 @@ 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));
@@ -1713,6 +1832,7 @@ 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;
@@ -1773,6 +1893,22 @@ 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));
@@ -1943,6 +2079,20 @@ 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));
@@ -1975,6 +2125,7 @@ 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)
@@ -2143,6 +2294,20 @@ 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));
@@ -2358,7 +2523,6 @@ static bool CompareBorderLine(const std::unique_ptr<SvxBorderLine> & pBrd1, cons
return *pBrd1 == *pBrd2;
}
-
bool SvxBoxItem::operator==( const SfxPoolItem& rAttr ) const
{
assert(SfxPoolItem::operator==(rAttr));
@@ -3263,12 +3427,6 @@ 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)
@@ -3983,12 +4141,6 @@ 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)
@@ -4600,12 +4752,6 @@ 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 a63f73c25335..5cfedf113620 100644
--- a/editeng/source/items/paraitem.cxx
+++ b/editeng/source/items/paraitem.cxx
@@ -50,6 +50,7 @@
#include <editeng/memberids.h>
#include <editeng/itemtype.hxx>
#include <editeng/eerdll.hxx>
+#include <o3tl/hash_combine.hxx>
using namespace ::com::sun::star;
@@ -339,12 +340,6 @@ 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 )
diff --git a/editeng/source/items/textitem.cxx b/editeng/source/items/textitem.cxx
index 638948e747de..9801f594d519 100644
--- a/editeng/source/items/textitem.cxx
+++ b/editeng/source/items/textitem.cxx
@@ -159,30 +159,21 @@ bool SvxFontListItem::GetPresentation
// class SvxFontItem -----------------------------------------------------
-namespace
+bool SvxFontItem::isHashable() const
{
- 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;
- }
- };
+ return true;
}
-ItemInstanceManager* SvxFontItem::getItemInstanceManager() const
+size_t SvxFontItem::hashCode() const
{
- static SvxFontItemInstanceManager aInstanceManager;
- return &aInstanceManager;
+ 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;
}
SvxFontItem::SvxFontItem(
@@ -243,6 +234,7 @@ 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)
{
@@ -409,28 +401,6 @@ 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 )
{
@@ -495,6 +465,7 @@ 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 )
{
@@ -547,12 +518,6 @@ 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 )
{
@@ -677,28 +642,18 @@ void SvxWeightItem::dumpAsXml(xmlTextWriterPtr pWriter) const
// class SvxFontHeightItem -----------------------------------------------
-namespace
+bool SvxFontHeightItem::isHashable() const
{
- 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;
- }
- };
+ return true;
}
-ItemInstanceManager* SvxFontHeightItem::getItemInstanceManager() const
+size_t SvxFontHeightItem::hashCode() const
{
- static SvxFontHeightItemInstanceManager aInstanceManager;
- return &aInstanceManager;
+ std::size_t seed(0);
+ o3tl::hash_combine(seed, GetHeight());
+ o3tl::hash_combine(seed, GetProp());
+ o3tl::hash_combine(seed, GetPropUnit());
+ return seed;
}
SvxFontHeightItem::SvxFontHeightItem( const sal_uInt32 nSz,
@@ -862,6 +817,7 @@ 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 )
@@ -1194,12 +1150,6 @@ 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 )
{
@@ -1241,12 +1191,6 @@ 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 )
{
@@ -1288,12 +1232,6 @@ 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 )
{
@@ -2090,12 +2028,6 @@ 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 )
{
@@ -2238,12 +2170,6 @@ 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 )
@@ -2678,12 +2604,6 @@ 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 )
@@ -2967,28 +2887,6 @@ 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();
@@ -2997,6 +2895,7 @@ 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 c660598abfc7..4a6324893820 100644
--- a/include/editeng/adjustitem.hxx
+++ b/include/editeng/adjustitem.hxx
@@ -44,9 +44,6 @@ class EDITENG_DLLPUBLIC SvxAdjustItem final : public SfxEnumItemInterface
bool bLastCenter : 1;
bool bLastBlock : 1;
-protected:
- virtual ItemInstanceManager* getItemInstanceManager() const override;
-
public:
static SfxPoolItem* CreateDefault();
diff --git a/include/editeng/boxitem.hxx b/include/editeng/boxitem.hxx
index 49f18d6de4b4..0d9ee80281ef 100644
--- a/include/editeng/boxitem.hxx
+++ b/include/editeng/boxitem.hxx
@@ -73,9 +73,6 @@ 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 6897e319a3b6..8412634a1157 100644
--- a/include/editeng/brushitem.hxx
+++ b/include/editeng/brushitem.hxx
@@ -54,9 +54,6 @@ 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 910adcf11e24..78b57fa7df00 100644
--- a/include/editeng/charreliefitem.hxx
+++ b/include/editeng/charreliefitem.hxx
@@ -33,9 +33,6 @@
class EDITENG_DLLPUBLIC SvxCharReliefItem final : public SfxEnumItem<FontRelief>
{
-protected:
- virtual ItemInstanceManager* getItemInstanceManager() const override;
-
public:
static SfxPoolItem* CreateDefault();
diff --git a/include/editeng/crossedoutitem.hxx b/include/editeng/crossedoutitem.hxx
index 259eb412e1e1..5d8b18fe2650 100644
--- a/include/editeng/crossedoutitem.hxx
+++ b/include/editeng/crossedoutitem.hxx
@@ -31,9 +31,6 @@
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 94d48e4b8d9c..e0fd74cf4400 100644
--- a/include/editeng/emphasismarkitem.hxx
+++ b/include/editeng/emphasismarkitem.hxx
@@ -32,9 +32,6 @@
class EDITENG_DLLPUBLIC SvxEmphasisMarkItem final : public SfxUInt16Item
{
-protected:
- virtual ItemInstanceManager* getItemInstanceManager() const override;
-
public:
static SfxPoolItem* CreateDefault();
diff --git a/include/editeng/fhgtitem.hxx b/include/editeng/fhgtitem.hxx
index bdde8c6f0afd..342419e4e359 100644
--- a/include/editeng/fhgtitem.hxx
+++ b/include/editeng/fhgtitem.hxx
@@ -44,9 +44,6 @@ 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();
@@ -54,6 +51,8 @@ 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 f892178c521e..82d19ca40490 100644
--- a/include/editeng/fontitem.hxx
+++ b/include/editeng/fontitem.hxx
@@ -34,9 +34,6 @@ class EDITENG_DLLPUBLIC SvxFontItem final : public SfxPoolItem
FontPitch ePitch;
rtl_TextEncoding eTextEncoding;
-protected:
- virtual ItemInstanceManager* getItemInstanceManager() const override;
-
public:
static SfxPoolItem* CreateDefault();
@@ -48,6 +45,8 @@ 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 e2bba96b8974..7bb6dc09950d 100644
--- a/include/editeng/frmdiritem.hxx
+++ b/include/editeng/frmdiritem.hxx
@@ -30,9 +30,6 @@
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 4ebef0837a6c..c84aebf3b33c 100644
--- a/include/editeng/langitem.hxx
+++ b/include/editeng/langitem.hxx
@@ -40,9 +40,6 @@ 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 edab3ef23d73..998ea71fbb84 100644
--- a/include/editeng/lrspitem.hxx
+++ b/include/editeng/lrspitem.hxx
@@ -68,6 +68,8 @@ 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;
@@ -110,6 +112,8 @@ 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;
@@ -145,17 +149,19 @@ public:
void SetTextFirstLineOffset(const short nF, const sal_uInt16 nProp = 100);
short GetTextFirstLineOffset() const { return m_nFirstLineOffset; }
void SetPropTextFirstLineOffset(const sal_uInt16 nProp)
- { m_nPropFirstLineOffset = nProp; }
+ { ASSERT_CHANGE_REFCOUNTED_ITEM; m_nPropFirstLineOffset = nProp; }
sal_uInt16 GetPropTextFirstLineOffset() const
{ return m_nPropFirstLineOffset; }
void SetTextFirstLineOffsetValue(const short nValue)
- { m_nFirstLineOffset = nValue; }
+ { ASSERT_CHANGE_REFCOUNTED_ITEM; 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;
@@ -195,6 +201,8 @@ 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;
@@ -221,13 +229,15 @@ private:
tools::Long m_nGutterMargin = 0;
public:
- void SetGutterMargin(const tools::Long nGutterMargin) { m_nGutterMargin = nGutterMargin; }
+ void SetGutterMargin(const tools::Long nGutterMargin) { ASSERT_CHANGE_REFCOUNTED_ITEM; 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;
@@ -260,6 +270,8 @@ 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;
@@ -305,6 +317,8 @@ 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;
@@ -326,15 +340,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(nFirstLineOffset == 0); nLeftMargin = nL; }
- void SetRightValue( const tools::Long nR ) { nRightMargin = nR; }
+ 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; }
bool IsAutoFirst() const { return bAutoFirst; }
- void SetAutoFirst( const bool bNew ) { bAutoFirst = bNew; }
+ void SetAutoFirst( const bool bNew ) { ASSERT_CHANGE_REFCOUNTED_ITEM; bAutoFirst = bNew; }
bool IsExplicitZeroMarginValRight() const { return bExplicitZeroMarginValRight; }
bool IsExplicitZeroMarginValLeft() const { return bExplicitZeroMarginValLeft; }
- void SetExplicitZeroMarginValRight( const bool eR ) { bExplicitZeroMarginValRight = eR; }
- void SetExplicitZeroMarginValLeft( const bool eL ) { bExplicitZeroMarginValLeft = eL; }
+ void SetExplicitZeroMarginValRight( const bool eR ) { ASSERT_CHANGE_REFCOUNTED_ITEM; bExplicitZeroMarginValRight = eR; }
+ void SetExplicitZeroMarginValLeft( const bool eL ) { ASSERT_CHANGE_REFCOUNTED_ITEM; bExplicitZeroMarginValLeft = eL; }
sal_uInt16 GetPropLeft() const { return nPropLeftMargin; }
sal_uInt16 GetPropRight() const { return nPropRightMargin;}
@@ -345,14 +359,14 @@ public:
void SetTextFirstLineOffset(const short nF, const sal_uInt16 nProp = 100);
short GetTextFirstLineOffset() const { return nFirstLineOffset; }
void SetPropTextFirstLineOffset( const sal_uInt16 nProp )
- { nPropFirstLineOffset = nProp; }
+ { ASSERT_CHANGE_REFCOUNTED_ITEM; nPropFirstLineOffset = nProp; }
sal_uInt16 GetPropTextFirstLineOffset() const
{ return nPropFirstLineOffset; }
void SetTextFirstLineOffsetValue( const short nValue )
- { nFirstLineOffset = nValue; }
- void SetGutterMargin(const tools::Long nGutterMargin) { m_nGutterMargin = nGutterMargin; }
+ { ASSERT_CHANGE_REFCOUNTED_ITEM; nFirstLineOffset = nValue; }
+ void SetGutterMargin(const tools::Long nGutterMargin) { ASSERT_CHANGE_REFCOUNTED_ITEM; m_nGutterMargin = nGutterMargin; }
tools::Long GetGutterMargin() const { return m_nGutterMargin; }
- void SetRightGutterMargin(const tools::Long nRightGutterMargin) { m_nRightGutterMargin = nRightGutterMargin; }
+ void SetRightGutterMargin(const tools::Long nRightGutterMargin) { ASSERT_CHANGE_REFCOUNTED_ITEM; 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 392a9627feb6..93ed44b6b794 100644
--- a/include/editeng/postitem.hxx
+++ b/include/editeng/postitem.hxx
@@ -32,9 +32,6 @@
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 0c3b473700d1..18ad76fcf3ac 100644
--- a/include/editeng/protitem.hxx
+++ b/include/editeng/protitem.hxx
@@ -43,6 +43,8 @@ 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,
@@ -56,9 +58,9 @@ public:
bool IsContentProtected() const { return bCntnt; }
bool IsSizeProtected() const { return bSize; }
bool IsPosProtected() const { return bPos; }
- void SetContentProtect( bool bNew ) { bCntnt = bNew; }
- void SetSizeProtect ( bool bNew ) { bSize = bNew; }
- void SetPosProtect ( bool bNew ) { bPos = bNew; }
+ 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; }
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 64b4c1cc2b1f..24213c3fa697 100644
--- a/include/editeng/rsiditem.hxx
+++ b/include/editeng/rsiditem.hxx
@@ -33,8 +33,6 @@ 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 bed848215985..9d15e5ea56e5 100644
--- a/include/editeng/shaditem.hxx
+++ b/include/editeng/shaditem.hxx
@@ -48,6 +48,8 @@ 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;
@@ -62,13 +64,13 @@ public:
virtual bool HasMetrics() const override;
const Color& GetColor() const { return aShadowColor;}
- void SetColor( const Color &rNew ) { aShadowColor = rNew; }
+ void SetColor( const Color &rNew ) { ASSERT_CHANGE_REFCOUNTED_ITEM; aShadowColor = rNew; }
sal_uInt16 GetWidth() const { return nWidth; }
SvxShadowLocation GetLocation() const { return eLocation; }
- void SetWidth( sal_uInt16 nNew ) { nWidth = nNew; }
- void SetLocation( SvxShadowLocation eNew ) { eLocation = eNew; }
+ void SetWidth( sal_uInt16 nNew ) { ASSERT_CHANGE_REFCOUNTED_ITEM; nWidth = nNew; }
+ void SetLocation( SvxShadowLocation eNew ) { ASSERT_CHANGE_REFCOUNTED_ITEM; 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 4e20699f1cef..841846b30235 100644
--- a/include/editeng/sizeitem.hxx
+++ b/include/editeng/sizeitem.hxx
@@ -42,6 +42,8 @@ public:
SvxSizeItem( const sal_uInt16 nId, const Size& rSize);
// "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 b140c47b8bc5..b4f3107b5c7f 100644
--- a/include/editeng/udlnitem.hxx
+++ b/include/editeng/udlnitem.hxx
@@ -87,9 +87,6 @@ public:
class EDITENG_DLLPUBLIC SvxUnderlineItem final : public SvxTextLineItem
{
-protected:
- virtual ItemInstanceManager* getItemInstanceManager() const override;
-
public:
static SfxPoolItem* CreateDefault();
@@ -106,9 +103,6 @@ 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 b0131ab9904d..5c26ce2eb6a8 100644
--- a/include/editeng/ulspitem.hxx
+++ b/include/editeng/ulspitem.hxx
@@ -46,6 +46,8 @@ 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;
@@ -63,11 +65,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 ) { 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; }
+ 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; }
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 f8beb7c7a62f..121cfcf318a6 100644
--- a/include/editeng/wghtitem.hxx
+++ b/include/editeng/wghtitem.hxx
@@ -32,9 +32,6 @@
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 d9c0f273f260..c10be9ccb8f9 100644
--- a/include/svl/cintitem.hxx
+++ b/include/svl/cintitem.hxx
@@ -33,6 +33,8 @@ 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,
@@ -64,6 +66,8 @@ 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,
@@ -96,6 +100,8 @@ 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,
@@ -128,6 +134,8 @@ 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/eitem.hxx b/include/svl/eitem.hxx
index f6fb22bfeb7d..141e292ceaad 100644
--- a/include/svl/eitem.hxx
+++ b/include/svl/eitem.hxx
@@ -62,6 +62,16 @@ 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
@@ -69,9 +79,6 @@ class SVL_DLLPUBLIC SfxBoolItem
{
bool m_bValue;
-protected:
- virtual ItemInstanceManager* getItemInstanceManager() const override;
-
public:
static SfxPoolItem* CreateDefault();
@@ -81,6 +88,9 @@ 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 ac32bab18ca9..f9967af78b9c 100644
--- a/include/svl/flagitem.hxx
+++ b/include/svl/flagitem.hxx
@@ -36,6 +36,8 @@ 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 edbb56273232..36824d3a39e4 100644
--- a/include/svl/globalnameitem.hxx
+++ b/include/svl/globalnameitem.hxx
@@ -39,6 +39,8 @@ 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 77a619aec4c1..d14bde539620 100644
--- a/include/svl/grabbagitem.hxx
+++ b/include/svl/grabbagitem.hxx
@@ -33,8 +33,14 @@ public:
const std::map<OUString, css::uno::Any>& GetGrabBag() const { return m_aMap; }
- std::map<OUString, css::uno::Any>& GetGrabBag() { 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;
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 bb49d18c9dbb..53f2a6204b64 100644
--- a/include/svl/ilstitem.hxx
+++ b/include/svl/ilstitem.hxx
@@ -44,6 +44,8 @@ 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 f06eb7fd6902..d5c871ed8c4c 100644
--- a/include/svl/imageitm.hxx
+++ b/include/svl/imageitm.hxx
@@ -34,13 +34,15 @@ 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 ) { mnAngle = nValue; }
+ void SetRotation( Degree10 nValue ) { ASSERT_CHANGE_REFCOUNTED_ITEM; mnAngle = nValue; }
Degree10 GetRotation() const { return mnAngle; }
- void SetMirrored( bool bSet ) { mbMirrored = bSet; }
+ void SetMirrored( bool bSet ) { ASSERT_CHANGE_REFCOUNTED_ITEM; mbMirrored = bSet; }
bool IsMirrored() const { return mbMirrored; }
private:
diff --git a/include/svl/int64item.hxx b/include/svl/int64item.hxx
index 70a502c645a8..0dd33e0a735c 100644
--- a/include/svl/int64item.hxx
+++ b/include/svl/int64item.hxx
@@ -27,6 +27,8 @@ 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 0fff3142cdc6..12ad37e85340 100644
--- a/include/svl/intitem.hxx
+++ b/include/svl/intitem.hxx
@@ -50,6 +50,8 @@ 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 b1fc8280736c..0d0c4771d429 100644
--- a/include/svl/poolitem.hxx
+++ b/include/svl/poolitem.hxx
@@ -422,7 +422,6 @@ SVL_DLLPUBLIC void listAllocatedSfxPoolItems();
class SfxItemPool;
class SfxItemSet;
typedef struct _xmlTextWriter* xmlTextWriterPtr;
-class ItemInstanceManager;
class SVL_DLLPUBLIC SfxPoolItem
{
@@ -479,15 +478,6 @@ 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
{
@@ -600,100 +590,14 @@ public:
virtual void dumpAsXml(xmlTextWriterPtr pWriter) const;
virtual boost::property_tree::ptree dumpAsJSON() 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;
+ // Only return true from isHashable() if hashCode is implemented.
+ virtual bool isHashable() const;
+ virtual size_t hashCode() const;
private:
- std::unordered_map<size_t, const SfxPoolItem*> maRegistered;
+ SfxPoolItem& operator=( const SfxPoolItem& ) = delete;
};
-
inline bool IsStaticDefaultItem(const SfxPoolItem *pItem )
{
return pItem && pItem->isStaticDefault();
diff --git a/include/svl/ptitem.hxx b/include/svl/ptitem.hxx
index 90db98bbc869..66a47fd992e1 100644
--- a/include/svl/ptitem.hxx
+++ b/include/svl/ptitem.hxx
@@ -41,6 +41,8 @@ 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 26c2acd37b65..ff7dce5fb3aa 100644
--- a/include/svl/rectitem.hxx
+++ b/include/svl/rectitem.hxx
@@ -40,6 +40,8 @@ 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 8e41184749b1..bb606b7149af 100644
--- a/include/svl/rngitem.hxx
+++ b/include/svl/rngitem.hxx
@@ -34,6 +34,8 @@ 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 8a458bbf2f6c..04d76365cda8 100644
--- a/include/svl/visitem.hxx
+++ b/include/svl/visitem.hxx
@@ -36,6 +36,8 @@ 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/svl/source/items/cenumitm.cxx b/svl/source/items/cenumitm.cxx
index e5e53e18d0b7..2ff149592fd0 100644
--- a/svl/source/items/cenumitm.cxx
+++ b/svl/source/items/cenumitm.cxx
@@ -83,83 +83,14 @@ bool SfxEnumItemInterface::GetBoolValue() const
void SfxEnumItemInterface::SetBoolValue(bool)
{}
-typedef std::unordered_map<sal_uInt16, std::pair<const SfxPoolItem*, const SfxPoolItem*>> SfxBoolItemMap;
-
-namespace
+bool SfxBoolItem::isHashable() const
{
- 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);
- }
- }
+ return true;
}
-ItemInstanceManager* SfxBoolItem::getItemInstanceManager() const
+size_t SfxBoolItem::hashCode() const
{
- static SfxBoolItemInstanceManager aInstanceManager;
- return &aInstanceManager;
+ return size_t(GetValue());
}
void SfxBoolItem::SetValue(bool const bTheValue)
diff --git a/svl/source/items/custritm.cxx b/svl/source/items/custritm.cxx
index 0d68b6d4559f..9f4df1892094 100644
--- a/svl/source/items/custritm.cxx
+++ b/svl/source/items/custritm.cxx
@@ -53,6 +53,7 @@ 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 6cd1ece098ee..311b5f4389fc 100644
--- a/svl/source/items/globalnameitem.cxx
+++ b/svl/source/items/globalnameitem.cxx
@@ -26,6 +26,7 @@
#include <comphelper/processfactory.hxx>
#include <svl/globalnameitem.hxx>
+#include <o3tl/hash_combine.hxx>
SfxPoolItem* SfxGlobalNameItem::CreateDefault() { return new SfxGlobalNameItem; }
@@ -46,6 +47,20 @@ 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) &&
@@ -60,6 +75,7 @@ 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 66bc650a2791..94a14ba846af 100644
--- a/svl/source/items/globalpool.cxx
+++ b/svl/source/items/globalpool.cxx
@@ -19,12 +19,14 @@
#include <svl/itemset.hxx>
#include <svl/itempool.hxx>
+#include <svl/poolitem.hxx>
#include <svl/setitem.hxx>
#include <sal/log.hxx>
+#include <unordered_map>
+#include <unordered_set>
+#include <memory>
-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)
+// Classes that implement global SfxPoolItem sharing.
#ifdef DBG_UTIL
@@ -77,173 +79,116 @@ void listSfxPoolItemsWithHighestUsage(sal_uInt16 nNum)
#endif
-void DefaultItemInstanceManager::add(const SfxPoolItem& rItem)
+namespace
{
- maRegistered[rItem.Which()].insert(&rItem);
-}
-
-void DefaultItemInstanceManager::remove(const SfxPoolItem& rItem)
+// basic Interface definition
+struct ItemInstanceManager
{
- maRegistered[rItem.Which()].erase(&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;
+};
-// 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
+// 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
{
- typedef std::unordered_map<std::size_t, std::pair<sal_uInt16, DefaultItemInstanceManager*>>
- managerTypeMap;
- managerTypeMap maManagerPerType;
+ std::unordered_set<const SfxPoolItem*> maRegistered;
-public:
- InstanceManagerHelper() {}
- ~InstanceManagerHelper()
+ 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
{
- for (auto& rCandidate : maManagerPerType)
- if (nullptr != rCandidate.second.second)
- delete rCandidate.second.second;
+ bool bSuccess = maRegistered.erase(&rItem);
+ assert(bSuccess && "removing item but it is already gone");
+ (void)bSuccess;
}
+};
- ItemInstanceManager* getOrCreateItemInstanceManager(const SfxPoolItem& rItem)
+struct HashableItemInstanceManager : public ItemInstanceManager
+{
+ struct ItemHash
{
- // deactivated?
- if (g_bDisableItemInstanceManager)
- return nullptr;
+ size_t operator()(const SfxPoolItem* pItem) const { return pItem->hashCode(); }
+ };
+ struct ItemEqual
+ {
+ bool operator()(const SfxPoolItem* lhs, const SfxPoolItem* rhs) const
+ {
+ return *lhs == *rhs;
+ }
+ };
+ std::unordered_set<const SfxPoolItem*, ItemHash, ItemEqual> maRegistered;
- // Item cannot be shared?
- if (!rItem.isShareable())
+ virtual const SfxPoolItem* find(const SfxPoolItem& rItem) const override
+ {
+ auto it = maRegistered.find(&rItem);
+ if (it == maRegistered.end())
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));
-
- // no instance yet
- if (aHit == maManagerPerType.end())
+ 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())
{
- // create a default one to start usage-counting
- if (g_bShareImmediately)
+ if (&rItem != *it)
{
- // create, insert locally and immediately start sharing
- DefaultItemInstanceManager* pNew(new DefaultItemInstanceManager(aHash));
- maManagerPerType.insert({ aHash, std::make_pair(0, pNew) });
- return pNew;
+ SAL_WARN("svl", "erasing wrong object, hash/operator== methods likely bad "
+ << typeid(rItem).name());
+ assert(false && "erasing wrong object, hash/operator== methods likely bad");
}
-
- // start countdown from NUMBER_OF_UNSHARED_INSTANCES until zero is reached
- maManagerPerType.insert(
- { aHash, std::make_pair(NUMBER_OF_UNSHARED_INSTANCES, nullptr) });
- return nullptr;
+ maRegistered.erase(it);
}
-
- // if there is already an ItemInstanceManager incarnated, return it
- if (nullptr != aHit->second.second)
- return aHit->second.second;
-
- if (aHit->second.first > 0)
+ else
{
- // still not the needed number of hits, countdown & return nullptr
- aHit->second.first--;
- return nullptr;
+ 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");
}
-
- // 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;
}
+};
- ItemInstanceManager* getExistingItemInstanceManager(const SfxPoolItem& rItem)
+struct PairHash
+{
+ size_t operator()(const std::pair<SfxItemType, sal_uInt16>& rKey) const
{
- // 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;
+ return (static_cast<int>(rKey.first) << 16) | rKey.second;
}
};
-
-// the single static instance that takes over that global Item sharing
-static InstanceManagerHelper aInstanceManagerHelper;
+}
+// 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() overides
+// in SfxPoolItem sub-classes.
+static std::unordered_map<std::pair<SfxItemType, sal_uInt16>, std::unique_ptr<ItemInstanceManager>,
+ PairHash>
+ gInstanceManagerMap;
SfxPoolItem const* implCreateItemEntry(SfxItemPool& rPool, SfxPoolItem const* pSource,
bool bPassingOwnership)
@@ -326,30 +271,33 @@ SfxPoolItem const* implCreateItemEntry(SfxItemPool& rPool, SfxPoolItem const* pS
return pSource;
}
- // 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)
+ // Item cannot be shared?
+ SfxItemType nSourceItemType(pSource->ItemType());
+ if (pSource->isShareable())
{
- 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 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)
+ {
+ // 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
@@ -387,8 +335,28 @@ 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 (nullptr != pManager)
- pManager->add(*pSource);
+ 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>() });
+ pManager = gInstanceManagerMap.find(aManagerKey)->second.get();
+ }
+
+ bool bSuccess = pManager->add(*pSource);
+ assert(bSuccess && "failed to add item to pool");
+ (void)bSuccess;
+ }
return pSource;
}
@@ -434,13 +402,14 @@ 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
- if (nullptr != pManager)
- pManager->remove(*pSource);
+ auto itemsetIt = gInstanceManagerMap.find({ pSource->ItemType(), pSource->Which() });
+ if (itemsetIt != gInstanceManagerMap.end())
+ {
+ auto& rInstanceManager = *(itemsetIt->second);
+ rInstanceManager.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 89c0c0336903..d16dc097296a 100644
--- a/svl/source/items/grabbagitem.cxx
+++ b/svl/source/items/grabbagitem.cxx
@@ -13,6 +13,8 @@
#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;
@@ -28,6 +30,20 @@ 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)
@@ -41,6 +57,7 @@ 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 adbc324c46ee..90a9c3686d80 100644
--- a/svl/source/items/ilstitem.cxx
+++ b/svl/source/items/ilstitem.cxx
@@ -23,6 +23,7 @@
#include <comphelper/sequence.hxx>
#include <svl/ilstitem.hxx>
+#include <o3tl/hash_combine.hxx>
SfxPoolItem* SfxIntegerListItem::CreateDefault() { return new SfxIntegerListItem; }
@@ -48,6 +49,19 @@ 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) )
@@ -64,6 +78,7 @@ 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 7020054d6889..4b5ee5eccc32 100644
--- a/svl/source/items/imageitm.cxx
+++ b/svl/source/items/imageitm.cxx
@@ -20,6 +20,7 @@
#include <svl/imageitm.hxx>
#include <com/sun/star/uno/Sequence.hxx>
+#include <o3tl/hash_combine.hxx>
SfxPoolItem* SfxImageItem::CreateDefault() { return new SfxImageItem; }
@@ -44,6 +45,20 @@ 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))
@@ -64,6 +79,7 @@ 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 709d7aa64a83..ebc2d08636a9 100644
--- a/svl/source/items/poolitem.cxx
+++ b/svl/source/items/poolitem.cxx
@@ -501,20 +501,14 @@ void listAllocatedSfxPoolItems()
}
#endif
-const SfxPoolItem* DefaultItemInstanceManager::find(const SfxPoolItem& rItem) const
+bool SfxPoolItem::isHashable() const { return false; }
+
+size_t SfxPoolItem::hashCode() const
{
- 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;
+ assert(false && "not implemented");
+ return 0;
}
-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 71ac1205b682..120786b4b047 100644
--- a/svl/source/items/ptitem.cxx
+++ b/svl/source/items/ptitem.cxx
@@ -27,6 +27,7 @@
#include <svl/poolitem.hxx>
#include <svl/memberid.h>
+#include <o3tl/hash_combine.hxx>
using namespace ::com::sun::star;
@@ -61,6 +62,19 @@ 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));
@@ -98,6 +112,7 @@ 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 cd9eecdf672a..c2c4774d7920 100644
--- a/svl/source/items/rectitem.cxx
+++ b/svl/source/items/rectitem.cxx
@@ -25,6 +25,7 @@
#include <svl/poolitem.hxx>
#include <svl/memberid.h>
+#include <o3tl/hash_combine.hxx>
SfxPoolItem* SfxRectangleItem::CreateDefault() { return new SfxRectangleItem; }
@@ -60,6 +61,21 @@ 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));
@@ -99,6 +115,7 @@ 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/sw/inc/fmtfsize.hxx b/sw/inc/fmtfsize.hxx
index 4607d2c83579..fae54e25729b 100644
--- a/sw/inc/fmtfsize.hxx
+++ b/sw/inc/fmtfsize.hxx
@@ -112,8 +112,8 @@ public:
void dumpAsXml(xmlTextWriterPtr pWriter) const override;
-protected:
- virtual ItemInstanceManager* getItemInstanceManager() const override;
+ virtual bool isHashable() const override;
+ virtual size_t hashCode() const override;
};
inline const SwFormatFrameSize &SwAttrSet::GetFrameSize(bool bInP) const
diff --git a/sw/inc/fmtornt.hxx b/sw/inc/fmtornt.hxx
index 9e4ef933c97e..238bd2def862 100644
--- a/sw/inc/fmtornt.hxx
+++ b/sw/inc/fmtornt.hxx
@@ -67,8 +67,8 @@ public:
void dumpAsXml(xmlTextWriterPtr pWriter) const override;
-protected:
- virtual ItemInstanceManager* getItemInstanceManager() const override;
+ virtual bool isHashable() const override;
+ virtual size_t hashCode() const override;
};
/// Defines the horizontal position of a fly frame.
@@ -110,8 +110,8 @@ public:
void dumpAsXml(xmlTextWriterPtr pWriter) const override;
-protected:
- virtual ItemInstanceManager* getItemInstanceManager() const override;
+ virtual bool isHashable() const override;
+ virtual size_t hashCode() const override;
};
inline const SwFormatVertOrient &SwAttrSet::GetVertOrient(bool bInP) const
diff --git a/sw/source/core/layout/atrfrm.cxx b/sw/source/core/layout/atrfrm.cxx
index 8c44f2ac893b..2c620c7127df 100644
--- a/sw/source/core/layout/atrfrm.cxx
+++ b/sw/source/core/layout/atrfrm.cxx
@@ -216,32 +216,23 @@ static void lcl_DelHFFormat( SwClient *pToRemove, SwFrameFormat *pFormat )
delete pFormat;
}
-namespace
+bool SwFormatFrameSize::isHashable() const
{
- 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;
- }
- };
+ return true;
}
-ItemInstanceManager* SwFormatFrameSize::getItemInstanceManager() const
+size_t SwFormatFrameSize::hashCode() const
{
- static SwFormatFrameSizeInstanceManager aInstanceManager;
- return &aInstanceManager;
+ 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;
}
void SwFormatFrameSize::ScaleMetrics(tools::Long lMult, tools::Long lDiv) {
@@ -341,6 +332,7 @@ 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;
@@ -1403,27 +1395,18 @@ void SwFormatSurround::dumpAsXml(xmlTextWriterPtr pWriter) const
(void)xmlTextWriterEndElement(pWriter);
}
-namespace
+bool SwFormatVertOrient::isHashable() const
{
- 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;
- }
- };
+ return true;
}
-ItemInstanceManager* SwFormatVertOrient::getItemInstanceManager() const
+size_t SwFormatVertOrient::hashCode() const
{
- static SwFormatVertOrientInstanceManager aInstanceManager;
- return &aInstanceManager;
+ std::size_t seed(0);
+ o3tl::hash_combine(seed, GetPos());
+ o3tl::hash_combine(seed, GetVertOrient());
+ o3tl::hash_combine(seed, GetRelationOrient());
+ return seed;
}
// Partially implemented inline in hxx
@@ -1518,28 +1501,19 @@ void SwFormatVertOrient::dumpAsXml(xmlTextWriterPtr pWriter) const
(void)xmlTextWriterEndElement(pWriter);
}
-namespace
+bool SwFormatHoriOrient::isHashable() const
{
- 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;
- }
- };
+ return true;
}
-ItemInstanceManager* SwFormatHoriOrient::getItemInstanceManager() const
+size_t SwFormatHoriOrient::hashCode() const
{
- static SwFormatHoriOrientInstanceManager aInstanceManager;
- return &aInstanceManager;
+ 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;
}
// Partially implemented inline in hxx
@@ -1596,6 +1570,7 @@ 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;