summaryrefslogtreecommitdiff
path: root/include/svl
diff options
context:
space:
mode:
Diffstat (limited to 'include/svl')
-rw-r--r--include/svl/cintitem.hxx12
-rw-r--r--include/svl/eitem.hxx10
-rw-r--r--include/svl/poolitem.hxx14
3 files changed, 28 insertions, 8 deletions
diff --git a/include/svl/cintitem.hxx b/include/svl/cintitem.hxx
index d9c0f273f260..17becbaba92c 100644
--- a/include/svl/cintitem.hxx
+++ b/include/svl/cintitem.hxx
@@ -35,6 +35,9 @@ public:
virtual bool operator ==(const SfxPoolItem & rItem) const override;
+ virtual bool supportsHashCode() const override;
+ virtual size_t hashCode() const override final;
+
virtual bool GetPresentation(SfxItemPresentation,
MapUnit, MapUnit,
OUString & rText,
@@ -66,6 +69,9 @@ public:
virtual bool operator ==(const SfxPoolItem & rItem) const override;
+ virtual bool supportsHashCode() const override final;
+ virtual size_t hashCode() const override final;
+
virtual bool GetPresentation(SfxItemPresentation,
MapUnit, MapUnit,
OUString & rText,
@@ -98,6 +104,9 @@ public:
virtual bool operator ==(const SfxPoolItem & rItem) const override;
+ virtual bool supportsHashCode() const override final;
+ virtual size_t hashCode() const override final;
+
virtual bool GetPresentation(SfxItemPresentation,
MapUnit, MapUnit,
OUString & rText,
@@ -130,6 +139,9 @@ public:
virtual bool operator ==(const SfxPoolItem & rItem) const override;
+ virtual bool supportsHashCode() const override final;
+ virtual size_t hashCode() const override final;
+
virtual bool GetPresentation(SfxItemPresentation,
MapUnit, MapUnit,
OUString & rText,
diff --git a/include/svl/eitem.hxx b/include/svl/eitem.hxx
index f6fb22bfeb7d..fd398e8f0cbb 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 supportsHashCode() const override final
+ {
+ return true;
+ }
+
+ virtual size_t hashCode() const override final
+ {
+ return Which() ^ GetEnumValue();
+ }
};
class SVL_DLLPUBLIC SfxBoolItem
diff --git a/include/svl/poolitem.hxx b/include/svl/poolitem.hxx
index 722c30df2bee..60b6ae98068b 100644
--- a/include/svl/poolitem.hxx
+++ b/include/svl/poolitem.hxx
@@ -675,6 +675,9 @@ public:
virtual bool operator==( const SfxPoolItem& ) const = 0;
bool operator!=( const SfxPoolItem& rItem ) const
{ return !(*this == rItem); }
+ // Used by HashedItemInstanceManager
+ virtual bool supportsHashCode() const;
+ virtual size_t hashCode() const;
/** @return true if it has a valid string representation */
virtual bool GetPresentation( SfxItemPresentation ePresentation,
@@ -762,14 +765,12 @@ private:
for specific PoolItem subclasses that can be hashed which is faster than using
the linear search with operator== that DefaultItemInstanceManager has to do
*/
-class HashedItemInstanceManager : public ItemInstanceManager
+class HashedItemInstanceManager final : public ItemInstanceManager
{
struct ItemHash {
- HashedItemInstanceManager& mrManager;
- ItemHash(HashedItemInstanceManager& rManager) : mrManager(rManager) {}
size_t operator()(const SfxPoolItem* p) const
{
- return mrManager.hashCode(*p);
+ return p->hashCode();
}
};
struct ItemEqual {
@@ -781,13 +782,10 @@ class HashedItemInstanceManager : public ItemInstanceManager
std::unordered_set<const SfxPoolItem*, ItemHash, ItemEqual> maRegistered;
-protected:
- virtual size_t hashCode(const SfxPoolItem&) const = 0;
-
public:
HashedItemInstanceManager(SfxItemType aSfxItemType)
: ItemInstanceManager(aSfxItemType)
- , maRegistered(0, ItemHash(*this), ItemEqual())
+ , maRegistered(0, ItemHash(), ItemEqual())
{
}