diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2019-10-05 13:32:10 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-10-06 11:58:50 +0200 |
commit | 6a789e617ed07bfddc516c8fc0cf94cd6dfe7250 (patch) | |
tree | 11d6097893a301ae65cf4668077134ac7510091a /svl | |
parent | 070b3a848d6824ea154ae2d68fc7571feed60a5f (diff) |
improve SfxPoolItem operator== implementations
(*) make them all call the superclass operator==
(*) make the base class check which and typeid to ensure
we are only comparing the safe subclasses together
(*) remove a couple of operator== that were not doing
anything useful
Change-Id: Ia6234aed42df04157a5d6a323dc951916a9cb316
Reviewed-on: https://gerrit.libreoffice.org/80308
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'svl')
-rw-r--r-- | svl/source/items/aeitem.cxx | 3 | ||||
-rw-r--r-- | svl/source/items/globalnameitem.cxx | 3 | ||||
-rw-r--r-- | svl/source/items/grabbagitem.cxx | 5 | ||||
-rw-r--r-- | svl/source/items/ilstitem.cxx | 2 | ||||
-rw-r--r-- | svl/source/items/imageitm.cxx | 4 | ||||
-rw-r--r-- | svl/source/items/int64item.cxx | 2 | ||||
-rw-r--r-- | svl/source/items/lckbitem.cxx | 2 | ||||
-rw-r--r-- | svl/source/items/poolitem.cxx | 4 |
8 files changed, 13 insertions, 12 deletions
diff --git a/svl/source/items/aeitem.cxx b/svl/source/items/aeitem.cxx index 00e58d27f464..5ac6fbac3980 100644 --- a/svl/source/items/aeitem.cxx +++ b/svl/source/items/aeitem.cxx @@ -62,10 +62,9 @@ void SfxAllEnumItem::SetTextByPos( sal_uInt16 nPos, const OUString &rText ) bool SfxAllEnumItem::operator==( const SfxPoolItem& rCmp ) const { - assert(dynamic_cast< const SfxAllEnumItem* >(&rCmp) && "operator==Types not matching"); - const SfxAllEnumItem& rOther = static_cast<const SfxAllEnumItem&>(rCmp); if (!SfxPoolItem::operator==(rCmp)) return false; + const SfxAllEnumItem& rOther = static_cast<const SfxAllEnumItem&>(rCmp); return m_Values == rOther.m_Values; } diff --git a/svl/source/items/globalnameitem.cxx b/svl/source/items/globalnameitem.cxx index 529a3398c3b7..2cd289f05f84 100644 --- a/svl/source/items/globalnameitem.cxx +++ b/svl/source/items/globalnameitem.cxx @@ -49,7 +49,8 @@ SfxGlobalNameItem::~SfxGlobalNameItem() bool SfxGlobalNameItem::operator==( const SfxPoolItem& rItem ) const { - return static_cast<const SfxGlobalNameItem&>(rItem).m_aName == m_aName; + return SfxPoolItem::operator==(rItem) && + static_cast<const SfxGlobalNameItem&>(rItem).m_aName == m_aName; } diff --git a/svl/source/items/grabbagitem.cxx b/svl/source/items/grabbagitem.cxx index 83c0323450ab..e4d70bded1e8 100644 --- a/svl/source/items/grabbagitem.cxx +++ b/svl/source/items/grabbagitem.cxx @@ -27,9 +27,8 @@ SfxGrabBagItem::~SfxGrabBagItem() = default; bool SfxGrabBagItem::operator==(const SfxPoolItem& rItem) const { - auto pItem = static_cast<const SfxGrabBagItem*>(&rItem); - - return m_aMap == pItem->m_aMap; + return SfxPoolItem::operator==(rItem) + && m_aMap == static_cast<const SfxGrabBagItem*>(&rItem)->m_aMap; } SfxPoolItem* SfxGrabBagItem::Clone(SfxItemPool* /*pPool*/) const diff --git a/svl/source/items/ilstitem.cxx b/svl/source/items/ilstitem.cxx index a63055c7ffef..221bb0b074e2 100644 --- a/svl/source/items/ilstitem.cxx +++ b/svl/source/items/ilstitem.cxx @@ -49,7 +49,7 @@ SfxIntegerListItem::~SfxIntegerListItem() bool SfxIntegerListItem::operator==( const SfxPoolItem& rPoolItem ) const { - if ( dynamic_cast< const SfxIntegerListItem* >( &rPoolItem) == nullptr ) + if ( !SfxPoolItem::operator==(rPoolItem) ) return false; const SfxIntegerListItem & rItem = static_cast<const SfxIntegerListItem&>(rPoolItem); diff --git a/svl/source/items/imageitm.cxx b/svl/source/items/imageitm.cxx index 269e80936af3..e7ca5db4455e 100644 --- a/svl/source/items/imageitm.cxx +++ b/svl/source/items/imageitm.cxx @@ -61,8 +61,8 @@ SfxPoolItem* SfxImageItem::Clone( SfxItemPool* ) const bool SfxImageItem::operator==( const SfxPoolItem& rItem ) const { - return (static_cast<const SfxImageItem&>(rItem).GetValue() == GetValue()) && - (*pImpl == *static_cast<const SfxImageItem&>(rItem).pImpl); + return SfxInt16Item::operator==(rItem) && + *pImpl == *static_cast<const SfxImageItem&>(rItem).pImpl; } bool SfxImageItem::QueryValue( css::uno::Any& rVal, sal_uInt8 ) const diff --git a/svl/source/items/int64item.cxx b/svl/source/items/int64item.cxx index f128bc4d4275..c7f46452c27a 100644 --- a/svl/source/items/int64item.cxx +++ b/svl/source/items/int64item.cxx @@ -18,7 +18,7 @@ SfxInt64Item::~SfxInt64Item() {} bool SfxInt64Item::operator== ( const SfxPoolItem& rItem ) const { - return mnValue == static_cast<const SfxInt64Item&>(rItem).mnValue; + return SfxPoolItem::operator==(rItem) && mnValue == static_cast<const SfxInt64Item&>(rItem).mnValue; } bool SfxInt64Item::GetPresentation( diff --git a/svl/source/items/lckbitem.cxx b/svl/source/items/lckbitem.cxx index 25cebefc01d5..e2ad91a4c30f 100644 --- a/svl/source/items/lckbitem.cxx +++ b/svl/source/items/lckbitem.cxx @@ -39,7 +39,7 @@ SfxLockBytesItem::~SfxLockBytesItem() bool SfxLockBytesItem::operator==( const SfxPoolItem& rItem ) const { - return static_cast<const SfxLockBytesItem&>(rItem)._xVal == _xVal; + return SfxPoolItem::operator==(rItem) && static_cast<const SfxLockBytesItem&>(rItem)._xVal == _xVal; } diff --git a/svl/source/items/poolitem.cxx b/svl/source/items/poolitem.cxx index 5c4e81c89e10..ec37b68d3417 100644 --- a/svl/source/items/poolitem.cxx +++ b/svl/source/items/poolitem.cxx @@ -486,7 +486,9 @@ SfxPoolItem::~SfxPoolItem() bool SfxPoolItem::operator==( const SfxPoolItem& rCmp ) const { - return typeid(rCmp) == typeid(*this); + assert(typeid(rCmp) == typeid(*this) && "comparing different pool item subclasses"); + (void)rCmp; + return true; } |