summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2016-10-20 10:19:21 +0200
committerNoel Grandin <noel@peralex.com>2016-10-20 10:19:42 +0200
commit553ee72041d6f66e26156eb1ad0d9e3c13457f7a (patch)
tree80ac3524394bf3f58737f2c8dd877c34a3e9e123
parente23f54d4175840edb24a39d17ba08edd28c95091 (diff)
simplify some use of typeid
Change-Id: I92362af5ef25052ec09b10a24c8fe051f6a51134
-rw-r--r--sw/source/core/attr/calbck.cxx3
-rw-r--r--sw/source/core/doc/tblrwcl.cxx4
-rw-r--r--sw/source/core/docnode/ndcopy.cxx4
-rw-r--r--sw/source/core/layout/atrfrm.cxx10
-rw-r--r--sw/source/core/unocore/unotbl.cxx6
5 files changed, 11 insertions, 16 deletions
diff --git a/sw/source/core/attr/calbck.cxx b/sw/source/core/attr/calbck.cxx
index d38532e32b9c..54a036bdb110 100644
--- a/sw/source/core/attr/calbck.cxx
+++ b/sw/source/core/attr/calbck.cxx
@@ -62,9 +62,8 @@ void SwClient::CheckRegistration( const SfxPoolItem* pOld, const SfxPoolItem* )
void SwClient::SwClientNotify(const SwModify&, const SfxHint& rHint)
{
- if (typeid(rHint) == typeid(sw::LegacyModifyHint))
+ if (auto pLegacyHint = dynamic_cast<const sw::LegacyModifyHint*>(&rHint))
{
- auto pLegacyHint(static_cast<const sw::LegacyModifyHint*>(&rHint));
Modify(pLegacyHint->m_pOld, pLegacyHint->m_pNew);
}
};
diff --git a/sw/source/core/doc/tblrwcl.cxx b/sw/source/core/doc/tblrwcl.cxx
index de3a79186a9f..1efc14126af8 100644
--- a/sw/source/core/doc/tblrwcl.cxx
+++ b/sw/source/core/doc/tblrwcl.cxx
@@ -2092,12 +2092,12 @@ bool SwTable::MakeCopy( SwDoc* pInsDoc, const SwPosition& rPos,
pNewTable->SetTableStyleName(pTableNd->GetTable().GetTableStyleName());
- if( typeid( SwDDETable) == typeid(*this))
+ if( auto pSwDDETable = dynamic_cast<const SwDDETable*>(this) )
{
// A DDE-Table is being copied
// Does the new Document actually have it's FieldType?
SwFieldType* pFieldType = pInsDoc->getIDocumentFieldsAccess().InsertFieldType(
- *static_cast<const SwDDETable*>(this)->GetDDEFieldType() );
+ *pSwDDETable->GetDDEFieldType() );
OSL_ENSURE( pFieldType, "unknown FieldType" );
// Change the Table Pointer at the Node
diff --git a/sw/source/core/docnode/ndcopy.cxx b/sw/source/core/docnode/ndcopy.cxx
index 64e87f5529be..86837982e842 100644
--- a/sw/source/core/docnode/ndcopy.cxx
+++ b/sw/source/core/docnode/ndcopy.cxx
@@ -270,11 +270,11 @@ SwTableNode* SwTableNode::MakeCopy( SwDoc* pDoc, const SwNodeIndex& rIdx ) const
rTable.SetTableModel( GetTable().IsNewModel() );
SwDDEFieldType* pDDEType = nullptr;
- if( typeid(SwDDETable) == typeid( &GetTable() ))
+ if( auto pSwDDETable = dynamic_cast<const SwDDETable*>( &GetTable() ) )
{
// We're copying a DDE table
// Is the field type available in the new document?
- pDDEType = const_cast<SwDDETable&>(static_cast<const SwDDETable&>(GetTable())).GetDDEFieldType();
+ pDDEType = const_cast<SwDDETable*>(pSwDDETable)->GetDDEFieldType();
if( pDDEType->IsDeleted() )
pDoc->getIDocumentFieldsAccess().InsDeletedFieldType( *pDDEType );
else
diff --git a/sw/source/core/layout/atrfrm.cxx b/sw/source/core/layout/atrfrm.cxx
index f8eb4a5505f2..4f554babfd6a 100644
--- a/sw/source/core/layout/atrfrm.cxx
+++ b/sw/source/core/layout/atrfrm.cxx
@@ -664,17 +664,15 @@ void SwFormatPageDesc::Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew
case RES_OBJECTDYING:
//The Pagedesc where I'm registered dies, therefore I unregister
//from that format. During this I get deleted!
- if( typeid(SwFormat) == typeid( pDefinedIn ))
+ if( auto pSwFormat = dynamic_cast<SwFormat*>(pDefinedIn) )
{
- bool const bResult =
- static_cast<SwFormat*>(pDefinedIn)->ResetFormatAttr(RES_PAGEDESC);
+ bool const bResult = pSwFormat->ResetFormatAttr(RES_PAGEDESC);
OSL_ENSURE( bResult, "FormatPageDesc not deleted" );
(void) bResult; // unused in non-debug
}
- else if( typeid(SwContentNode) == typeid( pDefinedIn ))
+ else if( auto pSwContentNode = dynamic_cast<SwContentNode*>(pDefinedIn) )
{
- bool const bResult = static_cast<SwContentNode*>(pDefinedIn)
- ->ResetAttr(RES_PAGEDESC);
+ bool const bResult = pSwContentNode->ResetAttr(RES_PAGEDESC);
OSL_ENSURE( bResult, "FormatPageDesc not deleted" );
(void) bResult; // unused in non-debug
}
diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx
index 43b3b7ed2e86..108802c0dca1 100644
--- a/sw/source/core/unocore/unotbl.cxx
+++ b/sw/source/core/unocore/unotbl.cxx
@@ -1150,9 +1150,8 @@ void SwXCell::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew)
void SwXCell::SwClientNotify(const SwModify& rModify, const SfxHint& rHint)
{
- if(typeid(FindUnoInstanceHint<SwTableBox, SwXCell>) == typeid(rHint))
+ if(auto pFindHint = dynamic_cast<const FindUnoInstanceHint<SwTableBox, SwXCell>*>(&rHint))
{
- auto* pFindHint(static_cast<const FindUnoInstanceHint<SwTableBox, SwXCell>* >(&rHint));
if(!pFindHint->m_pCore && pFindHint->m_pCore == GetTableBox())
pFindHint->m_pResult = this;
}
@@ -1440,9 +1439,8 @@ void SwXTextTableRow::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew)
void SwXTextTableRow::SwClientNotify(const SwModify& rModify, const SfxHint& rHint)
{
- if(typeid(FindUnoInstanceHint<SwTableLine, SwXTextTableRow>) == typeid(rHint))
+ if(auto pFindHint = dynamic_cast<const FindUnoInstanceHint<SwTableLine, SwXTextTableRow>*>(&rHint))
{
- auto* pFindHint(static_cast<const FindUnoInstanceHint<SwTableLine,SwXTextTableRow>* >(&rHint));
if(!pFindHint->m_pCore && pFindHint->m_pCore == GetTableRow())
pFindHint->m_pResult = this;
}