diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2018-01-17 18:11:41 +0100 |
---|---|---|
committer | Julien Nabet <serval2412@yahoo.fr> | 2018-01-18 07:12:42 +0100 |
commit | 27938e1bbd5f3405c47b9933be7489eeb03920f3 (patch) | |
tree | 792f4df230b6364ef8eb578e647454648e2afd62 | |
parent | c915fdbfc77ac78d543bc097cd809edd7e6da8cb (diff) |
sfx2 store: create temp files next to local files (storage case)
This is similar to commit 5259ab8104cfba60c40748ed0cd59d93df038c5b (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/48071
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Tested-by: Jenkins <ci@libreoffice.org>
-rw-r--r-- | sfx2/source/doc/docfile.cxx | 36 |
1 files changed, 24 insertions, 12 deletions
diff --git a/sfx2/source/doc/docfile.cxx b/sfx2/source/doc/docfile.cxx index e862a88ecabe..bfc4476fdcd0 100644 --- a/sfx2/source/doc/docfile.cxx +++ b/sfx2/source/doc/docfile.cxx @@ -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() ) |