Huw Davies : ole32: Rewrite OleQueryCreateFromData so it compares clipboard format ids rather than strings and be sure to free the enumerator .
Alexandre Julliard
julliard at winehq.org
Thu Apr 23 11:27:26 CDT 2009
Module: wine
Branch: master
Commit: 211268a74e739b5902be4246be2402a96a4afe82
URL: http://source.winehq.org/git/wine.git/?a=commit;h=211268a74e739b5902be4246be2402a96a4afe82
Author: Huw Davies <huw at codeweavers.com>
Date: Thu Apr 23 11:52:22 2009 +0100
ole32: Rewrite OleQueryCreateFromData so it compares clipboard format ids rather than strings and be sure to free the enumerator.
---
dlls/ole32/ole2impl.c | 69 ++++++++++++++++++++++++-------------------------
1 files changed, 34 insertions(+), 35 deletions(-)
diff --git a/dlls/ole32/ole2impl.c b/dlls/ole32/ole2impl.c
index e9310ac..f7da399 100644
--- a/dlls/ole32/ole2impl.c
+++ b/dlls/ole32/ole2impl.c
@@ -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;
}
/******************************************************************************
More information about the wine-cvs
mailing list