No need to own SfxBasicManagerHolder by pointer in SfxObjectShell_Impl

Change-Id: I55da464ef1d3381fb51949a349f844dbd7da49eb
This commit is contained in:
Stephan Bergmann 2014-08-22 08:50:56 +02:00
parent 10b6bda51c
commit 8a08ddd737
3 changed files with 17 additions and 18 deletions

View file

@ -1060,13 +1060,13 @@ bool SfxObjectShell::DoSave()
GetBasicManager();
// disconnect from the current storage
pImp->pBasicManager->setStorage( xTmpStorage );
pImp->aBasicManager.setStorage( xTmpStorage );
// store to the current storage
pImp->pBasicManager->storeLibrariesToStorage( GetMedium()->GetStorage() );
pImp->aBasicManager.storeLibrariesToStorage( GetMedium()->GetStorage() );
// connect to the current storage back
pImp->pBasicManager->setStorage( GetMedium()->GetStorage() );
pImp->aBasicManager.setStorage( GetMedium()->GetStorage() );
}
catch( uno::Exception& )
{
@ -1858,7 +1858,7 @@ bool SfxObjectShell::ConnectTmpStorage_Impl(
if ( bResult )
{
pImp->pBasicManager->setStorage( xTmpStorage );
pImp->aBasicManager.setStorage( xTmpStorage );
// Get rid of this workaround after issue i113914 is fixed
try
@ -2014,7 +2014,7 @@ bool SfxObjectShell::DoSaveCompleted( SfxMedium* pNewMed )
// TODO/LATER: may be this code will be replaced, but not sure
// Set storage in document library containers
pImp->pBasicManager->setStorage( xStorage );
pImp->aBasicManager.setStorage( xStorage );
// Get rid of this workaround after issue i113914 is fixed
try
@ -3097,7 +3097,7 @@ bool SfxObjectShell::SaveAsOwnFormat( SfxMedium& rMedium )
GetBasicManager();
// Save dialog/script container
pImp->pBasicManager->storeLibrariesToStorage( xStorage );
pImp->aBasicManager.storeLibrariesToStorage( xStorage );
}
#endif
return SaveAs( rMedium );
@ -3632,12 +3632,12 @@ bool SfxObjectShell::QuerySaveSizeExceededModules_Impl( const uno::Reference< ta
if ( !HasBasic() )
return true;
if ( !pImp->pBasicManager->isValid() )
if ( !pImp->aBasicManager.isValid() )
GetBasicManager();
uno::Sequence< OUString > sModules;
if ( xHandler.is() )
{
if( pImp->pBasicManager->LegacyPsswdBinaryLimitExceeded( sModules ) )
if( pImp->aBasicManager.LegacyPsswdBinaryLimitExceeded( sModules ) )
{
ModuleSizeExceeded* pReq = new ModuleSizeExceeded( sModules );
uno::Reference< task::XInteractionRequest > xReq( pReq );

View file

@ -205,7 +205,6 @@ TYPEINIT1(SfxObjectShell, SfxShell);
SfxObjectShell_Impl::SfxObjectShell_Impl( SfxObjectShell& _rDocShell )
:mpObjectContainer(0)
,pBasicManager( new SfxBasicManagerHolder )
,rDocShell( _rDocShell )
,aMacroMode( *this )
,pProgress( 0)
@ -276,7 +275,6 @@ SfxObjectShell_Impl::SfxObjectShell_Impl( SfxObjectShell& _rDocShell )
SfxObjectShell_Impl::~SfxObjectShell_Impl()
{
delete pBasicManager;
}
@ -364,7 +362,7 @@ SfxObjectShell::~SfxObjectShell()
pSfxApp->ReleaseIndex(pImp->nVisualDocumentNumber);
// Destroy Basic-Manager
pImp->pBasicManager->reset( NULL );
pImp->aBasicManager.reset( NULL );
if ( pSfxApp->GetDdeService() )
pSfxApp->RemoveDdeTopic( this );
@ -688,7 +686,7 @@ namespace
{
if ( !_rDocument.Get_Impl()->bBasicInitialized )
const_cast< SfxObjectShell& >( _rDocument ).InitBasicManager_Impl();
return _rDocument.Get_Impl()->pBasicManager->get();
return _rDocument.Get_Impl()->aBasicManager.get();
}
// assume we do not have Basic ourself, but we can refer to another
@ -749,7 +747,7 @@ bool SfxObjectShell::HasBasic() const
if ( !pImp->bBasicInitialized )
const_cast< SfxObjectShell* >( this )->InitBasicManager_Impl();
return pImp->pBasicManager->isValid();
return pImp->aBasicManager.isValid();
#endif
}
@ -876,16 +874,16 @@ void SfxObjectShell::InitBasicManager_Impl()
Basic managers is the global BasicManagerRepository instance.
*/
#ifndef DISABLE_SCRIPTING
DBG_ASSERT( !pImp->bBasicInitialized && !pImp->pBasicManager->isValid(), "Lokaler BasicManager bereits vorhanden");
DBG_ASSERT( !pImp->bBasicInitialized && !pImp->aBasicManager.isValid(), "Lokaler BasicManager bereits vorhanden");
try
{
pImp->pBasicManager->reset( BasicManagerRepository::getDocumentBasicManager( GetModel() ) );
pImp->aBasicManager.reset( BasicManagerRepository::getDocumentBasicManager( GetModel() ) );
}
catch (const css::ucb::ContentCreationException& e)
{
SAL_WARN("sfx.doc", "caught exception " << e.Message);
}
DBG_ASSERT( pImp->pBasicManager->isValid(), "SfxObjectShell::InitBasicManager_Impl: did not get a BasicManager!" );
DBG_ASSERT( pImp->aBasicManager.isValid(), "SfxObjectShell::InitBasicManager_Impl: did not get a BasicManager!" );
pImp->bBasicInitialized = true;
#endif
}

View file

@ -31,6 +31,8 @@
#include <sfx2/docmacromode.hxx>
#include "bitset.hxx"
#include <appbaslib.hxx>
namespace svtools { class AsynchronLink; }
class SfxViewFrame;
@ -46,8 +48,7 @@ class SfxBasicManagerHolder;
struct SfxObjectShell_Impl : public ::sfx2::IMacroDocumentAccess
{
::comphelper::EmbeddedObjectContainer* mpObjectContainer;
SfxBasicManagerHolder*
pBasicManager;
SfxBasicManagerHolder aBasicManager;
SfxObjectShell& rDocShell;
::com::sun::star::uno::Reference< ::com::sun::star::script::XLibraryContainer >
xBasicLibraries;