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

Alexandre Julliard julliard at winehq.org
Tue Jul 17 11:05:33 CDT 2012


Module: wine
Branch: master
Commit: 52ce30d242154530a0a46bae4d5bc332f7906c08
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=52ce30d242154530a0a46bae4d5bc332f7906c08

Author: Nikolay Sivov <nsivov at codeweavers.com>
Date:   Tue Jul 17 10:31:08 2012 +0400

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

---

 dlls/ole32/clipboard.c |    2 +-
 dlls/ole32/storage32.c |   73 +++++++++++++++++++----------------------------
 dlls/ole32/storage32.h |    2 +-
 3 files changed, 32 insertions(+), 45 deletions(-)

diff --git a/dlls/ole32/clipboard.c b/dlls/ole32/clipboard.c
index b98404f..57b0c46 100644
--- a/dlls/ole32/clipboard.c
+++ b/dlls/ole32/clipboard.c
@@ -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);
         }
     }
diff --git a/dlls/ole32/storage32.c b/dlls/ole32/storage32.c
index 30d380b..f4f2d88 100644
--- a/dlls/ole32/storage32.c
+++ b/dlls/ole32/storage32.c
@@ -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);
diff --git a/dlls/ole32/storage32.h b/dlls/ole32/storage32.h
index 80fe01b..f2061f3 100644
--- a/dlls/ole32/storage32.h
+++ b/dlls/ole32/storage32.h
@@ -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;
 
 




More information about the wine-cvs mailing list