Kaydet (Commit) f004aa99 authored tarafından Jacek Fraczek's avatar Jacek Fraczek Kaydeden (comit) Stephan Bergmann

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/29621Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarStephan Bergmann <sbergman@redhat.com>
üst 728c7327
......@@ -285,7 +285,7 @@ void ModulWindow::CheckCompileBasic()
if ( bDone )
{
GetBreakPoints().SetBreakPointsInBasic( m_xModule );
GetBreakPoints().SetBreakPointsInBasic( m_xModule.get() );
}
GetShell()->GetViewFrame()->GetWindow().LeaveWait();
......@@ -1280,7 +1280,7 @@ void ModulWindow::BasicStarted()
if ( rList.size() )
{
rList.ResetHitCount();
rList.SetBreakPointsInBasic( m_xModule );
rList.SetBreakPointsInBasic( m_xModule.get() );
for ( sal_uInt16 nMethod = 0; nMethod < m_xModule->GetMethods()->Count(); nMethod++ )
{
SbMethod* pMethod = static_cast<SbMethod*>(m_xModule->GetMethods()->Get( nMethod ));
......@@ -1400,7 +1400,7 @@ void ModulWindow::UpdateModule ()
OUString const aModule = getTextEngineText(*GetEditEngine());
// update module in basic
assert(m_xModule);
assert(m_xModule.Is());
// update module in module window
SetModule(aModule);
......
......@@ -344,9 +344,9 @@ public:
virtual void SetReadOnly (bool bReadOnly) override;
virtual bool IsReadOnly() override;
StarBASIC* GetBasic() { XModule(); return m_xBasic; }
StarBASIC* GetBasic() { XModule(); return m_xBasic.get(); }
SbModule* GetSbModule() { return m_xModule; }
SbModule* GetSbModule() { return m_xModule.get(); }
void SetSbModule( SbModule* pModule ) { m_xModule = pModule; }
OUString GetSbModuleName();
......
......@@ -645,7 +645,7 @@ void EditorWindow::HandleAutoCorrect()
else
{
//autocorrect procedures
SbxArray* pArr = rModulWindow.GetSbModule()->GetMethods();
SbxArray* pArr = rModulWindow.GetSbModule()->GetMethods().get();
for( sal_uInt32 i=0; i < pArr->Count32(); ++i )
{
if( pArr->Get32(i)->GetName().equalsIgnoreAsciiCase( sStr ) )
......@@ -1724,7 +1724,7 @@ SbxDimArray* WatchItem::GetRootArray()
WatchItem* pRootItem = GetRootItem();
SbxDimArray* pRet = nullptr;
if( pRootItem )
pRet = pRootItem->mpArray;
pRet = pRootItem->mpArray.get();
return pRet;
}
......@@ -2132,7 +2132,7 @@ void WatchTreeListBox::RequestingChildren( SvTreeListEntry * pParent )
SvTreeListEntry* pEntry = pParent;
WatchItem* pItem = static_cast<WatchItem*>(pEntry->GetUserData());
SbxDimArray* pArray = pItem->mpArray;
SbxDimArray* pArray = pItem->mpArray.get();
SbxDimArray* pRootArray = pItem->GetRootArray();
bool bArrayIsRootArray = false;
if( !pArray && pRootArray )
......@@ -2141,7 +2141,7 @@ void WatchTreeListBox::RequestingChildren( SvTreeListEntry * pParent )
bArrayIsRootArray = true;
}
SbxObject* pObj = pItem->mpObject;
SbxObject* pObj = pItem->mpObject.get();
if( pObj )
{
createAllObjectProperties( pObj );
......@@ -2231,7 +2231,7 @@ SbxBase* WatchTreeListBox::ImplGetSBXForEntry( SvTreeListEntry* pEntry, bool& rb
WatchItem* pParentItem = pParentEntry ? static_cast<WatchItem*>(pParentEntry->GetUserData()) : nullptr;
if( pParentItem )
{
SbxObject* pObj = pParentItem->mpObject;
SbxObject* pObj = pParentItem->mpObject.get();
SbxDimArray* pArray;
if( pObj )
{
......@@ -2272,7 +2272,7 @@ bool WatchTreeListBox::EditingEntry( SvTreeListEntry* pEntry, Selection& )
if (IsSbxVariable(pSbx) || bArrayElement)
{
// Accept no objects and only end nodes of arrays for editing
if( !pItem->mpObject && (pItem->mpArray == nullptr || pItem->nDimLevel == pItem->nDimCount) )
if( !pItem->mpObject.Is() && ( !pItem->mpArray.Is() || pItem->nDimLevel == pItem->nDimCount ) )
{
aEditingRes = SvHeaderTabListBox::GetEntryText( pEntry, ITEM_ID_VALUE-1 );
aEditingRes = comphelper::string::strip(aEditingRes, ' ');
......@@ -2349,7 +2349,7 @@ OUString implCreateTypeStringForDimArray( WatchItem* pItem, SbxDataType eType )
{
OUString aRetStr = getBasicTypeName( eType );
SbxDimArray* pArray = pItem->mpArray;
SbxDimArray* pArray = pItem->mpArray.get();
if( !pArray )
pArray = pItem->GetRootArray();
if( pArray )
......@@ -2427,7 +2427,7 @@ void WatchTreeListBox::UpdateWatches( bool bBasicStopped )
// consider multidimensinal arrays!
if (SbxDimArray* pNewArray = dynamic_cast<SbxDimArray*>(pVar->GetObject()))
{
SbxDimArray* pOldArray = pItem->mpArray;
SbxDimArray* pOldArray = pItem->mpArray.get();
bool bArrayChanged = false;
if( pNewArray != nullptr && pOldArray != nullptr )
......@@ -2494,7 +2494,7 @@ void WatchTreeListBox::UpdateWatches( bool bBasicStopped )
{
if (SbxObject* pObj = dynamic_cast<SbxObject*>(pVar->GetObject()))
{
if (pItem->mpObject && !pItem->maMemberList.empty())
if ( pItem->mpObject.Is() && !pItem->maMemberList.empty() )
{
bool bObjChanged = false; // Check if member list has changed
SbxArray* pProps = pObj->GetProperties();
......@@ -2522,7 +2522,7 @@ void WatchTreeListBox::UpdateWatches( bool bBasicStopped )
else
{
aWatchStr = "Null";
if( pItem->mpObject != nullptr )
if( pItem->mpObject.Is() )
{
bCollapse = true;
pItem->clearWatchItem();
......@@ -2533,7 +2533,7 @@ void WatchTreeListBox::UpdateWatches( bool bBasicStopped )
}
else
{
if( pItem->mpObject != nullptr )
if( pItem->mpObject.Is() )
{
bCollapse = true;
pItem->clearWatchItem();
......@@ -2575,7 +2575,7 @@ void WatchTreeListBox::UpdateWatches( bool bBasicStopped )
}
else if( bBasicStopped )
{
if( pItem->mpObject || pItem->mpArray )
if( pItem->mpObject.Is() || pItem->mpArray.Is() )
{
implCollapseModifiedObjectEntry( pEntry, this );
pItem->mpObject = nullptr;
......
......@@ -311,7 +311,7 @@ void Shell::ExecuteGlobal( SfxRequest& rReq )
pModule = pBasic->FindModule( aModName );
}
else
pModule = pBasic->GetModules().front();
pModule = pBasic->GetModules().front().get();
}
DBG_ASSERT( pModule, "Kein Modul!" );
if ( pModule && !pModule->GetMethods()->Find( rInfo.GetMethod(), SbxClassType::Method ) )
......
......@@ -227,7 +227,7 @@ namespace
if ( pData->aDocument.isDocument() )
pUndoGuard.reset( new ::framework::DocumentUndoGuard( pData->aDocument.getDocument() ) );
RunMethod(pData->xMethod);
RunMethod( pData->xMethod.get() );
}
}
......@@ -374,7 +374,7 @@ Sequence< OUString > GetMethodNames( const ScriptDocument& rDocument, const OUSt
{
xModule = new SbModule( rModName );
xModule->SetSource32( aOUSource );
pMod = xModule;
pMod = xModule.get();
}
sal_uInt16 nCount = pMod->GetMethods()->Count();
......@@ -424,9 +424,9 @@ bool HasMethod (
{
xModule = new SbModule( rModName );
xModule->SetSource32( aOUSource );
pMod = xModule;
pMod = xModule.get();
}
SbxArray* pMethods = pMod->GetMethods();
SbxArray* pMethods = pMod->GetMethods().get();
if ( pMethods )
{
SbMethod* pMethod = static_cast<SbMethod*>(pMethods->Find( rMethName, SbxClassType::Method ));
......
......@@ -361,7 +361,7 @@ SbMethod* MacroChooser::CreateMacro()
pModule = pBasic->FindModule( aModName );
}
else if ( !pBasic->GetModules().empty() )
pModule = pBasic->GetModules().front();
pModule = pBasic->GetModules().front().get();
if ( !pModule )
{
......
......@@ -77,7 +77,7 @@ void Coverage::run_test(const OUString& sFileURL)
if( !testMacro.HasError() )
{
SbxVariableRef pResult = testMacro.Run();
if( pResult && pResult->GetInteger() == 1 )
if( pResult.Is() && pResult->GetInteger() == 1 )
{
bResult = true;
}
......
......@@ -78,7 +78,7 @@ SbxVariableRef MacroSnippet::Run( const css::uno::Sequence< css::uno::Any >& rAr
SbxVariableRef pReturn = nullptr;
if ( !Compile() )
return pReturn;
SbMethod* pMeth = mpMod ? static_cast<SbMethod*>(mpMod->Find( "doUnitTest", SbxClassType::Method )) : nullptr;
SbMethod* pMeth = mpMod.Is() ? static_cast<SbMethod*>(mpMod->Find( "doUnitTest", SbxClassType::Method )) : nullptr;
if ( pMeth )
{
if ( rArgs.getLength() )
......@@ -90,7 +90,7 @@ SbxVariableRef MacroSnippet::Run( const css::uno::Sequence< css::uno::Any >& rAr
unoToSbxValue( pVar, rArgs[ i ] );
aArgs->Put( pVar, i + 1 );
}
pMeth->SetParameters( aArgs );
pMeth->SetParameters( aArgs.get() );
}
pReturn = new SbxMethod( *static_cast<SbxMethod*>(pMeth));
}
......@@ -105,7 +105,7 @@ SbxVariableRef MacroSnippet::Run()
bool MacroSnippet::Compile()
{
CPPUNIT_ASSERT_MESSAGE("module is NULL", mpMod != nullptr );
CPPUNIT_ASSERT_MESSAGE("module is NULL", mpMod.get() != nullptr );
mpMod->Compile();
return !mbError;
}
......
......@@ -182,7 +182,7 @@ void Nested_Struct::testAssign1Alt()
myMacro.Compile();
CPPUNIT_ASSERT_MESSAGE("testAssign1Alt fails with compile error",!myMacro.HasError() );
SbxVariableRef pNew = myMacro.Run();
uno::Any aRet = sbxToUnoValue( pNew );
uno::Any aRet = sbxToUnoValue( pNew.get() );
table::TableBorder aBorder;
aRet >>= aBorder;
......@@ -205,7 +205,7 @@ void Nested_Struct::testOldAssignAlt()
myMacro.Compile();
CPPUNIT_ASSERT_MESSAGE("testOldAssign fails with compile error",!myMacro.HasError() );
SbxVariableRef pNew = myMacro.Run();
uno::Any aRet = sbxToUnoValue( pNew );
uno::Any aRet = sbxToUnoValue( pNew.get() );
table::TableBorder aBorder;
aRet >>= aBorder;
......@@ -229,7 +229,7 @@ void Nested_Struct::testUnfixedVarAssignAlt()
myMacro.Compile();
CPPUNIT_ASSERT_MESSAGE("testUnfixedVarAssignAlt fails with compile error",!myMacro.HasError() );
SbxVariableRef pNew = myMacro.Run();
uno::Any aRet = sbxToUnoValue( pNew );
uno::Any aRet = sbxToUnoValue( pNew.get() );
uno::Sequence< uno::Any > aResult;
bool bRes = aRet >>= aResult;
......@@ -265,7 +265,7 @@ void Nested_Struct::testFixedVarAssignAlt()
myMacro.Compile();
CPPUNIT_ASSERT_MESSAGE("testFixedVarAssignAlt fails with compile error",!myMacro.HasError() );
SbxVariableRef pNew = myMacro.Run();
uno::Any aRet = sbxToUnoValue( pNew );
uno::Any aRet = sbxToUnoValue( pNew.get() );
uno::Sequence< uno::Any > aResult;
bool bRes = aRet >>= aResult;
......@@ -292,7 +292,7 @@ void Nested_Struct::testUnoAccess()
myMacro.Compile();
CPPUNIT_ASSERT_MESSAGE("testUnoAccess fails with compile error",!myMacro.HasError() );
SbxVariableRef pNew = myMacro.Run();
uno::Any aRet = sbxToUnoValue( pNew );
uno::Any aRet = sbxToUnoValue( pNew.get() );
awt::WindowDescriptor aWinDesc;
aRet >>= aWinDesc;
......
......@@ -75,12 +75,12 @@ void VBATest::testMiscVBAFunctions()
MacroSnippet myMacro;
myMacro.LoadSourceFromFile( sMacroURL );
SbxVariableRef pReturn = myMacro.Run();
if ( pReturn )
if ( pReturn.Is() )
{
fprintf(stderr, "macro result for %s\n", macroSource[ i ] );
fprintf(stderr, "macro returned:\n%s\n", OUStringToOString( pReturn->GetOUString(), RTL_TEXTENCODING_UTF8 ).getStr() );
}
CPPUNIT_ASSERT_MESSAGE("No return variable huh?", pReturn != nullptr );
CPPUNIT_ASSERT_MESSAGE("No return variable huh?", pReturn.get() != nullptr );
CPPUNIT_ASSERT_EQUAL_MESSAGE("Result not as expected", OUString("OK"), pReturn->GetOUString() );
}
}
......@@ -146,12 +146,12 @@ void VBATest::testMiscOLEStuff()
MacroSnippet myMacro;
myMacro.LoadSourceFromFile( sMacroURL );
SbxVariableRef pReturn = myMacro.Run( aArgs );
if ( pReturn )
if ( pReturn.Is() )
{
fprintf(stderr, "macro result for %s\n", macroSource[ i ] );
fprintf(stderr, "macro returned:\n%s\n", OUStringToOString( pReturn->GetOUString(), RTL_TEXTENCODING_UTF8 ).getStr() );
}
CPPUNIT_ASSERT_MESSAGE("No return variable huh?", pReturn != NULL );
CPPUNIT_ASSERT_MESSAGE("No return variable huh?", pReturn.get() != NULL );
CPPUNIT_ASSERT_MESSAGE("Result not as expected", pReturn->GetOUString() == "OK" );
}
#else
......
......@@ -599,12 +599,12 @@ void BasicManager::SetLibraryContainerInfo( const LibraryContainerInfo& rInfo )
// No libs? Maybe an 5.2 document already loaded
for (auto const& rpBasLibInfo : mpImpl->aLibs)
{
StarBASIC* pLib = rpBasLibInfo->GetLib();
StarBASIC* pLib = rpBasLibInfo->GetLib().get();
if( !pLib )
{
bool bLoaded = ImpLoadLibrary( rpBasLibInfo.get(), nullptr );
if( bLoaded )
pLib = rpBasLibInfo->GetLib();
pLib = rpBasLibInfo->GetLib().get();
}
if( pLib )
{
......@@ -973,7 +973,7 @@ bool BasicManager::ImpLoadLibrary( BasicLibInfo* pLibInfo, SotStorage* pCurStora
pLibInfo->SetPassword( aPassword );
}
xBasicStream->SetCryptMaskKey(OString());
CheckModules( pLibInfo->GetLib(), pLibInfo->IsReference() );
CheckModules( pLibInfo->GetLib().get(), pLibInfo->IsReference() );
}
return bLoaded;
}
......@@ -1013,7 +1013,7 @@ bool BasicManager::ImplLoadBasic( SvStream& rStrm, StarBASICRef& rOldBasic ) con
{
if( nullptr != dynamic_cast<const StarBASIC*>( &xNew ) )
{
StarBASIC* pNew = static_cast<StarBASIC*>(static_cast<SbxBase*>(xNew));
StarBASIC* pNew = static_cast<StarBASIC*>(xNew.get());
// Use the Parent of the old BASICs
if( rOldBasic.Is() )
{
......@@ -1050,7 +1050,7 @@ void BasicManager::CheckModules( StarBASIC* pLib, bool bReference )
for ( const auto& pModule: pLib->GetModules() )
{
DBG_ASSERT( pModule, "Module not received!" );
DBG_ASSERT( pModule.get(), "Module not received!" );
if ( !pModule->IsCompiled() && !StarBASIC::GetErrorCode() )
{
pModule->Compile();
......@@ -1212,7 +1212,7 @@ bool BasicManager::RemoveLib( sal_uInt16 nLib, bool bDelBasicFromStorage )
}
if ((*itLibInfo)->GetLib().Is())
{
GetStdLib()->Remove( (*itLibInfo)->GetLib() );
GetStdLib()->Remove( (*itLibInfo)->GetLib().get() );
}
mpImpl->aLibs.erase(itLibInfo);
return true; // Remove was successful, del unimportant
......@@ -1228,7 +1228,7 @@ StarBASIC* BasicManager::GetLib( sal_uInt16 nLib ) const
DBG_ASSERT( nLib < mpImpl->aLibs.size(), "Lib does not exist!" );
if ( nLib < mpImpl->aLibs.size() )
{
return mpImpl->aLibs[nLib]->GetLib();
return mpImpl->aLibs[nLib]->GetLib().get();
}
return nullptr;
}
......@@ -1245,7 +1245,7 @@ StarBASIC* BasicManager::GetLib( const OUString& rName ) const
{
if (rpLib->GetLibName().equalsIgnoreAsciiCase(rName)) // Check if available...
{
return rpLib->GetLib();
return rpLib->GetLib().get();
}
}
return nullptr;
......@@ -1331,7 +1331,7 @@ StarBASIC* BasicManager::CreateLib( const OUString& rLibName )
pLibInfo->SetLib( pNew );
pLibInfo->SetLibName( rLibName );
pLibInfo->GetLib()->SetName( rLibName );
return pLibInfo->GetLib();
return pLibInfo->GetLib().get();
}
// For XML import/export:
......@@ -1395,7 +1395,7 @@ BasicLibInfo* BasicManager::FindLibInfo( StarBASIC* pBasic )
{
for (auto const& rpLib : mpImpl->aLibs)
{
if (rpLib->GetLib() == pBasic)
if (rpLib->GetLib().get() == pBasic)
{
return rpLib.get();
}
......@@ -1443,7 +1443,7 @@ uno::Any BasicManager::SetGlobalUNOConstant( const OUString& rName, const uno::A
SbxObjectRef xUnoObj = GetSbUnoObject( rName, _rValue );
xUnoObj->SetFlag( SbxFlagBits::DontStore );
pStandardLib->Insert( xUnoObj );
pStandardLib->Insert( xUnoObj.get() );
return aOldValue;
}
......@@ -1992,7 +1992,7 @@ void DialogContainer_Impl::insertByName( const OUString& aName, const uno::Any&
uno::Reference< script::XStarBasicDialogInfo > xMod;
aElement >>= xMod;
SbxObjectRef xDialog = implCreateDialog( xMod->getData() );
mpLib->Insert( xDialog );
mpLib->Insert( xDialog.get() );
}
void DialogContainer_Impl::removeByName( const OUString& Name )
......
......@@ -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;
}
......
......@@ -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 );
}
......
......@@ -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 )
......
......@@ -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
{
......
......@@ -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() )