ole32: Use a single implementation for 1Ole stream initialization

Nikolay Sivov nsivov at codeweavers.com
Thu Jul 19 01:47:26 CDT 2012


Use a single implementation for 1Ole stream initialization
-------------- next part --------------
>From a34117b2f72535f62aa769e0ca1ac3f3967ebda7 Mon Sep 17 00:00:00 2001
From: Nikolay Sivov <nsivov at codeweavers.com>
Date: Thu, 19 Jul 2012 10:35:08 +0400
Subject: [PATCH 2/2] Use a single implementation for 1Ole stream initialization

---
 dlls/ole32/defaulthandler.c |   37 ++++++-------------------------------
 1 files changed, 6 insertions(+), 31 deletions(-)

diff --git a/dlls/ole32/defaulthandler.c b/dlls/ole32/defaulthandler.c
index 68d85ec..b43b962 100644
--- a/dlls/ole32/defaulthandler.c
+++ b/dlls/ole32/defaulthandler.c
@@ -58,6 +58,7 @@
 #include "ole2.h"
 
 #include "compobj_private.h"
+#include "storage32.h"
 
 #include "wine/unicode.h"
 #include "wine/debug.h"
@@ -1583,10 +1584,8 @@ static HRESULT WINAPI DefaultHandler_IPersistStorage_IsDirty(
 }
 
 /***********************************************************************
- *   init_ole_stream
  *
- * Creates the '\1Ole' stream.
- * The format of this stream is as follows:
+ * The format of '\1Ole' stream is as follows:
  *
  * DWORD Version == 0x02000001
  * DWORD Flags - low bit set indicates the object is a link otherwise it's embedded.
@@ -1611,29 +1610,6 @@ typedef struct
 } ole_stream_header_t;
 static const DWORD ole_stream_version = 0x02000001;
 
-static void init_ole_stream(IStorage *storage)
-{
-    HRESULT hr;
-    IStream *stream;
-
-    hr = IStorage_CreateStream(storage, OleStream, STGM_READWRITE | STGM_SHARE_EXCLUSIVE, 0, 0, &stream);
-    if(SUCCEEDED(hr))
-    {
-        DWORD written;
-        ole_stream_header_t header;
-
-        header.version         = ole_stream_version;
-        header.flags           = 0;
-        header.link_update_opt = 0;
-        header.res             = 0;
-        header.moniker_size    = 0;
-
-        IStream_Write(stream, &header, sizeof(header), &written);
-        IStream_Release(stream);
-    }
-    return;
-}
-
 static HRESULT load_ole_stream(DefaultHandler *This, IStorage *storage)
 {
     IStream *stream;
@@ -1663,10 +1639,8 @@ static HRESULT load_ole_stream(DefaultHandler *This, IStorage *storage)
         IStream_Release(stream);
     }
     else
-    {
-        init_ole_stream(storage);
-        hr = S_OK;
-    }
+        hr = STORAGE_CreateOleStream(storage, 0);
+
     return hr;
 }
 
@@ -1682,7 +1656,8 @@ static HRESULT WINAPI DefaultHandler_IPersistStorage_InitNew(
     HRESULT hr;
 
     TRACE("(%p)->(%p)\n", iface, pStg);
-    init_ole_stream(pStg);
+    hr = STORAGE_CreateOleStream(pStg, 0);
+    if (hr != S_OK) return hr;
 
     hr = IPersistStorage_InitNew(This->dataCache_PersistStg, pStg);
 
-- 
1.5.6.5



More information about the wine-patches mailing list