diff options
Diffstat (limited to 'svl/source/items/poolitem.cxx')
-rw-r--r-- | svl/source/items/poolitem.cxx | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/svl/source/items/poolitem.cxx b/svl/source/items/poolitem.cxx index ae7c97136c48..d8395c836592 100644 --- a/svl/source/items/poolitem.cxx +++ b/svl/source/items/poolitem.cxx @@ -488,9 +488,10 @@ void listAllocatedSfxPoolItems() } #endif -SfxPoolItem::SfxPoolItem(sal_uInt16 const nWhich) +SfxPoolItem::SfxPoolItem(sal_uInt16 const nWhich, SfxItemType eType) : m_nRefCount(0) , m_nWhich(nWhich) + , m_eItemType(eType) #ifdef DBG_UTIL , m_nSerialNumber(nUsedSfxPoolItemCount) #endif @@ -524,11 +525,10 @@ SfxPoolItem::~SfxPoolItem() bool SfxPoolItem::operator==(const SfxPoolItem& rCmp) const { - SAL_WARN_IF(typeid(rCmp) != typeid(*this), "svl", + SAL_WARN_IF(rCmp.ItemType() != ItemType(), "svl", "comparing different pool item subclasses " << typeid(rCmp).name() << " && " << typeid(*this).name()); - assert(typeid(rCmp) == typeid(*this) && "comparing different pool item subclasses"); - (void)rCmp; + assert(rCmp.ItemType() == ItemType() && "comparing different pool item subclasses"); return true; } @@ -656,10 +656,8 @@ bool SfxPoolItem::areSame(const SfxPoolItem* pItem1, const SfxPoolItem* pItem2) // WhichIDs differ (fast) return false; - if (typeid(*pItem1) != typeid(*pItem2)) + if (pItem1->ItemType() != pItem2->ItemType()) // types differ (fast) - // NOTE: we can now use typeid since we do not have (-1) - // anymore for Invalid state -> safe return false; // return content compare using operator== at last @@ -678,10 +676,8 @@ bool SfxPoolItem::areSame(const SfxPoolItem& rItem1, const SfxPoolItem& rItem2) // WhichIDs differ (fast) return false; - if (typeid(rItem1) != typeid(rItem2)) + if (rItem1.ItemType() != rItem2.ItemType()) // types differ (fast) - // NOTE: we can now use typeid since we do not have (-1) - // anymore for Invalid state -> safe return false; // return content compare using operator== at last @@ -694,6 +690,15 @@ class InvalidItem final : public SfxPoolItem { virtual bool operator==(const SfxPoolItem&) const override { return true; } virtual SfxPoolItem* Clone(SfxItemPool*) const override { return nullptr; } + +public: + // make it StaticDefaultItem to process similar to these + // which is plausible (never change and are not allowed to) + InvalidItem() + : SfxPoolItem(0, SfxItemType::InvalidOrDisabledItemType) + { + setStaticDefault(); + } }; InvalidItem aInvalidItem; } |