summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noelgrandin@gmail.com>2018-08-09 16:30:57 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-08-10 08:21:55 +0200
commitd977e02ec6350115c39f03d588539e8bd423a1c3 (patch)
treebd624f4037b1d498cde385e56d48e383335c32ce
parent76dd6bb9cc6dff0f59cdfce87b61210be6476965 (diff)
unnecessary null check before dynamic_cast, in various
Change-Id: I76ad0b3152030c29ee28f6a6cc80d0832188d02b Reviewed-on: https://gerrit.libreoffice.org/58774 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r--basic/source/classes/eventatt.cxx3
-rw-r--r--basic/source/classes/sb.cxx2
-rw-r--r--basic/source/classes/sbxmod.cxx8
-rw-r--r--basic/source/runtime/methods.cxx3
-rw-r--r--basic/source/runtime/methods1.cxx4
-rw-r--r--basic/source/sbx/sbxobj.cxx2
-rw-r--r--chart2/source/controller/main/SelectionHelper.cxx6
-rw-r--r--chart2/source/view/charttypes/BarChart.cxx3
-rw-r--r--chart2/source/view/diagram/VDiagram.cxx3
-rw-r--r--cui/source/tabpages/tplneend.cxx2
-rw-r--r--oox/source/export/shapes.cxx2
-rw-r--r--sfx2/source/appl/appdde.cxx2
-rw-r--r--starmath/source/edit.cxx4
-rw-r--r--svl/source/items/itempool.cxx2
-rw-r--r--xmloff/source/draw/ximpshap.cxx2
15 files changed, 21 insertions, 27 deletions
diff --git a/basic/source/classes/eventatt.cxx b/basic/source/classes/eventatt.cxx
index 15f2617dfe48..f76f694adb43 100644
--- a/basic/source/classes/eventatt.cxx
+++ b/basic/source/classes/eventatt.cxx
@@ -321,9 +321,8 @@ css::uno::Reference< css::container::XNameContainer > implFindDialogLibForDialog
css::uno::Reference< css::container::XNameContainer > aRetDlgLib;
SbxVariable* pDlgLibContVar = pBasic->Find("DialogLibraries", SbxClassType::Object);
- if( pDlgLibContVar && dynamic_cast<const SbUnoObject*>( pDlgLibContVar) != nullptr )
+ if( auto pDlgLibContUnoObj = dynamic_cast<SbUnoObject*>( pDlgLibContVar) )
{
- SbUnoObject* pDlgLibContUnoObj = static_cast<SbUnoObject*>(static_cast<SbxBase*>(pDlgLibContVar));
Any aDlgLibContAny = pDlgLibContUnoObj->getUnoAny();
Reference< XLibraryContainer > xDlgLibContNameAccess( aDlgLibContAny, UNO_QUERY );
diff --git a/basic/source/classes/sb.cxx b/basic/source/classes/sb.cxx
index 82e7b377af55..13f366c8d6c4 100644
--- a/basic/source/classes/sb.cxx
+++ b/basic/source/classes/sb.cxx
@@ -681,7 +681,7 @@ SbClassModuleObject::SbClassModuleObject( SbModule* pClassModule )
// Search for own copy of ImplMethod
SbxVariable* p = pMethods->Find( pImplMethod->GetName(), SbxClassType::Method );
- SbMethod* pImplMethodCopy = p ? dynamic_cast<SbMethod*>( p ) : nullptr;
+ SbMethod* pImplMethodCopy = dynamic_cast<SbMethod*>( p );
if( !pImplMethodCopy )
{
OSL_FAIL( "Found no ImplMethod copy" );
diff --git a/basic/source/classes/sbxmod.cxx b/basic/source/classes/sbxmod.cxx
index bf1a90c7b70e..c26df9c906ee 100644
--- a/basic/source/classes/sbxmod.cxx
+++ b/basic/source/classes/sbxmod.cxx
@@ -499,7 +499,7 @@ void SbModule::StartDefinitions()
SbMethod* SbModule::GetMethod( const OUString& rName, SbxDataType t )
{
SbxVariable* p = pMethods->Find( rName, SbxClassType::Method );
- SbMethod* pMeth = p ? dynamic_cast<SbMethod*>( p ) : nullptr;
+ SbMethod* pMeth = dynamic_cast<SbMethod*>( p );
if( p && !pMeth )
{
pMethods->Remove( p );
@@ -537,7 +537,7 @@ SbMethod* SbModule::FindMethod( const OUString& rName, SbxClassType t )
SbProperty* SbModule::GetProperty( const OUString& rName, SbxDataType t )
{
SbxVariable* p = pProps->Find( rName, SbxClassType::Property );
- SbProperty* pProp = p ? dynamic_cast<SbProperty*>( p ) : nullptr;
+ SbProperty* pProp = dynamic_cast<SbProperty*>( p );
if( p && !pProp )
{
pProps->Remove( p );
@@ -556,7 +556,7 @@ SbProperty* SbModule::GetProperty( const OUString& rName, SbxDataType t )
void SbModule::GetProcedureProperty( const OUString& rName, SbxDataType t )
{
SbxVariable* p = pProps->Find( rName, SbxClassType::Property );
- SbProcedureProperty* pProp = p ? dynamic_cast<SbProcedureProperty*>( p ) : nullptr;
+ SbProcedureProperty* pProp = dynamic_cast<SbProcedureProperty*>( p );
if( p && !pProp )
{
pProps->Remove( p );
@@ -574,7 +574,7 @@ void SbModule::GetProcedureProperty( const OUString& rName, SbxDataType t )
void SbModule::GetIfaceMapperMethod( const OUString& rName, SbMethod* pImplMeth )
{
SbxVariable* p = pMethods->Find( rName, SbxClassType::Method );
- SbIfaceMapperMethod* pMapperMethod = p ? dynamic_cast<SbIfaceMapperMethod*>( p ) : nullptr;
+ SbIfaceMapperMethod* pMapperMethod = dynamic_cast<SbIfaceMapperMethod*>( p );
if( p && !pMapperMethod )
{
pMethods->Remove( p );
diff --git a/basic/source/runtime/methods.cxx b/basic/source/runtime/methods.cxx
index 4a1a6b66cd29..b9bdbec05748 100644
--- a/basic/source/runtime/methods.cxx
+++ b/basic/source/runtime/methods.cxx
@@ -2370,8 +2370,7 @@ void SbRtl_IsObject(StarBASIC *, SbxArray & rPar, bool)
bool bObject = pVar->IsObject();
SbxBase* pObj = (bObject ? pVar->GetObject() : nullptr);
- SbUnoClass* pUnoClass;
- if( pObj && ( pUnoClass=dynamic_cast<SbUnoClass*>( pObj) ) != nullptr )
+ if( auto pUnoClass = dynamic_cast<SbUnoClass*>( pObj) )
{
bObject = pUnoClass->getUnoClass().is();
}
diff --git a/basic/source/runtime/methods1.cxx b/basic/source/runtime/methods1.cxx
index 4b59ea081c28..7f5ab0233096 100644
--- a/basic/source/runtime/methods1.cxx
+++ b/basic/source/runtime/methods1.cxx
@@ -123,7 +123,7 @@ void SbRtl_CallByName(StarBASIC *, SbxArray & rPar, bool)
SbxObject* pObj = nullptr;
if( pObjVar )
pObj = dynamic_cast<SbxObject*>( pObjVar );
- if( !pObj && pObjVar && dynamic_cast<const SbxVariable*>( pObjVar) != nullptr )
+ if( !pObj && dynamic_cast<const SbxVariable*>( pObjVar) )
{
SbxBase* pObjVarObj = static_cast<SbxVariable*>(pObjVar)->GetObject();
pObj = dynamic_cast<SbxObject*>( pObjVarObj );
@@ -864,7 +864,7 @@ void SbRtl_FindPropertyObject(StarBASIC *, SbxArray & rPar, bool)
{
pObj = dynamic_cast<SbxObject*>( pObjVar );
}
- if( !pObj && pObjVar && dynamic_cast<const SbxVariable*>( pObjVar) != nullptr )
+ if( !pObj && dynamic_cast<const SbxVariable*>( pObjVar) )
{
SbxBase* pObjVarObj = static_cast<SbxVariable*>(pObjVar)->GetObject();
pObj = dynamic_cast<SbxObject*>( pObjVarObj );
diff --git a/basic/source/sbx/sbxobj.cxx b/basic/source/sbx/sbxobj.cxx
index b0cf727672ff..a9bee2a803ed 100644
--- a/basic/source/sbx/sbxobj.cxx
+++ b/basic/source/sbx/sbxobj.cxx
@@ -290,7 +290,7 @@ SbxVariable* SbxObject::Find( const OUString& rName, SbxClassType t )
bool SbxObject::Call( const OUString& rName, SbxArray* pParam )
{
SbxVariable* pMeth = FindQualified( rName, SbxClassType::DontCare);
- if( pMeth && dynamic_cast<const SbxMethod*>( pMeth) != nullptr )
+ if( dynamic_cast<const SbxMethod*>( pMeth) )
{
// FindQualified() might have struck already!
if( pParam )
diff --git a/chart2/source/controller/main/SelectionHelper.cxx b/chart2/source/controller/main/SelectionHelper.cxx
index bc18ffe79334..30fbfdb648cd 100644
--- a/chart2/source/controller/main/SelectionHelper.cxx
+++ b/chart2/source/controller/main/SelectionHelper.cxx
@@ -462,10 +462,8 @@ SelectionHelper::~SelectionHelper()
bool SelectionHelper::getFrameDragSingles()
{
- bool bFrameDragSingles = true;//true == green == surrounding handles
- if( m_pSelectedObj && dynamic_cast<const E3dObject*>( m_pSelectedObj) != nullptr )
- bFrameDragSingles = false;
- return bFrameDragSingles;
+ //true == green == surrounding handles
+ return dynamic_cast<const E3dObject*>( m_pSelectedObj) == nullptr;
}
SdrObject* SelectionHelper::getMarkHandlesObject( SdrObject* pObj )
diff --git a/chart2/source/view/charttypes/BarChart.cxx b/chart2/source/view/charttypes/BarChart.cxx
index b757b1286c3b..3a7bf3f6a599 100644
--- a/chart2/source/view/charttypes/BarChart.cxx
+++ b/chart2/source/view/charttypes/BarChart.cxx
@@ -440,8 +440,7 @@ E3dScene* lcl_getE3dScene(uno::Reference<uno::XInterface> const & xInterface)
if (pSvxShape)
{
SdrObject* pObject = pSvxShape->GetSdrObject();
- if (pObject && dynamic_cast<const E3dScene*>(pObject) != nullptr)
- pScene = static_cast<E3dScene*>(pObject);
+ pScene = dynamic_cast<E3dScene*>(pObject);
}
return pScene;
}
diff --git a/chart2/source/view/diagram/VDiagram.cxx b/chart2/source/view/diagram/VDiagram.cxx
index 655d472f50e3..bdebf2516703 100644
--- a/chart2/source/view/diagram/VDiagram.cxx
+++ b/chart2/source/view/diagram/VDiagram.cxx
@@ -222,8 +222,7 @@ E3dScene* lcl_getE3dScene( const uno::Reference< drawing::XShape >& xShape )
if(pSvxShape)
{
SdrObject* pObj = pSvxShape->GetSdrObject();
- if( pObj && dynamic_cast< const E3dScene* >(pObj) != nullptr )
- pRet = static_cast<E3dScene*>(pObj);
+ pRet = dynamic_cast< E3dScene* >(pObj);
}
}
return pRet;
diff --git a/cui/source/tabpages/tplneend.cxx b/cui/source/tabpages/tplneend.cxx
index 89345008fda6..a94926300d8f 100644
--- a/cui/source/tabpages/tplneend.cxx
+++ b/cui/source/tabpages/tplneend.cxx
@@ -146,7 +146,7 @@ void SvxLineEndDefTabPage::Construct()
if( aInfoRec.bCanConvToPath )
pNewObj = pPolyObj->ConvertToPolyObj( true, false );
- bCreateArrowPossible = pNewObj && nullptr != dynamic_cast<const SdrPathObj*>( pNewObj);
+ bCreateArrowPossible = nullptr != dynamic_cast<const SdrPathObj*>( pNewObj);
SdrObject::Free( pNewObj );
}
diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx
index a4e43f03c9e3..80e0d65a9042 100644
--- a/oox/source/export/shapes.cxx
+++ b/oox/source/export/shapes.cxx
@@ -2092,7 +2092,7 @@ ShapeExport& ShapeExport::WriteOLE2Shape( const Reference< XShape >& xShape )
SdrObject* pSdrOLE2( GetSdrObjectFromXShape( xShape ) );
// The spec doesn't allow <p:pic> here, but PowerPoint requires it.
bool bEcma = mpFB->getVersion() == oox::core::ECMA_DIALECT;
- if (pSdrOLE2 && dynamic_cast<const SdrOle2Obj*>( pSdrOLE2) != nullptr && bEcma)
+ if (dynamic_cast<const SdrOle2Obj*>( pSdrOLE2) && bEcma)
{
const Graphic* pGraphic = static_cast<SdrOle2Obj*>(pSdrOLE2)->GetGraphic();
if (pGraphic)
diff --git a/sfx2/source/appl/appdde.cxx b/sfx2/source/appl/appdde.cxx
index 7a572c94236d..92021f283ec5 100644
--- a/sfx2/source/appl/appdde.cxx
+++ b/sfx2/source/appl/appdde.cxx
@@ -154,7 +154,7 @@ bool ImplDdeService::MakeTopic( const OUString& rNm )
SfxCallMode::SYNCHRON,
{ &aName, &aNewView, &aSilent });
- if( pRet && dynamic_cast< const SfxViewFrameItem *>( pRet ) != nullptr &&
+ if( dynamic_cast< const SfxViewFrameItem *>( pRet ) &&
static_cast<SfxViewFrameItem const *>(pRet)->GetFrame() &&
nullptr != ( pShell = static_cast<SfxViewFrameItem const *>(pRet)
->GetFrame()->GetObjectShell() ) )
diff --git a/starmath/source/edit.cxx b/starmath/source/edit.cxx
index cc77f688eefc..cb3b2853ee44 100644
--- a/starmath/source/edit.cxx
+++ b/starmath/source/edit.cxx
@@ -373,7 +373,7 @@ void SmEditWindow::KeyInput(const KeyEvent& rKEvt)
{
bool bCallBase = true;
SfxViewShell* pViewShell = GetView();
- if ( pViewShell && dynamic_cast<const SmViewShell *>(pViewShell) != nullptr )
+ if ( dynamic_cast<const SmViewShell *>(pViewShell) )
{
// Terminate possible InPlace mode
bCallBase = !pViewShell->Escape();
@@ -445,7 +445,7 @@ void SmEditWindow::KeyInput(const KeyEvent& rKEvt)
// SFX has maybe called a slot of the view and thus (because of a hack in SFX)
// set the focus to the view
SfxViewShell* pVShell = GetView();
- if ( pVShell && dynamic_cast<const SmViewShell *>(pVShell) != nullptr &&
+ if ( dynamic_cast<const SmViewShell *>(pVShell) &&
static_cast<SmViewShell*>(pVShell)->GetGraphicWindow().HasFocus() )
{
GrabFocus();
diff --git a/svl/source/items/itempool.cxx b/svl/source/items/itempool.cxx
index 76e9d90b485f..f90588288163 100644
--- a/svl/source/items/itempool.cxx
+++ b/svl/source/items/itempool.cxx
@@ -482,7 +482,7 @@ void SfxItemPool::Delete()
// from SfxItemPool
// This causes chaos in Itempool!
const SfxPoolItem* pStaticDefaultItem = (*pImpl->mpStaticDefaults)[n];
- if (pStaticDefaultItem && dynamic_cast<const SfxSetItem*>(pStaticDefaultItem) != nullptr)
+ if (dynamic_cast<const SfxSetItem*>(pStaticDefaultItem))
{
// SfxSetItem found, remove PoolItems (and defaults) with same ID
auto& rArrayPtr = pImpl->maPoolItems[n];
diff --git a/xmloff/source/draw/ximpshap.cxx b/xmloff/source/draw/ximpshap.cxx
index 137def939f91..c68be43fc9c9 100644
--- a/xmloff/source/draw/ximpshap.cxx
+++ b/xmloff/source/draw/ximpshap.cxx
@@ -620,7 +620,7 @@ void SdXMLShapeContext::SetStyle( bool bSupportsStyle /* = true */)
OUString aStyleName = maDrawStyleName;
uno::Reference< style::XStyle > xStyle;
- if( pStyle && dynamic_cast<const XMLShapeStyleContext*>( pStyle ) != nullptr)
+ if( dynamic_cast<const XMLShapeStyleContext*>( pStyle ) )
{
pDocStyle = const_cast<XMLShapeStyleContext*>(dynamic_cast<const XMLShapeStyleContext*>( pStyle ) );