Commit 211268a7 authored by Huw Davies's avatar Huw Davies Committed by Alexandre Julliard

ole32: Rewrite OleQueryCreateFromData so it compares clipboard format ids rather…

ole32: Rewrite OleQueryCreateFromData so it compares clipboard format ids rather than strings and be sure to free the enumerator.
parent b133e94b
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include "wine/debug.h" #include "wine/debug.h"
#include "ole2.h" #include "ole2.h"
#include "olestd.h" #include "olestd.h"
#include "compobj_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(ole); WINE_DEFAULT_DEBUG_CHANNEL(ole);
...@@ -40,7 +41,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(ole); ...@@ -40,7 +41,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(ole);
/****************************************************************************** /******************************************************************************
* OleQueryCreateFromData [OLE32.@] * OleQueryCreateFromData [OLE32.@]
* *
* Author : Abey George
* Checks whether an object can become an embedded object. * Checks whether an object can become an embedded object.
* the clipboard or OLE drag and drop. * the clipboard or OLE drag and drop.
* Returns : S_OK - Format that supports Embedded object creation are present. * Returns : S_OK - Format that supports Embedded object creation are present.
...@@ -48,41 +48,40 @@ WINE_DEFAULT_DEBUG_CHANNEL(ole); ...@@ -48,41 +48,40 @@ WINE_DEFAULT_DEBUG_CHANNEL(ole);
* S_FALSE - No acceptable format is available. * S_FALSE - No acceptable format is available.
*/ */
HRESULT WINAPI OleQueryCreateFromData(LPDATAOBJECT pSrcDataObject) HRESULT WINAPI OleQueryCreateFromData(IDataObject *data)
{ {
IEnumFORMATETC *pfmt; IEnumFORMATETC *enum_fmt;
FORMATETC fmt; FORMATETC fmt;
CHAR szFmtName[MAX_CLIPFORMAT_NAME]; BOOL found_static = FALSE;
BOOL bFoundStatic = FALSE; HRESULT hr;
HRESULT hr = IDataObject_EnumFormatEtc(pSrcDataObject, DATADIR_GET, &pfmt);
if (hr == S_OK)
hr = IEnumFORMATETC_Next(pfmt, 1, &fmt, NULL);
while (hr == S_OK)
{
GetClipboardFormatNameA(fmt.cfFormat, szFmtName, MAX_CLIPFORMAT_NAME-1);
/* first, Check for Embedded Object, Embed Source or Filename */ hr = IDataObject_EnumFormatEtc(data, DATADIR_GET, &enum_fmt);
if (!strcmp(szFmtName, CF_EMBEDDEDOBJECT) || !strcmp(szFmtName, CF_EMBEDSOURCE) || !strcmp(szFmtName, CF_FILENAME)) if(FAILED(hr)) return hr;
return S_OK;
/* Check for Metafile, Bitmap or DIB */ do
{
if (fmt.cfFormat == CF_METAFILEPICT || fmt.cfFormat == CF_BITMAP || fmt.cfFormat == CF_DIB) hr = IEnumFORMATETC_Next(enum_fmt, 1, &fmt, NULL);
bFoundStatic = TRUE; if(hr == S_OK)
{
hr = IEnumFORMATETC_Next(pfmt, 1, &fmt, NULL); if(fmt.cfFormat == embedded_object_clipboard_format ||
} fmt.cfFormat == embed_source_clipboard_format ||
fmt.cfFormat == filename_clipboard_format)
{
IEnumFORMATETC_Release(enum_fmt);
return S_OK;
}
/* Found a static format, but no embed format */ if(fmt.cfFormat == CF_METAFILEPICT ||
fmt.cfFormat == CF_BITMAP ||
fmt.cfFormat == CF_DIB)
found_static = TRUE;
}
} while (hr == S_OK);
if (bFoundStatic) IEnumFORMATETC_Release(enum_fmt);
return OLE_S_STATIC;
return S_FALSE; return found_static ? OLE_S_STATIC : S_FALSE;
} }
/****************************************************************************** /******************************************************************************
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment