Commit 52ce30d2 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

ole32: Make ole stream creation helper capable of handling flags data.

parent 88e6c817
......@@ -662,7 +662,7 @@ static HRESULT render_embed_source_hack(IDataObject *data, LPFORMATETC fmt)
ProgIDFromCLSID(&clsID, &strProgID);
WideCharToMultiByte( CP_ACP, 0, strProgID, -1, strOleTypeName, sizeof(strOleTypeName), NULL, NULL );
OLECONVERT_CreateOleStream(std.u.pstg);
STORAGE_CreateOleStream(std.u.pstg, 0);
OLECONVERT_CreateCompObjStream(std.u.pstg, strOleTypeName);
}
}
......
......@@ -8520,18 +8520,18 @@ static DWORD OLECONVERT_WriteOLE20ToBuffer(LPSTORAGE pStorage, BYTE **pData)
}
/*************************************************************************
* OLECONVERT_CreateOleStream [Internal]
* STORAGE_CreateOleStream [Internal]
*
* Creates the "\001OLE" stream in the IStorage if necessary.
*
* PARAMS
* pStorage [I] Dest storage to create the stream in
* storage [I] Dest storage to create the stream in
* flags [I] flags to be set for newly created stream
*
* RETURNS
* Nothing
* HRESULT return value
*
* NOTES
* This function is used by OleConvertOLESTREAMToIStorage only.
*
* This stream is still unknown, MS Word seems to have extra data
* but since the data is stored in the OLESTREAM there should be
......@@ -8539,28 +8539,32 @@ static DWORD OLECONVERT_WriteOLE20ToBuffer(LPSTORAGE pStorage, BYTE **pData)
* deleted it will create it with this default data.
*
*/
void OLECONVERT_CreateOleStream(LPSTORAGE pStorage)
HRESULT STORAGE_CreateOleStream(IStorage *storage, DWORD flags)
{
HRESULT hRes;
IStream *pStream;
static const WCHAR wstrStreamName[] = {1,'O', 'l', 'e', 0};
BYTE pOleStreamHeader [] =
static const WCHAR stream_1oleW[] = {1,'O','l','e',0};
static const DWORD version_magic = 0x02000001;
IStream *stream;
HRESULT hr;
hr = IStorage_CreateStream(storage, stream_1oleW, STGM_WRITE | STGM_SHARE_EXCLUSIVE, 0, 0, &stream);
if (hr == S_OK)
{
0x01, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00
};
struct empty_1ole_stream {
DWORD version_magic;
DWORD flags;
BYTE padding[12];
};
struct empty_1ole_stream stream_data;
/* Create stream if not present */
hRes = IStorage_CreateStream(pStorage, wstrStreamName,
STGM_WRITE | STGM_SHARE_EXCLUSIVE, 0, 0, &pStream );
stream_data.version_magic = version_magic;
stream_data.flags = flags;
memset(stream_data.padding, 0, sizeof(stream_data.padding));
if(hRes == S_OK)
{
/* Write default Data */
hRes = IStream_Write(pStream, pOleStreamHeader, sizeof(pOleStreamHeader), NULL);
IStream_Release(pStream);
hr = IStream_Write(stream, &stream_data, sizeof(stream_data), NULL);
IStream_Release(stream);
}
return hr;
}
/* write a string to a stream, preceded by its length */
......@@ -9291,7 +9295,7 @@ HRESULT WINAPI OleConvertOLESTREAMToIStorage (
if(hRes == S_OK)
{
/*Create the Ole Stream if necessary */
OLECONVERT_CreateOleStream(pstg);
STORAGE_CreateOleStream(pstg, 0);
}
}
......@@ -9418,33 +9422,16 @@ HRESULT WINAPI GetConvertStg(IStorage *stg)
*/
HRESULT WINAPI SetConvertStg(IStorage *storage, BOOL convert)
{
static const WCHAR stream_1oleW[] = {1,'O','l','e',0};
static const DWORD version_magic = 0x02000001;
DWORD flags = convert ? OleStream_Convert : 0;
IStream *stream;
HRESULT hr;
TRACE("(%p, %d)\n", storage, convert);
hr = IStorage_CreateStream(storage, stream_1oleW, STGM_WRITE | STGM_SHARE_EXCLUSIVE, 0, 0, &stream);
if (hr == S_OK)
{
struct empty_1ole_stream {
DWORD version_magic;
DWORD flags;
BYTE padding[12];
};
struct empty_1ole_stream stream_data;
stream_data.version_magic = version_magic;
stream_data.flags = flags;
memset(stream_data.padding, 0, sizeof(stream_data.padding));
hr = IStream_Write(stream, &stream_data, sizeof(stream_data), NULL);
IStream_Release(stream);
}
else if (hr == STG_E_FILEALREADYEXISTS)
hr = STORAGE_CreateOleStream(storage, flags);
if (hr == STG_E_FILEALREADYEXISTS)
{
static const WCHAR stream_1oleW[] = {1,'O','l','e',0};
IStream *stream;
DWORD header[2];
hr = IStorage_OpenStream(storage, stream_1oleW, NULL, STGM_READWRITE | STGM_SHARE_EXCLUSIVE, 0, &stream);
......
......@@ -160,7 +160,7 @@ HRESULT FileLockBytesImpl_Construct(HANDLE hFile, DWORD openFlags, LPCWSTR pwcsN
* Ole Convert support
*/
void OLECONVERT_CreateOleStream(LPSTORAGE pStorage) DECLSPEC_HIDDEN;
HRESULT STORAGE_CreateOleStream(IStorage*, DWORD) DECLSPEC_HIDDEN;
HRESULT OLECONVERT_CreateCompObjStream(LPSTORAGE pStorage, LPCSTR strOleTypeName) DECLSPEC_HIDDEN;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment