[Libreoffice-commits] core.git: sw/source

Noel Grandin noel at peralex.com
Thu Oct 20 08:20:11 UTC 2016


 sw/source/core/attr/calbck.cxx    |    3 +--
 sw/source/core/doc/tblrwcl.cxx    |    4 ++--
 sw/source/core/docnode/ndcopy.cxx |    4 ++--
 sw/source/core/layout/atrfrm.cxx  |   10 ++++------
 sw/source/core/unocore/unotbl.cxx |    6 ++----
 5 files changed, 11 insertions(+), 16 deletions(-)

New commits:
commit 553ee72041d6f66e26156eb1ad0d9e3c13457f7a
Author: Noel Grandin <noel at peralex.com>
Date:   Thu Oct 20 10:19:21 2016 +0200

    simplify some use of typeid
    
    Change-Id: I92362af5ef25052ec09b10a24c8fe051f6a51134

diff --git a/sw/source/core/attr/calbck.cxx b/sw/source/core/attr/calbck.cxx
index d38532e..54a036b 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 de3a791..1efc141 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 64e87f5..8683798 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 f8eb4a5..4f554ba 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 43b3b7e..108802c 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;
     }


More information about the Libreoffice-commits mailing list