4 * Copyright 2003 Ulrich Czekalla
5 * Copyright 2007 Damjan Jovanovic
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 #include "wine/port.h"
32 #define NONAMELESSUNION
42 #include "shlobj.h" /* DROPFILES */
46 #include "wine/unicode.h"
47 #include "wine/debug.h"
48 #include "wine/list.h"
50 WINE_DEFAULT_DEBUG_CHANNEL(xdnd
);
52 /* Maximum wait time for selection notify */
53 #define SELECTION_RETRIES 500 /* wait for .1 seconds */
54 #define SELECTION_WAIT 1000 /* us */
56 typedef struct tagXDNDDATA
62 } XDNDDATA
, *LPXDNDDATA
;
64 static struct list xdndData
= LIST_INIT(xdndData
);
65 static POINT XDNDxy
= { 0, 0 };
66 static IDataObject XDNDDataObject
;
67 static BOOL XDNDAccepted
= FALSE
;
68 static DWORD XDNDDropEffect
= DROPEFFECT_NONE
;
69 /* the last window the mouse was over */
70 static HWND XDNDLastTargetWnd
;
71 /* might be an ancestor of XDNDLastTargetWnd */
72 static HWND XDNDLastDropTargetWnd
;
74 static void X11DRV_XDND_InsertXDNDData(int property
, int format
, HANDLE contents
);
75 static void X11DRV_XDND_ResolveProperty(Display
*display
, Window xwin
, Time tm
,
76 Atom
*types
, unsigned long count
);
77 static void X11DRV_XDND_SendDropFiles(HWND hwnd
);
78 static void X11DRV_XDND_FreeDragDropOp(void);
80 static CRITICAL_SECTION xdnd_cs
;
81 static CRITICAL_SECTION_DEBUG critsect_debug
=
84 { &critsect_debug
.ProcessLocksList
, &critsect_debug
.ProcessLocksList
},
85 0, 0, { (DWORD_PTR
)(__FILE__
": xdnd_cs") }
87 static CRITICAL_SECTION xdnd_cs
= { &critsect_debug
, -1, 0, 0, 0, 0 };
90 /* Based on functions in dlls/ole32/ole2.c */
91 static HANDLE
get_droptarget_local_handle(HWND hwnd
)
93 static const WCHAR prop_marshalleddroptarget
[] =
94 {'W','i','n','e','M','a','r','s','h','a','l','l','e','d','D','r','o','p','T','a','r','g','e','t',0};
96 HANDLE local_handle
= 0;
98 handle
= GetPropW(hwnd
, prop_marshalleddroptarget
);
104 GetWindowThreadProcessId(hwnd
, &pid
);
105 process
= OpenProcess(PROCESS_DUP_HANDLE
, FALSE
, pid
);
108 DuplicateHandle(process
, handle
, GetCurrentProcess(), &local_handle
, 0, FALSE
, DUPLICATE_SAME_ACCESS
);
109 CloseHandle(process
);
115 static HRESULT
create_stream_from_map(HANDLE map
, IStream
**stream
)
117 HRESULT hr
= E_OUTOFMEMORY
;
120 MEMORY_BASIC_INFORMATION info
;
122 data
= MapViewOfFile(map
, FILE_MAP_READ
, 0, 0, 0);
125 VirtualQuery(data
, &info
, sizeof(info
));
126 TRACE("size %d\n", (int)info
.RegionSize
);
128 hmem
= GlobalAlloc(GMEM_MOVEABLE
, info
.RegionSize
);
131 memcpy(GlobalLock(hmem
), data
, info
.RegionSize
);
133 hr
= CreateStreamOnHGlobal(hmem
, TRUE
, stream
);
135 UnmapViewOfFile(data
);
139 static IDropTarget
* get_droptarget_pointer(HWND hwnd
)
141 IDropTarget
*droptarget
= NULL
;
145 map
= get_droptarget_local_handle(hwnd
);
146 if(!map
) return NULL
;
148 if(SUCCEEDED(create_stream_from_map(map
, &stream
)))
150 CoUnmarshalInterface(stream
, &IID_IDropTarget
, (void**)&droptarget
);
151 IStream_Release(stream
);
157 /**************************************************************************
158 * X11DRV_XDND_XdndActionToDROPEFFECT
160 static DWORD
X11DRV_XDND_XdndActionToDROPEFFECT(long action
)
162 /* In Windows, nothing but the given effects is allowed.
163 * In X the given action is just a hint, and you can always
164 * XdndActionCopy and XdndActionPrivate, so be more permissive. */
165 if (action
== x11drv_atom(XdndActionCopy
))
166 return DROPEFFECT_COPY
;
167 else if (action
== x11drv_atom(XdndActionMove
))
168 return DROPEFFECT_MOVE
| DROPEFFECT_COPY
;
169 else if (action
== x11drv_atom(XdndActionLink
))
170 return DROPEFFECT_LINK
| DROPEFFECT_COPY
;
171 else if (action
== x11drv_atom(XdndActionAsk
))
172 /* FIXME: should we somehow ask the user what to do here? */
173 return DROPEFFECT_COPY
| DROPEFFECT_MOVE
| DROPEFFECT_LINK
;
174 FIXME("unknown action %ld, assuming DROPEFFECT_COPY\n", action
);
175 return DROPEFFECT_COPY
;
178 /**************************************************************************
179 * X11DRV_XDND_DROPEFFECTToXdndAction
181 static long X11DRV_XDND_DROPEFFECTToXdndAction(DWORD effect
)
183 if (effect
== DROPEFFECT_COPY
)
184 return x11drv_atom(XdndActionCopy
);
185 else if (effect
== DROPEFFECT_MOVE
)
186 return x11drv_atom(XdndActionMove
);
187 else if (effect
== DROPEFFECT_LINK
)
188 return x11drv_atom(XdndActionLink
);
189 FIXME("unknown drop effect %u, assuming XdndActionCopy\n", effect
);
190 return x11drv_atom(XdndActionCopy
);
193 /**************************************************************************
194 * X11DRV_XDND_EnterEvent
196 * Handle an XdndEnter event.
198 void X11DRV_XDND_EnterEvent( HWND hWnd
, XClientMessageEvent
*event
)
202 unsigned long count
= 0;
204 version
= (event
->data
.l
[1] & 0xFF000000) >> 24;
205 TRACE("ver(%d) check-XdndTypeList(%ld) data=%ld,%ld,%ld,%ld,%ld\n",
206 version
, (event
->data
.l
[1] & 1),
207 event
->data
.l
[0], event
->data
.l
[1], event
->data
.l
[2],
208 event
->data
.l
[3], event
->data
.l
[4]);
210 if (version
> WINE_XDND_VERSION
)
212 TRACE("Ignores unsupported version\n");
216 XDNDAccepted
= FALSE
;
218 /* If the source supports more than 3 data types we retrieve
219 * the entire list. */
220 if (event
->data
.l
[1] & 1)
224 unsigned long bytesret
;
226 /* Request supported formats from source window */
227 XGetWindowProperty(event
->display
, event
->data
.l
[0], x11drv_atom(XdndTypeList
),
228 0, 65535, FALSE
, AnyPropertyType
, &acttype
, &actfmt
, &count
,
229 &bytesret
, (unsigned char**)&xdndtypes
);
234 xdndtypes
= (Atom
*) &event
->data
.l
[2];
241 for (i
= 0; i
< count
; i
++)
243 if (xdndtypes
[i
] != 0)
245 char * pn
= XGetAtomName(event
->display
, xdndtypes
[i
]);
246 TRACE("XDNDEnterAtom %ld: %s\n", xdndtypes
[i
], pn
);
252 /* Do a one-time data read and cache results */
253 X11DRV_XDND_ResolveProperty(event
->display
, event
->window
,
254 event
->data
.l
[1], xdndtypes
, count
);
256 if (event
->data
.l
[1] & 1)
260 /**************************************************************************
261 * X11DRV_XDND_PositionEvent
263 * Handle an XdndPosition event.
265 void X11DRV_XDND_PositionEvent( HWND hWnd
, XClientMessageEvent
*event
)
267 XClientMessageEvent e
;
268 int accept
= 0; /* Assume we're not accepting */
269 IDropTarget
*dropTarget
= NULL
;
275 XDNDxy
= root_to_virtual_screen( event
->data
.l
[2] >> 16, event
->data
.l
[2] & 0xFFFF );
276 targetWindow
= WindowFromPoint(XDNDxy
);
280 effect
= X11DRV_XDND_XdndActionToDROPEFFECT(event
->data
.l
[4]);
282 if (!XDNDAccepted
|| XDNDLastTargetWnd
!= targetWindow
)
284 /* Notify OLE of DragEnter. Result determines if we accept */
285 HWND dropTargetWindow
;
287 if (XDNDLastDropTargetWnd
)
289 dropTarget
= get_droptarget_pointer(XDNDLastDropTargetWnd
);
292 hr
= IDropTarget_DragLeave(dropTarget
);
294 WARN("IDropTarget_DragLeave failed, error 0x%08X\n", hr
);
295 IDropTarget_Release(dropTarget
);
298 dropTargetWindow
= targetWindow
;
301 dropTarget
= get_droptarget_pointer(dropTargetWindow
);
302 } while (dropTarget
== NULL
&& (dropTargetWindow
= GetParent(dropTargetWindow
)) != NULL
);
303 XDNDLastTargetWnd
= targetWindow
;
304 XDNDLastDropTargetWnd
= dropTargetWindow
;
307 hr
= IDropTarget_DragEnter(dropTarget
, &XDNDDataObject
,
308 MK_LBUTTON
, pointl
, &effect
);
311 if (effect
!= DROPEFFECT_NONE
)
314 TRACE("the application accepted the drop\n");
317 TRACE("the application refused the drop\n");
320 WARN("IDropTarget_DragEnter failed, error 0x%08X\n", hr
);
321 IDropTarget_Release(dropTarget
);
324 if (XDNDAccepted
&& XDNDLastTargetWnd
== targetWindow
)
326 /* If drag accepted notify OLE of DragOver */
327 dropTarget
= get_droptarget_pointer(XDNDLastDropTargetWnd
);
330 hr
= IDropTarget_DragOver(dropTarget
, MK_LBUTTON
, pointl
, &effect
);
332 XDNDDropEffect
= effect
;
334 WARN("IDropTarget_DragOver failed, error 0x%08X\n", hr
);
335 IDropTarget_Release(dropTarget
);
341 if (GetWindowLongW( hWnd
, GWL_EXSTYLE
) & WS_EX_ACCEPTFILES
)
344 TRACE("action req: %ld accept(%d) at x(%d),y(%d)\n",
345 event
->data
.l
[4], accept
, XDNDxy
.x
, XDNDxy
.y
);
348 * Let source know if we're accepting the drop by
349 * sending a status message.
351 e
.type
= ClientMessage
;
352 e
.display
= event
->display
;
353 e
.window
= event
->data
.l
[0];
354 e
.message_type
= x11drv_atom(XdndStatus
);
356 e
.data
.l
[0] = event
->window
;
357 e
.data
.l
[1] = accept
;
358 e
.data
.l
[2] = 0; /* Empty Rect */
359 e
.data
.l
[3] = 0; /* Empty Rect */
361 e
.data
.l
[4] = X11DRV_XDND_DROPEFFECTToXdndAction(effect
);
364 XSendEvent(event
->display
, event
->data
.l
[0], False
, NoEventMask
, (XEvent
*)&e
);
367 /**************************************************************************
368 * X11DRV_XDND_DropEvent
370 * Handle an XdndDrop event.
372 void X11DRV_XDND_DropEvent( HWND hWnd
, XClientMessageEvent
*event
)
374 XClientMessageEvent e
;
375 IDropTarget
*dropTarget
;
379 /* If we have a HDROP type we send a WM_ACCEPTFILES.*/
380 if (GetWindowLongW( hWnd
, GWL_EXSTYLE
) & WS_EX_ACCEPTFILES
)
381 X11DRV_XDND_SendDropFiles( hWnd
);
383 /* Notify OLE of Drop */
384 dropTarget
= get_droptarget_pointer(XDNDLastDropTargetWnd
);
389 DWORD effect
= XDNDDropEffect
;
393 hr
= IDropTarget_Drop(dropTarget
, &XDNDDataObject
, MK_LBUTTON
,
397 if (effect
!= DROPEFFECT_NONE
)
398 TRACE("drop succeeded\n");
400 TRACE("the application refused the drop\n");
403 WARN("drop failed, error 0x%08X\n", hr
);
404 IDropTarget_Release(dropTarget
);
407 X11DRV_XDND_FreeDragDropOp();
409 /* Tell the target we are finished. */
410 memset(&e
, 0, sizeof(e
));
411 e
.type
= ClientMessage
;
412 e
.display
= event
->display
;
413 e
.window
= event
->data
.l
[0];
414 e
.message_type
= x11drv_atom(XdndFinished
);
416 e
.data
.l
[0] = event
->window
;
417 XSendEvent(event
->display
, event
->data
.l
[0], False
, NoEventMask
, (XEvent
*)&e
);
420 /**************************************************************************
421 * X11DRV_XDND_LeaveEvent
423 * Handle an XdndLeave event.
425 void X11DRV_XDND_LeaveEvent( HWND hWnd
, XClientMessageEvent
*event
)
427 IDropTarget
*dropTarget
;
429 TRACE("DND Operation canceled\n");
431 /* Notify OLE of DragLeave */
432 dropTarget
= get_droptarget_pointer(XDNDLastDropTargetWnd
);
435 HRESULT hr
= IDropTarget_DragLeave(dropTarget
);
437 WARN("IDropTarget_DragLeave failed, error 0x%08X\n", hr
);
438 IDropTarget_Release(dropTarget
);
441 X11DRV_XDND_FreeDragDropOp();
445 /**************************************************************************
446 * X11DRV_XDND_ResolveProperty
448 * Resolve all MIME types to windows clipboard formats. All data is cached.
450 static void X11DRV_XDND_ResolveProperty(Display
*display
, Window xwin
, Time tm
,
451 Atom
*types
, unsigned long count
)
456 XDNDDATA
*current
, *next
;
457 BOOL haveHDROP
= FALSE
;
459 TRACE("count(%ld)\n", count
);
461 X11DRV_XDND_FreeDragDropOp(); /* Clear previously cached data */
463 for (i
= 0; i
< count
; i
++)
468 TRACE("requesting atom %ld from xwin %ld\n", types
[i
], xwin
);
473 XConvertSelection(display
, x11drv_atom(XdndSelection
), types
[i
],
474 x11drv_atom(XdndTarget
), xwin
, /*tm*/CurrentTime
);
477 * Wait for SelectionNotify
479 for (j
= 0; j
< SELECTION_RETRIES
; j
++)
481 res
= XCheckTypedWindowEvent(display
, xwin
, SelectionNotify
, &xe
);
482 if (res
&& xe
.xselection
.selection
== x11drv_atom(XdndSelection
)) break;
484 usleep(SELECTION_WAIT
);
487 if (xe
.xselection
.property
== None
)
490 contents
= X11DRV_CLIPBOARD_ImportSelection(display
, types
[i
], xwin
, x11drv_atom(XdndTarget
), &windowsFormat
);
492 X11DRV_XDND_InsertXDNDData(types
[i
], windowsFormat
, contents
);
495 /* On Windows when there is a CF_HDROP, there are no other CF_ formats.
496 * foobar2000 relies on this (spaces -> %20's without it).
498 LIST_FOR_EACH_ENTRY(current
, &xdndData
, XDNDDATA
, entry
)
500 if (current
->cf_win
== CF_HDROP
)
508 LIST_FOR_EACH_ENTRY_SAFE(current
, next
, &xdndData
, XDNDDATA
, entry
)
510 if (current
->cf_win
!= CF_HDROP
&& current
->cf_win
< CF_MAX
)
512 list_remove(¤t
->entry
);
513 GlobalFree(current
->contents
);
514 HeapFree(GetProcessHeap(), 0, current
);
521 /**************************************************************************
522 * X11DRV_XDND_InsertXDNDData
524 * Cache available XDND property
526 static void X11DRV_XDND_InsertXDNDData(int property
, int format
, HANDLE contents
)
528 LPXDNDDATA current
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(XDNDDATA
));
532 EnterCriticalSection(&xdnd_cs
);
533 current
->cf_xdnd
= property
;
534 current
->cf_win
= format
;
535 current
->contents
= contents
;
536 list_add_tail(&xdndData
, ¤t
->entry
);
537 LeaveCriticalSection(&xdnd_cs
);
542 /**************************************************************************
543 * X11DRV_XDND_SendDropFiles
545 static void X11DRV_XDND_SendDropFiles(HWND hwnd
)
547 LPXDNDDATA current
= NULL
;
550 EnterCriticalSection(&xdnd_cs
);
552 /* Find CF_HDROP type if any */
553 LIST_FOR_EACH_ENTRY(current
, &xdndData
, XDNDDATA
, entry
)
555 if (current
->cf_win
== CF_HDROP
)
564 HGLOBAL dropHandle
= GlobalAlloc(GMEM_FIXED
, GlobalSize(current
->contents
));
568 DROPFILES
*lpDrop
= GlobalLock(dropHandle
);
569 memcpy(lpDrop
, GlobalLock(current
->contents
), GlobalSize(current
->contents
));
570 GlobalUnlock(current
->contents
);
571 lpDrop
->pt
.x
= XDNDxy
.x
;
572 lpDrop
->pt
.y
= XDNDxy
.y
;
573 lpDrop
->fNC
= !ScreenToClient(hwnd
, &lpDrop
->pt
);
574 TRACE("Sending WM_DROPFILES: hWnd=0x%p, fNC=%d, x=%d, y=%d, files=%p(%s)\n", hwnd
,
575 lpDrop
->fNC
, lpDrop
->pt
.x
, lpDrop
->pt
.y
, ((char*)lpDrop
) + lpDrop
->pFiles
,
576 debugstr_w((WCHAR
*)(((char*)lpDrop
) + lpDrop
->pFiles
)));
577 GlobalUnlock(dropHandle
);
578 if (!PostMessageW(hwnd
, WM_DROPFILES
, (WPARAM
)dropHandle
, 0))
579 GlobalFree(dropHandle
);
583 LeaveCriticalSection(&xdnd_cs
);
587 /**************************************************************************
588 * X11DRV_XDND_FreeDragDropOp
590 static void X11DRV_XDND_FreeDragDropOp(void)
597 EnterCriticalSection(&xdnd_cs
);
599 /** Free data cache */
600 LIST_FOR_EACH_ENTRY_SAFE(current
, next
, &xdndData
, XDNDDATA
, entry
)
602 list_remove(¤t
->entry
);
603 GlobalFree(current
->contents
);
604 HeapFree(GetProcessHeap(), 0, current
);
607 XDNDxy
.x
= XDNDxy
.y
= 0;
608 XDNDLastTargetWnd
= NULL
;
609 XDNDLastDropTargetWnd
= NULL
;
610 XDNDAccepted
= FALSE
;
612 LeaveCriticalSection(&xdnd_cs
);
616 /**************************************************************************
617 * X11DRV_XDND_DescribeClipboardFormat
619 static void X11DRV_XDND_DescribeClipboardFormat(int cfFormat
, char *buffer
, int size
)
621 #define D(x) case x: lstrcpynA(buffer, #x, size); return;
644 if (CF_PRIVATEFIRST
<= cfFormat
&& cfFormat
<= CF_PRIVATELAST
)
646 lstrcpynA(buffer
, "some private object", size
);
649 if (CF_GDIOBJFIRST
<= cfFormat
&& cfFormat
<= CF_GDIOBJLAST
)
651 lstrcpynA(buffer
, "some GDI object", size
);
655 GetClipboardFormatNameA(cfFormat
, buffer
, size
);
659 /* The IDataObject singleton we feed to OLE follows */
661 static HRESULT WINAPI
XDNDDATAOBJECT_QueryInterface(IDataObject
*dataObject
,
662 REFIID riid
, void **ppvObject
)
664 TRACE("(%p, %s, %p)\n", dataObject
, debugstr_guid(riid
), ppvObject
);
665 if (IsEqualIID(riid
, &IID_IUnknown
) || IsEqualIID(riid
, &IID_IDataObject
))
667 *ppvObject
= dataObject
;
668 IDataObject_AddRef(dataObject
);
672 return E_NOINTERFACE
;
675 static ULONG WINAPI
XDNDDATAOBJECT_AddRef(IDataObject
*dataObject
)
677 TRACE("(%p)\n", dataObject
);
681 static ULONG WINAPI
XDNDDATAOBJECT_Release(IDataObject
*dataObject
)
683 TRACE("(%p)\n", dataObject
);
687 static HRESULT WINAPI
XDNDDATAOBJECT_GetData(IDataObject
*dataObject
,
688 FORMATETC
*formatEtc
,
692 char formatDesc
[1024];
694 TRACE("(%p, %p, %p)\n", dataObject
, formatEtc
, pMedium
);
695 X11DRV_XDND_DescribeClipboardFormat(formatEtc
->cfFormat
,
696 formatDesc
, sizeof(formatDesc
));
697 TRACE("application is looking for %s\n", formatDesc
);
699 hr
= IDataObject_QueryGetData(dataObject
, formatEtc
);
703 LIST_FOR_EACH_ENTRY(current
, &xdndData
, XDNDDATA
, entry
)
705 if (current
->cf_win
== formatEtc
->cfFormat
)
707 pMedium
->tymed
= TYMED_HGLOBAL
;
708 pMedium
->u
.hGlobal
= GlobalAlloc(GMEM_FIXED
| GMEM_ZEROINIT
, GlobalSize(current
->contents
));
709 if (pMedium
->u
.hGlobal
== NULL
)
710 return E_OUTOFMEMORY
;
711 memcpy(GlobalLock(pMedium
->u
.hGlobal
), GlobalLock(current
->contents
), GlobalSize(current
->contents
));
712 GlobalUnlock(pMedium
->u
.hGlobal
);
713 GlobalUnlock(current
->contents
);
714 pMedium
->pUnkForRelease
= 0;
722 static HRESULT WINAPI
XDNDDATAOBJECT_GetDataHere(IDataObject
*dataObject
,
723 FORMATETC
*formatEtc
,
726 FIXME("(%p, %p, %p): stub\n", dataObject
, formatEtc
, pMedium
);
727 return DATA_E_FORMATETC
;
730 static HRESULT WINAPI
XDNDDATAOBJECT_QueryGetData(IDataObject
*dataObject
,
731 FORMATETC
*formatEtc
)
733 char formatDesc
[1024];
736 TRACE("(%p, %p={.tymed=0x%x, .dwAspect=%d, .cfFormat=%d}\n",
737 dataObject
, formatEtc
, formatEtc
->tymed
, formatEtc
->dwAspect
, formatEtc
->cfFormat
);
738 X11DRV_XDND_DescribeClipboardFormat(formatEtc
->cfFormat
, formatDesc
, sizeof(formatDesc
));
740 if (formatEtc
->tymed
&& !(formatEtc
->tymed
& TYMED_HGLOBAL
))
742 FIXME("only HGLOBAL medium types supported right now\n");
745 if (formatEtc
->dwAspect
!= DVASPECT_CONTENT
)
747 FIXME("only the content aspect is supported right now\n");
751 LIST_FOR_EACH_ENTRY(current
, &xdndData
, XDNDDATA
, entry
)
753 if (current
->cf_win
== formatEtc
->cfFormat
)
755 TRACE("application found %s\n", formatDesc
);
759 TRACE("application didn't find %s\n", formatDesc
);
760 return DV_E_FORMATETC
;
763 static HRESULT WINAPI
XDNDDATAOBJECT_GetCanonicalFormatEtc(IDataObject
*dataObject
,
764 FORMATETC
*formatEtc
,
765 FORMATETC
*formatEtcOut
)
767 FIXME("(%p, %p, %p): stub\n", dataObject
, formatEtc
, formatEtcOut
);
768 formatEtcOut
->ptd
= NULL
;
772 static HRESULT WINAPI
XDNDDATAOBJECT_SetData(IDataObject
*dataObject
,
773 FORMATETC
*formatEtc
,
774 STGMEDIUM
*pMedium
, BOOL fRelease
)
776 FIXME("(%p, %p, %p, %s): stub\n", dataObject
, formatEtc
,
777 pMedium
, fRelease
?"TRUE":"FALSE");
781 static HRESULT WINAPI
XDNDDATAOBJECT_EnumFormatEtc(IDataObject
*dataObject
,
783 IEnumFORMATETC
**ppEnumFormatEtc
)
788 TRACE("(%p, %u, %p)\n", dataObject
, dwDirection
, ppEnumFormatEtc
);
790 if (dwDirection
!= DATADIR_GET
)
792 FIXME("only the get direction is implemented\n");
796 count
= list_count(&xdndData
);
797 formats
= HeapAlloc(GetProcessHeap(), 0, count
* sizeof(FORMATETC
));
803 LIST_FOR_EACH_ENTRY(current
, &xdndData
, XDNDDATA
, entry
)
805 formats
[i
].cfFormat
= current
->cf_win
;
806 formats
[i
].ptd
= NULL
;
807 formats
[i
].dwAspect
= DVASPECT_CONTENT
;
808 formats
[i
].lindex
= -1;
809 formats
[i
].tymed
= TYMED_HGLOBAL
;
812 hr
= SHCreateStdEnumFmtEtc(count
, formats
, ppEnumFormatEtc
);
813 HeapFree(GetProcessHeap(), 0, formats
);
817 return E_OUTOFMEMORY
;
820 static HRESULT WINAPI
XDNDDATAOBJECT_DAdvise(IDataObject
*dataObject
,
821 FORMATETC
*formatEtc
, DWORD advf
,
822 IAdviseSink
*adviseSink
,
823 DWORD
*pdwConnection
)
825 FIXME("(%p, %p, %u, %p, %p): stub\n", dataObject
, formatEtc
, advf
,
826 adviseSink
, pdwConnection
);
827 return OLE_E_ADVISENOTSUPPORTED
;
830 static HRESULT WINAPI
XDNDDATAOBJECT_DUnadvise(IDataObject
*dataObject
,
833 FIXME("(%p, %u): stub\n", dataObject
, dwConnection
);
834 return OLE_E_ADVISENOTSUPPORTED
;
837 static HRESULT WINAPI
XDNDDATAOBJECT_EnumDAdvise(IDataObject
*dataObject
,
838 IEnumSTATDATA
**pEnumAdvise
)
840 FIXME("(%p, %p): stub\n", dataObject
, pEnumAdvise
);
841 return OLE_E_ADVISENOTSUPPORTED
;
844 static IDataObjectVtbl xdndDataObjectVtbl
=
846 XDNDDATAOBJECT_QueryInterface
,
847 XDNDDATAOBJECT_AddRef
,
848 XDNDDATAOBJECT_Release
,
849 XDNDDATAOBJECT_GetData
,
850 XDNDDATAOBJECT_GetDataHere
,
851 XDNDDATAOBJECT_QueryGetData
,
852 XDNDDATAOBJECT_GetCanonicalFormatEtc
,
853 XDNDDATAOBJECT_SetData
,
854 XDNDDATAOBJECT_EnumFormatEtc
,
855 XDNDDATAOBJECT_DAdvise
,
856 XDNDDATAOBJECT_DUnadvise
,
857 XDNDDATAOBJECT_EnumDAdvise
860 static IDataObject XDNDDataObject
= { &xdndDataObjectVtbl
};