sfx2/source/doc/docfile.cxx | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-)
New commits: commit 27938e1bbd5f3405c47b9933be7489eeb03920f3 Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Wed Jan 17 18:11:41 2018 +0100 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 <vmik...@collabora.co.uk> Tested-by: Jenkins <c...@libreoffice.org> 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() ) _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits