ole32: Move the logic in StgCreateDocfile for "if no share mode given then DENY_NONE is the default" to before the validateSTGM check.

Add a test that shows this behaviour is correct.

Remove a test on the access mode that is redundant because it is already 
done in validateSTGM.
This commit is contained in:
Rob Shearman 2007-05-09 23:31:08 +01:00 committed by Alexandre Julliard
parent 12aa9e33c5
commit b005e9ed0d
2 changed files with 10 additions and 8 deletions

View File

@ -5680,6 +5680,10 @@ HRESULT WINAPI StgCreateDocfile(
if (reserved != 0)
return STG_E_INVALIDPARAMETER;
/* if no share mode given then DENY_NONE is the default */
if (STGM_SHARE_MODE(grfMode) == 0)
grfMode |= STGM_SHARE_DENY_NONE;
/*
* Validate the STGM flags
*/
@ -5696,14 +5700,6 @@ HRESULT WINAPI StgCreateDocfile(
goto end;
}
/* if no share mode given then DENY_NONE is the default */
if (STGM_SHARE_MODE(grfMode) == 0)
grfMode |= STGM_SHARE_DENY_NONE;
/* must have at least one access mode */
if (STGM_ACCESS_MODE(grfMode) == 0)
goto end;
/* in direct mode, can only use SHARE_EXCLUSIVE */
if (!(grfMode & STGM_TRANSACTED) && (STGM_SHARE_MODE(grfMode) != STGM_SHARE_EXCLUSIVE))
goto end;

View File

@ -163,6 +163,12 @@ static void test_create_storage_modes(void)
ok(r == 0, "storage not released\n");
ok(DeleteFileW(filename), "failed to delete file\n");
r = StgCreateDocfile( filename, STGM_CREATE | STGM_READWRITE |STGM_TRANSACTED, 0, &stg);
ok(r==S_OK, "StgCreateDocfile failed\n");
r = IStorage_Release(stg);
ok(r == 0, "storage not released\n");
ok(DeleteFileW(filename), "failed to delete file\n");
/* test the way excel uses StgCreateDocFile */
r = StgCreateDocfile( filename, STGM_TRANSACTED|STGM_CREATE|STGM_SHARE_DENY_WRITE|STGM_READWRITE, 0, &stg);
ok(r==S_OK, "StgCreateDocfile the excel way failed\n");