Kaydet (Commit) d977e02e authored tarafından Noel Grandin's avatar Noel Grandin Kaydeden (comit) Noel Grandin

unnecessary null check before dynamic_cast, in various

Change-Id: I76ad0b3152030c29ee28f6a6cc80d0832188d02b
Reviewed-on: https://gerrit.libreoffice.org/58774
Tested-by: Jenkins
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst 76dd6bb9
......@@ -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 );
......
......@@ -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" );
......
......@@ -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 );
......
......@@ -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();
}
......
......@@ -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 );
......
......@@ -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 )
......
......@@ -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 )
......
......@@ -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;
}
......
......@@ -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;
......
......@@ -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 );
}
......
......@@ -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)
......
......@@ -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() ) )
......
......@@ -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();
......
......@@ -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];
......
......@@ -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 ) );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment