summaryrefslogtreecommitdiff
path: root/sc/source
diff options
context:
space:
mode:
authorNoel Grandin <noelgrandin@gmail.com>2019-10-05 13:32:10 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2019-10-06 11:58:50 +0200
commit6a789e617ed07bfddc516c8fc0cf94cd6dfe7250 (patch)
tree11d6097893a301ae65cf4668077134ac7510091a /sc/source
parent070b3a848d6824ea154ae2d68fc7571feed60a5f (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 'sc/source')
-rw-r--r--sc/source/core/data/attrib.cxx8
-rw-r--r--sc/source/core/data/patattr.cxx5
-rw-r--r--sc/source/ui/condformat/condformatdlgitem.cxx3
3 files changed, 9 insertions, 7 deletions
diff --git a/sc/source/core/data/attrib.cxx b/sc/source/core/data/attrib.cxx
index f35d2c7219d7..5f1517250998 100644
--- a/sc/source/core/data/attrib.cxx
+++ b/sc/source/core/data/attrib.cxx
@@ -101,8 +101,7 @@ ScMergeAttr::~ScMergeAttr()
bool ScMergeAttr::operator==( const SfxPoolItem& rItem ) const
{
- OSL_ENSURE( Which() != rItem.Which() || typeid(*this) == typeid(rItem), "which ==, type !=" );
- return (Which() == rItem.Which())
+ return SfxPoolItem::operator==(rItem)
&& (nColMerge == static_cast<const ScMergeAttr&>(rItem).nColMerge)
&& (nRowMerge == static_cast<const ScMergeAttr&>(rItem).nRowMerge);
}
@@ -333,8 +332,7 @@ bool ScProtectionAttr::GetPresentation
bool ScProtectionAttr::operator==( const SfxPoolItem& rItem ) const
{
- OSL_ENSURE( Which() != rItem.Which() || typeid(*this) == typeid(rItem), "which ==, type !=" );
- return (Which() == rItem.Which())
+ return SfxPoolItem::operator==(rItem)
&& (bProtection == static_cast<const ScProtectionAttr&>(rItem).bProtection)
&& (bHideFormula == static_cast<const ScProtectionAttr&>(rItem).bHideFormula)
&& (bHideCell == static_cast<const ScProtectionAttr&>(rItem).bHideCell)
@@ -689,6 +687,8 @@ ScCondFormatItem::~ScCondFormatItem()
bool ScCondFormatItem::operator==( const SfxPoolItem& rCmp ) const
{
+ if (!SfxPoolItem::operator==(rCmp))
+ return false;
auto const & other = static_cast<const ScCondFormatItem&>(rCmp);
if (maIndex.empty() && other.maIndex.empty())
return true;
diff --git a/sc/source/core/data/patattr.cxx b/sc/source/core/data/patattr.cxx
index d3ce46ddff61..ec3ffb74bef0 100644
--- a/sc/source/core/data/patattr.cxx
+++ b/sc/source/core/data/patattr.cxx
@@ -139,8 +139,9 @@ bool ScPatternAttr::operator==( const SfxPoolItem& rCmp ) const
{
// #i62090# Use quick comparison between ScPatternAttr's ItemSets
- return ( EqualPatternSets( GetItemSet(), static_cast<const ScPatternAttr&>(rCmp).GetItemSet() ) &&
- StrCmp( GetStyleName(), static_cast<const ScPatternAttr&>(rCmp).GetStyleName() ) );
+ return SfxPoolItem::operator==(rCmp) &&
+ EqualPatternSets( GetItemSet(), static_cast<const ScPatternAttr&>(rCmp).GetItemSet() ) &&
+ StrCmp( GetStyleName(), static_cast<const ScPatternAttr&>(rCmp).GetStyleName() );
}
SvxCellOrientation ScPatternAttr::GetCellOrientation( const SfxItemSet& rItemSet, const SfxItemSet* pCondSet )
diff --git a/sc/source/ui/condformat/condformatdlgitem.cxx b/sc/source/ui/condformat/condformatdlgitem.cxx
index ee37c734d94d..ee1713b06f04 100644
--- a/sc/source/ui/condformat/condformatdlgitem.cxx
+++ b/sc/source/ui/condformat/condformatdlgitem.cxx
@@ -27,8 +27,9 @@ ScCondFormatDlgItem::~ScCondFormatDlgItem()
{
}
-bool ScCondFormatDlgItem::operator==(const SfxPoolItem& /*rItem*/) const
+bool ScCondFormatDlgItem::operator==(const SfxPoolItem& rItem) const
{
+ assert(SfxPoolItem::operator==(rItem)); (void)rItem;
return false;
}