diff options
author | Jacek Fraczek <fraczek.jacek@gmail.com> | 2016-10-05 22:00:51 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2016-10-10 08:48:30 +0000 |
commit | f004aa99514d385f3ee254bba735f5eaeb7d9ad8 (patch) | |
tree | aacd5792f553b8e9cbf029cc7e0797ed0dd423fe /basic/source/classes | |
parent | 728c7327bd97602a38723553ed044ea4c01d13b2 (diff) |
tdf#89307: Removed SvRef::operator T*()
Conditional statements are using SvRef::Is() method.
Changed static_cast<T*>(svRef<T>) occurances to svRef.get().
Added operator == and != to SvRef.
SbxObject::Execute is using SbxVariableRef internally.
SbxObject::FindQualified is using SbxVariableRef internally.
Change-Id: I45b553e35d8fca9bf71163e6eefc60802a066395
Reviewed-on: https://gerrit.libreoffice.org/29621
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'basic/source/classes')
-rw-r--r-- | basic/source/classes/errobject.cxx | 3 | ||||
-rw-r--r-- | basic/source/classes/eventatt.cxx | 21 | ||||
-rw-r--r-- | basic/source/classes/image.cxx | 2 | ||||
-rw-r--r-- | basic/source/classes/sb.cxx | 23 | ||||
-rw-r--r-- | basic/source/classes/sbunoobj.cxx | 154 | ||||
-rw-r--r-- | basic/source/classes/sbxmod.cxx | 54 |
6 files changed, 128 insertions, 129 deletions
diff --git a/basic/source/classes/errobject.cxx b/basic/source/classes/errobject.cxx index 23914649a187..ddeb1aee585b 100644 --- a/basic/source/classes/errobject.cxx +++ b/basic/source/classes/errobject.cxx @@ -192,8 +192,7 @@ SbxErrObject::~SbxErrObject() uno::Reference< vba::XErrObject > const & SbxErrObject::getUnoErrObject() { - SbxVariable* pVar = getErrObject(); - SbxErrObject* pGlobErr = static_cast< SbxErrObject* >( pVar ); + SbxErrObject* pGlobErr = static_cast< SbxErrObject* >( getErrObject().get() ); return pGlobErr->m_xErr; } diff --git a/basic/source/classes/eventatt.cxx b/basic/source/classes/eventatt.cxx index c89e3523f9a7..a90adf8bd385 100644 --- a/basic/source/classes/eventatt.cxx +++ b/basic/source/classes/eventatt.cxx @@ -208,7 +208,7 @@ void BasicScriptListener_Impl::firing_impl( const ScriptEvent& aScriptEvent, Any aMacro = aMacro.copy( nLast ); } - SbxObject* p = maBasicRef; + SbxObject* p = maBasicRef.get(); SbxObject* pParent = p->GetParent(); SbxObject* pParentParent = pParent ? pParent->GetParent() : nullptr; @@ -253,14 +253,13 @@ void BasicScriptListener_Impl::firing_impl( const ScriptEvent& aScriptEvent, Any // Be still tolerant and make default search if no search basic exists if( bSearchLib && xLibSearchBasic.Is() ) { - StarBASICRef xLibBasic; sal_Int16 nCount = xLibSearchBasic->GetObjects()->Count(); for( sal_Int16 nObj = -1; nObj < nCount ; nObj++ ) { StarBASIC* pBasic; if( nObj == -1 ) { - pBasic = static_cast<StarBASIC*>(xLibSearchBasic); + pBasic = xLibSearchBasic.get(); } else { @@ -303,8 +302,8 @@ void BasicScriptListener_Impl::firing_impl( const ScriptEvent& aScriptEvent, Any for( sal_Int32 i = 0; i < nCnt; i++ ) { SbxVariableRef xVar = new SbxVariable( SbxVARIANT ); - unoToSbxValue( static_cast<SbxVariable*>(xVar), pArgs[i] ); - xArray->Put( xVar, sal::static_int_cast< sal_uInt16 >(i+1) ); + unoToSbxValue( xVar.get(), pArgs[i] ); + xArray->Put( xVar.get(), sal::static_int_cast< sal_uInt16 >(i+1) ); } } @@ -312,12 +311,12 @@ void BasicScriptListener_Impl::firing_impl( const ScriptEvent& aScriptEvent, Any SbxVariableRef xValue = pRet ? new SbxVariable : nullptr; if( xArray.Is() ) { - pMeth->SetParameters( xArray ); + pMeth->SetParameters( xArray.get() ); } - pMeth->Call( xValue ); + pMeth->Call( xValue.get() ); if( pRet ) { - *pRet = sbxToUnoValue( xValue ); + *pRet = sbxToUnoValue( xValue.get() ); } pMeth->SetParameters( nullptr ); } @@ -432,12 +431,12 @@ void RTL_Impl_CreateUnoDialog( StarBASIC* pBasic, SbxArray& rPar, bool bWrite ) // Get dialog SbxBaseRef pObj = rPar.Get( 1 )->GetObject(); - if( !(pObj && nullptr != dynamic_cast<const SbUnoObject*>( &pObj )) ) + if( !(pObj.Is() && nullptr != dynamic_cast<const SbUnoObject*>( &pObj )) ) { StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT ); return; } - SbUnoObject* pUnoObj = static_cast<SbUnoObject*>(static_cast<SbxBase*>(pObj)); + SbUnoObject* pUnoObj = static_cast<SbUnoObject*>(pObj.get()); Any aAnyISP = pUnoObj->getUnoAny(); TypeClass eType = aAnyISP.getValueType().getTypeClass(); @@ -556,7 +555,7 @@ void RTL_Impl_CreateUnoDialog( StarBASIC* pBasic, SbxArray& rPar, bool bWrite ) Any aRetVal; aRetVal <<= xCntrl; SbxVariableRef refVar = rPar.Get(0); - unoToSbxValue( static_cast<SbxVariable*>(refVar), aRetVal ); + unoToSbxValue( refVar.get(), aRetVal ); } diff --git a/basic/source/classes/image.cxx b/basic/source/classes/image.cxx index 05ec8a2f8f8e..7c079a8b531c 100644 --- a/basic/source/classes/image.cxx +++ b/basic/source/classes/image.cxx @@ -462,7 +462,7 @@ bool SbiImage::Save( SvStream& r, sal_uInt32 nVer ) SbiCloseRecord( r, nPos ); } // User defined types - if (rTypes) + if ( rTypes.Is() ) { sal_uInt16 nTypes = rTypes->Count(); if (nTypes > 0 ) diff --git a/basic/source/classes/sb.cxx b/basic/source/classes/sb.cxx index b47c3a864104..704169bac8b8 100644 --- a/basic/source/classes/sb.cxx +++ b/basic/source/classes/sb.cxx @@ -232,7 +232,7 @@ StarBASIC* lclGetDocBasicForModule( SbModule* pModule ) SbxObject* StarBASIC::getVBAGlobals( ) { - if ( !pVBAGlobals ) + if ( !pVBAGlobals.Is() ) { Any aThisDoc; if ( GetUNOConstant("ThisComponent", aThisDoc) ) @@ -253,7 +253,7 @@ SbxObject* StarBASIC::getVBAGlobals( ) const OUString aVBAHook("VBAGlobals"); pVBAGlobals = static_cast<SbUnoObject*>(Find( aVBAHook , SbxClassType::DontCare )); } - return pVBAGlobals; + return pVBAGlobals.get(); } // i#i68894# @@ -641,7 +641,7 @@ SbClassModuleObject::SbClassModuleObject( SbModule* pClassModule ) ResetFlag( SbxFlagBits::GlobalSearch ); // Copy the methods from original class module - SbxArray* pClassMethods = pClassModule->GetMethods(); + SbxArray* pClassMethods = pClassModule->GetMethods().get(); sal_uInt32 nMethodCount = pClassMethods->Count32(); sal_uInt32 i; for( i = 0 ; i < nMethodCount ; i++ ) @@ -1098,11 +1098,12 @@ void StarBASIC::Insert( SbxVariable* pVar ) void StarBASIC::Remove( SbxVariable* pVar ) { - if( dynamic_cast<const SbModule*>(pVar) != nullptr) + SbModule* pModule = dynamic_cast<SbModule*>(pVar); + if( pModule ) { // #87540 Can be last reference! - SbxVariableRef xVar = pVar; - pModules.erase(std::remove(pModules.begin(), pModules.end(), pVar)); + SbModuleRef xVar = pModule; + pModules.erase(std::remove(pModules.begin(), pModules.end(), xVar)); pVar->SetParent( nullptr ); EndListening( pVar->GetBroadcaster() ); } @@ -1290,12 +1291,12 @@ SbxVariable* StarBASIC::Find( const OUString& rName, SbxClassType t ) { if( rName.equalsIgnoreAsciiCase( RTLNAME ) ) { - pRes = pRtl; + pRes = pRtl.get(); } } if( !pRes ) { - pRes = static_cast<SbiStdObject*>(static_cast<SbxObject*>(pRtl))->Find( rName, t ); + pRes = static_cast<SbiStdObject*>(pRtl.get())->Find( rName, t ); } if( pRes ) { @@ -2106,12 +2107,12 @@ void BasicCollection::Notify( SfxBroadcaster& rCst, const SfxHint& rHint ) if( pVar->GetHashCode() == nAddHash && aVarName.equalsIgnoreAsciiCase( pAddStr ) ) { - pVar->SetInfo( xAddInfo ); + pVar->SetInfo( xAddInfo.get() ); } else if( pVar->GetHashCode() == nItemHash && aVarName.equalsIgnoreAsciiCase( pItemStr ) ) { - pVar->SetInfo( xItemInfo ); + pVar->SetInfo( xItemInfo.get() ); } } } @@ -2219,7 +2220,7 @@ void BasicCollection::CollAdd( SbxArray* pPar_ ) } } pNewItem->SetFlag( SbxFlagBits::ReadWrite ); - xItemArray->Insert32( pNewItem, nNextIndex ); + xItemArray->Insert32( pNewItem.get(), nNextIndex ); } else { diff --git a/basic/source/classes/sbunoobj.cxx b/basic/source/classes/sbunoobj.cxx index 8d24420bdd4d..561767afe199 100644 --- a/basic/source/classes/sbunoobj.cxx +++ b/basic/source/classes/sbunoobj.cxx @@ -473,7 +473,7 @@ static SbxObject* lcl_getNativeObject( sal_uInt32 nIndex ) ObjectItem& rItem = rNativeObjectWrapperVector[ nIndex ]; xRetObj = rItem.m_xNativeObj; } - return xRetObj; + return xRetObj.get(); } // convert from Uno to Sbx @@ -632,7 +632,7 @@ void unoToSbxValue( SbxVariable* pVar, const Any& aValue ) } else { - pVar->PutObject( xWrapper ); + pVar->PutObject( xWrapper.get() ); } } break; @@ -657,7 +657,7 @@ void unoToSbxValue( SbxVariable* pVar, const Any& aValue ) SbxDimArrayRef xArray = pArray; SbxFlagBits nFlags = pVar->GetFlags(); pVar->ResetFlag( SbxFlagBits::Fixed ); - pVar->PutObject( static_cast<SbxDimArray*>(xArray) ); + pVar->PutObject( xArray.get() ); pVar->SetFlags( nFlags ); } else @@ -733,7 +733,7 @@ void unoToSbxValue( SbxVariable* pVar, const Any& aValue ) } else { - pVar->PutObject( xWrapper ); + pVar->PutObject( xWrapper.get() ); } } break; @@ -787,7 +787,7 @@ void unoToSbxValue( SbxVariable* pVar, const Any& aValue ) // return the Array SbxFlagBits nFlags = pVar->GetFlags(); pVar->ResetFlag( SbxFlagBits::Fixed ); - pVar->PutObject( static_cast<SbxDimArray*>(xArray) ); + pVar->PutObject( xArray.get() ); pVar->SetFlags( nFlags ); } @@ -862,7 +862,7 @@ Type getUnoTypeForSbxValue( const SbxValue* pVal ) if( eBaseType == SbxOBJECT ) { SbxBaseRef xObj = pVal->GetObject(); - if( !xObj ) + if( !xObj.Is() ) { aRetType = cppu::UnoType<XInterface>::get(); return aRetType; @@ -870,7 +870,7 @@ Type getUnoTypeForSbxValue( const SbxValue* pVal ) if( nullptr != dynamic_cast<const SbxDimArray*>( &xObj) ) { - SbxBase* pObj = static_cast<SbxBase*>(xObj); + SbxBase* pObj = xObj.get(); SbxDimArray* pArray = static_cast<SbxDimArray*>(pObj); short nDims = pArray->GetDims(); @@ -964,12 +964,12 @@ Type getUnoTypeForSbxValue( const SbxValue* pVal ) // No array, but ... else if( nullptr != dynamic_cast<const SbUnoObject*>( &xObj) ) { - aRetType = static_cast<SbUnoObject*>(static_cast<SbxBase*>(xObj))->getUnoAny().getValueType(); + aRetType = static_cast<SbUnoObject*>(xObj.get())->getUnoAny().getValueType(); } // SbUnoAnyObject? else if( nullptr != dynamic_cast<const SbUnoAnyObject*>( &xObj) ) { - aRetType = static_cast<SbUnoAnyObject*>(static_cast<SbxBase*>(xObj))->getValue().getValueType(); + aRetType = static_cast<SbUnoAnyObject*>(xObj.get())->getValue().getValueType(); } // Otherwise it is a No-Uno-Basic-Object -> default==deliver void } @@ -991,11 +991,11 @@ Any sbxToUnoValueImpl( const SbxValue* pVar, bool bBlockConversionToSmallestType if( xObj.Is() ) { if( nullptr != dynamic_cast<const SbUnoAnyObject*>( &xObj) ) - return static_cast<SbUnoAnyObject*>(static_cast<SbxBase*>(xObj))->getValue(); + return static_cast<SbUnoAnyObject*>(xObj.get())->getValue(); if( nullptr != dynamic_cast<const SbClassModuleObject*>( &xObj) ) { Any aRetAny; - SbClassModuleObject* pClassModuleObj = static_cast<SbClassModuleObject*>(static_cast<SbxBase*>(xObj)); + SbClassModuleObject* pClassModuleObj = static_cast<SbClassModuleObject*>(xObj.get()); SbModule* pClassModule = pClassModuleObj->getClassModule(); if( pClassModule->createCOMWrapperForIface( aRetAny, pClassModuleObj ) ) return aRetAny; @@ -1191,7 +1191,7 @@ Any sbxToUnoValue( const SbxValue* pVar, const Type& rType, Property* pUnoProper SbxBaseRef xObj = pVar->GetObject(); if( xObj.Is() && nullptr != dynamic_cast<const SbUnoAnyObject*>( &xObj) ) { - return static_cast<SbUnoAnyObject*>(static_cast<SbxBase*>(xObj))->getValue(); + return static_cast<SbUnoAnyObject*>(xObj.get())->getValue(); } } @@ -1244,13 +1244,13 @@ Any sbxToUnoValue( const SbxValue* pVar, const Type& rType, Property* pUnoProper } SbxBaseRef pObj = pVar->GetObject(); - if( pObj && nullptr != dynamic_cast<const SbUnoObject*>( &pObj) ) + if( pObj.Is() && nullptr != dynamic_cast<const SbUnoObject*>( &pObj) ) { - aRetVal = static_cast<SbUnoObject*>(static_cast<SbxBase*>(pObj))->getUnoAny(); + aRetVal = static_cast<SbUnoObject*>(pObj.get())->getUnoAny(); } - else if( pObj && nullptr != dynamic_cast<const SbUnoStructRefObject*>( &pObj) ) + else if( pObj.Is() && nullptr != dynamic_cast<const SbUnoStructRefObject*>( &pObj) ) { - aRetVal = static_cast<SbUnoStructRefObject*>(static_cast<SbxBase*>(pObj))->getUnoAny(); + aRetVal = static_cast<SbUnoStructRefObject*>(pObj.get())->getUnoAny(); } else { @@ -1270,9 +1270,9 @@ Any sbxToUnoValue( const SbxValue* pVar, const Type& rType, Property* pUnoProper Reference< XIdlClass > xIdlClass; SbxBaseRef pObj = pVar->GetObject(); - if( pObj && nullptr != dynamic_cast<const SbUnoObject*>( &pObj) ) + if( pObj.Is() && nullptr != dynamic_cast<const SbUnoObject*>( &pObj) ) { - Any aUnoAny = static_cast<SbUnoObject*>(static_cast<SbxBase*>(pObj))->getUnoAny(); + Any aUnoAny = static_cast<SbUnoObject*>( pObj.get() )->getUnoAny(); aUnoAny >>= xIdlClass; } @@ -1306,9 +1306,9 @@ Any sbxToUnoValue( const SbxValue* pVar, const Type& rType, Property* pUnoProper case TypeClass_SEQUENCE: { SbxBaseRef xObj = pVar->GetObject(); - if( xObj && nullptr != dynamic_cast<const SbxDimArray*>( &xObj) ) + if( xObj.Is() && nullptr != dynamic_cast<const SbxDimArray*>( &xObj) ) { - SbxBase* pObj = static_cast<SbxBase*>(xObj); + SbxBase* pObj = xObj.get(); SbxDimArray* pArray = static_cast<SbxDimArray*>(pObj); short nDims = pArray->GetDims(); @@ -2055,7 +2055,7 @@ void SbUnoObject::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) { SbUnoStructRefObject* pSbUnoObject = new SbUnoStructRefObject( pProp->GetName(), aMember ); SbxObjectRef xWrapper = static_cast<SbxObject*>(pSbUnoObject); - pVar->PutObject( xWrapper ); + pVar->PutObject( xWrapper.get() ); } else { @@ -2532,7 +2532,7 @@ SbUnoMethod::~SbUnoMethod() SbxInfo* SbUnoMethod::GetInfo() { - if( !pInfo && m_xUnoMethod.is() ) + if( !pInfo.Is() && m_xUnoMethod.is() ) { SbiInstance* pInst = GetSbData()->pInst; if( pInst && pInst->IsCompatibility() ) @@ -2554,7 +2554,7 @@ SbxInfo* SbUnoMethod::GetInfo() } } } - return pInfo; + return pInfo.get(); } const Sequence<ParamInfo>& SbUnoMethod::getParamInfos() @@ -2589,7 +2589,7 @@ SbUnoProperty::SbUnoProperty // as needed establish an dummy array so that SbiRuntime::CheckArray() works static SbxArrayRef xDummyArray = new SbxArray( SbxVARIANT ); if( eSbxType & SbxARRAY ) - PutObject( xDummyArray ); + PutObject( xDummyArray.get() ); } SbUnoProperty::~SbUnoProperty() @@ -2637,7 +2637,7 @@ SbxVariable* SbUnoObject::Find( const OUString& rName, SbxClassType t ) // create the property and superimpose it auto pProp = tools::make_ref<SbUnoProperty>( rProp.Name, eSbxType, eRealSbxType, rProp, 0, false, ( rProp.Type.getTypeClass() == css::uno::TypeClass_STRUCT ) ); QuickInsert( pProp.get() ); - pRes = pProp; + pRes = pProp.get(); } else if( mxUnoAccess->hasMethod( aUName, MethodConcept::ALL - MethodConcept::DANGEROUS ) ) @@ -2650,7 +2650,7 @@ SbxVariable* SbUnoObject::Find( const OUString& rName, SbxClassType t ) auto xMethRef = tools::make_ref<SbUnoMethod>( rxMethod->getName(), unoToSbxType( rxMethod->getReturnType() ), rxMethod, false ); QuickInsert( xMethRef.get() ); - pRes = xMethRef; + pRes = xMethRef.get(); } // If nothing was found check via XNameAccess @@ -2707,14 +2707,14 @@ SbxVariable* SbUnoObject::Find( const OUString& rName, SbxClassType t ) // create a property and superimpose it auto xVarRef = tools::make_ref<SbUnoProperty>( aUName, SbxVARIANT, SbxVARIANT, aDummyProp, 0, true, false ); QuickInsert( xVarRef.get() ); - pRes = xVarRef; + pRes = xVarRef.get(); } else if( mxInvocation->hasMethod( aUName ) ) { // create SbUnoMethode and superimpose it auto xMethRef = tools::make_ref<SbUnoMethod>( aUName, SbxVARIANT, xDummyMethod, true ); QuickInsert( xMethRef.get() ); - pRes = xMethRef; + pRes = xMethRef.get(); } else { @@ -2723,7 +2723,7 @@ SbxVariable* SbUnoObject::Find( const OUString& rName, SbxClassType t ) { auto xMethRef = tools::make_ref<SbUnoMethod>( aUName, SbxVARIANT, xDummyMethod, true ); QuickInsert( xMethRef.get() ); - pRes = xMethRef; + pRes = xMethRef.get(); } } @@ -2941,7 +2941,7 @@ void RTL_Impl_CreateUnoStruct( StarBASIC* pBasic, SbxArray& rPar, bool bWrite ) // try to create Struct with the same name SbUnoObjectRef xUnoObj = Impl_CreateUnoStruct( aClassName ); - if( !xUnoObj ) + if( !xUnoObj.Is() ) { return; } @@ -2985,7 +2985,7 @@ void RTL_Impl_CreateUnoService( StarBASIC* pBasic, SbxArray& rPar, bool bWrite ) if( xUnoObj->getUnoAny().hasValue() ) { // return the object - refVar->PutObject( static_cast<SbUnoObject*>(xUnoObj) ); + refVar->PutObject( xUnoObj.get() ); } else { @@ -3037,7 +3037,7 @@ void RTL_Impl_CreateUnoServiceWithArguments( StarBASIC* pBasic, SbxArray& rPar, if( xUnoObj->getUnoAny().hasValue() ) { // return the object - refVar->PutObject( static_cast<SbUnoObject*>(xUnoObj) ); + refVar->PutObject( xUnoObj.get() ); } else { @@ -3062,7 +3062,7 @@ void RTL_Impl_GetProcessServiceManager( StarBASIC* pBasic, SbxArray& rPar, bool // Create a SbUnoObject out of it and return it SbUnoObjectRef xUnoObj = new SbUnoObject( OUString( "ProcessServiceManager" ), Any(xFactory) ); - refVar->PutObject( static_cast<SbUnoObject*>(xUnoObj) ); + refVar->PutObject( xUnoObj.get() ); } void RTL_Impl_HasInterfaces( StarBASIC* pBasic, SbxArray& rPar, bool bWrite ) @@ -3084,11 +3084,11 @@ void RTL_Impl_HasInterfaces( StarBASIC* pBasic, SbxArray& rPar, bool bWrite ) // get the Uno-Object SbxBaseRef pObj = rPar.Get( 1 )->GetObject(); - if( !(pObj && nullptr != dynamic_cast<const SbUnoObject*>( &pObj)) ) + if( !(pObj.Is() && nullptr != dynamic_cast<const SbUnoObject*>( &pObj)) ) { return; } - Any aAny = static_cast<SbUnoObject*>(static_cast<SbxBase*>(pObj))->getUnoAny(); + Any aAny = static_cast<SbUnoObject*>(pObj.get())->getUnoAny(); auto x = o3tl::tryAccess<Reference<XInterface>>(aAny); if( !x ) { @@ -3148,11 +3148,11 @@ void RTL_Impl_IsUnoStruct( StarBASIC* pBasic, SbxArray& rPar, bool bWrite ) return; } SbxBaseRef pObj = rPar.Get( 1 )->GetObject(); - if( !(pObj && nullptr != dynamic_cast<const SbUnoObject*>( &pObj)) ) + if( !(pObj.Is() && nullptr != dynamic_cast<const SbUnoObject*>( &pObj)) ) { return; } - Any aAny = static_cast<SbUnoObject*>(static_cast<SbxBase*>(pObj))->getUnoAny(); + Any aAny = static_cast<SbUnoObject*>(pObj.get())->getUnoAny(); TypeClass eType = aAny.getValueType().getTypeClass(); if( eType == TypeClass_STRUCT ) { @@ -3183,11 +3183,11 @@ void RTL_Impl_EqualUnoObjects( StarBASIC* pBasic, SbxArray& rPar, bool bWrite ) return; } SbxBaseRef pObj1 = xParam1->GetObject(); - if( !(pObj1 && nullptr != dynamic_cast<const SbUnoObject*>( &pObj1 )) ) + if( !(pObj1.Is() && nullptr != dynamic_cast<const SbUnoObject*>( &pObj1 )) ) { return; } - Any aAny1 = static_cast<SbUnoObject*>(static_cast<SbxBase*>(pObj1))->getUnoAny(); + Any aAny1 = static_cast<SbUnoObject*>(pObj1.get())->getUnoAny(); TypeClass eType1 = aAny1.getValueType().getTypeClass(); if( eType1 != TypeClass_INTERFACE ) { @@ -3202,11 +3202,11 @@ void RTL_Impl_EqualUnoObjects( StarBASIC* pBasic, SbxArray& rPar, bool bWrite ) return; } SbxBaseRef pObj2 = xParam2->GetObject(); - if( !(pObj2 && nullptr != dynamic_cast<const SbUnoObject*>( &pObj2 )) ) + if( !(pObj2.Is() && nullptr != dynamic_cast<const SbUnoObject*>( &pObj2 )) ) { return; } - Any aAny2 = static_cast<SbUnoObject*>(static_cast<SbxBase*>(pObj2))->getUnoAny(); + Any aAny2 = static_cast<SbUnoObject*>(pObj2.get())->getUnoAny(); TypeClass eType2 = aAny2.getValueType().getTypeClass(); if( eType2 != TypeClass_INTERFACE ) { @@ -3421,7 +3421,7 @@ SbxVariable* SbUnoClass::Find( const OUString& rName, SbxClassType ) { pRes = new SbxVariable( SbxVARIANT ); SbxObjectRef xWrapper = static_cast<SbxObject*>(new SbUnoClass( aNewName, xClass )); - pRes->PutObject( xWrapper ); + pRes->PutObject( xWrapper.get() ); } } else @@ -3443,7 +3443,7 @@ SbxVariable* SbUnoClass::Find( const OUString& rName, SbxClassType ) { pRes = new SbxVariable( SbxVARIANT ); SbxObjectRef xWrapper = static_cast<SbxObject*>(pNewClass); - pRes->PutObject( xWrapper ); + pRes->PutObject( xWrapper.get() ); } } @@ -3455,7 +3455,7 @@ SbxVariable* SbUnoClass::Find( const OUString& rName, SbxClassType ) { pRes = new SbxVariable( SbxVARIANT ); SbxObjectRef xWrapper = static_cast<SbxObject*>(pUnoService); - pRes->PutObject( xWrapper ); + pRes->PutObject( xWrapper.get() ); } } @@ -3467,7 +3467,7 @@ SbxVariable* SbUnoClass::Find( const OUString& rName, SbxClassType ) { pRes = new SbxVariable( SbxVARIANT ); SbxObjectRef xWrapper = static_cast<SbxObject*>(pUnoSingleton); - pRes->PutObject( xWrapper ); + pRes->PutObject( xWrapper.get() ); } } } @@ -3546,7 +3546,7 @@ SbxVariable* SbUnoService::Find( const OUString& rName, SbxClassType ) { // Create and insert SbUnoServiceCtor SbxVariableRef xSbCtorRef = new SbUnoServiceCtor( aName, xCtor ); - QuickInsert( static_cast<SbxVariable*>(xSbCtorRef) ); + QuickInsert( xSbCtorRef.get() ); } } pRes = SbxObject::Find( rName, SbxClassType::Method ); @@ -3766,7 +3766,7 @@ SbUnoSingleton::SbUnoSingleton( const OUString& aName_ ) : SbxObject( aName_ ) { SbxVariableRef xGetMethodRef = new SbxMethod( OUString( "get" ), SbxOBJECT ); - QuickInsert( static_cast<SbxVariable*>(xGetMethodRef) ); + QuickInsert( xGetMethodRef.get() ); } void SbUnoSingleton::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) @@ -3861,7 +3861,7 @@ void BasicAllListener_Impl::firing_impl( const AllEventObject& Event, Any* pRet OUString aMethodName = aPrefixName; aMethodName = aMethodName + Event.MethodName; - SbxVariable * pP = xSbxObj; + SbxVariable * pP = xSbxObj.get(); while( pP->GetParent() ) { pP = pP->GetParent(); @@ -3876,11 +3876,11 @@ void BasicAllListener_Impl::firing_impl( const AllEventObject& Event, Any* pRet { // Convert elements SbxVariableRef xVar = new SbxVariable( SbxVARIANT ); - unoToSbxValue( static_cast<SbxVariable*>(xVar), pArgs[i] ); - xSbxArray->Put( xVar, sal::static_int_cast< sal_uInt16 >(i+1) ); + unoToSbxValue( xVar.get(), pArgs[i] ); + xSbxArray->Put( xVar.get(), sal::static_int_cast< sal_uInt16 >(i+1) ); } - pLib->Call( aMethodName, xSbxArray ); + pLib->Call( aMethodName, xSbxArray.get() ); // get the return value from the Param-Array, if requested if( pRet ) @@ -4138,7 +4138,7 @@ void SbRtl_CreateUnoListener( StarBASIC* pBasic, SbxArray& rPar, bool bWrite ) // return the object SbxVariableRef refVar = rPar.Get(0); - refVar->PutObject( p->xSbxObj ); + refVar->PutObject( p->xSbxObj.get() ); } @@ -4154,7 +4154,7 @@ void RTL_Impl_GetDefaultContext( StarBASIC* pBasic, SbxArray& rPar, bool bWrite Any aContextAny( comphelper::getProcessComponentContext() ); SbUnoObjectRef xUnoObj = new SbUnoObject( OUString( "DefaultContext" ), aContextAny ); - refVar->PutObject( static_cast<SbUnoObject*>(xUnoObj) ); + refVar->PutObject( xUnoObj.get() ); } @@ -4192,9 +4192,9 @@ void RTL_Impl_CreateUnoValue( StarBASIC* pBasic, SbxArray& rPar, bool bWrite ) Reference< XIdlClass > xIdlClass; SbxBaseRef pObj = pVal->GetObject(); - if( pObj && nullptr != dynamic_cast<const SbUnoObject*>( &pObj) ) + if( pObj.Is() && nullptr != dynamic_cast<const SbUnoObject*>( &pObj) ) { - Any aUnoAny = static_cast<SbUnoObject*>(static_cast<SbxBase*>(pObj))->getUnoAny(); + Any aUnoAny = static_cast<SbUnoObject*>(pObj.get())->getUnoAny(); aUnoAny >>= xIdlClass; } @@ -4210,7 +4210,7 @@ void RTL_Impl_CreateUnoValue( StarBASIC* pBasic, SbxArray& rPar, bool bWrite ) Any aTypeAny( aType ); SbxVariableRef refVar = rPar.Get(0); SbxObjectRef xUnoAnyObject = new SbUnoAnyObject( aTypeAny ); - refVar->PutObject( xUnoAnyObject ); + refVar->PutObject( xUnoAnyObject.get() ); } return; } @@ -4240,7 +4240,7 @@ void RTL_Impl_CreateUnoValue( StarBASIC* pBasic, SbxArray& rPar, bool bWrite ) SbxVariableRef refVar = rPar.Get(0); SbxObjectRef xUnoAnyObject = new SbUnoAnyObject( aConvertedVal ); - refVar->PutObject( xUnoAnyObject ); + refVar->PutObject( xUnoAnyObject.get() ); } @@ -4318,13 +4318,13 @@ void SAL_CALL ModuleInvocationProxy::setValue(const OUString& rProperty, const A // Setup parameter SbxArrayRef xArray = new SbxArray; SbxVariableRef xVar = new SbxVariable( SbxVARIANT ); - unoToSbxValue( static_cast<SbxVariable*>(xVar), rValue ); - xArray->Put( xVar, 1 ); + unoToSbxValue( xVar.get(), rValue ); + xArray->Put( xVar.get(), 1 ); // Call property method SbxVariableRef xValue = new SbxVariable; - pMeth->SetParameters( xArray ); - pMeth->Call( xValue ); + pMeth->SetParameters( xArray.get() ); + pMeth->Call( xValue.get() ); pMeth->SetParameters( nullptr ); // TODO: OutParameter? @@ -4356,8 +4356,8 @@ Any SAL_CALL ModuleInvocationProxy::getValue(const OUString& rProperty) // Call method SbxVariableRef xValue = new SbxVariable; - pMeth->Call( xValue ); - Any aRet = sbxToUnoValue( xValue ); + pMeth->Call( xValue.get() ); + Any aRet = sbxToUnoValue( xValue.get() ); return aRet; } @@ -4421,17 +4421,17 @@ Any SAL_CALL ModuleInvocationProxy::invoke( const OUString& rFunction, for( sal_Int32 i = 0 ; i < nParamCount ; i++ ) { SbxVariableRef xVar = new SbxVariable( SbxVARIANT ); - unoToSbxValue( static_cast<SbxVariable*>(xVar), pArgs[i] ); - xArray->Put( xVar, sal::static_int_cast< sal_uInt16 >(i+1) ); + unoToSbxValue( xVar.get(), pArgs[i] ); + xArray->Put( xVar.get(), sal::static_int_cast< sal_uInt16 >(i+1) ); } } // Call method SbxVariableRef xValue = new SbxVariable; if( xArray.Is() ) - pMeth->SetParameters( xArray ); - pMeth->Call( xValue ); - aRet = sbxToUnoValue( xValue ); + pMeth->SetParameters( xArray.get() ); + pMeth->Call( xValue.get() ); + aRet = sbxToUnoValue( xValue.get() ); pMeth->SetParameters( nullptr ); if( bSetRescheduleBack ) @@ -4549,7 +4549,7 @@ void registerComponentToBeDisposedForBasic void registerComListenerVariableForBasic( SbxVariable* pVar, StarBASIC* pBasic ) { StarBasicDisposeItem* pItem = lcl_getOrCreateItemForBasic( pBasic ); - SbxArray* pArray = pItem->m_pRegisteredVariables; + SbxArray* pArray = pItem->m_pRegisteredVariables.get(); pArray->Put( pVar, pArray->Count() ); } @@ -4560,7 +4560,7 @@ void disposeComVariablesForBasic( StarBASIC* pBasic ) { StarBasicDisposeItem* pItem = *it; - SbxArray* pArray = pItem->m_pRegisteredVariables; + SbxArray* pArray = pItem->m_pRegisteredVariables.get(); sal_uInt16 nCount = pArray->Count(); for( sal_uInt16 i = 0 ; i < nCount ; ++i ) { @@ -4602,7 +4602,7 @@ bool SbModule::createCOMWrapperForIface( Any& o_rRetAny, SbClassModuleObject* pP bool bSuccess = false; - SbxArray* pModIfaces = pClassData->mxIfaces; + SbxArray* pModIfaces = pClassData->mxIfaces.get(); sal_uInt16 nCount = pModIfaces->Count(); for( sal_uInt16 i = 0 ; i < nCount ; ++i ) { @@ -4786,8 +4786,8 @@ SbxVariable* SbUnoStructRefObject::Find( const OUString& rName, SbxClassType t ) aProp.Type = css::uno::Type( it->second->getTypeClass(), it->second->getTypeName() ); SbUnoProperty* pProp = new SbUnoProperty( rName, eSbxType, eRealSbxType, aProp, 0, false, ( aProp.Type.getTypeClass() == css::uno::TypeClass_STRUCT) ); SbxVariableRef xVarRef = pProp; - QuickInsert( static_cast<SbxVariable*>(xVarRef) ); - pRes = xVarRef; + QuickInsert( xVarRef.get() ); + pRes = xVarRef.get(); } } @@ -4815,15 +4815,15 @@ void SbUnoStructRefObject::implCreateDbgProperties() // Id == -1: display the implemented interfaces corresponding the ClassProvider SbxVariableRef xVarRef = new SbUnoProperty( OUString(ID_DBG_SUPPORTEDINTERFACES), SbxSTRING, SbxSTRING, aProp, -1, false, false ); - QuickInsert( static_cast<SbxVariable*>(xVarRef) ); + QuickInsert( xVarRef.get() ); // Id == -2: output the properties xVarRef = new SbUnoProperty( OUString(ID_DBG_PROPERTIES), SbxSTRING, SbxSTRING, aProp, -2, false, false ); - QuickInsert( static_cast<SbxVariable*>(xVarRef) ); + QuickInsert( xVarRef.get() ); // Id == -3: output the Methods xVarRef = new SbUnoProperty( OUString(ID_DBG_METHODS), SbxSTRING, SbxSTRING, aProp, -3, false, false ); - QuickInsert( static_cast<SbxVariable*>(xVarRef) ); + QuickInsert( xVarRef.get() ); } void SbUnoStructRefObject::implCreateAll() @@ -4846,7 +4846,7 @@ void SbUnoStructRefObject::implCreateAll() aProp.Type = css::uno::Type( it->second->getTypeClass(), it->second->getTypeName() ); SbUnoProperty* pProp = new SbUnoProperty( rName, eSbxType, eRealSbxType, aProp, 0, false, ( aProp.Type.getTypeClass() == css::uno::TypeClass_STRUCT) ); SbxVariableRef xVarRef = pProp; - QuickInsert( static_cast<SbxVariable*>(xVarRef) ); + QuickInsert( xVarRef.get() ); } // Create Dbg_-Properties diff --git a/basic/source/classes/sbxmod.cxx b/basic/source/classes/sbxmod.cxx index 6388ef712ed9..b7d9d5937b73 100644 --- a/basic/source/classes/sbxmod.cxx +++ b/basic/source/classes/sbxmod.cxx @@ -228,7 +228,7 @@ DocObjectWrapper::invoke( const OUString& aFunctionName, const Sequence< Any >& if ( m_xAggInv.is() && m_xAggInv->hasMethod( aFunctionName ) ) return m_xAggInv->invoke( aFunctionName, aParams, aOutParamIndex, aOutParam ); SbMethodRef pMethod = getMethod( aFunctionName ); - if ( !pMethod ) + if ( !pMethod.Is() ) throw RuntimeException(); // check number of parameters sal_Int32 nParamsCount = aParams.getLength(); @@ -259,8 +259,8 @@ DocObjectWrapper::invoke( const OUString& aFunctionName, const Sequence< Any >& for ( sal_Int32 i = 0; i < nParamsCount; ++i ) { SbxVariableRef xSbxVar = new SbxVariable( SbxVARIANT ); - unoToSbxValue( static_cast< SbxVariable* >( xSbxVar ), pParams[i] ); - xSbxParams->Put( xSbxVar, static_cast< sal_uInt16 >( i ) + 1 ); + unoToSbxValue( xSbxVar.get(), pParams[i] ); + xSbxParams->Put( xSbxVar.get(), static_cast< sal_uInt16 >( i ) + 1 ); // Enable passing by ref if ( xSbxVar->GetType() != SbxVARIANT ) @@ -268,12 +268,12 @@ DocObjectWrapper::invoke( const OUString& aFunctionName, const Sequence< Any >& } } if ( xSbxParams.Is() ) - pMethod->SetParameters( xSbxParams ); + pMethod->SetParameters( xSbxParams.get() ); // call method SbxVariableRef xReturn = new SbxVariable; - pMethod->Call( xReturn ); + pMethod->Call( xReturn.get() ); Any aReturn; // get output parameters if ( xSbxParams.Is() ) @@ -291,7 +291,7 @@ DocObjectWrapper::invoke( const OUString& aFunctionName, const Sequence< Any >& if ( pVar ) { SbxVariableRef xVar = pVar; - aOutParamMap.insert( OutParamMap::value_type( n - 1, sbxToUnoValue( xVar ) ) ); + aOutParamMap.insert( OutParamMap::value_type( n - 1, sbxToUnoValue( xVar.get() ) ) ); } } } @@ -309,7 +309,7 @@ DocObjectWrapper::invoke( const OUString& aFunctionName, const Sequence< Any >& } // get return value - aReturn = sbxToUnoValue( xReturn ); + aReturn = sbxToUnoValue( xReturn.get() ); pMethod->SetParameters( nullptr ); @@ -325,7 +325,7 @@ DocObjectWrapper::setValue( const OUString& aPropertyName, const Any& aValue ) t SbPropertyRef pProperty = getProperty( aPropertyName ); if ( !pProperty.Is() ) throw UnknownPropertyException(); - unoToSbxValue( static_cast<SbxVariable*>(pProperty), aValue ); + unoToSbxValue( pProperty.get(), aValue ); } Any SAL_CALL @@ -338,7 +338,7 @@ DocObjectWrapper::getValue( const OUString& aPropertyName ) throw (UnknownProper if ( !pProperty.Is() ) throw UnknownPropertyException(); - SbxVariable* pProp = static_cast<SbxVariable*>(pProperty); + SbxVariable* pProp = pProperty.get(); if ( pProp->GetType() == SbxEMPTY ) pProperty->Broadcast( SBX_HINT_DATAWANTED ); @@ -763,7 +763,7 @@ void SbModule::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) xMethParameters->Put( pPar, i ); } - pMethVar->SetParameters( xMethParameters ); + pMethVar->SetParameters( xMethParameters.get() ); pMethVar->Get( aVals ); pMethVar->SetParameters( nullptr ); } @@ -801,7 +801,7 @@ void SbModule::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) SbxArrayRef xArray = new SbxArray; xArray->Put( pMethVar, 0 ); // Method as parameter 0 xArray->Put( pVar, 1 ); - pMethVar->SetParameters( xArray ); + pMethVar->SetParameters( xArray.get() ); SbxValues aVals; pMethVar->Get( aVals ); @@ -1197,7 +1197,7 @@ void SbModule::Run( SbMethod* pMeth ) { // #57841 Clear Uno-Objects, which were helt in RTL functions, // at the end of the program, so that nothing were helt. - ClearUnoObjectsInRTL_Impl( xBasic ); + ClearUnoObjectsInRTL_Impl( xBasic.get() ); clearNativeObjectWrapperVector(); @@ -1242,7 +1242,7 @@ void SbModule::Run( SbMethod* pMeth ) { // #57841 Clear Uno-Objects, which were helt in RTL functions, // the end of the program, so that nothing were helt. - ClearUnoObjectsInRTL_Impl( xBasic ); + ClearUnoObjectsInRTL_Impl( xBasic.get() ); delete GetSbData()->pInst; GetSbData()->pInst = nullptr; @@ -1309,7 +1309,7 @@ void SbModule::RemoveVars() // which would cause basic to be re-run in the middle of the init ( and remember RemoveVars is called from compile and we don't want code to run as part of the compile ) SbxVariableRef p = SbModule::Find( rModuleVariableName, SbxClassType::Property ); if( p.Is() ) - Remove (p); + Remove( p.get() ); } } @@ -1838,7 +1838,7 @@ void SbModule::LoadBinaryData( SvStream& rStrm ) bool SbModule::LoadCompleted() { - SbxArray* p = GetMethods(); + SbxArray* p = GetMethods().get(); sal_uInt16 i; for( i = 0; i < p->Count(); i++ ) { @@ -1892,7 +1892,7 @@ void SbModule::handleProcedureProperties( SfxBroadcaster& rBC, const SfxHint& rH xMethParameters->Put( pPar, i ); } - pMeth->SetParameters( xMethParameters ); + pMeth->SetParameters( xMethParameters.get() ); pMeth->Get( aVals ); pMeth->SetParameters( nullptr ); } @@ -1930,7 +1930,7 @@ void SbModule::handleProcedureProperties( SfxBroadcaster& rBC, const SfxHint& rH SbxArrayRef xArray = new SbxArray; xArray->Put( pMeth, 0 ); // Method as parameter 0 xArray->Put( pVar, 1 ); - pMeth->SetParameters( xArray ); + pMeth->SetParameters( xArray.get() ); SbxValues aVals; pMeth->Get( aVals ); @@ -2015,7 +2015,7 @@ void SbMethod::ClearStatics() } SbxArray* SbMethod::GetStatics() { - return refStatics; + return refStatics.get(); } bool SbMethod::LoadData( SvStream& rStrm, sal_uInt16 nVer ) @@ -2083,7 +2083,7 @@ void SbMethod::GetLineRange( sal_uInt16& l1, sal_uInt16& l2 ) SbxInfo* SbMethod::GetInfo() { - return pInfo; + return pInfo.get(); } // Interface to execute a method of the applications @@ -2198,7 +2198,7 @@ SbObjModule::~SbObjModule() void SbObjModule::SetUnoObject( const uno::Any& aObj ) throw ( uno::RuntimeException, std::exception ) { - SbUnoObject* pUnoObj = dynamic_cast<SbUnoObject*>( static_cast<SbxVariable*>(pDocObject) ); + SbUnoObject* pUnoObj = dynamic_cast<SbUnoObject*>( pDocObject.get() ); if ( pUnoObj && pUnoObj->getUnoAny() == aObj ) // object is equal, nothing to do return; pDocObject = new SbUnoObject( GetName(), aObj ); @@ -2217,13 +2217,13 @@ SbObjModule::SetUnoObject( const uno::Any& aObj ) throw ( uno::RuntimeException, SbxVariable* SbObjModule::GetObject() { - return pDocObject; + return pDocObject.get(); } SbxVariable* SbObjModule::Find( const OUString& rName, SbxClassType t ) { SbxVariable* pVar = nullptr; - if ( pDocObject) + if ( pDocObject.get() ) pVar = pDocObject->Find( rName, t ); if ( !pVar ) pVar = SbModule::Find( rName, t ); @@ -2489,14 +2489,14 @@ void SbUserFormModule::triggerMethod( const OUString& aMethodToRun, Sequence< An for ( sal_Int32 i = 0; i < aArguments.getLength(); ++i ) { auto xSbxVar = tools::make_ref<SbxVariable>( SbxVARIANT ); - unoToSbxValue( static_cast< SbxVariable* >( xSbxVar ), aArguments[i] ); - xArray->Put( xSbxVar, static_cast< sal_uInt16 >( i ) + 1 ); + unoToSbxValue( xSbxVar.get(), aArguments[i] ); + xArray->Put( xSbxVar.get(), static_cast< sal_uInt16 >( i ) + 1 ); // Enable passing by ref if ( xSbxVar->GetType() != SbxVARIANT ) xSbxVar->SetFlag( SbxFlagBits::Fixed ); } - pMeth->SetParameters( xArray ); + pMeth->SetParameters( xArray.get() ); SbxValues aVals; pMeth->Get( aVals ); @@ -2585,7 +2585,7 @@ void SbUserFormModule::Load() { SAL_INFO("basic", "** load() "); // forces a load - if ( !pDocObject ) + if ( !pDocObject.Is() ) InitObject(); } @@ -2711,7 +2711,7 @@ void SbUserFormModule::InitObject() SbxVariable* SbUserFormModule::Find( const OUString& rName, SbxClassType t ) { - if ( !pDocObject && !GetSbData()->bRunInit && GetSbData()->pInst ) + if ( !pDocObject.Is() && !GetSbData()->bRunInit && GetSbData()->pInst ) InitObject(); return SbObjModule::Find( rName, t ); } |