summaryrefslogtreecommitdiff
path: root/sfx2/source/appl
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2022-05-31 09:57:02 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2022-05-31 14:55:23 +0200
commitaf44198d80edce92bdbb82dfd6f218eeb6163484 (patch)
treed7c978a978b1e66c2a61307cebcc768ca393ec88 /sfx2/source/appl
parent6f26b6aeca827329dd8d55f344e509fcf7685172 (diff)
these can be stack allocated
Change-Id: Idd2e5e49ba4fcef2e80fd9c569f374a6a69f380e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135175 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sfx2/source/appl')
-rw-r--r--sfx2/source/appl/childwin.cxx6
-rw-r--r--sfx2/source/appl/macroloader.cxx4
-rw-r--r--sfx2/source/appl/xpackcreator.cxx22
3 files changed, 12 insertions, 20 deletions
diff --git a/sfx2/source/appl/childwin.cxx b/sfx2/source/appl/childwin.cxx
index 8fb4fa8f6a01..75d72cae0e2b 100644
--- a/sfx2/source/appl/childwin.cxx
+++ b/sfx2/source/appl/childwin.cxx
@@ -355,14 +355,14 @@ void SfxChildWindow::InitializeChildWinFactory_Impl(sal_uInt16 nId, SfxChildWinI
{
// load configuration
- std::unique_ptr<SvtViewOptions> xWinOpt;
+ std::optional<SvtViewOptions> xWinOpt;
// first see if a module specific id exists
if (rInfo.aModule.getLength())
- xWinOpt.reset(new SvtViewOptions(EViewType::Window, rInfo.aModule + "/" + OUString::number(nId)));
+ xWinOpt.emplace(EViewType::Window, rInfo.aModule + "/" + OUString::number(nId));
// if not then try the generic id
if (!xWinOpt || !xWinOpt->Exists())
- xWinOpt.reset(new SvtViewOptions(EViewType::Window, OUString::number(nId)));
+ xWinOpt.emplace(EViewType::Window, OUString::number(nId));
if (xWinOpt->Exists() && xWinOpt->HasVisible() )
rInfo.bVisible = xWinOpt->IsVisible(); // set state from configuration. Can be overwritten by UserData, see below
diff --git a/sfx2/source/appl/macroloader.cxx b/sfx2/source/appl/macroloader.cxx
index 0892bb78e4d9..a6fe07000187 100644
--- a/sfx2/source/appl/macroloader.cxx
+++ b/sfx2/source/appl/macroloader.cxx
@@ -283,9 +283,9 @@ ErrCode SfxMacroLoader::loadMacro( const OUString& rURL, css::uno::Any& rRetval,
{
// attempt to protect the document against the script tampering with its Undo Context
- std::unique_ptr< ::framework::DocumentUndoGuard > pUndoGuard;
+ std::optional< ::framework::DocumentUndoGuard > pUndoGuard;
if ( bIsDocBasic )
- pUndoGuard.reset( new ::framework::DocumentUndoGuard( pDoc->GetModel() ) );
+ pUndoGuard.emplace( pDoc->GetModel() );
// execute the method
SbxVariableRef retValRef = new SbxVariable;
diff --git a/sfx2/source/appl/xpackcreator.cxx b/sfx2/source/appl/xpackcreator.cxx
index 825a334f30ee..b9aa2b53cdcf 100644
--- a/sfx2/source/appl/xpackcreator.cxx
+++ b/sfx2/source/appl/xpackcreator.cxx
@@ -65,8 +65,6 @@ void SAL_CALL OPackageStructureCreator::convertToPackage( const OUString& aFolde
::ucbhelper::Content aContent;
if( ::ucbhelper::Content::create( aFolderUrl, xComEnv, comphelper::getProcessComponentContext(), aContent ) )
{
- std::unique_ptr<SvStream> pTempStream;
-
OUString aTempURL = ::utl::TempFile().GetURL();
try {
if ( aContent.isFolder() )
@@ -80,18 +78,18 @@ void SAL_CALL OPackageStructureCreator::convertToPackage( const OUString& aFolde
if ( !aTempURL.isEmpty() )
{
- pTempStream.reset(new SvFileStream( aTempURL, StreamMode::STD_READWRITE ));
- tools::SvRef<SotStorage> aTargetStorage = new SotStorage( true, *pTempStream );
+ SvFileStream aTempStream( aTempURL, StreamMode::STD_READWRITE );
+ tools::SvRef<SotStorage> aTargetStorage = new SotStorage( true, aTempStream );
aStorage->CopyTo( aTargetStorage.get() );
aTargetStorage->Commit();
- if ( aStorage->GetError() || aTargetStorage->GetError() || pTempStream->GetError() )
+ if ( aStorage->GetError() || aTargetStorage->GetError() || aTempStream.GetError() )
throw io::IOException();
aTargetStorage = nullptr;
aStorage = nullptr;
- pTempStream->Seek( 0 );
+ aTempStream.Seek( 0 );
uno::Sequence< sal_Int8 > aSeq( 32000 );
sal_uInt32 nRead = 0;
@@ -99,13 +97,13 @@ void SAL_CALL OPackageStructureCreator::convertToPackage( const OUString& aFolde
if ( aSeq.getLength() < 32000 )
aSeq.realloc( 32000 );
- nRead = pTempStream->ReadBytes(aSeq.getArray(), 32000);
+ nRead = aTempStream.ReadBytes(aSeq.getArray(), 32000);
if ( nRead < 32000 )
aSeq.realloc( nRead );
xTargetStream->writeBytes( aSeq );
- } while (pTempStream->good() && nRead);
+ } while (aTempStream.good() && nRead);
- if ( pTempStream->GetError() )
+ if ( aTempStream.GetError() )
throw io::IOException();
bSuccess = true;
@@ -114,8 +112,6 @@ void SAL_CALL OPackageStructureCreator::convertToPackage( const OUString& aFolde
}
catch (const uno::RuntimeException&)
{
- pTempStream.reset();
-
if ( !aTempURL.isEmpty() )
::utl::UCBContentHelper::Kill( aTempURL );
@@ -123,8 +119,6 @@ void SAL_CALL OPackageStructureCreator::convertToPackage( const OUString& aFolde
}
catch (const io::IOException&)
{
- pTempStream.reset();
-
if ( !aTempURL.isEmpty() )
::utl::UCBContentHelper::Kill( aTempURL );
@@ -134,8 +128,6 @@ void SAL_CALL OPackageStructureCreator::convertToPackage( const OUString& aFolde
{
}
- pTempStream.reset();
-
if ( !aTempURL.isEmpty() )
::utl::UCBContentHelper::Kill( aTempURL );
}