Huw Davies : ole32: Add support for getting storage based objects from a flushed clipboard.

Alexandre Julliard julliard at winehq.org
Thu Apr 16 14:34:52 CDT 2009


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

Author: Huw Davies <huw at codeweavers.com>
Date:   Thu Apr 16 12:34:25 2009 +0100

ole32: Add support for getting storage based objects from a flushed clipboard.

---

 dlls/ole32/clipboard.c |   40 +++++++++++++++++++++++++++++++++++++++-
 1 files changed, 39 insertions(+), 1 deletions(-)

diff --git a/dlls/ole32/clipboard.c b/dlls/ole32/clipboard.c
index 9f2f9e7..7188297 100644
--- a/dlls/ole32/clipboard.c
+++ b/dlls/ole32/clipboard.c
@@ -986,6 +986,42 @@ static HRESULT get_stgmed_for_stream(HGLOBAL h, STGMEDIUM *med)
 }
 
 /************************************************************************
+ *                    get_stgmed_for_storage
+ *
+ * Returns a stg medium with a storage based on the handle
+ */
+static HRESULT get_stgmed_for_storage(HGLOBAL h, STGMEDIUM *med)
+{
+    HRESULT hr;
+    HGLOBAL dst;
+    ILockBytes *lbs;
+
+    med->pUnkForRelease = NULL;
+    med->tymed = TYMED_NULL;
+
+    hr = dup_global_mem(h, GMEM_MOVEABLE, &dst);
+    if(FAILED(hr)) return hr;
+
+    hr = CreateILockBytesOnHGlobal(dst, TRUE, &lbs);
+    if(FAILED(hr))
+    {
+        GlobalFree(dst);
+        return hr;
+    }
+
+    hr = StgOpenStorageOnILockBytes(lbs, NULL,  STGM_SHARE_EXCLUSIVE | STGM_READWRITE, NULL, 0, &med->u.pstg);
+    ILockBytes_Release(lbs);
+    if(FAILED(hr))
+    {
+        GlobalFree(dst);
+        return hr;
+    }
+
+    med->tymed = TYMED_ISTORAGE;
+    return hr;
+}
+
+/************************************************************************
  *         snapshot_GetData
  */
 static HRESULT WINAPI snapshot_GetData(IDataObject *iface, FORMATETC *fmt,
@@ -1030,7 +1066,9 @@ static HRESULT WINAPI snapshot_GetData(IDataObject *iface, FORMATETC *fmt,
     else /* non-Ole format */
         mask = fmt->tymed & TYMED_HGLOBAL;
 
-    if(mask & TYMED_HGLOBAL)
+    if(mask & TYMED_ISTORAGE)
+        hr = get_stgmed_for_storage(h, med);
+    else if(mask & TYMED_HGLOBAL)
         hr = get_stgmed_for_global(h, med);
     else if(mask & TYMED_ISTREAM)
         hr = get_stgmed_for_stream(h, med);




More information about the wine-cvs mailing list