Kaydet (Commit) 27938e1b authored tarafından Miklos Vajna's avatar Miklos Vajna Kaydeden (comit) Julien Nabet

sfx2 store: create temp files next to local files (storage case)

This is similar to commit 5259ab81 (sfx2
store: create temp files next to local files, 2018-01-08), except there
only the stream case was handled (e.g. sw HTML export), while this is
the storage case (e.g. ODT export).

Change-Id: I88d78aa0f09e9fdfdd27cd0fad1a2633ff54d576
Reviewed-on: https://gerrit.libreoffice.org/48071Reviewed-by: 's avatarMiklos Vajna <vmiklos@collabora.co.uk>
Tested-by: 's avatarJenkins <ci@libreoffice.org>
üst c915fdbf
......@@ -3398,19 +3398,13 @@ bool SfxMedium::SetWritableForUserOnly( const OUString& aURL )
return bResult;
}
void SfxMedium::CreateTempFile( bool bReplace )
namespace
{
/// Get the parent directory of a temporary file for output purposes.
OUString GetLogicBase(std::unique_ptr<SfxMedium_Impl>& pImpl)
{
if ( pImpl->pTempFile )
{
if ( !bReplace )
return;
DELETEZ( pImpl->pTempFile );
pImpl->m_aName.clear();
}
OUString aLogicBase;
if (comphelper::isFileUrl(pImpl->m_aLogicName) && !pImpl->m_pInStream)
{
// Try to create the temp file in the same directory when storing.
......@@ -3421,6 +3415,23 @@ void SfxMedium::CreateTempFile( bool bReplace )
// Doesn't make sense.
aLogicBase.clear();
}
return aLogicBase;
}
}
void SfxMedium::CreateTempFile( bool bReplace )
{
if ( pImpl->pTempFile )
{
if ( !bReplace )
return;
DELETEZ( pImpl->pTempFile );
pImpl->m_aName.clear();
}
OUString aLogicBase = GetLogicBase(pImpl);
pImpl->pTempFile = new ::utl::TempFile(aLogicBase.isEmpty() ? nullptr : &aLogicBase);
pImpl->pTempFile->EnableKillingFile();
pImpl->m_aName = pImpl->pTempFile->GetFileName();
......@@ -3519,7 +3530,8 @@ void SfxMedium::CreateTempFileNoCopy()
// this call always replaces the existing temporary file
delete pImpl->pTempFile;
pImpl->pTempFile = new ::utl::TempFile();
OUString aLogicBase = GetLogicBase(pImpl);
pImpl->pTempFile = new ::utl::TempFile(aLogicBase.isEmpty() ? nullptr : &aLogicBase);
pImpl->pTempFile->EnableKillingFile();
pImpl->m_aName = pImpl->pTempFile->GetFileName();
if ( pImpl->m_aName.isEmpty() )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment