[OLE32] Sync with Wine Staging 2.2. CORE-12823
authorAmine Khaldi <amine.khaldi@reactos.org>
Sun, 5 Mar 2017 21:03:00 +0000 (21:03 +0000)
committerAmine Khaldi <amine.khaldi@reactos.org>
Sun, 5 Mar 2017 21:03:00 +0000 (21:03 +0000)
23607d0 ole32: Implement returning a name in IEnumSTATPROPSTG.
5cf1db5 ole32: Support reading VT_BOOL, VT_R8 and VT_I8 into propery storage.
591c9c8 ole32: Correctly parse unicode property storage dictionaries.
93a8ede ole32: Add a __WINE_ALLOC_SIZE attribute to heap_alloc().
182fad8 ole32: Call GetClipboardFormatName with the correct parameters.
e31dd0f ole32: Use a HWND_MESSAGE window for the clipboard.
c85eaae ole32: Only trace a clipboard format name if it has one.
77e566a ole32: Don't set zero-size clipboard data, this no longer works.

svn path=/trunk/; revision=74094

reactos/dll/win32/ole32/clipboard.c
reactos/dll/win32/ole32/compobj_private.h
reactos/dll/win32/ole32/enumx.c
reactos/dll/win32/ole32/enumx.h
reactos/dll/win32/ole32/ole32.spec
reactos/dll/win32/ole32/stg_prop.c
reactos/media/doc/README.WINE

index 6b7ccd5..cc14d17 100644 (file)
@@ -1094,7 +1094,7 @@ static HRESULT get_current_dataobject(IDataObject **data)
 
     h = GetClipboardData(wine_marshal_clipboard_format);
     if(!h) return S_FALSE;
-    if(GlobalSize(h) == 0) return S_FALSE;
+    if(GlobalSize(h) <= 1) return S_FALSE;
     ptr = GlobalLock(h);
     if(!ptr) return S_FALSE;
 
@@ -1182,9 +1182,11 @@ static HRESULT get_priv_data(ole_priv_data **data)
 
         for(cf = 0; (cf = EnumClipboardFormats(cf)) != 0; count++)
         {
-            char buf[100];
-            GetClipboardFormatNameA(cf, buf, sizeof(buf));
-            TRACE("cf %04x %s\n", cf, buf);
+            WCHAR buf[256];
+            if (GetClipboardFormatNameW(cf, buf, sizeof(buf) / sizeof(WCHAR)))
+                TRACE("cf %04x %s\n", cf, debugstr_w(buf));
+            else
+                TRACE("cf %04x\n", cf);
         }
         TRACE("count %d\n", count);
         size += count * sizeof(ret->entries[0]);
@@ -1941,7 +1943,7 @@ static HRESULT expose_marshalled_dataobject(ole_clipbrd *clipbrd, IDataObject *d
         dup_global_mem(h_stm, GMEM_DDESHARE|GMEM_MOVEABLE, &h);
     }
     else /* flushed */
-        h = GlobalAlloc(GMEM_DDESHARE|GMEM_MOVEABLE, 0);
+        h = GlobalAlloc(GMEM_DDESHARE|GMEM_MOVEABLE, 1);
 
     if(!h) return E_OUTOFMEMORY;
 
@@ -2084,8 +2086,7 @@ static HWND create_clipbrd_window(void)
     RegisterClassExW(&class);
 
     return CreateWindowW(clipbrd_wndclass, title, WS_POPUP | WS_CLIPSIBLINGS | WS_OVERLAPPED,
-                         CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
-                         NULL, NULL, hinst, 0);
+                         0, 0, 0, 0, HWND_MESSAGE, NULL, hinst, 0);
 }
 
 /*********************************************************************
index 64f3cf6..44f3094 100644 (file)
@@ -309,7 +309,7 @@ extern BOOL actctx_get_miscstatus(const CLSID*, DWORD, DWORD*) DECLSPEC_HIDDEN;
 
 extern const char *debugstr_formatetc(const FORMATETC *formatetc) DECLSPEC_HIDDEN;
 
-static inline void *heap_alloc(size_t len)
+static inline void* __WINE_ALLOC_SIZE(1) heap_alloc(size_t len)
 {
     return HeapAlloc(GetProcessHeap(), 0, len);
 }
index 7399a02..3af0cd1 100644 (file)
@@ -30,6 +30,8 @@ struct tagEnumSTATPROPSETSTG_impl
     struct list *current;
     ULONG elem_size;
     GUID riid;
+    IUnknown *parent;
+    enumx_copy_cb copy_cb;
 };
 
 /************************************************************************
@@ -80,6 +82,7 @@ ULONG WINAPI enumx_Release(enumx_impl *This)
              list_remove(x);
              HeapFree(GetProcessHeap(), 0, x);
         }
+        IUnknown_Release(This->parent);
         HeapFree(GetProcessHeap(), 0, This);
     }
     return ref;
@@ -101,7 +104,10 @@ HRESULT WINAPI enumx_Next(enumx_impl *This, ULONG celt,
     p = rgelt;
     while (count < celt && This->current && This->current != &This->elements)
     {
-        memcpy(p, &This->current[1], This->elem_size);
+        if (This->copy_cb)
+            This->copy_cb(This->parent, &This->current[1], p);
+        else
+            memcpy(p, &This->current[1], This->elem_size);
         p += This->elem_size;
         This->current = This->current->next;
         count++;
@@ -158,7 +164,8 @@ HRESULT WINAPI enumx_Clone(
  *
  * Allocate a generic enumerator
  */
-enumx_impl *enumx_allocate(REFIID riid, const void *vtbl, ULONG elem_size)
+enumx_impl *enumx_allocate(REFIID riid, const void *vtbl, ULONG elem_size,
+                           IUnknown *parent, enumx_copy_cb copy_cb)
 {
     enumx_impl *enumx;
 
@@ -170,6 +177,11 @@ enumx_impl *enumx_allocate(REFIID riid, const void *vtbl, ULONG elem_size)
         enumx->current = NULL;
         enumx->elem_size = elem_size;
         enumx->riid = *riid;
+        enumx->parent = parent;
+        enumx->copy_cb = copy_cb;
+
+        IUnknown_AddRef(parent);
+
         list_init(&enumx->elements);
     }
 
index d4347d9..6f784e1 100644 (file)
@@ -21,6 +21,8 @@
 
 typedef struct tagEnumSTATPROPSETSTG_impl enumx_impl;
 
+typedef void (*enumx_copy_cb)(IUnknown *parent, void *orig, void *dest);
+
 extern HRESULT WINAPI enumx_QueryInterface(enumx_impl *, REFIID, void**) DECLSPEC_HIDDEN;
 extern ULONG WINAPI enumx_AddRef(enumx_impl *) DECLSPEC_HIDDEN;
 extern ULONG WINAPI enumx_Release(enumx_impl *) DECLSPEC_HIDDEN;
@@ -28,7 +30,8 @@ extern HRESULT WINAPI enumx_Next(enumx_impl *, ULONG, void *, ULONG *) DECLSPEC_
 extern HRESULT WINAPI enumx_Skip(enumx_impl *, ULONG) DECLSPEC_HIDDEN;
 extern HRESULT WINAPI enumx_Reset(enumx_impl *) DECLSPEC_HIDDEN;
 extern HRESULT WINAPI enumx_Clone(enumx_impl *, enumx_impl **) DECLSPEC_HIDDEN;
-extern enumx_impl *enumx_allocate(REFIID, const void *, ULONG) DECLSPEC_HIDDEN;
+extern enumx_impl *enumx_allocate(REFIID, const void *, ULONG,
+                                  IUnknown *, enumx_copy_cb) DECLSPEC_HIDDEN;
 extern void *enumx_add_element(enumx_impl *, const void *) DECLSPEC_HIDDEN;
 
 #endif /* __OLE_ENUM_H__ */
index 5cef650..b2da889 100644 (file)
@@ -45,7 +45,7 @@
 @ stdcall CoGetDefaultContext(long ptr ptr)
 @ stdcall CoGetInstanceFromFile(ptr ptr ptr long long wstr long ptr)
 @ stdcall CoGetInstanceFromIStorage(ptr ptr ptr long ptr long ptr)
-# CoGetInterceptor
+@ stdcall -stub CoGetInterceptor(ptr ptr ptr ptr)
 # CoGetInterceptorFromTypeInfo
 @ stdcall CoGetInterfaceAndReleaseStream(ptr ptr ptr)
 @ stdcall CoGetMalloc(long ptr)
index a9308d6..aca47c8 100644 (file)
@@ -1004,15 +1004,18 @@ static HRESULT PropertyStorage_ReadDictionary(PropertyStorage_impl *This,
         if (This->codePage != CP_UNICODE)
             ptr[cbEntry - 1] = '\0';
         else
-            *((LPWSTR)ptr + cbEntry / sizeof(WCHAR)) = '\0';
+            ((LPWSTR)ptr)[cbEntry - 1] = 0;
         hr = PropertyStorage_StoreNameWithId(This, (char*)ptr, This->codePage, propid);
         if (This->codePage == CP_UNICODE)
         {
+            /* cbEntry is the number of characters */
+            cbEntry *= 2;
+
             /* Unicode entries are padded to DWORD boundaries */
             if (cbEntry % sizeof(DWORD))
                 ptr += sizeof(DWORD) - (cbEntry % sizeof(DWORD));
         }
-        ptr += sizeof(DWORD) + cbEntry;
+        ptr += cbEntry;
     }
     return hr;
 }
@@ -1053,6 +1056,10 @@ static HRESULT PropertyStorage_ReadProperty(PROPVARIANT *prop, const BYTE *data,
         prop->u.bVal = *data;
         TRACE("Read byte 0x%x\n", prop->u.bVal);
         break;
+    case VT_BOOL:
+        StorageUtl_ReadWord(data, 0, (WORD*)&prop->u.boolVal);
+        TRACE("Read bool %d\n", prop->u.boolVal);
+        break;
     case VT_I2:
         StorageUtl_ReadWord(data, 0, (WORD*)&prop->u.iVal);
         TRACE("Read short %d\n", prop->u.iVal);
@@ -1071,6 +1078,18 @@ static HRESULT PropertyStorage_ReadProperty(PROPVARIANT *prop, const BYTE *data,
         StorageUtl_ReadDWord(data, 0, &prop->u.ulVal);
         TRACE("Read ulong %d\n", prop->u.ulVal);
         break;
+    case VT_I8:
+        StorageUtl_ReadULargeInteger(data, 0, (ULARGE_INTEGER *)&prop->u.hVal);
+        TRACE("Read long long %s\n", wine_dbgstr_longlong(prop->u.hVal.QuadPart));
+        break;
+    case VT_UI8:
+        StorageUtl_ReadULargeInteger(data, 0, &prop->u.uhVal);
+        TRACE("Read ulong long %s\n", wine_dbgstr_longlong(prop->u.uhVal.QuadPart));
+        break;
+    case VT_R8:
+        memcpy(&prop->u.dblVal, data, sizeof(double));
+        TRACE("Read double %f\n", prop->u.dblVal);
+        break;
     case VT_LPSTR:
     {
         DWORD count;
@@ -2364,7 +2383,9 @@ static HRESULT create_EnumSTATPROPSETSTG(
 
     enumx = enumx_allocate(&IID_IEnumSTATPROPSETSTG,
                            &IEnumSTATPROPSETSTG_Vtbl,
-                           sizeof (STATPROPSETSTG));
+                           sizeof (STATPROPSETSTG),
+                           (IUnknown*)&This->base.IStorage_iface,
+                           NULL);
 
     /* add all the property set elements into a list */
     r = IStorage_EnumElements(stg, 0, NULL, 0, &penum);
@@ -2457,6 +2478,27 @@ static HRESULT WINAPI IEnumSTATPROPSTG_fnClone(
     return enumx_Clone((enumx_impl*)iface, (enumx_impl**)ppenum);
 }
 
+static void prop_enum_copy_cb(IUnknown *parent, void *orig, void *dest)
+{
+    PropertyStorage_impl *storage = impl_from_IPropertyStorage((IPropertyStorage*)parent);
+    STATPROPSTG *src_prop = orig;
+    STATPROPSTG *dest_prop = dest;
+    LPWSTR name;
+
+    dest_prop->propid = src_prop->propid;
+    dest_prop->vt = src_prop->vt;
+    dest_prop->lpwstrName = NULL;
+
+    if (dictionary_find(storage->propid_to_name, UlongToPtr(src_prop->propid), (void**)&name))
+    {
+        DWORD size = (strlenW(name) + 1) * sizeof(WCHAR);
+
+        dest_prop->lpwstrName = CoTaskMemAlloc(size);
+        if (!dest_prop->lpwstrName) return;
+        memcpy(dest_prop->lpwstrName, name, size);
+    }
+}
+
 static BOOL prop_enum_stat(const void *k, const void *v, void *extra, void *arg)
 {
     enumx_impl *enumx = arg;
@@ -2483,7 +2525,9 @@ static HRESULT create_EnumSTATPROPSTG(
 
     enumx = enumx_allocate(&IID_IEnumSTATPROPSTG,
                            &IEnumSTATPROPSTG_Vtbl,
-                           sizeof (STATPROPSTG));
+                           sizeof (STATPROPSTG),
+                           (IUnknown*)&This->IPropertyStorage_iface,
+                           prop_enum_copy_cb);
 
     dictionary_enumerate(This->propid_to_prop, prop_enum_stat, enumx);
 
index 5335a44..98d0ca4 100644 (file)
@@ -139,7 +139,7 @@ reactos/dll/win32/ntdsapi             # Synced to WineStaging-1.9.11
 reactos/dll/win32/objsel              # Synced to WineStaging-1.9.11
 reactos/dll/win32/odbc32              # Synced to WineStaging-2.2. Depends on port of Linux ODBC.
 reactos/dll/win32/odbccp32            # Synced to WineStaging-1.9.11
-reactos/dll/win32/ole32               # Synced to WineStaging-1.9.23
+reactos/dll/win32/ole32               # Synced to WineStaging-2.2
 reactos/dll/win32/oleacc              # Synced to WineStaging-1.9.11
 reactos/dll/win32/oleaut32            # Synced to WineStaging-1.9.23
 reactos/dll/win32/olecli32            # Synced to WineStaging-1.9.11