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 @@
#include "wine/debug.h"
#include "ole2.h"
#include "olestd.h"
#include "compobj_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(ole);
......@@ -40,7 +41,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(ole);
/******************************************************************************
* OleQueryCreateFromData [OLE32.@]
*
* Author : Abey George
* Checks whether an object can become an embedded object.
* the clipboard or OLE drag and drop.
* Returns : S_OK - Format that supports Embedded object creation are present.
......@@ -48,41 +48,40 @@ WINE_DEFAULT_DEBUG_CHANNEL(ole);
* S_FALSE - No acceptable format is available.
*/
HRESULT WINAPI OleQueryCreateFromData(LPDATAOBJECT pSrcDataObject)
HRESULT WINAPI OleQueryCreateFromData(IDataObject *data)
{
IEnumFORMATETC *pfmt;
FORMATETC fmt;
CHAR szFmtName[MAX_CLIPFORMAT_NAME];
BOOL bFoundStatic = FALSE;
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);
IEnumFORMATETC *enum_fmt;
FORMATETC fmt;
BOOL found_static = FALSE;
HRESULT hr;
/* 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))
return S_OK;
if(FAILED(hr)) return hr;
/* Check for Metafile, Bitmap or DIB */
if (fmt.cfFormat == CF_METAFILEPICT || fmt.cfFormat == CF_BITMAP || fmt.cfFormat == CF_DIB)
bFoundStatic = TRUE;
hr = IEnumFORMATETC_Next(pfmt, 1, &fmt, NULL);
}
do
{
hr = IEnumFORMATETC_Next(enum_fmt, 1, &fmt, NULL);
if(hr == S_OK)
{
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)
return OLE_S_STATIC;
IEnumFORMATETC_Release(enum_fmt);
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