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 BOOL
X11DRV_XDND_HasHDROP(void);
78 static HRESULT
X11DRV_XDND_SendDropFiles(HWND hwnd
);
79 static void X11DRV_XDND_FreeDragDropOp(void);
81 static CRITICAL_SECTION xdnd_cs
;
82 static CRITICAL_SECTION_DEBUG critsect_debug
=
85 { &critsect_debug
.ProcessLocksList
, &critsect_debug
.ProcessLocksList
},
86 0, 0, { (DWORD_PTR
)(__FILE__
": xdnd_cs") }
88 static CRITICAL_SECTION xdnd_cs
= { &critsect_debug
, -1, 0, 0, 0, 0 };
91 /* Based on functions in dlls/ole32/ole2.c */
92 static HANDLE
get_droptarget_local_handle(HWND hwnd
)
94 static const WCHAR prop_marshalleddroptarget
[] =
95 {'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};
97 HANDLE local_handle
= 0;
99 handle
= GetPropW(hwnd
, prop_marshalleddroptarget
);
105 GetWindowThreadProcessId(hwnd
, &pid
);
106 process
= OpenProcess(PROCESS_DUP_HANDLE
, FALSE
, pid
);
109 DuplicateHandle(process
, handle
, GetCurrentProcess(), &local_handle
, 0, FALSE
, DUPLICATE_SAME_ACCESS
);
110 CloseHandle(process
);
116 static HRESULT
create_stream_from_map(HANDLE map
, IStream
**stream
)
118 HRESULT hr
= E_OUTOFMEMORY
;
121 MEMORY_BASIC_INFORMATION info
;
123 data
= MapViewOfFile(map
, FILE_MAP_READ
, 0, 0, 0);
126 VirtualQuery(data
, &info
, sizeof(info
));
127 TRACE("size %d\n", (int)info
.RegionSize
);
129 hmem
= GlobalAlloc(GMEM_MOVEABLE
, info
.RegionSize
);
132 memcpy(GlobalLock(hmem
), data
, info
.RegionSize
);
134 hr
= CreateStreamOnHGlobal(hmem
, TRUE
, stream
);
136 UnmapViewOfFile(data
);
140 static IDropTarget
* get_droptarget_pointer(HWND hwnd
)
142 IDropTarget
*droptarget
= NULL
;
146 map
= get_droptarget_local_handle(hwnd
);
147 if(!map
) return NULL
;
149 if(SUCCEEDED(create_stream_from_map(map
, &stream
)))
151 CoUnmarshalInterface(stream
, &IID_IDropTarget
, (void**)&droptarget
);
152 IStream_Release(stream
);
158 /**************************************************************************
159 * X11DRV_XDND_XdndActionToDROPEFFECT
161 static DWORD
X11DRV_XDND_XdndActionToDROPEFFECT(long action
)
163 /* In Windows, nothing but the given effects is allowed.
164 * In X the given action is just a hint, and you can always
165 * XdndActionCopy and XdndActionPrivate, so be more permissive. */
166 if (action
== x11drv_atom(XdndActionCopy
))
167 return DROPEFFECT_COPY
;
168 else if (action
== x11drv_atom(XdndActionMove
))
169 return DROPEFFECT_MOVE
| DROPEFFECT_COPY
;
170 else if (action
== x11drv_atom(XdndActionLink
))
171 return DROPEFFECT_LINK
| DROPEFFECT_COPY
;
172 else if (action
== x11drv_atom(XdndActionAsk
))
173 /* FIXME: should we somehow ask the user what to do here? */
174 return DROPEFFECT_COPY
| DROPEFFECT_MOVE
| DROPEFFECT_LINK
;
175 FIXME("unknown action %ld, assuming DROPEFFECT_COPY\n", action
);
176 return DROPEFFECT_COPY
;
179 /**************************************************************************
180 * X11DRV_XDND_DROPEFFECTToXdndAction
182 static long X11DRV_XDND_DROPEFFECTToXdndAction(DWORD effect
)
184 if (effect
== DROPEFFECT_COPY
)
185 return x11drv_atom(XdndActionCopy
);
186 else if (effect
== DROPEFFECT_MOVE
)
187 return x11drv_atom(XdndActionMove
);
188 else if (effect
== DROPEFFECT_LINK
)
189 return x11drv_atom(XdndActionLink
);
190 FIXME("unknown drop effect %u, assuming XdndActionCopy\n", effect
);
191 return x11drv_atom(XdndActionCopy
);
194 /**************************************************************************
195 * X11DRV_XDND_EnterEvent
197 * Handle an XdndEnter event.
199 void X11DRV_XDND_EnterEvent( HWND hWnd
, XClientMessageEvent
*event
)
203 unsigned long count
= 0;
205 version
= (event
->data
.l
[1] & 0xFF000000) >> 24;
206 TRACE("ver(%d) check-XdndTypeList(%ld) data=%ld,%ld,%ld,%ld,%ld\n",
207 version
, (event
->data
.l
[1] & 1),
208 event
->data
.l
[0], event
->data
.l
[1], event
->data
.l
[2],
209 event
->data
.l
[3], event
->data
.l
[4]);
211 if (version
> WINE_XDND_VERSION
)
213 TRACE("Ignores unsupported version\n");
217 XDNDAccepted
= FALSE
;
219 /* If the source supports more than 3 data types we retrieve
220 * the entire list. */
221 if (event
->data
.l
[1] & 1)
225 unsigned long bytesret
;
227 /* Request supported formats from source window */
228 XGetWindowProperty(event
->display
, event
->data
.l
[0], x11drv_atom(XdndTypeList
),
229 0, 65535, FALSE
, AnyPropertyType
, &acttype
, &actfmt
, &count
,
230 &bytesret
, (unsigned char**)&xdndtypes
);
235 xdndtypes
= (Atom
*) &event
->data
.l
[2];
242 for (i
= 0; i
< count
; i
++)
244 if (xdndtypes
[i
] != 0)
246 char * pn
= XGetAtomName(event
->display
, xdndtypes
[i
]);
247 TRACE("XDNDEnterAtom %ld: %s\n", xdndtypes
[i
], pn
);
253 /* Do a one-time data read and cache results */
254 X11DRV_XDND_ResolveProperty(event
->display
, event
->window
,
255 event
->data
.l
[1], xdndtypes
, count
);
257 if (event
->data
.l
[1] & 1)
261 /**************************************************************************
262 * X11DRV_XDND_PositionEvent
264 * Handle an XdndPosition event.
266 void X11DRV_XDND_PositionEvent( HWND hWnd
, XClientMessageEvent
*event
)
268 XClientMessageEvent e
;
269 int accept
= 0; /* Assume we're not accepting */
270 IDropTarget
*dropTarget
= NULL
;
276 XDNDxy
= root_to_virtual_screen( event
->data
.l
[2] >> 16, event
->data
.l
[2] & 0xFFFF );
277 targetWindow
= WindowFromPoint(XDNDxy
);
281 effect
= X11DRV_XDND_XdndActionToDROPEFFECT(event
->data
.l
[4]);
283 if (!XDNDAccepted
|| XDNDLastTargetWnd
!= targetWindow
)
285 /* Notify OLE of DragEnter. Result determines if we accept */
286 HWND dropTargetWindow
;
288 if (XDNDLastDropTargetWnd
)
290 dropTarget
= get_droptarget_pointer(XDNDLastDropTargetWnd
);
293 hr
= IDropTarget_DragLeave(dropTarget
);
295 WARN("IDropTarget_DragLeave failed, error 0x%08X\n", hr
);
296 IDropTarget_Release(dropTarget
);
299 dropTargetWindow
= targetWindow
;
302 dropTarget
= get_droptarget_pointer(dropTargetWindow
);
303 } while (dropTarget
== NULL
&& (dropTargetWindow
= GetParent(dropTargetWindow
)) != NULL
);
304 XDNDLastTargetWnd
= targetWindow
;
305 XDNDLastDropTargetWnd
= dropTargetWindow
;
308 hr
= IDropTarget_DragEnter(dropTarget
, &XDNDDataObject
,
309 MK_LBUTTON
, pointl
, &effect
);
312 if (effect
!= DROPEFFECT_NONE
)
315 TRACE("the application accepted the drop\n");
318 TRACE("the application refused the drop\n");
321 WARN("IDropTarget_DragEnter failed, error 0x%08X\n", hr
);
322 IDropTarget_Release(dropTarget
);
325 if (XDNDAccepted
&& XDNDLastTargetWnd
== targetWindow
)
327 /* If drag accepted notify OLE of DragOver */
328 dropTarget
= get_droptarget_pointer(XDNDLastDropTargetWnd
);
331 hr
= IDropTarget_DragOver(dropTarget
, MK_LBUTTON
, pointl
, &effect
);
333 XDNDDropEffect
= effect
;
335 WARN("IDropTarget_DragOver failed, error 0x%08X\n", hr
);
336 IDropTarget_Release(dropTarget
);
342 else if (dropTarget
== NULL
&&
343 (GetWindowLongW( hWnd
, GWL_EXSTYLE
) & WS_EX_ACCEPTFILES
) &&
344 (effect
& DROPEFFECT_COPY
) &&
345 X11DRV_XDND_HasHDROP())
348 effect
= DROPEFFECT_COPY
;
349 XDNDDropEffect
= effect
;
352 TRACE("action req: %ld accept(%d) at x(%d),y(%d)\n",
353 event
->data
.l
[4], accept
, XDNDxy
.x
, XDNDxy
.y
);
356 * Let source know if we're accepting the drop by
357 * sending a status message.
359 e
.type
= ClientMessage
;
360 e
.display
= event
->display
;
361 e
.window
= event
->data
.l
[0];
362 e
.message_type
= x11drv_atom(XdndStatus
);
364 e
.data
.l
[0] = event
->window
;
365 e
.data
.l
[1] = accept
;
366 e
.data
.l
[2] = 0; /* Empty Rect */
367 e
.data
.l
[3] = 0; /* Empty Rect */
369 e
.data
.l
[4] = X11DRV_XDND_DROPEFFECTToXdndAction(effect
);
372 XSendEvent(event
->display
, event
->data
.l
[0], False
, NoEventMask
, (XEvent
*)&e
);
375 /**************************************************************************
376 * X11DRV_XDND_DropEvent
378 * Handle an XdndDrop event.
380 void X11DRV_XDND_DropEvent( HWND hWnd
, XClientMessageEvent
*event
)
382 XClientMessageEvent e
;
383 IDropTarget
*dropTarget
;
384 DWORD effect
= XDNDDropEffect
;
385 int accept
= 0; /* Assume we're not accepting */
389 /* Notify OLE of Drop */
390 dropTarget
= get_droptarget_pointer(XDNDLastDropTargetWnd
);
398 hr
= IDropTarget_Drop(dropTarget
, &XDNDDataObject
, MK_LBUTTON
,
402 if (effect
!= DROPEFFECT_NONE
)
404 TRACE("drop succeeded\n");
408 TRACE("the application refused the drop\n");
411 WARN("drop failed, error 0x%08X\n", hr
);
412 IDropTarget_Release(dropTarget
);
416 /* Only send WM_DROPFILES if there is no drop target. Doing both
417 * causes winamp to duplicate the dropped files (#29081) */
418 if ((GetWindowLongW( hWnd
, GWL_EXSTYLE
) & WS_EX_ACCEPTFILES
) &&
419 (effect
& DROPEFFECT_COPY
) &&
420 X11DRV_XDND_HasHDROP())
422 HRESULT hr
= X11DRV_XDND_SendDropFiles( hWnd
);
426 effect
= DROPEFFECT_COPY
;
431 X11DRV_XDND_FreeDragDropOp();
433 /* Tell the target we are finished. */
434 memset(&e
, 0, sizeof(e
));
435 e
.type
= ClientMessage
;
436 e
.display
= event
->display
;
437 e
.window
= event
->data
.l
[0];
438 e
.message_type
= x11drv_atom(XdndFinished
);
440 e
.data
.l
[0] = event
->window
;
441 e
.data
.l
[1] = accept
;
443 e
.data
.l
[2] = X11DRV_XDND_DROPEFFECTToXdndAction(effect
);
446 XSendEvent(event
->display
, event
->data
.l
[0], False
, NoEventMask
, (XEvent
*)&e
);
449 /**************************************************************************
450 * X11DRV_XDND_LeaveEvent
452 * Handle an XdndLeave event.
454 void X11DRV_XDND_LeaveEvent( HWND hWnd
, XClientMessageEvent
*event
)
456 IDropTarget
*dropTarget
;
458 TRACE("DND Operation canceled\n");
460 /* Notify OLE of DragLeave */
461 dropTarget
= get_droptarget_pointer(XDNDLastDropTargetWnd
);
464 HRESULT hr
= IDropTarget_DragLeave(dropTarget
);
466 WARN("IDropTarget_DragLeave failed, error 0x%08X\n", hr
);
467 IDropTarget_Release(dropTarget
);
470 X11DRV_XDND_FreeDragDropOp();
474 /**************************************************************************
475 * X11DRV_XDND_ResolveProperty
477 * Resolve all MIME types to windows clipboard formats. All data is cached.
479 static void X11DRV_XDND_ResolveProperty(Display
*display
, Window xwin
, Time tm
,
480 Atom
*types
, unsigned long count
)
485 XDNDDATA
*current
, *next
;
486 BOOL haveHDROP
= FALSE
;
488 TRACE("count(%ld)\n", count
);
490 X11DRV_XDND_FreeDragDropOp(); /* Clear previously cached data */
492 for (i
= 0; i
< count
; i
++)
497 TRACE("requesting atom %ld from xwin %ld\n", types
[i
], xwin
);
502 XConvertSelection(display
, x11drv_atom(XdndSelection
), types
[i
],
503 x11drv_atom(XdndTarget
), xwin
, /*tm*/CurrentTime
);
506 * Wait for SelectionNotify
508 for (j
= 0; j
< SELECTION_RETRIES
; j
++)
510 res
= XCheckTypedWindowEvent(display
, xwin
, SelectionNotify
, &xe
);
511 if (res
&& xe
.xselection
.selection
== x11drv_atom(XdndSelection
)) break;
513 usleep(SELECTION_WAIT
);
516 if (xe
.xselection
.property
== None
)
519 contents
= X11DRV_CLIPBOARD_ImportSelection(display
, types
[i
], xwin
, x11drv_atom(XdndTarget
), &windowsFormat
);
521 X11DRV_XDND_InsertXDNDData(types
[i
], windowsFormat
, contents
);
524 /* On Windows when there is a CF_HDROP, there are no other CF_ formats.
525 * foobar2000 relies on this (spaces -> %20's without it).
527 LIST_FOR_EACH_ENTRY(current
, &xdndData
, XDNDDATA
, entry
)
529 if (current
->cf_win
== CF_HDROP
)
537 LIST_FOR_EACH_ENTRY_SAFE(current
, next
, &xdndData
, XDNDDATA
, entry
)
539 if (current
->cf_win
!= CF_HDROP
&& current
->cf_win
< CF_MAX
)
541 list_remove(¤t
->entry
);
542 GlobalFree(current
->contents
);
543 HeapFree(GetProcessHeap(), 0, current
);
550 /**************************************************************************
551 * X11DRV_XDND_InsertXDNDData
553 * Cache available XDND property
555 static void X11DRV_XDND_InsertXDNDData(int property
, int format
, HANDLE contents
)
557 LPXDNDDATA current
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(XDNDDATA
));
561 EnterCriticalSection(&xdnd_cs
);
562 current
->cf_xdnd
= property
;
563 current
->cf_win
= format
;
564 current
->contents
= contents
;
565 list_add_tail(&xdndData
, ¤t
->entry
);
566 LeaveCriticalSection(&xdnd_cs
);
571 /**************************************************************************
572 * X11DRV_XDND_HasHDROP
574 static BOOL
X11DRV_XDND_HasHDROP(void)
576 LPXDNDDATA current
= NULL
;
579 EnterCriticalSection(&xdnd_cs
);
581 /* Find CF_HDROP type if any */
582 LIST_FOR_EACH_ENTRY(current
, &xdndData
, XDNDDATA
, entry
)
584 if (current
->cf_win
== CF_HDROP
)
591 LeaveCriticalSection(&xdnd_cs
);
596 /**************************************************************************
597 * X11DRV_XDND_SendDropFiles
599 static HRESULT
X11DRV_XDND_SendDropFiles(HWND hwnd
)
602 LPXDNDDATA current
= NULL
;
605 EnterCriticalSection(&xdnd_cs
);
607 LIST_FOR_EACH_ENTRY(current
, &xdndData
, XDNDDATA
, entry
)
609 if (current
->cf_win
== CF_HDROP
)
617 HGLOBAL dropHandle
= GlobalAlloc(GMEM_FIXED
, GlobalSize(current
->contents
));
620 DROPFILES
*lpDrop
= GlobalLock(dropHandle
);
621 memcpy(lpDrop
, GlobalLock(current
->contents
), GlobalSize(current
->contents
));
622 GlobalUnlock(current
->contents
);
623 lpDrop
->pt
.x
= XDNDxy
.x
;
624 lpDrop
->pt
.y
= XDNDxy
.y
;
625 lpDrop
->fNC
= !ScreenToClient(hwnd
, &lpDrop
->pt
);
626 TRACE("Sending WM_DROPFILES: hWnd=0x%p, fNC=%d, x=%d, y=%d, files=%p(%s)\n", hwnd
,
627 lpDrop
->fNC
, lpDrop
->pt
.x
, lpDrop
->pt
.y
, ((char*)lpDrop
) + lpDrop
->pFiles
,
628 debugstr_w((WCHAR
*)(((char*)lpDrop
) + lpDrop
->pFiles
)));
629 GlobalUnlock(dropHandle
);
630 if (PostMessageW(hwnd
, WM_DROPFILES
, (WPARAM
)dropHandle
, 0))
634 hr
= HRESULT_FROM_WIN32(GetLastError());
635 GlobalFree(dropHandle
);
639 hr
= HRESULT_FROM_WIN32(GetLastError());
644 LeaveCriticalSection(&xdnd_cs
);
650 /**************************************************************************
651 * X11DRV_XDND_FreeDragDropOp
653 static void X11DRV_XDND_FreeDragDropOp(void)
660 EnterCriticalSection(&xdnd_cs
);
662 /** Free data cache */
663 LIST_FOR_EACH_ENTRY_SAFE(current
, next
, &xdndData
, XDNDDATA
, entry
)
665 list_remove(¤t
->entry
);
666 GlobalFree(current
->contents
);
667 HeapFree(GetProcessHeap(), 0, current
);
670 XDNDxy
.x
= XDNDxy
.y
= 0;
671 XDNDLastTargetWnd
= NULL
;
672 XDNDLastDropTargetWnd
= NULL
;
673 XDNDAccepted
= FALSE
;
675 LeaveCriticalSection(&xdnd_cs
);
679 /**************************************************************************
680 * X11DRV_XDND_DescribeClipboardFormat
682 static void X11DRV_XDND_DescribeClipboardFormat(int cfFormat
, char *buffer
, int size
)
684 #define D(x) case x: lstrcpynA(buffer, #x, size); return;
707 if (CF_PRIVATEFIRST
<= cfFormat
&& cfFormat
<= CF_PRIVATELAST
)
709 lstrcpynA(buffer
, "some private object", size
);
712 if (CF_GDIOBJFIRST
<= cfFormat
&& cfFormat
<= CF_GDIOBJLAST
)
714 lstrcpynA(buffer
, "some GDI object", size
);
718 GetClipboardFormatNameA(cfFormat
, buffer
, size
);
722 /* The IDataObject singleton we feed to OLE follows */
724 static HRESULT WINAPI
XDNDDATAOBJECT_QueryInterface(IDataObject
*dataObject
,
725 REFIID riid
, void **ppvObject
)
727 TRACE("(%p, %s, %p)\n", dataObject
, debugstr_guid(riid
), ppvObject
);
728 if (IsEqualIID(riid
, &IID_IUnknown
) || IsEqualIID(riid
, &IID_IDataObject
))
730 *ppvObject
= dataObject
;
731 IDataObject_AddRef(dataObject
);
735 return E_NOINTERFACE
;
738 static ULONG WINAPI
XDNDDATAOBJECT_AddRef(IDataObject
*dataObject
)
740 TRACE("(%p)\n", dataObject
);
744 static ULONG WINAPI
XDNDDATAOBJECT_Release(IDataObject
*dataObject
)
746 TRACE("(%p)\n", dataObject
);
750 static HRESULT WINAPI
XDNDDATAOBJECT_GetData(IDataObject
*dataObject
,
751 FORMATETC
*formatEtc
,
755 char formatDesc
[1024];
757 TRACE("(%p, %p, %p)\n", dataObject
, formatEtc
, pMedium
);
758 X11DRV_XDND_DescribeClipboardFormat(formatEtc
->cfFormat
,
759 formatDesc
, sizeof(formatDesc
));
760 TRACE("application is looking for %s\n", formatDesc
);
762 hr
= IDataObject_QueryGetData(dataObject
, formatEtc
);
766 LIST_FOR_EACH_ENTRY(current
, &xdndData
, XDNDDATA
, entry
)
768 if (current
->cf_win
== formatEtc
->cfFormat
)
770 pMedium
->tymed
= TYMED_HGLOBAL
;
771 pMedium
->u
.hGlobal
= GlobalAlloc(GMEM_FIXED
| GMEM_ZEROINIT
, GlobalSize(current
->contents
));
772 if (pMedium
->u
.hGlobal
== NULL
)
773 return E_OUTOFMEMORY
;
774 memcpy(GlobalLock(pMedium
->u
.hGlobal
), GlobalLock(current
->contents
), GlobalSize(current
->contents
));
775 GlobalUnlock(pMedium
->u
.hGlobal
);
776 GlobalUnlock(current
->contents
);
777 pMedium
->pUnkForRelease
= 0;
785 static HRESULT WINAPI
XDNDDATAOBJECT_GetDataHere(IDataObject
*dataObject
,
786 FORMATETC
*formatEtc
,
789 FIXME("(%p, %p, %p): stub\n", dataObject
, formatEtc
, pMedium
);
790 return DATA_E_FORMATETC
;
793 static HRESULT WINAPI
XDNDDATAOBJECT_QueryGetData(IDataObject
*dataObject
,
794 FORMATETC
*formatEtc
)
796 char formatDesc
[1024];
799 TRACE("(%p, %p={.tymed=0x%x, .dwAspect=%d, .cfFormat=%d}\n",
800 dataObject
, formatEtc
, formatEtc
->tymed
, formatEtc
->dwAspect
, formatEtc
->cfFormat
);
801 X11DRV_XDND_DescribeClipboardFormat(formatEtc
->cfFormat
, formatDesc
, sizeof(formatDesc
));
803 if (formatEtc
->tymed
&& !(formatEtc
->tymed
& TYMED_HGLOBAL
))
805 FIXME("only HGLOBAL medium types supported right now\n");
808 if (formatEtc
->dwAspect
!= DVASPECT_CONTENT
)
810 FIXME("only the content aspect is supported right now\n");
814 LIST_FOR_EACH_ENTRY(current
, &xdndData
, XDNDDATA
, entry
)
816 if (current
->cf_win
== formatEtc
->cfFormat
)
818 TRACE("application found %s\n", formatDesc
);
822 TRACE("application didn't find %s\n", formatDesc
);
823 return DV_E_FORMATETC
;
826 static HRESULT WINAPI
XDNDDATAOBJECT_GetCanonicalFormatEtc(IDataObject
*dataObject
,
827 FORMATETC
*formatEtc
,
828 FORMATETC
*formatEtcOut
)
830 FIXME("(%p, %p, %p): stub\n", dataObject
, formatEtc
, formatEtcOut
);
831 formatEtcOut
->ptd
= NULL
;
835 static HRESULT WINAPI
XDNDDATAOBJECT_SetData(IDataObject
*dataObject
,
836 FORMATETC
*formatEtc
,
837 STGMEDIUM
*pMedium
, BOOL fRelease
)
839 FIXME("(%p, %p, %p, %s): stub\n", dataObject
, formatEtc
,
840 pMedium
, fRelease
?"TRUE":"FALSE");
844 static HRESULT WINAPI
XDNDDATAOBJECT_EnumFormatEtc(IDataObject
*dataObject
,
846 IEnumFORMATETC
**ppEnumFormatEtc
)
851 TRACE("(%p, %u, %p)\n", dataObject
, dwDirection
, ppEnumFormatEtc
);
853 if (dwDirection
!= DATADIR_GET
)
855 FIXME("only the get direction is implemented\n");
859 count
= list_count(&xdndData
);
860 formats
= HeapAlloc(GetProcessHeap(), 0, count
* sizeof(FORMATETC
));
866 LIST_FOR_EACH_ENTRY(current
, &xdndData
, XDNDDATA
, entry
)
868 formats
[i
].cfFormat
= current
->cf_win
;
869 formats
[i
].ptd
= NULL
;
870 formats
[i
].dwAspect
= DVASPECT_CONTENT
;
871 formats
[i
].lindex
= -1;
872 formats
[i
].tymed
= TYMED_HGLOBAL
;
875 hr
= SHCreateStdEnumFmtEtc(count
, formats
, ppEnumFormatEtc
);
876 HeapFree(GetProcessHeap(), 0, formats
);
880 return E_OUTOFMEMORY
;
883 static HRESULT WINAPI
XDNDDATAOBJECT_DAdvise(IDataObject
*dataObject
,
884 FORMATETC
*formatEtc
, DWORD advf
,
885 IAdviseSink
*adviseSink
,
886 DWORD
*pdwConnection
)
888 FIXME("(%p, %p, %u, %p, %p): stub\n", dataObject
, formatEtc
, advf
,
889 adviseSink
, pdwConnection
);
890 return OLE_E_ADVISENOTSUPPORTED
;
893 static HRESULT WINAPI
XDNDDATAOBJECT_DUnadvise(IDataObject
*dataObject
,
896 FIXME("(%p, %u): stub\n", dataObject
, dwConnection
);
897 return OLE_E_ADVISENOTSUPPORTED
;
900 static HRESULT WINAPI
XDNDDATAOBJECT_EnumDAdvise(IDataObject
*dataObject
,
901 IEnumSTATDATA
**pEnumAdvise
)
903 FIXME("(%p, %p): stub\n", dataObject
, pEnumAdvise
);
904 return OLE_E_ADVISENOTSUPPORTED
;
907 static IDataObjectVtbl xdndDataObjectVtbl
=
909 XDNDDATAOBJECT_QueryInterface
,
910 XDNDDATAOBJECT_AddRef
,
911 XDNDDATAOBJECT_Release
,
912 XDNDDATAOBJECT_GetData
,
913 XDNDDATAOBJECT_GetDataHere
,
914 XDNDDATAOBJECT_QueryGetData
,
915 XDNDDATAOBJECT_GetCanonicalFormatEtc
,
916 XDNDDATAOBJECT_SetData
,
917 XDNDDATAOBJECT_EnumFormatEtc
,
918 XDNDDATAOBJECT_DAdvise
,
919 XDNDDATAOBJECT_DUnadvise
,
920 XDNDDATAOBJECT_EnumDAdvise
923 static IDataObject XDNDDataObject
= { &xdndDataObjectVtbl
};