summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sfx2/qa/cppunit/test_misc.cxx8
-rw-r--r--sfx2/source/doc/docfile.cxx4
2 files changed, 11 insertions, 1 deletions
diff --git a/sfx2/qa/cppunit/test_misc.cxx b/sfx2/qa/cppunit/test_misc.cxx
index d74687b25431..817e246b6bf6 100644
--- a/sfx2/qa/cppunit/test_misc.cxx
+++ b/sfx2/qa/cppunit/test_misc.cxx
@@ -146,6 +146,14 @@ void MiscTest::testNoThumbnail()
// requested so.
CPPUNIT_ASSERT(aStatus.getAttributes() & osl_File_Attribute_GrpRead);
CPPUNIT_ASSERT(aStatus.getAttributes() & osl_File_Attribute_OthRead);
+
+ // Now "save as" again to trigger the "overwrite" case.
+ xStorable->storeToURL(aTempFile.GetURL(), {});
+ CPPUNIT_ASSERT_EQUAL(osl::DirectoryItem::E_None, aItem.getFileStatus(aStatus));
+ // The following check used to fail in the past, result had temp file
+ // permissions.
+ CPPUNIT_ASSERT(aStatus.getAttributes() & osl_File_Attribute_GrpRead);
+
umask(nMask);
#endif
diff --git a/sfx2/source/doc/docfile.cxx b/sfx2/source/doc/docfile.cxx
index 72a6c131fc41..2e8b874deedb 100644
--- a/sfx2/source/doc/docfile.cxx
+++ b/sfx2/source/doc/docfile.cxx
@@ -179,8 +179,10 @@ sal_uInt64 GetDefaultFileAttributes(const OUString& rURL)
if (!comphelper::isFileUrl(rURL))
return nRet;
+ // Make sure the file exists (and create it if not).
osl::File aFile(rURL);
- if (aFile.open(osl_File_OpenFlag_Create) != osl::File::E_None)
+ osl::File::RC nRes = aFile.open(osl_File_OpenFlag_Create);
+ if (nRes != osl::File::E_None && nRes != osl::File::E_EXIST)
return nRet;
aFile.close();