diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-12-21 13:29:14 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-12-21 13:43:06 +0100 |
commit | 26f46b861d8504033685b2eec4d003eef8109a27 (patch) | |
tree | d35bf900af9e17f0f7e17348c14aef9df74ef579 /basic | |
parent | ca28826a087245686d7fca3ffc8ca1f03307924d (diff) |
loplugin:flatten in accessibility..basic
Change-Id: If2cc282c2b135d634daf393a082c29049b10a677
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127223
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'basic')
-rw-r--r-- | basic/source/classes/sbxmod.cxx | 56 | ||||
-rw-r--r-- | basic/source/runtime/dllmgr-none.cxx | 41 | ||||
-rw-r--r-- | basic/source/runtime/runtime.cxx | 59 | ||||
-rw-r--r-- | basic/source/sbx/sbxvalue.cxx | 62 |
4 files changed, 108 insertions, 110 deletions
diff --git a/basic/source/classes/sbxmod.cxx b/basic/source/classes/sbxmod.cxx index cdd05c0c1f14..2d38de16dcfd 100644 --- a/basic/source/classes/sbxmod.cxx +++ b/basic/source/classes/sbxmod.cxx @@ -1596,38 +1596,38 @@ bool SbModule::LoadData( SvStream& rStrm, sal_uInt16 nVer ) SetFlag( SbxFlagBits::ExtSearch | SbxFlagBits::GlobalSearch ); sal_uInt8 bImage; rStrm.ReadUChar( bImage ); - if( bImage ) - { - std::unique_ptr<SbiImage> p(new SbiImage); - sal_uInt32 nImgVer = 0; + if( !bImage ) + return true; - if( !p->Load( rStrm, nImgVer ) ) - { - return false; - } - // If the image is in old format, we fix up the method start offsets - if ( nImgVer < B_EXT_IMG_VERSION ) - { - fixUpMethodStart( false, p.get() ); - p->ReleaseLegacyBuffer(); - } - aComment = p->aComment; - SetName( p->aName ); - if( p->GetCodeSize() ) - { - aOUSource = p->aOUSource; - // Old version: image away - if( nVer == 1 ) - { - SetSource32( p->aOUSource ); - } - else - pImage = std::move(p); - } - else + std::unique_ptr<SbiImage> p(new SbiImage); + sal_uInt32 nImgVer = 0; + + if( !p->Load( rStrm, nImgVer ) ) + { + return false; + } + // If the image is in old format, we fix up the method start offsets + if ( nImgVer < B_EXT_IMG_VERSION ) + { + fixUpMethodStart( false, p.get() ); + p->ReleaseLegacyBuffer(); + } + aComment = p->aComment; + SetName( p->aName ); + if( p->GetCodeSize() ) + { + aOUSource = p->aOUSource; + // Old version: image away + if( nVer == 1 ) { SetSource32( p->aOUSource ); } + else + pImage = std::move(p); + } + else + { + SetSource32( p->aOUSource ); } return true; } diff --git a/basic/source/runtime/dllmgr-none.cxx b/basic/source/runtime/dllmgr-none.cxx index 30070977d215..7d49ba1bdcdb 100644 --- a/basic/source/runtime/dllmgr-none.cxx +++ b/basic/source/runtime/dllmgr-none.cxx @@ -50,27 +50,26 @@ ErrCode returnInt64InOutArg(SbxArray *pArgs, SbxVariable &rRetVal, pOut->PutCurrency(nValue); return ERRCODE_NONE; } - if (pOut->IsObject()) - { - // FIXME: should we clone this and use pOut->PutObject ? - SbxObject* pObj = dynamic_cast<SbxObject*>( pOut->GetObject() ); - if (!pObj) - return ERRCODE_BASIC_BAD_ARGUMENT; - - // We expect two Longs but other mappings could be possible too. - SbxArray* pProps = pObj->GetProperties(); - if (pProps->Count() != 2) - return ERRCODE_BASIC_BAD_ARGUMENT; - SbxVariable* pLow = pProps->Get(0); - SbxVariable* pHigh = pProps->Get(1); - if (!pLow || !pLow->IsLong() || - !pHigh || !pHigh->IsLong()) - return ERRCODE_BASIC_BAD_ARGUMENT; - pLow->PutLong(nValue & 0xffffffff); - pHigh->PutLong(nValue >> 32); - return ERRCODE_NONE; - } - return ERRCODE_BASIC_BAD_ARGUMENT; + if (!pOut->IsObject()) + return ERRCODE_BASIC_BAD_ARGUMENT; + + // FIXME: should we clone this and use pOut->PutObject ? + SbxObject* pObj = dynamic_cast<SbxObject*>( pOut->GetObject() ); + if (!pObj) + return ERRCODE_BASIC_BAD_ARGUMENT; + + // We expect two Longs but other mappings could be possible too. + SbxArray* pProps = pObj->GetProperties(); + if (pProps->Count() != 2) + return ERRCODE_BASIC_BAD_ARGUMENT; + SbxVariable* pLow = pProps->Get(0); + SbxVariable* pHigh = pProps->Get(1); + if (!pLow || !pLow->IsLong() || + !pHigh || !pHigh->IsLong()) + return ERRCODE_BASIC_BAD_ARGUMENT; + pLow->PutLong(nValue & 0xffffffff); + pHigh->PutLong(nValue >> 32); + return ERRCODE_NONE; } ErrCode builtin_kernel32(std::u16string_view aFuncName, SbxArray *pArgs, diff --git a/basic/source/runtime/runtime.cxx b/basic/source/runtime/runtime.cxx index bad307f27dd6..afc785e76b32 100644 --- a/basic/source/runtime/runtime.cxx +++ b/basic/source/runtime/runtime.cxx @@ -1666,40 +1666,39 @@ static bool checkUnoStructCopy( bool bVBA, SbxVariableRef const & refVal, SbxVar aAny = pUnoVal ? pUnoVal->getUnoAny() : pUnoStructVal->getUnoAny(); else return false; - if ( aAny.getValueType().getTypeClass() == TypeClass_STRUCT ) - { - refVar->SetType( SbxOBJECT ); - ErrCode eOldErr = SbxBase::GetError(); - // There are some circumstances when calling GetObject - // will trigger an error, we need to squash those here. - // Alternatively it is possible that the same scenario - // could overwrite and existing error. Lets prevent that - SbxObjectRef xVarObj = static_cast<SbxObject*>(refVar->GetObject()); - if ( eOldErr != ERRCODE_NONE ) - SbxBase::SetError( eOldErr ); - else - SbxBase::ResetError(); + if ( aAny.getValueType().getTypeClass() != TypeClass_STRUCT ) + return false; - SbUnoStructRefObject* pUnoStructObj = dynamic_cast<SbUnoStructRefObject*>( xVarObj.get() ); + refVar->SetType( SbxOBJECT ); + ErrCode eOldErr = SbxBase::GetError(); + // There are some circumstances when calling GetObject + // will trigger an error, we need to squash those here. + // Alternatively it is possible that the same scenario + // could overwrite and existing error. Lets prevent that + SbxObjectRef xVarObj = static_cast<SbxObject*>(refVar->GetObject()); + if ( eOldErr != ERRCODE_NONE ) + SbxBase::SetError( eOldErr ); + else + SbxBase::ResetError(); - OUString sClassName = pUnoVal ? pUnoVal->GetClassName() : pUnoStructVal->GetClassName(); - OUString sName = pUnoVal ? pUnoVal->GetName() : pUnoStructVal->GetName(); + SbUnoStructRefObject* pUnoStructObj = dynamic_cast<SbUnoStructRefObject*>( xVarObj.get() ); - if ( pUnoStructObj ) - { - StructRefInfo aInfo = pUnoStructObj->getStructInfo(); - aInfo.setValue( aAny ); - } - else - { - SbUnoObject* pNewUnoObj = new SbUnoObject( sName, aAny ); - // #70324: adopt ClassName - pNewUnoObj->SetClassName( sClassName ); - refVar->PutObject( pNewUnoObj ); - } - return true; + OUString sClassName = pUnoVal ? pUnoVal->GetClassName() : pUnoStructVal->GetClassName(); + OUString sName = pUnoVal ? pUnoVal->GetName() : pUnoStructVal->GetName(); + + if ( pUnoStructObj ) + { + StructRefInfo aInfo = pUnoStructObj->getStructInfo(); + aInfo.setValue( aAny ); } - return false; + else + { + SbUnoObject* pNewUnoObj = new SbUnoObject( sName, aAny ); + // #70324: adopt ClassName + pNewUnoObj->SetClassName( sClassName ); + refVar->PutObject( pNewUnoObj ); + } + return true; } diff --git a/basic/source/sbx/sbxvalue.cxx b/basic/source/sbx/sbxvalue.cxx index fe7245a6da76..10396c3e5eb9 100644 --- a/basic/source/sbx/sbxvalue.cxx +++ b/basic/source/sbx/sbxvalue.cxx @@ -687,40 +687,40 @@ bool SbxValue::SetType( SbxDataType t ) } t = SbxEMPTY; } - if( ( t & 0x0FFF ) != ( aData.eType & 0x0FFF ) ) + if( ( t & 0x0FFF ) == ( aData.eType & 0x0FFF ) ) + return true; + + if( !CanWrite() || IsFixed() ) { - if( !CanWrite() || IsFixed() ) - { - SetError( ERRCODE_BASIC_CONVERSION ); - return false; - } - else + SetError( ERRCODE_BASIC_CONVERSION ); + return false; + } + else + { + // De-allocate potential objects + switch( aData.eType ) { - // De-allocate potential objects - switch( aData.eType ) - { - case SbxSTRING: - delete aData.pOUString; - break; - case SbxOBJECT: - if( aData.pObj && aData.pObj != this ) - { - SAL_WARN("basic.sbx", "Not at Parent-Prop - otherwise CyclicRef"); - SbxVariable *pThisVar = dynamic_cast<SbxVariable*>( this ); - sal_uInt32 nSlotId = pThisVar - ? pThisVar->GetUserData() & 0xFFFF - : 0; - DBG_ASSERT( nSlotId != 5345 || pThisVar->GetName() == "Parent", - "SID_PARENTOBJECT is not named 'Parent'" ); - bool bParentProp = nSlotId == 5345; - if ( !bParentProp ) - aData.pObj->ReleaseRef(); - } - break; - default: break; - } - aData.clear(t); + case SbxSTRING: + delete aData.pOUString; + break; + case SbxOBJECT: + if( aData.pObj && aData.pObj != this ) + { + SAL_WARN("basic.sbx", "Not at Parent-Prop - otherwise CyclicRef"); + SbxVariable *pThisVar = dynamic_cast<SbxVariable*>( this ); + sal_uInt32 nSlotId = pThisVar + ? pThisVar->GetUserData() & 0xFFFF + : 0; + DBG_ASSERT( nSlotId != 5345 || pThisVar->GetName() == "Parent", + "SID_PARENTOBJECT is not named 'Parent'" ); + bool bParentProp = nSlotId == 5345; + if ( !bParentProp ) + aData.pObj->ReleaseRef(); + } + break; + default: break; } + aData.clear(t); } return true; } |