diff options
Diffstat (limited to 'sfx2/source/doc/docfile.cxx')
-rw-r--r-- | sfx2/source/doc/docfile.cxx | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/sfx2/source/doc/docfile.cxx b/sfx2/source/doc/docfile.cxx index 9635f872b210..916acba81659 100644 --- a/sfx2/source/doc/docfile.cxx +++ b/sfx2/source/doc/docfile.cxx @@ -165,6 +165,32 @@ bool IsLockingUsed() #endif +/// Gets default attributes of a file:// URL. +sal_uInt64 GetDefaultFileAttributes(const OUString& rURL) +{ + sal_uInt64 nRet = 0; + + if (!comphelper::isFileUrl(rURL)) + return nRet; + + osl::File aFile(rURL); + if (aFile.open(osl_File_OpenFlag_Create) != osl::File::E_None) + return nRet; + + aFile.close(); + + osl::DirectoryItem aItem; + if (osl::DirectoryItem::get(rURL, aItem) != osl::DirectoryItem::E_None) + return nRet; + + osl::FileStatus aStatus(osl_FileStatus_Mask_Attributes); + if (aItem.getFileStatus(aStatus) != osl::DirectoryItem::E_None) + return nRet; + + nRet = aStatus.getAttributes(); + return nRet; +} + } // anonymous namespace class SfxMedium_Impl @@ -1785,8 +1811,16 @@ void SfxMedium::TransactedTransferForFS_Impl( const INetURLObject& aSource, { OUString aSourceMainURL = aSource.GetMainURL(INetURLObject::DecodeMechanism::NONE); OUString aDestMainURL = aDest.GetMainURL(INetURLObject::DecodeMechanism::NONE); + + sal_uInt64 nAttributes = GetDefaultFileAttributes(aDestMainURL); if (comphelper::isFileUrl(aDestMainURL) && osl::File::move(aSourceMainURL, aDestMainURL) == osl::FileBase::E_None) + { + if (nAttributes) + // Adjust attributes, source might be created with + // the osl_File_OpenFlag_Private flag. + osl::File::setAttributes(aDestMainURL, nAttributes); bResult = true; + } else { if (bOverWrite && ::utl::UCBContentHelper::IsDocument(aDestMainURL)) |