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>
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 );
|
||||
}
|
||||
|
||||
@@ -205,10 +205,10 @@ static void PropagateEvent_Impl( SfxObjectShell const *pDoc, const OUString& aEv
|
||||
|
||||
void SfxEventConfiguration::ConfigureEvent( const OUString& aName, const SvxMacro& rMacro, SfxObjectShell const *pDoc )
|
||||
{
|
||||
std::unique_ptr<SvxMacro> pMacro;
|
||||
std::optional<SvxMacro> pMacro;
|
||||
if ( rMacro.HasMacro() )
|
||||
pMacro.reset( new SvxMacro( rMacro.GetMacName(), rMacro.GetLibName(), rMacro.GetScriptType() ) );
|
||||
PropagateEvent_Impl( pDoc ? pDoc : nullptr, aName, pMacro.get() );
|
||||
pMacro.emplace( rMacro.GetMacName(), rMacro.GetLibName(), rMacro.GetScriptType() );
|
||||
PropagateEvent_Impl( pDoc ? pDoc : nullptr, aName, pMacro ? &*pMacro : nullptr );
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -110,18 +110,18 @@ std::unique_ptr<SfxMedium> DocumentInserter::CreateMedium(char const*const pFall
|
||||
m_pURLList[0], SFX_STREAM_READONLY,
|
||||
SfxGetpApp()->GetFilterMatcher().GetFilter4FilterName( m_sFilter ), m_xItemSet ));
|
||||
pMedium->UseInteractionHandler( true );
|
||||
std::unique_ptr<SfxFilterMatcher> pMatcher;
|
||||
std::optional<SfxFilterMatcher> pMatcher;
|
||||
if ( !m_sDocFactory.isEmpty() )
|
||||
pMatcher.reset(new SfxFilterMatcher(m_sDocFactory));
|
||||
pMatcher.emplace(m_sDocFactory);
|
||||
else
|
||||
pMatcher.reset(new SfxFilterMatcher());
|
||||
pMatcher.emplace();
|
||||
|
||||
std::shared_ptr<const SfxFilter> pFilter;
|
||||
ErrCode nError = pMatcher->DetectFilter( *pMedium, pFilter );
|
||||
// tdf#101813 hack: check again if it's a global document
|
||||
if (ERRCODE_NONE != nError && pFallbackHack)
|
||||
{
|
||||
pMatcher.reset(new SfxFilterMatcher(OUString::createFromAscii(pFallbackHack)));
|
||||
pMatcher.emplace(OUString::createFromAscii(pFallbackHack));
|
||||
nError = pMatcher->DetectFilter( *pMedium, pFilter );
|
||||
}
|
||||
if ( nError == ERRCODE_NONE && pFilter )
|
||||
|
||||
Reference in New Issue
Block a user