ReactOS 0.4.15-dev-7788-g1ad9096
ole2impl.c File Reference
#include <stdarg.h>
#include <string.h>
#include "windef.h"
#include "winbase.h"
#include "wingdi.h"
#include "winuser.h"
#include "wine/debug.h"
#include "ole2.h"
#include "olestd.h"
#include "compobj_private.h"
Include dependency graph for ole2impl.c:

Go to the source code of this file.

Macros

#define COBJMACROS
 
#define NONAMELESSUNION
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (ole)
 
HRESULT WINAPI OleQueryCreateFromData (IDataObject *data)
 
static void init_fmtetc (FORMATETC *fmt, CLIPFORMAT cf, TYMED tymed)
 
static HRESULT get_storage (IDataObject *data, IStorage *stg, UINT *src_cf, BOOL other_fmts)
 
HRESULT WINAPI OleCreateFromDataEx (IDataObject *data, REFIID iid, DWORD flags, DWORD renderopt, ULONG num_cache_fmts, DWORD *adv_flags, FORMATETC *cache_fmts, IAdviseSink *sink, DWORD *conns, IOleClientSite *client_site, IStorage *stg, void **obj)
 
HRESULT WINAPI OleCreateFromData (LPDATAOBJECT data, REFIID iid, DWORD renderopt, LPFORMATETC fmt, LPOLECLIENTSITE client_site, LPSTORAGE stg, LPVOID *obj)
 
HRESULT WINAPI OleCreateLinkFromData (IDataObject *data, REFIID iid, DWORD renderopt, FORMATETC *fmt, IOleClientSite *client_site, IStorage *stg, void **obj)
 
HRESULT WINAPI OleCreateStaticFromData (IDataObject *data, REFIID iid, DWORD renderopt, FORMATETC *fmt, IOleClientSite *client_site, IStorage *stg, void **obj)
 
HRESULT WINAPI OleCreateFromFileEx (REFCLSID clsid, const OLECHAR *filename, REFIID iid, DWORD flags, DWORD renderopt, ULONG num_fmts, DWORD *adv_flags, FORMATETC *fmts, IAdviseSink *sink, DWORD *conns, IOleClientSite *client_site, IStorage *stg, void **obj)
 
HRESULT WINAPI OleCreateFromFile (REFCLSID clsid, const OLECHAR *filename, REFIID iid, DWORD renderopt, FORMATETC *fmt, IOleClientSite *client_site, IStorage *storage, void **obj)
 
HANDLE WINAPI OleDuplicateData (HANDLE hSrc, CLIPFORMAT cfFormat, UINT uiFlags)
 

Macro Definition Documentation

◆ COBJMACROS

#define COBJMACROS

Definition at line 24 of file ole2impl.c.

◆ NONAMELESSUNION

#define NONAMELESSUNION

Definition at line 25 of file ole2impl.c.

Function Documentation

◆ get_storage()

static HRESULT get_storage ( IDataObject data,
IStorage stg,
UINT src_cf,
BOOL  other_fmts 
)
static

Definition at line 100 of file ole2impl.c.

101{
102 static const UINT fmt_id[] = { CF_METAFILEPICT, CF_BITMAP, CF_DIB };
103 UINT i;
104 HRESULT hr;
105 FORMATETC fmt;
106 STGMEDIUM med;
107 IPersistStorage *persist;
108 CLSID clsid;
109
110 if (src_cf) *src_cf = 0;
111
112 /* CF_EMBEDEDOBJECT */
114 med.tymed = TYMED_ISTORAGE;
115 med.u.pstg = stg;
116 med.pUnkForRelease = NULL;
117 hr = IDataObject_GetDataHere(data, &fmt, &med);
118 if(SUCCEEDED(hr))
119 {
120 if (src_cf) *src_cf = embedded_object_clipboard_format;
121 return hr;
122 }
123
124 /* CF_EMBEDSOURCE */
126 med.tymed = TYMED_ISTORAGE;
127 med.u.pstg = stg;
128 med.pUnkForRelease = NULL;
129 hr = IDataObject_GetDataHere(data, &fmt, &med);
130 if(SUCCEEDED(hr))
131 {
132 if (src_cf) *src_cf = embed_source_clipboard_format;
133 return hr;
134 }
135
136 if (other_fmts)
137 {
138 for (i = 0; i < ARRAY_SIZE(fmt_id); i++)
139 {
140 init_fmtetc(&fmt, fmt_id[i], TYMED_ISTORAGE);
141 hr = IDataObject_QueryGetData(data, &fmt);
142 if (SUCCEEDED(hr))
143 {
144 if (src_cf) *src_cf = fmt_id[i];
145 return hr;
146 }
147 }
148 }
149
150 /* IPersistStorage */
151 hr = IDataObject_QueryInterface(data, &IID_IPersistStorage, (void**)&persist);
152 if(FAILED(hr)) return hr;
153
154 hr = IPersistStorage_GetClassID(persist, &clsid);
155 if(FAILED(hr)) goto end;
156
157 hr = IStorage_SetClass(stg, &clsid);
158 if(FAILED(hr)) goto end;
159
160 hr = IPersistStorage_Save(persist, stg, FALSE);
161 if(FAILED(hr)) goto end;
162
163 hr = IPersistStorage_SaveCompleted(persist, NULL);
164
165end:
166 IPersistStorage_Release(persist);
167
168 return hr;
169}
#define CF_METAFILEPICT
Definition: constants.h:398
#define CF_BITMAP
Definition: constants.h:397
#define CF_DIB
Definition: constants.h:403
#define ARRAY_SIZE(A)
Definition: main.h:33
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
UINT embedded_object_clipboard_format
Definition: clipboard.c:207
UINT embed_source_clipboard_format
Definition: clipboard.c:208
GLuint GLuint end
Definition: gl.h:1545
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define FAILED(hr)
Definition: intsafe.h:51
REFCLSID clsid
Definition: msctf.c:82
unsigned int UINT
Definition: ndis.h:50
static void init_fmtetc(FORMATETC *fmt, CLIPFORMAT cf, TYMED tymed)
Definition: ole2impl.c:84
const GUID IID_IPersistStorage
HRESULT hr
Definition: shlfolder.c:183
Definition: dsound.c:943

Referenced by OleCreateFromDataEx(), and OleCreateFromFileEx().

◆ init_fmtetc()

static void init_fmtetc ( FORMATETC *  fmt,
CLIPFORMAT  cf,
TYMED  tymed 
)
inlinestatic

Definition at line 84 of file ole2impl.c.

85{
86 fmt->cfFormat = cf;
87 fmt->ptd = NULL;
88 fmt->dwAspect = DVASPECT_CONTENT;
89 fmt->lindex = -1;
90 fmt->tymed = tymed;
91}
static DWORD tymed
Definition: url.c:174

Referenced by get_storage().

◆ OleCreateFromData()

HRESULT WINAPI OleCreateFromData ( LPDATAOBJECT  data,
REFIID  iid,
DWORD  renderopt,
LPFORMATETC  fmt,
LPOLECLIENTSITE  client_site,
LPSTORAGE  stg,
LPVOID obj 
)

Definition at line 203 of file ole2impl.c.

207{
208 DWORD advf = ADVF_PRIMEFIRST;
209
210 return OleCreateFromDataEx(data, iid, 0, renderopt, fmt ? 1 : 0, fmt ? &advf : NULL,
211 fmt, NULL, NULL, client_site, stg, obj);
212}
unsigned long DWORD
Definition: ntddk_ex.h:95
static IOleClientSite * client_site
Definition: activex.c:198
HRESULT WINAPI OleCreateFromDataEx(IDataObject *data, REFIID iid, DWORD flags, DWORD renderopt, ULONG num_cache_fmts, DWORD *adv_flags, FORMATETC *cache_fmts, IAdviseSink *sink, DWORD *conns, IOleClientSite *client_site, IStorage *stg, void **obj)
Definition: ole2impl.c:177

Referenced by OleCreateLinkFromData(), OleCreateStaticFromData(), and test_OleCreateStaticFromData().

◆ OleCreateFromDataEx()

HRESULT WINAPI OleCreateFromDataEx ( IDataObject data,
REFIID  iid,
DWORD  flags,
DWORD  renderopt,
ULONG  num_cache_fmts,
DWORD adv_flags,
FORMATETC *  cache_fmts,
IAdviseSink sink,
DWORD conns,
IOleClientSite client_site,
IStorage stg,
void **  obj 
)

Definition at line 177 of file ole2impl.c.

181{
182 HRESULT hr;
183 UINT src_cf;
184
185 FIXME("(%p, %s, %08x, %08x, %d, %p, %p, %p, %p, %p, %p, %p): stub\n",
186 data, debugstr_guid(iid), flags, renderopt, num_cache_fmts, adv_flags, cache_fmts,
187 sink, conns, client_site, stg, obj);
188
189 hr = get_storage(data, stg, &src_cf, TRUE);
190 if(FAILED(hr)) return hr;
191
192 hr = OleLoad(stg, iid, client_site, obj);
193 if(FAILED(hr)) return hr;
194
195 /* FIXME: Init cache */
196
197 return hr;
198}
#define FIXME(fmt,...)
Definition: debug.h:111
#define TRUE
Definition: types.h:120
HRESULT WINAPI OleLoad(LPSTORAGE pStg, REFIID riid, LPOLECLIENTSITE pClientSite, LPVOID *ppvObj)
Definition: ole2.c:1224
GLbitfield flags
Definition: glext.h:7161
GLsizei GLenum GLboolean sink
Definition: glext.h:5672
#define debugstr_guid
Definition: kernel32.h:35
static HRESULT get_storage(IDataObject *data, IStorage *stg, UINT *src_cf, BOOL other_fmts)
Definition: ole2impl.c:100

Referenced by OleCreateFromData().

◆ OleCreateFromFile()

HRESULT WINAPI OleCreateFromFile ( REFCLSID  clsid,
const OLECHAR filename,
REFIID  iid,
DWORD  renderopt,
FORMATETC *  fmt,
IOleClientSite client_site,
IStorage storage,
void **  obj 
)

Definition at line 402 of file ole2impl.c.

404{
405 DWORD advf = ADVF_PRIMEFIRST;
406
407 return OleCreateFromFileEx(clsid, filename, iid, 0, renderopt, fmt ? 1 : 0, fmt ? &advf : NULL, fmt,
408 NULL, NULL, client_site, storage, obj);
409}
const char * filename
Definition: ioapi.h:137
HRESULT WINAPI OleCreateFromFileEx(REFCLSID clsid, const OLECHAR *filename, REFIID iid, DWORD flags, DWORD renderopt, ULONG num_fmts, DWORD *adv_flags, FORMATETC *fmts, IAdviseSink *sink, DWORD *conns, IOleClientSite *client_site, IStorage *stg, void **obj)
Definition: ole2impl.c:336

Referenced by UIINSERTOBJECTDLG_OnOpen().

◆ OleCreateFromFileEx()

HRESULT WINAPI OleCreateFromFileEx ( REFCLSID  clsid,
const OLECHAR filename,
REFIID  iid,
DWORD  flags,
DWORD  renderopt,
ULONG  num_fmts,
DWORD adv_flags,
FORMATETC *  fmts,
IAdviseSink sink,
DWORD conns,
IOleClientSite client_site,
IStorage stg,
void **  obj 
)

Definition at line 336 of file ole2impl.c.

339{
340 HRESULT hr;
341 IMoniker *mon;
343 IUnknown *unk = NULL;
345 ULONG i;
346
347 TRACE("cls %s, %s, iid %s, flags %d, render opts %d, num fmts %d, adv flags %p, fmts %p\n", debugstr_guid(clsid),
348 debugstr_w(filename), debugstr_guid(iid), flags, renderopt, num_fmts, adv_flags, fmts);
349 TRACE("sink %p, conns %p, client site %p, storage %p, obj %p\n", sink, conns, client_site, stg, obj);
350 for (i = 0; i < num_fmts; i++)
351 TRACE("\t%d: fmt %s adv flags %d\n", i, debugstr_formatetc(fmts + i), adv_flags[i]);
352
353 hr = CreateFileMoniker( filename, &mon );
354 if (FAILED(hr)) return hr;
355
356 hr = BindMoniker( mon, 0, &IID_IDataObject, (void**)&data );
357 IMoniker_Release( mon );
358 if (FAILED(hr)) return hr;
359
360 hr = get_storage( data, stg, NULL, FALSE );
361 if (FAILED(hr)) goto end;
362
363 hr = OleLoad( stg, &IID_IUnknown, client_site, (void**)&unk );
364 if (FAILED(hr)) goto end;
365
366 if (renderopt == OLERENDER_FORMAT)
367 {
368 hr = IUnknown_QueryInterface( unk, &IID_IOleCache, (void**)&cache );
369 if (FAILED(hr)) goto end;
370
371 for (i = 0; i < num_fmts; i++)
372 {
373 STGMEDIUM med;
374 DWORD dummy_conn;
375
376 memset( &med, 0, sizeof(med) );
377 hr = IDataObject_GetData( data, fmts + i, &med );
378 if (FAILED(hr)) goto end;
379 hr = IOleCache_Cache( cache, fmts + i, adv_flags[i], &dummy_conn );
380 if (SUCCEEDED(hr))
381 hr = IOleCache_SetData( cache, fmts + i, &med, TRUE );
382 if (FAILED(hr))
383 {
384 ReleaseStgMedium( &med );
385 goto end;
386 }
387 }
388 }
389
390 hr = IUnknown_QueryInterface( unk, iid, obj );
391
392end:
393 if (cache) IOleCache_Release( cache );
394 if (unk) IUnknown_Release( unk );
395 IDataObject_Release( data );
396 return hr;
397}
const GUID IID_IUnknown
const char * debugstr_formatetc(const FORMATETC *formatetc) DECLSPEC_HIDDEN
Definition: datacache.c:216
void WINAPI ReleaseStgMedium(STGMEDIUM *pmedium)
Definition: ole2.c:2033
HRESULT WINAPI CreateFileMoniker(LPCOLESTR lpszPathName, IMoniker **ppmk)
Definition: filemoniker.c:1414
#define debugstr_w
Definition: kernel32.h:32
static struct fmt fmts[]
HRESULT WINAPI BindMoniker(LPMONIKER pmk, DWORD grfOpt, REFIID riid, LPVOID *ppvResult)
Definition: bindctx.c:602
const GUID IID_IOleCache
const GUID IID_IDataObject
#define memset(x, y, z)
Definition: compat.h:39
#define TRACE(s)
Definition: solgame.cpp:4
Definition: cache.c:49
uint32_t ULONG
Definition: typedefs.h:59

Referenced by OleCreateFromFile().

◆ OleCreateLinkFromData()

HRESULT WINAPI OleCreateLinkFromData ( IDataObject data,
REFIID  iid,
DWORD  renderopt,
FORMATETC *  fmt,
IOleClientSite client_site,
IStorage stg,
void **  obj 
)

Definition at line 217 of file ole2impl.c.

221{
222 FIXME("%p,%s,%08x,%p,%p,%p,%p: semi-stub\n",
223 data, debugstr_guid(iid), renderopt, fmt, client_site, stg, obj);
224 return OleCreateFromData(data, iid, renderopt, fmt, client_site, stg, obj);
225}
HRESULT WINAPI OleCreateFromData(LPDATAOBJECT data, REFIID iid, DWORD renderopt, LPFORMATETC fmt, LPOLECLIENTSITE client_site, LPSTORAGE stg, LPVOID *obj)
Definition: ole2impl.c:203

◆ OleCreateStaticFromData()

HRESULT WINAPI OleCreateStaticFromData ( IDataObject data,
REFIID  iid,
DWORD  renderopt,
FORMATETC *  fmt,
IOleClientSite client_site,
IStorage stg,
void **  obj 
)

Definition at line 230 of file ole2impl.c.

234{
235 HRESULT hr;
236 CLSID clsid;
237 IOleObject * ole_object = NULL;
238 IOleCache2 *ole_cache = NULL;
239 IPersistStorage *persist = NULL;
240 DWORD connection;
241 STGMEDIUM stgmedium;
242 LPOLESTR ole_typename;
243
244 TRACE("(%p, %s, 0x%08x, %p, %p, %p, %p)\n",
245 data, debugstr_guid(iid), renderopt, fmt, client_site, stg, obj);
246
247 if (!obj || !stg)
248 return E_INVALIDARG;
249
250 if (renderopt != OLERENDER_FORMAT)
251 {
252 FIXME("semi-stub\n");
253 return OleCreateFromData(data, iid, renderopt, fmt, client_site, stg, obj);
254 }
255
256 if (!fmt)
257 return E_INVALIDARG;
258
259 hr = IDataObject_GetData(data, fmt, &stgmedium);
260 if (FAILED(hr)) return hr;
261
262 switch (fmt->cfFormat)
263 {
264 case CF_BITMAP:
265 case CF_DIB:
267 break;
268 case CF_ENHMETAFILE:
270 break;
271 case CF_METAFILEPICT:
273 break;
274 default:
275 ReleaseStgMedium(&stgmedium);
276 return DV_E_CLIPFORMAT;
277 }
278 hr = OleCreateDefaultHandler(&clsid, NULL, &IID_IOleObject, (void **)&ole_object);
279 if (FAILED(hr)) goto end;
280
281 if (client_site)
282 {
283 hr = IOleObject_SetClientSite(ole_object, client_site);
284 if (FAILED(hr)) goto end;
285 }
286
287 hr = IOleObject_QueryInterface(ole_object, &IID_IOleCache2, (void **)&ole_cache);
288 if (FAILED(hr)) goto end;
289
290 hr = IOleObject_QueryInterface(ole_object, &IID_IPersistStorage, (void **)&persist);
291 if (FAILED(hr)) goto end;
292
293 hr = WriteClassStg(stg, &clsid);
294 if (FAILED(hr)) goto end;
295
296 hr = IPersistStorage_InitNew(persist, stg);
297 if (FAILED(hr)) goto end;
298
299 hr = IOleCache2_Cache(ole_cache, fmt, ADVF_PRIMEFIRST, &connection);
300 if (FAILED(hr)) goto end;
301
302 hr = IOleCache2_SetData(ole_cache, fmt, &stgmedium, TRUE);
303 if (FAILED(hr)) goto end;
304 stgmedium.tymed = TYMED_NULL;
305
306 hr = IOleObject_GetUserType(ole_object, USERCLASSTYPE_FULL, &ole_typename);
307 if(FAILED(hr))
308 ole_typename = NULL;
309 hr = WriteFmtUserTypeStg(stg, fmt->cfFormat, ole_typename);
310 CoTaskMemFree(ole_typename);
311 if (FAILED(hr)) goto end;
312
313 hr = IPersistStorage_Save(persist, stg, TRUE);
314 if (FAILED(hr)) goto end;
315
316 hr = IPersistStorage_SaveCompleted(persist, NULL);
317 if (FAILED(hr)) goto end;
318
319 hr = IOleObject_QueryInterface(ole_object, iid, obj);
320
321end:
322 if (stgmedium.tymed == TYMED_NULL)
323 ReleaseStgMedium(&stgmedium);
324 if (persist)
325 IPersistStorage_Release(persist);
326 if (ole_cache)
327 IOleCache2_Release(ole_cache);
328 if (ole_object)
329 IOleObject_Release(ole_object);
330 return hr;
331}
#define CF_ENHMETAFILE
Definition: constants.h:409
const CLSID CLSID_Picture_EnhMetafile
const CLSID CLSID_Picture_Dib
const CLSID CLSID_Picture_Metafile
#define E_INVALIDARG
Definition: ddrawi.h:101
HRESULT WINAPI OleCreateDefaultHandler(REFCLSID clsid, LPUNKNOWN pUnkOuter, REFIID riid, LPVOID *ppvObj)
HRESULT WINAPI WriteClassStg(IStorage *pStg, REFCLSID rclsid)
Definition: storage32.c:9078
HRESULT WINAPI WriteFmtUserTypeStg(LPSTORAGE pstg, CLIPFORMAT cf, LPOLESTR lpszUserType)
Definition: storage32.c:9356
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:442
static LPOLESTR
Definition: stg_prop.c:27
const GUID IID_IOleCache2
const GUID IID_IOleObject
#define DV_E_CLIPFORMAT
Definition: winerror.h:2639

Referenced by test_OleCreateStaticFromData().

◆ OleDuplicateData()

HANDLE WINAPI OleDuplicateData ( HANDLE  hSrc,
CLIPFORMAT  cfFormat,
UINT  uiFlags 
)

Definition at line 425 of file ole2impl.c.

427{
428 HANDLE hDst = NULL;
429
430 TRACE("(%p,%x,%x)\n", hSrc, cfFormat, uiFlags);
431
432 if (!uiFlags) uiFlags = GMEM_MOVEABLE;
433
434 switch (cfFormat)
435 {
436 case CF_ENHMETAFILE:
437 hDst = CopyEnhMetaFileW(hSrc, NULL);
438 break;
439 case CF_METAFILEPICT:
440 hDst = CopyMetaFileW(hSrc, NULL);
441 break;
442 case CF_PALETTE:
443 {
445 UINT nEntries = GetPaletteEntries(hSrc, 0, 0, NULL);
446 if (!nEntries) return NULL;
448 FIELD_OFFSET(LOGPALETTE, palPalEntry[nEntries]));
449 if (!logpalette) return NULL;
450 if (!GetPaletteEntries(hSrc, 0, nEntries, logpalette->palPalEntry))
451 {
453 return NULL;
454 }
455 logpalette->palVersion = 0x300;
456 logpalette->palNumEntries = (WORD)nEntries;
457
459
461 break;
462 }
463 case CF_BITMAP:
464 {
465 LONG size;
466 BITMAP bm;
467 if (!GetObjectW(hSrc, sizeof(bm), &bm))
468 return NULL;
469 size = GetBitmapBits(hSrc, 0, NULL);
470 if (!size) return NULL;
471 bm.bmBits = HeapAlloc(GetProcessHeap(), 0, size);
472 if (!bm.bmBits) return NULL;
473 if (GetBitmapBits(hSrc, size, bm.bmBits))
474 hDst = CreateBitmapIndirect(&bm);
475 HeapFree(GetProcessHeap(), 0, bm.bmBits);
476 break;
477 }
478 default:
479 {
480 SIZE_T size = GlobalSize(hSrc);
481 LPVOID pvSrc = NULL;
482 LPVOID pvDst = NULL;
483
484 /* allocate space for object */
485 if (!size) return NULL;
486 hDst = GlobalAlloc(uiFlags, size);
487 if (!hDst) return NULL;
488
489 /* lock pointers */
490 pvSrc = GlobalLock(hSrc);
491 if (!pvSrc)
492 {
493 GlobalFree(hDst);
494 return NULL;
495 }
496 pvDst = GlobalLock(hDst);
497 if (!pvDst)
498 {
499 GlobalUnlock(hSrc);
500 GlobalFree(hDst);
501 return NULL;
502 }
503 /* copy data */
504 memcpy(pvDst, pvSrc, size);
505
506 /* cleanup */
507 GlobalUnlock(hDst);
508 GlobalUnlock(hSrc);
509 }
510 }
511
512 TRACE("returning %p\n", hDst);
513 return hDst;
514}
#define CF_PALETTE
Definition: constants.h:404
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
unsigned short WORD
Definition: ntddk_ex.h:93
GLsizeiptr size
Definition: glext.h:5919
LPVOID NTAPI GlobalLock(HGLOBAL hMem)
Definition: heapmem.c:755
HGLOBAL NTAPI GlobalFree(HGLOBAL hMem)
Definition: heapmem.c:611
BOOL NTAPI GlobalUnlock(HGLOBAL hMem)
Definition: heapmem.c:1190
HGLOBAL NTAPI GlobalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:368
SIZE_T NTAPI GlobalSize(HGLOBAL hMem)
Definition: heapmem.c:1090
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static const LOGPALETTE logpalette
Definition: clipboard.c:1346
long LONG
Definition: pedump.c:60
Definition: bl.h:1331
WORD palNumEntries
Definition: wingdi.h:1834
WORD palVersion
Definition: wingdi.h:1833
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
ULONG_PTR SIZE_T
Definition: typedefs.h:80
UINT WINAPI GetPaletteEntries(HPALETTE hpal, UINT iStartIndex, UINT cEntries, LPPALETTEENTRY ppe)
Definition: palette.c:64
#define GMEM_MOVEABLE
Definition: winbase.h:294
int WINAPI GetObjectW(_In_ HANDLE h, _In_ int c, _Out_writes_bytes_opt_(c) LPVOID pv)
HPALETTE WINAPI CreatePalette(_In_reads_(_Inexpressible_(2 *sizeof(WORD)+plpal->palNumEntries *sizeof(PALETTEENTRY))) const LOGPALETTE *)
HBITMAP WINAPI CreateBitmapIndirect(_In_ const BITMAP *pbm)
HENHMETAFILE WINAPI CopyEnhMetaFileW(_In_ HENHMETAFILE hemfSrc, _In_opt_ LPCWSTR pszFile)
HMETAFILE WINAPI CopyMetaFileW(_In_ HMETAFILE hmfSrc, _In_opt_ LPCWSTR pszFile)
LONG WINAPI GetBitmapBits(_In_ HBITMAP hbit, _In_ LONG cb, _Out_writes_bytes_(cb) LPVOID lpvBits)

Referenced by copy_stg_medium(), and IDataObjectImpl::CopyMedium().

◆ OleQueryCreateFromData()

HRESULT WINAPI OleQueryCreateFromData ( IDataObject data)

Definition at line 48 of file ole2impl.c.

49{
50 IEnumFORMATETC *enum_fmt;
51 FORMATETC fmt;
52 BOOL found_static = FALSE;
53 HRESULT hr;
54
55 hr = IDataObject_EnumFormatEtc(data, DATADIR_GET, &enum_fmt);
56
57 if(FAILED(hr)) return hr;
58
59 do
60 {
61 hr = IEnumFORMATETC_Next(enum_fmt, 1, &fmt, NULL);
62 if(hr == S_OK)
63 {
67 {
68 IEnumFORMATETC_Release(enum_fmt);
69 return S_OK;
70 }
71
72 if(fmt.cfFormat == CF_METAFILEPICT ||
73 fmt.cfFormat == CF_BITMAP ||
74 fmt.cfFormat == CF_DIB)
75 found_static = TRUE;
76 }
77 } while (hr == S_OK);
78
79 IEnumFORMATETC_Release(enum_fmt);
80
81 return found_static ? OLE_S_STATIC : S_FALSE;
82}
UINT filename_clipboard_format
Definition: clipboard.c:204
unsigned int BOOL
Definition: ntddk_ex.h:94
#define S_OK
Definition: intsafe.h:52
#define OLE_S_STATIC
Definition: winerror.h:2609
#define S_FALSE
Definition: winerror.h:2357

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( ole  )