ole32: Implement GetConvertStg().

This commit is contained in:
Nikolay Sivov 2012-07-13 11:56:26 +04:00 committed by Alexandre Julliard
parent ea196ef0eb
commit 7b373edb81
2 changed files with 62 additions and 3 deletions

View File

@ -9400,12 +9400,42 @@ HRESULT WINAPI OleConvertIStorageToOLESTREAM (
return hRes;
}
enum stream_1ole_flags {
OleStream_LinkedObject = 0x00000001,
OleStream_Convert = 0x00000100
};
/***********************************************************************
* GetConvertStg (OLE32.@)
*/
HRESULT WINAPI GetConvertStg(IStorage *stg) {
FIXME("unimplemented stub!\n");
return E_FAIL;
HRESULT WINAPI GetConvertStg(IStorage *stg)
{
static const WCHAR stream_1oleW[] = {1,'O','l','e',0};
static const DWORD version_magic = 0x02000001;
DWORD header[2];
IStream *stream;
HRESULT hr;
ULONG len;
TRACE("%p\n", stg);
if (!stg) return E_INVALIDARG;
hr = IStorage_OpenStream(stg, stream_1oleW, NULL, STGM_READ | STGM_SHARE_EXCLUSIVE, 0, &stream);
if (FAILED(hr)) return hr;
len = 0;
hr = IStream_Read(stream, header, sizeof(header), &len);
IStream_Release(stream);
if (FAILED(hr)) return hr;
if (header[0] != version_magic)
{
ERR("got wrong version magic for \1Ole stream, 0x%08x\n", header[0]);
return E_FAIL;
}
return header[1] & OleStream_Convert ? S_OK : S_FALSE;
}
/******************************************************************************

View File

@ -2995,6 +2995,34 @@ static void test_hglobal_storage_creation(void)
ILockBytes_Release(ilb);
}
static void test_convert(void)
{
static const WCHAR filename[] = {'s','t','o','r','a','g','e','.','s','t','g',0};
IStorage *stg;
HRESULT hr;
hr = GetConvertStg(NULL);
ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
hr = StgCreateDocfile( filename, STGM_CREATE | STGM_SHARE_EXCLUSIVE | STGM_READWRITE, 0, &stg);
ok(hr == S_OK, "StgCreateDocfile failed\n");
hr = GetConvertStg(stg);
ok(hr == STG_E_FILENOTFOUND, "got 0x%08x\n", hr);
hr = SetConvertStg(stg, TRUE);
todo_wine {
ok(hr == S_OK, "got 0x%08x\n", hr);
hr = GetConvertStg(stg);
ok(hr == S_OK, "got 0x%08x\n", hr);
hr = SetConvertStg(stg, FALSE);
ok(hr == S_OK, "got 0x%08x\n", hr);
hr = GetConvertStg(stg);
ok(hr == S_FALSE, "got 0x%08x\n", hr);
}
IStorage_Release(stg);
DeleteFileW(filename);
}
START_TEST(storage32)
{
CHAR temp[MAX_PATH];
@ -3038,4 +3066,5 @@ START_TEST(storage32)
test_copyto_locking();
test_copyto_recursive();
test_hglobal_storage_creation();
test_convert();
}