summaryrefslogtreecommitdiff
path: root/sw
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 /sw
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 'sw')
-rw-r--r--sw/source/core/attr/fmtfollowtextflow.cxx1
-rw-r--r--sw/source/core/attr/hints.cxx2
-rw-r--r--sw/source/core/txtnode/fmtatr2.cxx3
-rw-r--r--sw/source/filter/basflt/fltshell.cxx14
-rw-r--r--sw/source/uibase/config/cfgitems.cxx5
-rw-r--r--sw/source/uibase/dialog/swwrtshitem.cxx3
-rw-r--r--sw/source/uibase/utlui/uiitems.cxx18
7 files changed, 24 insertions, 22 deletions
diff --git a/sw/source/core/attr/fmtfollowtextflow.cxx b/sw/source/core/attr/fmtfollowtextflow.cxx
index eee767f47aca..469440cc2ad1 100644
--- a/sw/source/core/attr/fmtfollowtextflow.cxx
+++ b/sw/source/core/attr/fmtfollowtextflow.cxx
@@ -79,7 +79,6 @@ bool SwFormatFollowTextFlow::QueryValue(css::uno::Any& rVal, sal_uInt8 aInt) con
bool SwFormatFollowTextFlow::operator==(const SfxPoolItem& rItem) const
{
- assert(dynamic_cast<const SwFormatFollowTextFlow*>(&rItem) != nullptr);
return SfxBoolItem::operator==(rItem)
&& mbLayoutInCell == static_cast<SwFormatFollowTextFlow const*>(&rItem)->mbLayoutInCell;
}
diff --git a/sw/source/core/attr/hints.cxx b/sw/source/core/attr/hints.cxx
index 96784aeabe03..1b92d14c4f8d 100644
--- a/sw/source/core/attr/hints.cxx
+++ b/sw/source/core/attr/hints.cxx
@@ -139,7 +139,7 @@ SwMsgPoolItem::SwMsgPoolItem( sal_uInt16 nWhch )
bool SwMsgPoolItem::operator==( const SfxPoolItem& ) const
{
- OSL_FAIL( "SwMsgPoolItem knows no ==" );
+ assert( false && "SwMsgPoolItem knows no ==" );
return false;
}
diff --git a/sw/source/core/txtnode/fmtatr2.cxx b/sw/source/core/txtnode/fmtatr2.cxx
index 805d0dd1dddd..ef37d507efae 100644
--- a/sw/source/core/txtnode/fmtatr2.cxx
+++ b/sw/source/core/txtnode/fmtatr2.cxx
@@ -562,9 +562,8 @@ SwFormatMeta::~SwFormatMeta()
bool SwFormatMeta::operator==( const SfxPoolItem & i_rOther ) const
{
- assert(SfxPoolItem::operator==(i_rOther));
return SfxPoolItem::operator==( i_rOther )
- && (m_pMeta == static_cast<SwFormatMeta const &>( i_rOther ).m_pMeta);
+ && m_pMeta == static_cast<SwFormatMeta const &>( i_rOther ).m_pMeta;
}
SfxPoolItem * SwFormatMeta::Clone( SfxItemPool * /*pPool*/ ) const
diff --git a/sw/source/filter/basflt/fltshell.cxx b/sw/source/filter/basflt/fltshell.cxx
index d530d73c77ac..950a3b0c2029 100644
--- a/sw/source/filter/basflt/fltshell.cxx
+++ b/sw/source/filter/basflt/fltshell.cxx
@@ -966,7 +966,8 @@ void SwFltAnchor::SetFrameFormat(SwFrameFormat * _pFrameFormat)
bool SwFltAnchor::operator==(const SfxPoolItem& rItem) const
{
- return pFrameFormat == static_cast<const SwFltAnchor&>(rItem).pFrameFormat;
+ return SfxPoolItem::operator==(rItem) &&
+ pFrameFormat == static_cast<const SwFltAnchor&>(rItem).pFrameFormat;
}
SfxPoolItem* SwFltAnchor::Clone(SfxItemPool*) const
@@ -994,7 +995,8 @@ void SwFltAnchorListener::Notify(const SfxHint& rHint)
// methods of SwFltRedline follow
bool SwFltRedline::operator==(const SfxPoolItem& rItem) const
{
- return this == &rItem;
+ return SfxPoolItem::operator==(rItem) &&
+ this == &rItem;
}
SfxPoolItem* SwFltRedline::Clone( SfxItemPool* ) const
@@ -1026,8 +1028,9 @@ SwFltBookmark::SwFltBookmark( const OUString& rNa, const OUString& rVa,
bool SwFltBookmark::operator==(const SfxPoolItem& rItem) const
{
- return ( maName == static_cast<const SwFltBookmark&>(rItem).maName)
- && (mnHandle == static_cast<const SwFltBookmark&>(rItem).mnHandle);
+ return SfxPoolItem::operator==(rItem)
+ && maName == static_cast<const SwFltBookmark&>(rItem).maName
+ && mnHandle == static_cast<const SwFltBookmark&>(rItem).mnHandle;
}
SfxPoolItem* SwFltBookmark::Clone(SfxItemPool*) const
@@ -1085,7 +1088,8 @@ SwFltTOX::SwFltTOX(SwTOXBase* pBase)
bool SwFltTOX::operator==(const SfxPoolItem& rItem) const
{
- return m_xTOXBase.get() == static_cast<const SwFltTOX&>(rItem).m_xTOXBase.get();
+ return SfxPoolItem::operator==(rItem) &&
+ m_xTOXBase.get() == static_cast<const SwFltTOX&>(rItem).m_xTOXBase.get();
}
SfxPoolItem* SwFltTOX::Clone(SfxItemPool*) const
diff --git a/sw/source/uibase/config/cfgitems.cxx b/sw/source/uibase/config/cfgitems.cxx
index c07a0c84bbed..8846665ba6f9 100644
--- a/sw/source/uibase/config/cfgitems.cxx
+++ b/sw/source/uibase/config/cfgitems.cxx
@@ -212,8 +212,9 @@ SfxPoolItem* SwShadowCursorItem::Clone( SfxItemPool* ) const
bool SwShadowCursorItem::operator==( const SfxPoolItem& rCmp ) const
{
- return IsOn() == static_cast<const SwShadowCursorItem&>(rCmp).IsOn() &&
- GetMode() == static_cast<const SwShadowCursorItem&>(rCmp).GetMode();
+ return SfxPoolItem::operator==(rCmp) &&
+ IsOn() == static_cast<const SwShadowCursorItem&>(rCmp).IsOn() &&
+ GetMode() == static_cast<const SwShadowCursorItem&>(rCmp).GetMode();
}
void SwShadowCursorItem::FillViewOptions( SwViewOption& rVOpt ) const
diff --git a/sw/source/uibase/dialog/swwrtshitem.cxx b/sw/source/uibase/dialog/swwrtshitem.cxx
index 4c6671e5bbb9..03f7fabe4871 100644
--- a/sw/source/uibase/dialog/swwrtshitem.cxx
+++ b/sw/source/uibase/dialog/swwrtshitem.cxx
@@ -28,7 +28,8 @@ SwWrtShellItem::SwWrtShellItem( SwWrtShell* pSh )
bool SwWrtShellItem::operator==( const SfxPoolItem& rItem) const
{
- return static_cast<const SwWrtShellItem&>(rItem).pWrtSh == pWrtSh;
+ return SfxPoolItem::operator==(rItem)
+ && pWrtSh == static_cast<const SwWrtShellItem&>(rItem).pWrtSh;
}
SfxPoolItem* SwWrtShellItem::Clone( SfxItemPool * /*pPool*/ ) const
diff --git a/sw/source/uibase/utlui/uiitems.cxx b/sw/source/uibase/utlui/uiitems.cxx
index 89390a6735a4..20f9d48be8d8 100644
--- a/sw/source/uibase/utlui/uiitems.cxx
+++ b/sw/source/uibase/utlui/uiitems.cxx
@@ -51,8 +51,8 @@ SfxPoolItem* SwPageFootnoteInfoItem::Clone( SfxItemPool * /*pPool*/ ) const
bool SwPageFootnoteInfoItem::operator==( const SfxPoolItem& rAttr ) const
{
- OSL_ENSURE( Which() == rAttr.Which(), "no equal attributes" );
- return ( aFootnoteInfo == static_cast<const SwPageFootnoteInfoItem&>(rAttr).GetPageFootnoteInfo());
+ return SfxPoolItem::operator==(rAttr)
+ && aFootnoteInfo == static_cast<const SwPageFootnoteInfoItem&>(rAttr).aFootnoteInfo;
}
bool SwPageFootnoteInfoItem::GetPresentation
@@ -204,9 +204,8 @@ SfxPoolItem* SwPtrItem::Clone( SfxItemPool * /*pPool*/ ) const
bool SwPtrItem::operator==( const SfxPoolItem& rAttr ) const
{
- assert(SfxPoolItem::operator==(rAttr));
- const SwPtrItem& rItem = static_cast<const SwPtrItem&>(rAttr);
- return ( pMisc == rItem.pMisc );
+ return SfxPoolItem::operator==(rAttr)
+ && pMisc == static_cast<const SwPtrItem&>(rAttr).pMisc;
}
// SwUINumRuleItem for the NumTabPages of the FormatNumRule/Styleists
@@ -233,8 +232,8 @@ SfxPoolItem* SwUINumRuleItem::Clone( SfxItemPool * /*pPool*/ ) const
bool SwUINumRuleItem::operator==( const SfxPoolItem& rAttr ) const
{
- assert(SfxPoolItem::operator==(rAttr));
- return *pRule == *static_cast<const SwUINumRuleItem&>(rAttr).pRule;
+ return SfxPoolItem::operator==(rAttr)
+ && *pRule == *static_cast<const SwUINumRuleItem&>(rAttr).pRule;
}
bool SwUINumRuleItem::QueryValue( uno::Any& rVal, sal_uInt8 /*nMemberId*/ ) const
@@ -270,9 +269,8 @@ SfxPoolItem* SwPaMItem::Clone( SfxItemPool * /*pPool*/ ) const
bool SwPaMItem::operator==( const SfxPoolItem& rAttr ) const
{
- assert(SfxPoolItem::operator==(rAttr));
- const SwPaMItem& rItem = static_cast<const SwPaMItem&>(rAttr);
- return ( m_pPaM == rItem.m_pPaM );
+ return SfxPoolItem::operator==(rAttr)
+ && m_pPaM == static_cast<const SwPaMItem&>(rAttr).m_pPaM;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */