summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2020-08-12 12:46:35 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2020-08-13 08:17:22 +0200
commit8ce3647224c9aae6425dcb199d2b83de2359665c (patch)
tree99cc4cf45006b472a5ae2bfb38b9ded2de8b46aa
parent8436c023383e46d50c3d31736ea02896f7282781 (diff)
use unique_ptr in SfxObjectShell_Impl
Change-Id: I90fda5d15168027bb92d9c6265b0065e3fa0472d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100621 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r--sfx2/source/doc/objembed.cxx8
-rw-r--r--sfx2/source/doc/objmisc.cxx2
-rw-r--r--sfx2/source/doc/objstor.cxx24
-rw-r--r--sfx2/source/doc/objxtor.cxx9
-rw-r--r--sfx2/source/inc/objshimp.hxx2
5 files changed, 22 insertions, 23 deletions
diff --git a/sfx2/source/doc/objembed.cxx b/sfx2/source/doc/objembed.cxx
index 0436530b7d3b..f6b4f5345055 100644
--- a/sfx2/source/doc/objembed.cxx
+++ b/sfx2/source/doc/objembed.cxx
@@ -231,15 +231,15 @@ void SfxObjectShell::DoDraw_Impl( OutputDevice* pDev,
comphelper::EmbeddedObjectContainer& SfxObjectShell::GetEmbeddedObjectContainer() const
{
- if ( !pImpl->mpObjectContainer )
- pImpl->mpObjectContainer = new comphelper::EmbeddedObjectContainer( const_cast<SfxObjectShell*>(this)->GetStorage(), GetModel() );
- return *pImpl->mpObjectContainer;
+ if ( !pImpl->mxObjectContainer )
+ pImpl->mxObjectContainer.reset(new comphelper::EmbeddedObjectContainer( const_cast<SfxObjectShell*>(this)->GetStorage(), GetModel() ));
+ return *pImpl->mxObjectContainer;
}
void SfxObjectShell::ClearEmbeddedObjects()
{
// frees all space taken by embedded objects
- DELETEZ( pImpl->mpObjectContainer );
+ pImpl->mxObjectContainer.reset();
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sfx2/source/doc/objmisc.cxx b/sfx2/source/doc/objmisc.cxx
index 1961a7282ef5..1a5cde068054 100644
--- a/sfx2/source/doc/objmisc.cxx
+++ b/sfx2/source/doc/objmisc.cxx
@@ -263,7 +263,7 @@ bool SfxObjectShell::IsModified() const
return false;
}
- if (pImpl->mpObjectContainer)
+ if (pImpl->mxObjectContainer)
{
const uno::Sequence < OUString > aNames = GetEmbeddedObjectContainer().GetObjectNames();
for ( const auto& rName : aNames )
diff --git a/sfx2/source/doc/objstor.cxx b/sfx2/source/doc/objstor.cxx
index 76c929e1ee76..b22029107d59 100644
--- a/sfx2/source/doc/objstor.cxx
+++ b/sfx2/source/doc/objstor.cxx
@@ -3160,7 +3160,7 @@ uno::Reference< embed::XStorage > const & SfxObjectShell::GetStorage()
void SfxObjectShell::SaveChildren( bool bObjectsOnly )
{
- if ( pImpl->mpObjectContainer )
+ if ( pImpl->mxObjectContainer )
{
bool bOasis = ( SotStorage::GetVersion( GetStorage() ) > SOFFICE_FILEFORMAT_60 );
GetEmbeddedObjectContainer().StoreChildren(bOasis,bObjectsOnly);
@@ -3179,7 +3179,7 @@ bool SfxObjectShell::SaveAsChildren( SfxMedium& rMedium )
return true;
}
- if ( pImpl->mpObjectContainer )
+ if ( pImpl->mxObjectContainer )
{
bool bOasis = ( SotStorage::GetVersion( xStorage ) > SOFFICE_FILEFORMAT_60 );
GetEmbeddedObjectContainer().StoreAsChildren(bOasis,SfxObjectCreateMode::EMBEDDED == eCreateMode,xStorage);
@@ -3201,7 +3201,7 @@ bool SfxObjectShell::SaveCompletedChildren()
{
bool bResult = true;
- if ( pImpl->mpObjectContainer )
+ if ( pImpl->mxObjectContainer )
{
const uno::Sequence < OUString > aNames = GetEmbeddedObjectContainer().GetObjectNames();
for ( const auto& rName : aNames )
@@ -3240,8 +3240,8 @@ bool SfxObjectShell::SwitchChildrenPersistance( const uno::Reference< embed::XSt
return false;
}
- if ( pImpl->mpObjectContainer )
- pImpl->mpObjectContainer->SetPersistentEntries(xStorage,bForceNonModified);
+ if ( pImpl->mxObjectContainer )
+ pImpl->mxObjectContainer->SetPersistentEntries(xStorage,bForceNonModified);
return true;
}
@@ -3254,7 +3254,7 @@ bool SfxObjectShell::SaveCompleted( const uno::Reference< embed::XStorage >& xSt
uno::Reference< embed::XStorage > xOldStorageHolder;
// check for wrong creation of object container
- bool bHasContainer = ( pImpl->mpObjectContainer != nullptr );
+ bool bHasContainer( pImpl->mxObjectContainer );
if ( !xStorage.is() || xStorage == GetStorage() )
{
@@ -3263,7 +3263,7 @@ bool SfxObjectShell::SaveCompleted( const uno::Reference< embed::XStorage >& xSt
}
else
{
- if ( pImpl->mpObjectContainer )
+ if ( pImpl->mxObjectContainer )
GetEmbeddedObjectContainer().SwitchPersistence( xStorage );
bResult = SwitchChildrenPersistance( xStorage, true );
@@ -3275,7 +3275,7 @@ bool SfxObjectShell::SaveCompleted( const uno::Reference< embed::XStorage >& xSt
{
// make sure that until the storage is assigned the object
// container is not created by accident!
- DBG_ASSERT( bHasContainer == (pImpl->mpObjectContainer != nullptr), "Wrong storage in object container!" );
+ DBG_ASSERT( bHasContainer == (pImpl->mxObjectContainer != nullptr), "Wrong storage in object container!" );
xOldStorageHolder = pImpl->m_xDocStorage;
pImpl->m_xDocStorage = xStorage;
bSendNotification = true;
@@ -3286,7 +3286,7 @@ bool SfxObjectShell::SaveCompleted( const uno::Reference< embed::XStorage >& xSt
}
else
{
- if ( pImpl->mpObjectContainer )
+ if ( pImpl->mxObjectContainer )
GetEmbeddedObjectContainer().SwitchPersistence( pImpl->m_xDocStorage );
// let already successfully connected objects be switched back
@@ -3397,10 +3397,10 @@ bool SfxObjectShell::SwitchPersistance( const uno::Reference< embed::XStorage >&
{
bool bResult = false;
// check for wrong creation of object container
- bool bHasContainer = ( pImpl->mpObjectContainer != nullptr );
+ bool bHasContainer( pImpl->mxObjectContainer );
if ( xStorage.is() )
{
- if ( pImpl->mpObjectContainer )
+ if ( pImpl->mxObjectContainer )
GetEmbeddedObjectContainer().SwitchPersistence( xStorage );
bResult = SwitchChildrenPersistance( xStorage );
@@ -3412,7 +3412,7 @@ bool SfxObjectShell::SwitchPersistance( const uno::Reference< embed::XStorage >&
if ( bResult )
{
// make sure that until the storage is assigned the object container is not created by accident!
- DBG_ASSERT( bHasContainer == (pImpl->mpObjectContainer != nullptr), "Wrong storage in object container!" );
+ DBG_ASSERT( bHasContainer == (pImpl->mxObjectContainer != nullptr), "Wrong storage in object container!" );
if ( pImpl->m_xDocStorage != xStorage )
DoSaveCompleted( new SfxMedium( xStorage, GetMedium()->GetBaseURL() ) );
diff --git a/sfx2/source/doc/objxtor.cxx b/sfx2/source/doc/objxtor.cxx
index 94676951f0e1..fb5a1677d6d2 100644
--- a/sfx2/source/doc/objxtor.cxx
+++ b/sfx2/source/doc/objxtor.cxx
@@ -179,8 +179,7 @@ void SAL_CALL SfxModelListener_Impl::disposing( const css::lang::EventObject& _r
SfxObjectShell_Impl::SfxObjectShell_Impl( SfxObjectShell& _rDocShell )
- :mpObjectContainer(nullptr)
- ,rDocShell( _rDocShell )
+ :rDocShell( _rDocShell )
,aMacroMode( *this )
,pProgress( nullptr)
,nTime( DateTime::SYSTEM )
@@ -308,10 +307,10 @@ SfxObjectShell::~SfxObjectShell()
if ( pMedium && pMedium->HasStorage_Impl() && pMedium->GetStorage( false ) == pImpl->m_xDocStorage )
pMedium->CanDisposeStorage_Impl( false );
- if ( pImpl->mpObjectContainer )
+ if ( pImpl->mxObjectContainer )
{
- pImpl->mpObjectContainer->CloseEmbeddedObjects();
- delete pImpl->mpObjectContainer;
+ pImpl->mxObjectContainer->CloseEmbeddedObjects();
+ pImpl->mxObjectContainer.reset();
}
if ( pImpl->bOwnsStorage && pImpl->m_xDocStorage.is() )
diff --git a/sfx2/source/inc/objshimp.hxx b/sfx2/source/inc/objshimp.hxx
index ae0d1ed24c64..21799f7cad49 100644
--- a/sfx2/source/inc/objshimp.hxx
+++ b/sfx2/source/inc/objshimp.hxx
@@ -50,7 +50,7 @@ public:
struct SfxObjectShell_Impl : public ::sfx2::IMacroDocumentAccess
{
- ::comphelper::EmbeddedObjectContainer* mpObjectContainer;
+ std::unique_ptr<::comphelper::EmbeddedObjectContainer> mxObjectContainer;
SfxBasicManagerHolder aBasicManager;
SfxObjectShell& rDocShell;
css::uno::Reference< css::script::XLibraryContainer >