diff options
Diffstat (limited to 'sfx2')
-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() ) |