summaryrefslogtreecommitdiff
path: root/basic
diff options
context:
space:
mode:
authorNoel <noel.grandin@collabora.co.uk>2021-02-22 12:12:37 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2021-02-22 17:32:28 +0100
commit1571fd8bfdb1deb07b4d6a4abde4919d24550cea (patch)
tree948935177a86650075924356270c032281917900 /basic
parentdc37866f3266f92c71bb4b3cec2b869069230c28 (diff)
loplugin:refcounting in basic
Change-Id: I0c1e41436ddae176695a90c120303727aa3bc2ad Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111306 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'basic')
-rw-r--r--basic/source/basmgr/basicmanagerrepository.cxx8
-rw-r--r--basic/source/classes/sbunoobj.cxx9
-rw-r--r--basic/source/inc/dlgcont.hxx4
-rw-r--r--basic/source/inc/namecont.hxx4
-rw-r--r--basic/source/inc/scriptcont.hxx4
-rw-r--r--basic/source/uno/dlgcont.cxx10
-rw-r--r--basic/source/uno/namecont.cxx12
-rw-r--r--basic/source/uno/scriptcont.cxx15
8 files changed, 29 insertions, 37 deletions
diff --git a/basic/source/basmgr/basicmanagerrepository.cxx b/basic/source/basmgr/basicmanagerrepository.cxx
index 01ca8759e145..a70c49eb1149 100644
--- a/basic/source/basmgr/basicmanagerrepository.cxx
+++ b/basic/source/basmgr/basicmanagerrepository.cxx
@@ -292,15 +292,13 @@ namespace basic
pBasicManager->SetStorageName( aAppBasic.PathToFileName() );
// Basic container
- SfxScriptLibraryContainer* pBasicCont = new SfxScriptLibraryContainer( Reference< XStorage >() );
- Reference< XPersistentLibraryContainer > xBasicCont( pBasicCont );
+ rtl::Reference<SfxScriptLibraryContainer> pBasicCont = new SfxScriptLibraryContainer( Reference< XStorage >() );
pBasicCont->setBasicManager( pBasicManager );
// Dialog container
- SfxDialogLibraryContainer* pDialogCont = new SfxDialogLibraryContainer( Reference< XStorage >() );
- Reference< XPersistentLibraryContainer > xDialogCont( pDialogCont );
+ rtl::Reference<SfxDialogLibraryContainer> pDialogCont = new SfxDialogLibraryContainer( Reference< XStorage >() );
- LibraryContainerInfo aInfo( xBasicCont, xDialogCont, static_cast< OldBasicPassword* >( pBasicCont ) );
+ LibraryContainerInfo aInfo( pBasicCont, pDialogCont, static_cast< OldBasicPassword* >( pBasicCont.get() ) );
pBasicManager->SetLibraryContainerInfo( aInfo );
// global constants
diff --git a/basic/source/classes/sbunoobj.cxx b/basic/source/classes/sbunoobj.cxx
index 2afc7ed52604..259cd5ae88f4 100644
--- a/basic/source/classes/sbunoobj.cxx
+++ b/basic/source/classes/sbunoobj.cxx
@@ -4048,8 +4048,7 @@ void SbRtl_CreateUnoListener(StarBASIC * pBasic, SbxArray & rPar, bool)
Reference< XInvocationAdapterFactory2 > xInvocationAdapterFactory =
InvocationAdapterFactory::create( xContext );
- BasicAllListener_Impl * p;
- Reference< XAllListener > xAllLst = p = new BasicAllListener_Impl( aPrefixName );
+ rtl::Reference<BasicAllListener_Impl> xAllLst = new BasicAllListener_Impl( aPrefixName );
Any aTmp;
Reference< XInterface > xLst = createAllListenerAdapter( xInvocationAdapterFactory, xClass, xAllLst, aTmp );
if( !xLst.is() )
@@ -4062,8 +4061,8 @@ void SbRtl_CreateUnoListener(StarBASIC * pBasic, SbxArray & rPar, bool)
return;
SbUnoObject* pUnoObj = new SbUnoObject( aListenerClassName, aTmp );
- p->xSbxObj = pUnoObj;
- p->xSbxObj->SetParent( pBasic );
+ xAllLst->xSbxObj = pUnoObj;
+ xAllLst->xSbxObj->SetParent( pBasic );
// #100326 Register listener object to set Parent NULL in Dtor
SbxArrayRef xBasicUnoListeners = pBasic->getUnoListeners();
@@ -4071,7 +4070,7 @@ void SbRtl_CreateUnoListener(StarBASIC * pBasic, SbxArray & rPar, bool)
// return the object
SbxVariableRef refVar = rPar.Get32(0);
- refVar->PutObject( p->xSbxObj.get() );
+ refVar->PutObject( xAllLst->xSbxObj.get() );
}
diff --git a/basic/source/inc/dlgcont.hxx b/basic/source/inc/dlgcont.hxx
index f9dbe2745c25..1152dd82b2b3 100644
--- a/basic/source/inc/dlgcont.hxx
+++ b/basic/source/inc/dlgcont.hxx
@@ -34,8 +34,8 @@ namespace basic
class SfxDialogLibraryContainer : public SfxLibraryContainer
{
// Methods to distinguish between different library types
- virtual SfxLibrary* implCreateLibrary( const OUString& aName ) override;
- virtual SfxLibrary* implCreateLibraryLink
+ virtual rtl::Reference<SfxLibrary> implCreateLibrary( const OUString& aName ) override;
+ virtual rtl::Reference<SfxLibrary> implCreateLibraryLink
( const OUString& aName, const OUString& aLibInfoFileURL,
const OUString& StorageURL, bool ReadOnly ) override;
virtual css::uno::Any createEmptyLibraryElement() override;
diff --git a/basic/source/inc/namecont.hxx b/basic/source/inc/namecont.hxx
index 56b688dd1271..5a3ce4afd09e 100644
--- a/basic/source/inc/namecont.hxx
+++ b/basic/source/inc/namecont.hxx
@@ -255,8 +255,8 @@ protected:
void implImportLibDescriptor( SfxLibrary* pLib, ::xmlscript::LibDescriptor const & rLib );
// Methods to distinguish between different library types
- virtual SfxLibrary* implCreateLibrary( const OUString& aName ) = 0;
- virtual SfxLibrary* implCreateLibraryLink
+ virtual rtl::Reference<SfxLibrary> implCreateLibrary( const OUString& aName ) = 0;
+ virtual rtl::Reference<SfxLibrary> implCreateLibraryLink
( const OUString& aName, const OUString& aLibInfoFileURL,
const OUString& StorageURL, bool ReadOnly ) = 0;
virtual css::uno::Any createEmptyLibraryElement() = 0;
diff --git a/basic/source/inc/scriptcont.hxx b/basic/source/inc/scriptcont.hxx
index bc82a42ca915..17f3089f1092 100644
--- a/basic/source/inc/scriptcont.hxx
+++ b/basic/source/inc/scriptcont.hxx
@@ -34,8 +34,8 @@ class SfxScriptLibraryContainer : public SfxLibraryContainer, public OldBasicPas
css::uno::Reference< css::container::XNameAccess > mxCodeNameAccess;
// Methods to distinguish between different library types
- virtual SfxLibrary* implCreateLibrary( const OUString& aName ) override;
- virtual SfxLibrary* implCreateLibraryLink
+ virtual rtl::Reference<SfxLibrary> implCreateLibrary( const OUString& aName ) override;
+ virtual rtl::Reference<SfxLibrary> implCreateLibraryLink
( const OUString& aName, const OUString& aLibInfoFileURL,
const OUString& StorageURL, bool ReadOnly ) override;
virtual css::uno::Any createEmptyLibraryElement() override;
diff --git a/basic/source/uno/dlgcont.cxx b/basic/source/uno/dlgcont.cxx
index 13055cb130e1..ff89a780c2f5 100644
--- a/basic/source/uno/dlgcont.cxx
+++ b/basic/source/uno/dlgcont.cxx
@@ -80,19 +80,17 @@ SfxDialogLibraryContainer::SfxDialogLibraryContainer( const uno::Reference< embe
}
// Methods to get library instances of the correct type
-SfxLibrary* SfxDialogLibraryContainer::implCreateLibrary( const OUString& aName )
+rtl::Reference<SfxLibrary> SfxDialogLibraryContainer::implCreateLibrary( const OUString& aName )
{
- SfxLibrary* pRet = new SfxDialogLibrary( maModifiable, aName, mxSFI, this );
- return pRet;
+ return new SfxDialogLibrary( maModifiable, aName, mxSFI, this );
}
-SfxLibrary* SfxDialogLibraryContainer::implCreateLibraryLink
+rtl::Reference<SfxLibrary> SfxDialogLibraryContainer::implCreateLibraryLink
( const OUString& aName, const OUString& aLibInfoFileURL,
const OUString& StorageURL, bool ReadOnly )
{
- SfxLibrary* pRet = new SfxDialogLibrary
+ return new SfxDialogLibrary
( maModifiable, aName, mxSFI, aLibInfoFileURL, StorageURL, ReadOnly, this );
- return pRet;
}
Any SfxDialogLibraryContainer::createEmptyLibraryElement()
diff --git a/basic/source/uno/namecont.cxx b/basic/source/uno/namecont.cxx
index 806fbcf1a22d..28bdab04a298 100644
--- a/basic/source/uno/namecont.cxx
+++ b/basic/source/uno/namecont.cxx
@@ -2152,12 +2152,12 @@ sal_Bool SfxLibraryContainer::hasByName( const OUString& aName )
Reference< XNameContainer > SAL_CALL SfxLibraryContainer::createLibrary( const OUString& Name )
{
LibraryContainerMethodGuard aGuard( *this );
- SfxLibrary* pNewLib = implCreateLibrary( Name );
+ rtl::Reference<SfxLibrary> pNewLib = implCreateLibrary( Name );
pNewLib->maLibElementFileExtension = maLibElementFileExtension;
createVariableURL( pNewLib->maUnexpandedStorageURL, Name, maInfoFileName, true );
- Reference< XNameAccess > xNameAccess = static_cast< XNameAccess* >( pNewLib );
+ Reference< XNameAccess > xNameAccess( pNewLib );
Any aElement;
aElement <<= xNameAccess;
maNameContainer->insertByName( Name, aElement );
@@ -2181,17 +2181,17 @@ Reference< XNameAccess > SAL_CALL SfxLibraryContainer::createLibraryLink
checkStorageURL( StorageURL, aLibInfoFileURL, aLibDirURL, aUnexpandedStorageURL );
- SfxLibrary* pNewLib = implCreateLibraryLink( Name, aLibInfoFileURL, aLibDirURL, ReadOnly );
+ rtl::Reference<SfxLibrary> pNewLib = implCreateLibraryLink( Name, aLibInfoFileURL, aLibDirURL, ReadOnly );
pNewLib->maLibElementFileExtension = maLibElementFileExtension;
pNewLib->maUnexpandedStorageURL = aUnexpandedStorageURL;
pNewLib->maOriginalStorageURL = StorageURL;
uno::Reference< embed::XStorage > xDummyStor;
::xmlscript::LibDescriptor aLibDesc;
- implLoadLibraryIndexFile( pNewLib, aLibDesc, xDummyStor, OUString() );
- implImportLibDescriptor( pNewLib, aLibDesc );
+ implLoadLibraryIndexFile( pNewLib.get(), aLibDesc, xDummyStor, OUString() );
+ implImportLibDescriptor( pNewLib.get(), aLibDesc );
- Reference< XNameAccess > xRet = static_cast< XNameAccess* >( pNewLib );
+ Reference< XNameAccess > xRet( pNewLib );
Any aElement;
aElement <<= xRet;
maNameContainer->insertByName( Name, aElement );
diff --git a/basic/source/uno/scriptcont.cxx b/basic/source/uno/scriptcont.cxx
index 40c9c40ce6bc..eab8faf71735 100644
--- a/basic/source/uno/scriptcont.cxx
+++ b/basic/source/uno/scriptcont.cxx
@@ -105,20 +105,18 @@ SfxScriptLibraryContainer::SfxScriptLibraryContainer( const uno::Reference< embe
}
// Methods to get library instances of the correct type
-SfxLibrary* SfxScriptLibraryContainer::implCreateLibrary( const OUString& )
+rtl::Reference<SfxLibrary> SfxScriptLibraryContainer::implCreateLibrary( const OUString& )
{
- SfxLibrary* pRet = new SfxScriptLibrary( maModifiable, mxSFI );
- return pRet;
+ return new SfxScriptLibrary( maModifiable, mxSFI );
}
-SfxLibrary* SfxScriptLibraryContainer::implCreateLibraryLink( const OUString&,
+rtl::Reference<SfxLibrary> SfxScriptLibraryContainer::implCreateLibraryLink( const OUString&,
const OUString& aLibInfoFileURL,
const OUString& StorageURL,
bool ReadOnly )
{
- SfxLibrary* pRet = new SfxScriptLibrary( maModifiable, mxSFI,
+ return new SfxScriptLibrary( maModifiable, mxSFI,
aLibInfoFileURL, StorageURL, ReadOnly );
- return pRet;
}
Any SfxScriptLibraryContainer::createEmptyLibraryElement()
@@ -563,9 +561,8 @@ bool SfxScriptLibraryContainer::implStorePasswordLibrary( SfxLibrary* pLib, cons
{
if ( xHandler.is() )
{
- ModuleSizeExceeded* pReq = new ModuleSizeExceeded( aNames );
- uno::Reference< task::XInteractionRequest > xReq( pReq );
- xHandler->handle( xReq );
+ rtl::Reference<ModuleSizeExceeded> pReq = new ModuleSizeExceeded( aNames );
+ xHandler->handle( pReq );
if ( pReq->isAbort() )
{
throw util::VetoException();