ole32: Make ole stream creation helper capable of handling flags data.
This commit is contained in:
parent
88e6c8175b
commit
52ce30d242
|
@ -662,7 +662,7 @@ static HRESULT render_embed_source_hack(IDataObject *data, LPFORMATETC fmt)
|
||||||
ProgIDFromCLSID(&clsID, &strProgID);
|
ProgIDFromCLSID(&clsID, &strProgID);
|
||||||
|
|
||||||
WideCharToMultiByte( CP_ACP, 0, strProgID, -1, strOleTypeName, sizeof(strOleTypeName), NULL, NULL );
|
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);
|
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.
|
* Creates the "\001OLE" stream in the IStorage if necessary.
|
||||||
*
|
*
|
||||||
* PARAMS
|
* 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
|
* RETURNS
|
||||||
* Nothing
|
* HRESULT return value
|
||||||
*
|
*
|
||||||
* NOTES
|
* NOTES
|
||||||
* This function is used by OleConvertOLESTREAMToIStorage only.
|
|
||||||
*
|
*
|
||||||
* This stream is still unknown, MS Word seems to have extra data
|
* This stream is still unknown, MS Word seems to have extra data
|
||||||
* but since the data is stored in the OLESTREAM there should be
|
* 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.
|
* deleted it will create it with this default data.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void OLECONVERT_CreateOleStream(LPSTORAGE pStorage)
|
HRESULT STORAGE_CreateOleStream(IStorage *storage, DWORD flags)
|
||||||
{
|
{
|
||||||
HRESULT hRes;
|
static const WCHAR stream_1oleW[] = {1,'O','l','e',0};
|
||||||
IStream *pStream;
|
static const DWORD version_magic = 0x02000001;
|
||||||
static const WCHAR wstrStreamName[] = {1,'O', 'l', 'e', 0};
|
IStream *stream;
|
||||||
BYTE pOleStreamHeader [] =
|
HRESULT hr;
|
||||||
{
|
|
||||||
0x01, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00
|
|
||||||
};
|
|
||||||
|
|
||||||
/* Create stream if not present */
|
hr = IStorage_CreateStream(storage, stream_1oleW, STGM_WRITE | STGM_SHARE_EXCLUSIVE, 0, 0, &stream);
|
||||||
hRes = IStorage_CreateStream(pStorage, wstrStreamName,
|
if (hr == S_OK)
|
||||||
STGM_WRITE | STGM_SHARE_EXCLUSIVE, 0, 0, &pStream );
|
|
||||||
|
|
||||||
if(hRes == S_OK)
|
|
||||||
{
|
{
|
||||||
/* Write default Data */
|
struct empty_1ole_stream {
|
||||||
hRes = IStream_Write(pStream, pOleStreamHeader, sizeof(pOleStreamHeader), NULL);
|
DWORD version_magic;
|
||||||
IStream_Release(pStream);
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return hr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* write a string to a stream, preceded by its length */
|
/* write a string to a stream, preceded by its length */
|
||||||
|
@ -9291,7 +9295,7 @@ HRESULT WINAPI OleConvertOLESTREAMToIStorage (
|
||||||
if(hRes == S_OK)
|
if(hRes == S_OK)
|
||||||
{
|
{
|
||||||
/*Create the Ole Stream if necessary */
|
/*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)
|
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;
|
DWORD flags = convert ? OleStream_Convert : 0;
|
||||||
IStream *stream;
|
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
|
|
||||||
TRACE("(%p, %d)\n", storage, convert);
|
TRACE("(%p, %d)\n", storage, convert);
|
||||||
|
|
||||||
hr = IStorage_CreateStream(storage, stream_1oleW, STGM_WRITE | STGM_SHARE_EXCLUSIVE, 0, 0, &stream);
|
hr = STORAGE_CreateOleStream(storage, flags);
|
||||||
if (hr == S_OK)
|
if (hr == STG_E_FILEALREADYEXISTS)
|
||||||
{
|
|
||||||
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)
|
|
||||||
{
|
{
|
||||||
|
static const WCHAR stream_1oleW[] = {1,'O','l','e',0};
|
||||||
|
IStream *stream;
|
||||||
DWORD header[2];
|
DWORD header[2];
|
||||||
|
|
||||||
hr = IStorage_OpenStream(storage, stream_1oleW, NULL, STGM_READWRITE | STGM_SHARE_EXCLUSIVE, 0, &stream);
|
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
|
* 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;
|
HRESULT OLECONVERT_CreateCompObjStream(LPSTORAGE pStorage, LPCSTR strOleTypeName) DECLSPEC_HIDDEN;
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue