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 typedef struct tagXDNDDATA
58 } XDNDDATA
, *LPXDNDDATA
;
60 static struct list xdndData
= LIST_INIT(xdndData
);
61 static POINT XDNDxy
= { 0, 0 };
62 static IDataObject XDNDDataObject
;
63 static BOOL XDNDAccepted
= FALSE
;
64 static DWORD XDNDDropEffect
= DROPEFFECT_NONE
;
65 /* the last window the mouse was over */
66 static HWND XDNDLastTargetWnd
;
67 /* might be an ancestor of XDNDLastTargetWnd */
68 static HWND XDNDLastDropTargetWnd
;
70 static void X11DRV_XDND_InsertXDNDData( Atom property
, UINT format
, HANDLE contents
);
71 static void X11DRV_XDND_ResolveProperty(Display
*display
, Window xwin
, Time tm
,
72 Atom
*types
, unsigned long count
);
73 static BOOL
X11DRV_XDND_HasHDROP(void);
74 static HRESULT
X11DRV_XDND_SendDropFiles(HWND hwnd
);
75 static void X11DRV_XDND_FreeDragDropOp(void);
77 static CRITICAL_SECTION xdnd_cs
;
78 static CRITICAL_SECTION_DEBUG critsect_debug
=
81 { &critsect_debug
.ProcessLocksList
, &critsect_debug
.ProcessLocksList
},
82 0, 0, { (DWORD_PTR
)(__FILE__
": xdnd_cs") }
84 static CRITICAL_SECTION xdnd_cs
= { &critsect_debug
, -1, 0, 0, 0, 0 };
87 /* Based on functions in dlls/ole32/ole2.c */
88 static HANDLE
get_droptarget_local_handle(HWND hwnd
)
90 static const WCHAR prop_marshalleddroptarget
[] =
91 {'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};
93 HANDLE local_handle
= 0;
95 handle
= GetPropW(hwnd
, prop_marshalleddroptarget
);
101 GetWindowThreadProcessId(hwnd
, &pid
);
102 process
= OpenProcess(PROCESS_DUP_HANDLE
, FALSE
, pid
);
105 DuplicateHandle(process
, handle
, GetCurrentProcess(), &local_handle
, 0, FALSE
, DUPLICATE_SAME_ACCESS
);
106 CloseHandle(process
);
112 static HRESULT
create_stream_from_map(HANDLE map
, IStream
**stream
)
114 HRESULT hr
= E_OUTOFMEMORY
;
117 MEMORY_BASIC_INFORMATION info
;
119 data
= MapViewOfFile(map
, FILE_MAP_READ
, 0, 0, 0);
122 VirtualQuery(data
, &info
, sizeof(info
));
123 TRACE("size %d\n", (int)info
.RegionSize
);
125 hmem
= GlobalAlloc(GMEM_MOVEABLE
, info
.RegionSize
);
128 memcpy(GlobalLock(hmem
), data
, info
.RegionSize
);
130 hr
= CreateStreamOnHGlobal(hmem
, TRUE
, stream
);
132 UnmapViewOfFile(data
);
136 static IDropTarget
* get_droptarget_pointer(HWND hwnd
)
138 IDropTarget
*droptarget
= NULL
;
142 map
= get_droptarget_local_handle(hwnd
);
143 if(!map
) return NULL
;
145 if(SUCCEEDED(create_stream_from_map(map
, &stream
)))
147 CoUnmarshalInterface(stream
, &IID_IDropTarget
, (void**)&droptarget
);
148 IStream_Release(stream
);
154 /**************************************************************************
155 * X11DRV_XDND_XdndActionToDROPEFFECT
157 static DWORD
X11DRV_XDND_XdndActionToDROPEFFECT(long action
)
159 /* In Windows, nothing but the given effects is allowed.
160 * In X the given action is just a hint, and you can always
161 * XdndActionCopy and XdndActionPrivate, so be more permissive. */
162 if (action
== x11drv_atom(XdndActionCopy
))
163 return DROPEFFECT_COPY
;
164 else if (action
== x11drv_atom(XdndActionMove
))
165 return DROPEFFECT_MOVE
| DROPEFFECT_COPY
;
166 else if (action
== x11drv_atom(XdndActionLink
))
167 return DROPEFFECT_LINK
| DROPEFFECT_COPY
;
168 else if (action
== x11drv_atom(XdndActionAsk
))
169 /* FIXME: should we somehow ask the user what to do here? */
170 return DROPEFFECT_COPY
| DROPEFFECT_MOVE
| DROPEFFECT_LINK
;
171 FIXME("unknown action %ld, assuming DROPEFFECT_COPY\n", action
);
172 return DROPEFFECT_COPY
;
175 /**************************************************************************
176 * X11DRV_XDND_DROPEFFECTToXdndAction
178 static long X11DRV_XDND_DROPEFFECTToXdndAction(DWORD effect
)
180 if (effect
== DROPEFFECT_COPY
)
181 return x11drv_atom(XdndActionCopy
);
182 else if (effect
== DROPEFFECT_MOVE
)
183 return x11drv_atom(XdndActionMove
);
184 else if (effect
== DROPEFFECT_LINK
)
185 return x11drv_atom(XdndActionLink
);
186 FIXME("unknown drop effect %u, assuming XdndActionCopy\n", effect
);
187 return x11drv_atom(XdndActionCopy
);
190 /**************************************************************************
191 * X11DRV_XDND_EnterEvent
193 * Handle an XdndEnter event.
195 void X11DRV_XDND_EnterEvent( HWND hWnd
, XClientMessageEvent
*event
)
199 unsigned long count
= 0;
201 version
= (event
->data
.l
[1] & 0xFF000000) >> 24;
202 TRACE("ver(%d) check-XdndTypeList(%ld) data=%ld,%ld,%ld,%ld,%ld\n",
203 version
, (event
->data
.l
[1] & 1),
204 event
->data
.l
[0], event
->data
.l
[1], event
->data
.l
[2],
205 event
->data
.l
[3], event
->data
.l
[4]);
207 if (version
> WINE_XDND_VERSION
)
209 ERR("ignoring unsupported XDND version %d\n", version
);
213 XDNDAccepted
= FALSE
;
215 /* If the source supports more than 3 data types we retrieve
216 * the entire list. */
217 if (event
->data
.l
[1] & 1)
221 unsigned long bytesret
;
223 /* Request supported formats from source window */
224 XGetWindowProperty(event
->display
, event
->data
.l
[0], x11drv_atom(XdndTypeList
),
225 0, 65535, FALSE
, AnyPropertyType
, &acttype
, &actfmt
, &count
,
226 &bytesret
, (unsigned char**)&xdndtypes
);
231 xdndtypes
= (Atom
*) &event
->data
.l
[2];
238 for (i
= 0; i
< count
; i
++)
240 if (xdndtypes
[i
] != 0)
242 char * pn
= XGetAtomName(event
->display
, xdndtypes
[i
]);
243 TRACE("XDNDEnterAtom %ld: %s\n", xdndtypes
[i
], pn
);
249 /* Do a one-time data read and cache results */
250 X11DRV_XDND_ResolveProperty(event
->display
, event
->window
,
251 event
->data
.l
[1], xdndtypes
, count
);
253 if (event
->data
.l
[1] & 1)
257 /**************************************************************************
258 * X11DRV_XDND_PositionEvent
260 * Handle an XdndPosition event.
262 void X11DRV_XDND_PositionEvent( HWND hWnd
, XClientMessageEvent
*event
)
264 XClientMessageEvent e
;
265 int accept
= 0; /* Assume we're not accepting */
266 IDropTarget
*dropTarget
= NULL
;
272 XDNDxy
= root_to_virtual_screen( event
->data
.l
[2] >> 16, event
->data
.l
[2] & 0xFFFF );
273 targetWindow
= WindowFromPoint(XDNDxy
);
277 effect
= X11DRV_XDND_XdndActionToDROPEFFECT(event
->data
.l
[4]);
279 if (!XDNDAccepted
|| XDNDLastTargetWnd
!= targetWindow
)
281 /* Notify OLE of DragEnter. Result determines if we accept */
282 HWND dropTargetWindow
;
284 if (XDNDAccepted
&& XDNDLastDropTargetWnd
)
286 dropTarget
= get_droptarget_pointer(XDNDLastDropTargetWnd
);
289 hr
= IDropTarget_DragLeave(dropTarget
);
291 WARN("IDropTarget_DragLeave failed, error 0x%08X\n", hr
);
292 IDropTarget_Release(dropTarget
);
295 dropTargetWindow
= targetWindow
;
298 dropTarget
= get_droptarget_pointer(dropTargetWindow
);
299 } while (dropTarget
== NULL
&& (dropTargetWindow
= GetParent(dropTargetWindow
)) != NULL
);
300 XDNDLastTargetWnd
= targetWindow
;
301 XDNDLastDropTargetWnd
= dropTargetWindow
;
304 DWORD effect_ignore
= effect
;
305 hr
= IDropTarget_DragEnter(dropTarget
, &XDNDDataObject
,
306 MK_LBUTTON
, pointl
, &effect_ignore
);
310 TRACE("the application accepted the drop (effect = %d)\n", effect_ignore
);
314 XDNDAccepted
= FALSE
;
315 WARN("IDropTarget_DragEnter failed, error 0x%08X\n", hr
);
317 IDropTarget_Release(dropTarget
);
320 if (XDNDAccepted
&& XDNDLastTargetWnd
== targetWindow
)
322 /* If drag accepted notify OLE of DragOver */
323 dropTarget
= get_droptarget_pointer(XDNDLastDropTargetWnd
);
326 hr
= IDropTarget_DragOver(dropTarget
, MK_LBUTTON
, pointl
, &effect
);
328 XDNDDropEffect
= effect
;
330 WARN("IDropTarget_DragOver failed, error 0x%08X\n", hr
);
331 IDropTarget_Release(dropTarget
);
337 else if ((GetWindowLongW( hWnd
, GWL_EXSTYLE
) & WS_EX_ACCEPTFILES
) &&
338 X11DRV_XDND_HasHDROP())
341 effect
= DROPEFFECT_COPY
;
344 TRACE("actionRequested(%ld) accept(%d) chosen(0x%x) at x(%d),y(%d)\n",
345 event
->data
.l
[4], accept
, effect
, 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
;
376 DWORD effect
= XDNDDropEffect
;
377 int accept
= 0; /* Assume we're not accepting */
378 BOOL drop_file
= TRUE
;
380 /* Notify OLE of Drop */
383 dropTarget
= get_droptarget_pointer(XDNDLastDropTargetWnd
);
384 if (dropTarget
&& effect
!=DROPEFFECT_NONE
)
391 hr
= IDropTarget_Drop(dropTarget
, &XDNDDataObject
, MK_LBUTTON
,
395 if (effect
!= DROPEFFECT_NONE
)
397 TRACE("drop succeeded\n");
402 TRACE("the application refused the drop\n");
405 WARN("drop failed, error 0x%08X\n", hr
);
408 WARN("drop returned 0x%08X\n", hr
);
411 IDropTarget_Release(dropTarget
);
415 HRESULT hr
= IDropTarget_DragLeave(dropTarget
);
417 WARN("IDropTarget_DragLeave failed, error 0x%08X\n", hr
);
418 IDropTarget_Release(dropTarget
);
424 /* Only send WM_DROPFILES if Drop didn't succeed or DROPEFFECT_NONE was set.
425 * Doing both causes winamp to duplicate the dropped files (#29081) */
426 if ((GetWindowLongW( hWnd
, GWL_EXSTYLE
) & WS_EX_ACCEPTFILES
) &&
427 X11DRV_XDND_HasHDROP())
429 HRESULT hr
= X11DRV_XDND_SendDropFiles( hWnd
);
433 effect
= DROPEFFECT_COPY
;
438 TRACE("effectRequested(0x%x) accept(%d) performed(0x%x) at x(%d),y(%d)\n",
439 XDNDDropEffect
, accept
, effect
, XDNDxy
.x
, XDNDxy
.y
);
441 X11DRV_XDND_FreeDragDropOp();
443 /* Tell the target we are finished. */
444 memset(&e
, 0, sizeof(e
));
445 e
.type
= ClientMessage
;
446 e
.display
= event
->display
;
447 e
.window
= event
->data
.l
[0];
448 e
.message_type
= x11drv_atom(XdndFinished
);
450 e
.data
.l
[0] = event
->window
;
451 e
.data
.l
[1] = accept
;
453 e
.data
.l
[2] = X11DRV_XDND_DROPEFFECTToXdndAction(effect
);
456 XSendEvent(event
->display
, event
->data
.l
[0], False
, NoEventMask
, (XEvent
*)&e
);
459 /**************************************************************************
460 * X11DRV_XDND_LeaveEvent
462 * Handle an XdndLeave event.
464 void X11DRV_XDND_LeaveEvent( HWND hWnd
, XClientMessageEvent
*event
)
466 IDropTarget
*dropTarget
;
468 TRACE("DND Operation canceled\n");
470 /* Notify OLE of DragLeave */
473 dropTarget
= get_droptarget_pointer(XDNDLastDropTargetWnd
);
476 HRESULT hr
= IDropTarget_DragLeave(dropTarget
);
478 WARN("IDropTarget_DragLeave failed, error 0x%08X\n", hr
);
479 IDropTarget_Release(dropTarget
);
483 X11DRV_XDND_FreeDragDropOp();
487 /**************************************************************************
488 * X11DRV_XDND_ResolveProperty
490 * Resolve all MIME types to windows clipboard formats. All data is cached.
492 static void X11DRV_XDND_ResolveProperty(Display
*display
, Window xwin
, Time tm
,
493 Atom
*types
, unsigned long count
)
495 XDNDDATA
*current
, *next
;
496 BOOL haveHDROP
= FALSE
;
498 TRACE("count(%ld)\n", count
);
500 X11DRV_XDND_FreeDragDropOp(); /* Clear previously cached data */
502 X11DRV_CLIPBOARD_ImportSelection( display
, xwin
, x11drv_atom(XdndSelection
),
503 types
, count
, X11DRV_XDND_InsertXDNDData
);
505 /* On Windows when there is a CF_HDROP, there are no other CF_ formats.
506 * foobar2000 relies on this (spaces -> %20's without it).
508 LIST_FOR_EACH_ENTRY(current
, &xdndData
, XDNDDATA
, entry
)
510 if (current
->cf_win
== CF_HDROP
)
518 LIST_FOR_EACH_ENTRY_SAFE(current
, next
, &xdndData
, XDNDDATA
, entry
)
520 if (current
->cf_win
!= CF_HDROP
&& current
->cf_win
< CF_MAX
)
522 list_remove(¤t
->entry
);
523 GlobalFree(current
->contents
);
524 HeapFree(GetProcessHeap(), 0, current
);
531 /**************************************************************************
532 * X11DRV_XDND_InsertXDNDData
534 * Cache available XDND property
536 static void X11DRV_XDND_InsertXDNDData( Atom property
, UINT format
, HANDLE contents
)
538 LPXDNDDATA current
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(XDNDDATA
));
542 EnterCriticalSection(&xdnd_cs
);
543 current
->cf_xdnd
= property
;
544 current
->cf_win
= format
;
545 current
->contents
= contents
;
546 list_add_tail(&xdndData
, ¤t
->entry
);
547 LeaveCriticalSection(&xdnd_cs
);
552 /**************************************************************************
553 * X11DRV_XDND_HasHDROP
555 static BOOL
X11DRV_XDND_HasHDROP(void)
557 LPXDNDDATA current
= NULL
;
560 EnterCriticalSection(&xdnd_cs
);
562 /* Find CF_HDROP type if any */
563 LIST_FOR_EACH_ENTRY(current
, &xdndData
, XDNDDATA
, entry
)
565 if (current
->cf_win
== CF_HDROP
)
572 LeaveCriticalSection(&xdnd_cs
);
577 /**************************************************************************
578 * X11DRV_XDND_SendDropFiles
580 static HRESULT
X11DRV_XDND_SendDropFiles(HWND hwnd
)
583 LPXDNDDATA current
= NULL
;
586 EnterCriticalSection(&xdnd_cs
);
588 LIST_FOR_EACH_ENTRY(current
, &xdndData
, XDNDDATA
, entry
)
590 if (current
->cf_win
== CF_HDROP
)
598 HGLOBAL dropHandle
= GlobalAlloc(GMEM_FIXED
, GlobalSize(current
->contents
));
601 DROPFILES
*lpDrop
= GlobalLock(dropHandle
);
602 memcpy(lpDrop
, GlobalLock(current
->contents
), GlobalSize(current
->contents
));
603 GlobalUnlock(current
->contents
);
604 lpDrop
->pt
.x
= XDNDxy
.x
;
605 lpDrop
->pt
.y
= XDNDxy
.y
;
606 lpDrop
->fNC
= !ScreenToClient(hwnd
, &lpDrop
->pt
);
607 TRACE("Sending WM_DROPFILES: hWnd=0x%p, fNC=%d, x=%d, y=%d, files=%p(%s)\n", hwnd
,
608 lpDrop
->fNC
, lpDrop
->pt
.x
, lpDrop
->pt
.y
, ((char*)lpDrop
) + lpDrop
->pFiles
,
609 debugstr_w((WCHAR
*)(((char*)lpDrop
) + lpDrop
->pFiles
)));
610 GlobalUnlock(dropHandle
);
611 if (PostMessageW(hwnd
, WM_DROPFILES
, (WPARAM
)dropHandle
, 0))
615 hr
= HRESULT_FROM_WIN32(GetLastError());
616 GlobalFree(dropHandle
);
620 hr
= HRESULT_FROM_WIN32(GetLastError());
625 LeaveCriticalSection(&xdnd_cs
);
631 /**************************************************************************
632 * X11DRV_XDND_FreeDragDropOp
634 static void X11DRV_XDND_FreeDragDropOp(void)
641 EnterCriticalSection(&xdnd_cs
);
643 /** Free data cache */
644 LIST_FOR_EACH_ENTRY_SAFE(current
, next
, &xdndData
, XDNDDATA
, entry
)
646 list_remove(¤t
->entry
);
647 GlobalFree(current
->contents
);
648 HeapFree(GetProcessHeap(), 0, current
);
651 XDNDxy
.x
= XDNDxy
.y
= 0;
652 XDNDLastTargetWnd
= NULL
;
653 XDNDLastDropTargetWnd
= NULL
;
654 XDNDAccepted
= FALSE
;
656 LeaveCriticalSection(&xdnd_cs
);
660 /**************************************************************************
661 * X11DRV_XDND_DescribeClipboardFormat
663 static void X11DRV_XDND_DescribeClipboardFormat(int cfFormat
, char *buffer
, int size
)
665 #define D(x) case x: lstrcpynA(buffer, #x, size); return;
688 if (CF_PRIVATEFIRST
<= cfFormat
&& cfFormat
<= CF_PRIVATELAST
)
690 lstrcpynA(buffer
, "some private object", size
);
693 if (CF_GDIOBJFIRST
<= cfFormat
&& cfFormat
<= CF_GDIOBJLAST
)
695 lstrcpynA(buffer
, "some GDI object", size
);
699 GetClipboardFormatNameA(cfFormat
, buffer
, size
);
703 /* The IDataObject singleton we feed to OLE follows */
705 static HRESULT WINAPI
XDNDDATAOBJECT_QueryInterface(IDataObject
*dataObject
,
706 REFIID riid
, void **ppvObject
)
708 TRACE("(%p, %s, %p)\n", dataObject
, debugstr_guid(riid
), ppvObject
);
709 if (IsEqualIID(riid
, &IID_IUnknown
) || IsEqualIID(riid
, &IID_IDataObject
))
711 *ppvObject
= dataObject
;
712 IDataObject_AddRef(dataObject
);
716 return E_NOINTERFACE
;
719 static ULONG WINAPI
XDNDDATAOBJECT_AddRef(IDataObject
*dataObject
)
721 TRACE("(%p)\n", dataObject
);
725 static ULONG WINAPI
XDNDDATAOBJECT_Release(IDataObject
*dataObject
)
727 TRACE("(%p)\n", dataObject
);
731 static HRESULT WINAPI
XDNDDATAOBJECT_GetData(IDataObject
*dataObject
,
732 FORMATETC
*formatEtc
,
736 char formatDesc
[1024];
738 TRACE("(%p, %p, %p)\n", dataObject
, formatEtc
, pMedium
);
739 X11DRV_XDND_DescribeClipboardFormat(formatEtc
->cfFormat
,
740 formatDesc
, sizeof(formatDesc
));
741 TRACE("application is looking for %s\n", formatDesc
);
743 hr
= IDataObject_QueryGetData(dataObject
, formatEtc
);
747 LIST_FOR_EACH_ENTRY(current
, &xdndData
, XDNDDATA
, entry
)
749 if (current
->cf_win
== formatEtc
->cfFormat
)
751 pMedium
->tymed
= TYMED_HGLOBAL
;
752 pMedium
->u
.hGlobal
= GlobalAlloc(GMEM_FIXED
| GMEM_ZEROINIT
, GlobalSize(current
->contents
));
753 if (pMedium
->u
.hGlobal
== NULL
)
754 return E_OUTOFMEMORY
;
755 memcpy(GlobalLock(pMedium
->u
.hGlobal
), GlobalLock(current
->contents
), GlobalSize(current
->contents
));
756 GlobalUnlock(pMedium
->u
.hGlobal
);
757 GlobalUnlock(current
->contents
);
758 pMedium
->pUnkForRelease
= 0;
766 static HRESULT WINAPI
XDNDDATAOBJECT_GetDataHere(IDataObject
*dataObject
,
767 FORMATETC
*formatEtc
,
770 FIXME("(%p, %p, %p): stub\n", dataObject
, formatEtc
, pMedium
);
771 return DATA_E_FORMATETC
;
774 static HRESULT WINAPI
XDNDDATAOBJECT_QueryGetData(IDataObject
*dataObject
,
775 FORMATETC
*formatEtc
)
777 char formatDesc
[1024];
780 TRACE("(%p, %p={.tymed=0x%x, .dwAspect=%d, .cfFormat=%d}\n",
781 dataObject
, formatEtc
, formatEtc
->tymed
, formatEtc
->dwAspect
, formatEtc
->cfFormat
);
782 X11DRV_XDND_DescribeClipboardFormat(formatEtc
->cfFormat
, formatDesc
, sizeof(formatDesc
));
784 if (formatEtc
->tymed
&& !(formatEtc
->tymed
& TYMED_HGLOBAL
))
786 FIXME("only HGLOBAL medium types supported right now\n");
789 if (formatEtc
->dwAspect
!= DVASPECT_CONTENT
)
791 FIXME("only the content aspect is supported right now\n");
795 LIST_FOR_EACH_ENTRY(current
, &xdndData
, XDNDDATA
, entry
)
797 if (current
->cf_win
== formatEtc
->cfFormat
)
799 TRACE("application found %s\n", formatDesc
);
803 TRACE("application didn't find %s\n", formatDesc
);
804 return DV_E_FORMATETC
;
807 static HRESULT WINAPI
XDNDDATAOBJECT_GetCanonicalFormatEtc(IDataObject
*dataObject
,
808 FORMATETC
*formatEtc
,
809 FORMATETC
*formatEtcOut
)
811 FIXME("(%p, %p, %p): stub\n", dataObject
, formatEtc
, formatEtcOut
);
812 formatEtcOut
->ptd
= NULL
;
816 static HRESULT WINAPI
XDNDDATAOBJECT_SetData(IDataObject
*dataObject
,
817 FORMATETC
*formatEtc
,
818 STGMEDIUM
*pMedium
, BOOL fRelease
)
820 FIXME("(%p, %p, %p, %s): stub\n", dataObject
, formatEtc
,
821 pMedium
, fRelease
?"TRUE":"FALSE");
825 static HRESULT WINAPI
XDNDDATAOBJECT_EnumFormatEtc(IDataObject
*dataObject
,
827 IEnumFORMATETC
**ppEnumFormatEtc
)
832 TRACE("(%p, %u, %p)\n", dataObject
, dwDirection
, ppEnumFormatEtc
);
834 if (dwDirection
!= DATADIR_GET
)
836 FIXME("only the get direction is implemented\n");
840 count
= list_count(&xdndData
);
841 formats
= HeapAlloc(GetProcessHeap(), 0, count
* sizeof(FORMATETC
));
847 LIST_FOR_EACH_ENTRY(current
, &xdndData
, XDNDDATA
, entry
)
849 formats
[i
].cfFormat
= current
->cf_win
;
850 formats
[i
].ptd
= NULL
;
851 formats
[i
].dwAspect
= DVASPECT_CONTENT
;
852 formats
[i
].lindex
= -1;
853 formats
[i
].tymed
= TYMED_HGLOBAL
;
856 hr
= SHCreateStdEnumFmtEtc(count
, formats
, ppEnumFormatEtc
);
857 HeapFree(GetProcessHeap(), 0, formats
);
861 return E_OUTOFMEMORY
;
864 static HRESULT WINAPI
XDNDDATAOBJECT_DAdvise(IDataObject
*dataObject
,
865 FORMATETC
*formatEtc
, DWORD advf
,
866 IAdviseSink
*adviseSink
,
867 DWORD
*pdwConnection
)
869 FIXME("(%p, %p, %u, %p, %p): stub\n", dataObject
, formatEtc
, advf
,
870 adviseSink
, pdwConnection
);
871 return OLE_E_ADVISENOTSUPPORTED
;
874 static HRESULT WINAPI
XDNDDATAOBJECT_DUnadvise(IDataObject
*dataObject
,
877 FIXME("(%p, %u): stub\n", dataObject
, dwConnection
);
878 return OLE_E_ADVISENOTSUPPORTED
;
881 static HRESULT WINAPI
XDNDDATAOBJECT_EnumDAdvise(IDataObject
*dataObject
,
882 IEnumSTATDATA
**pEnumAdvise
)
884 FIXME("(%p, %p): stub\n", dataObject
, pEnumAdvise
);
885 return OLE_E_ADVISENOTSUPPORTED
;
888 static IDataObjectVtbl xdndDataObjectVtbl
=
890 XDNDDATAOBJECT_QueryInterface
,
891 XDNDDATAOBJECT_AddRef
,
892 XDNDDATAOBJECT_Release
,
893 XDNDDATAOBJECT_GetData
,
894 XDNDDATAOBJECT_GetDataHere
,
895 XDNDDATAOBJECT_QueryGetData
,
896 XDNDDATAOBJECT_GetCanonicalFormatEtc
,
897 XDNDDATAOBJECT_SetData
,
898 XDNDDATAOBJECT_EnumFormatEtc
,
899 XDNDDATAOBJECT_DAdvise
,
900 XDNDDATAOBJECT_DUnadvise
,
901 XDNDDATAOBJECT_EnumDAdvise
904 static IDataObject XDNDDataObject
= { &xdndDataObjectVtbl
};