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 /editeng | |
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 'editeng')
-rw-r--r-- | editeng/source/items/bulitem.cxx | 2 | ||||
-rw-r--r-- | editeng/source/items/numitem.cxx | 3 | ||||
-rw-r--r-- | editeng/source/items/paraitem.cxx | 7 | ||||
-rw-r--r-- | editeng/source/items/textitem.cxx | 9 | ||||
-rw-r--r-- | editeng/source/items/writingmodeitem.cxx | 7 | ||||
-rw-r--r-- | editeng/source/items/xmlcnitm.cxx | 5 |
6 files changed, 6 insertions, 27 deletions
diff --git a/editeng/source/items/bulitem.cxx b/editeng/source/items/bulitem.cxx index 9518cf4abbe9..46f6271f2c33 100644 --- a/editeng/source/items/bulitem.cxx +++ b/editeng/source/items/bulitem.cxx @@ -87,7 +87,7 @@ void SvxBulletItem::CopyValidProperties( const SvxBulletItem& rCopyFrom ) bool SvxBulletItem::operator==( const SfxPoolItem& rItem ) const { - DBG_ASSERT(dynamic_cast< const SvxBulletItem* >(&rItem) != nullptr,"operator==Types not matching"); + assert(SfxPoolItem::operator==(rItem)); const SvxBulletItem& rBullet = static_cast<const SvxBulletItem&>(rItem); // Compare with ValidMask, otherwise no put possible in an AttrSet if the // item differs only in terms of the ValidMask from an existing one. diff --git a/editeng/source/items/numitem.cxx b/editeng/source/items/numitem.cxx index e35682e04fbe..67cf0373cc37 100644 --- a/editeng/source/items/numitem.cxx +++ b/editeng/source/items/numitem.cxx @@ -938,7 +938,8 @@ SvxNumBulletItem::~SvxNumBulletItem() bool SvxNumBulletItem::operator==( const SfxPoolItem& rCopy) const { - return *pNumRule == *static_cast<const SvxNumBulletItem&>(rCopy).pNumRule; + return SfxPoolItem::operator==(rCopy) && + *pNumRule == *static_cast<const SvxNumBulletItem&>(rCopy).pNumRule; } SfxPoolItem* SvxNumBulletItem::Clone( SfxItemPool * ) const diff --git a/editeng/source/items/paraitem.cxx b/editeng/source/items/paraitem.cxx index 2194b3ed9e5a..ed159e14ed08 100644 --- a/editeng/source/items/paraitem.cxx +++ b/editeng/source/items/paraitem.cxx @@ -1061,8 +1061,6 @@ bool SvxPageModelItem::PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId bool SvxPageModelItem::operator==( const SfxPoolItem& rAttr ) const { - assert(SfxPoolItem::operator==(rAttr)); - return SfxStringItem::operator==(rAttr) && bAuto == static_cast<const SvxPageModelItem&>( rAttr ).bAuto; } @@ -1217,11 +1215,6 @@ bool SvxParaVertAlignItem::PutValue( const css::uno::Any& rVal, return false; } -bool SvxParaVertAlignItem::operator==( const SfxPoolItem& rItem ) const -{ - assert(SfxPoolItem::operator==(rItem)); - return SfxUInt16Item::operator==( rItem ); -} SvxParaGridItem::SvxParaGridItem( bool bOn, const sal_uInt16 nId ) diff --git a/editeng/source/items/textitem.cxx b/editeng/source/items/textitem.cxx index e4ce386c68c9..ffb4e63e2e21 100644 --- a/editeng/source/items/textitem.cxx +++ b/editeng/source/items/textitem.cxx @@ -1040,8 +1040,7 @@ bool SvxTextLineItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId ) bool SvxTextLineItem::operator==( const SfxPoolItem& rItem ) const { - assert(SfxPoolItem::operator==(rItem)); - return SfxEnumItem::operator==( static_cast<const SfxEnumItem<FontLineStyle>&>(rItem) ) && + return SfxEnumItem::operator==( rItem ) && GetColor() == static_cast<const SvxTextLineItem&>(rItem).GetColor(); } @@ -2241,12 +2240,6 @@ bool SvxTextRotateItem::PutValue(const css::uno::Any& rVal, sal_uInt8 nMemberId) return bRet; } -bool SvxTextRotateItem::operator==(const SfxPoolItem& rItem) const -{ - assert(SfxPoolItem::operator==(rItem)); - return SfxUInt16Item::operator==(rItem); -} - void SvxTextRotateItem::dumpAsXml(xmlTextWriterPtr pWriter) const { xmlTextWriterStartElement(pWriter, BAD_CAST("SvxTextRotateItem")); diff --git a/editeng/source/items/writingmodeitem.cxx b/editeng/source/items/writingmodeitem.cxx index dfa2df0de9cd..2fa4ce5ebbd4 100644 --- a/editeng/source/items/writingmodeitem.cxx +++ b/editeng/source/items/writingmodeitem.cxx @@ -38,13 +38,6 @@ SvxWritingModeItem::~SvxWritingModeItem() { } -bool SvxWritingModeItem::operator==( const SfxPoolItem& rCmp ) const -{ - assert(SfxPoolItem::operator==(rCmp)); - - return GetValue() == static_cast<const SvxWritingModeItem&>(rCmp).GetValue(); -} - SfxPoolItem* SvxWritingModeItem::Clone( SfxItemPool * ) const { return new SvxWritingModeItem( *this ); diff --git a/editeng/source/items/xmlcnitm.cxx b/editeng/source/items/xmlcnitm.cxx index 4e0c25c9c239..be38d75ab5f4 100644 --- a/editeng/source/items/xmlcnitm.cxx +++ b/editeng/source/items/xmlcnitm.cxx @@ -53,9 +53,8 @@ SvXMLAttrContainerItem::~SvXMLAttrContainerItem() bool SvXMLAttrContainerItem::operator==( const SfxPoolItem& rItem ) const { - DBG_ASSERT( dynamic_cast< const SvXMLAttrContainerItem* >(&rItem) != nullptr, - "SvXMLAttrContainerItem::operator ==(): Bad type"); - return *pImpl == *static_cast<const SvXMLAttrContainerItem&>(rItem).pImpl; + return SfxPoolItem::operator==(rItem) && + *pImpl == *static_cast<const SvXMLAttrContainerItem&>(rItem).pImpl; } bool SvXMLAttrContainerItem::GetPresentation( |