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
;
376 DWORD effect
= XDNDDropEffect
;
377 int accept
= 0; /* Assume we're not accepting */
381 /* If we have a HDROP type we send a WM_ACCEPTFILES.*/
382 if (GetWindowLongW( hWnd
, GWL_EXSTYLE
) & WS_EX_ACCEPTFILES
)
383 X11DRV_XDND_SendDropFiles( hWnd
);
385 /* Notify OLE of Drop */
386 dropTarget
= get_droptarget_pointer(XDNDLastDropTargetWnd
);
394 hr
= IDropTarget_Drop(dropTarget
, &XDNDDataObject
, MK_LBUTTON
,
398 if (effect
!= DROPEFFECT_NONE
)
400 TRACE("drop succeeded\n");
404 TRACE("the application refused the drop\n");
407 WARN("drop failed, error 0x%08X\n", hr
);
408 IDropTarget_Release(dropTarget
);
411 X11DRV_XDND_FreeDragDropOp();
413 /* Tell the target we are finished. */
414 memset(&e
, 0, sizeof(e
));
415 e
.type
= ClientMessage
;
416 e
.display
= event
->display
;
417 e
.window
= event
->data
.l
[0];
418 e
.message_type
= x11drv_atom(XdndFinished
);
420 e
.data
.l
[0] = event
->window
;
421 e
.data
.l
[1] = accept
;
423 e
.data
.l
[2] = X11DRV_XDND_DROPEFFECTToXdndAction(effect
);
426 XSendEvent(event
->display
, event
->data
.l
[0], False
, NoEventMask
, (XEvent
*)&e
);
429 /**************************************************************************
430 * X11DRV_XDND_LeaveEvent
432 * Handle an XdndLeave event.
434 void X11DRV_XDND_LeaveEvent( HWND hWnd
, XClientMessageEvent
*event
)
436 IDropTarget
*dropTarget
;
438 TRACE("DND Operation canceled\n");
440 /* Notify OLE of DragLeave */
441 dropTarget
= get_droptarget_pointer(XDNDLastDropTargetWnd
);
444 HRESULT hr
= IDropTarget_DragLeave(dropTarget
);
446 WARN("IDropTarget_DragLeave failed, error 0x%08X\n", hr
);
447 IDropTarget_Release(dropTarget
);
450 X11DRV_XDND_FreeDragDropOp();
454 /**************************************************************************
455 * X11DRV_XDND_ResolveProperty
457 * Resolve all MIME types to windows clipboard formats. All data is cached.
459 static void X11DRV_XDND_ResolveProperty(Display
*display
, Window xwin
, Time tm
,
460 Atom
*types
, unsigned long count
)
465 XDNDDATA
*current
, *next
;
466 BOOL haveHDROP
= FALSE
;
468 TRACE("count(%ld)\n", count
);
470 X11DRV_XDND_FreeDragDropOp(); /* Clear previously cached data */
472 for (i
= 0; i
< count
; i
++)
477 TRACE("requesting atom %ld from xwin %ld\n", types
[i
], xwin
);
482 XConvertSelection(display
, x11drv_atom(XdndSelection
), types
[i
],
483 x11drv_atom(XdndTarget
), xwin
, /*tm*/CurrentTime
);
486 * Wait for SelectionNotify
488 for (j
= 0; j
< SELECTION_RETRIES
; j
++)
490 res
= XCheckTypedWindowEvent(display
, xwin
, SelectionNotify
, &xe
);
491 if (res
&& xe
.xselection
.selection
== x11drv_atom(XdndSelection
)) break;
493 usleep(SELECTION_WAIT
);
496 if (xe
.xselection
.property
== None
)
499 contents
= X11DRV_CLIPBOARD_ImportSelection(display
, types
[i
], xwin
, x11drv_atom(XdndTarget
), &windowsFormat
);
501 X11DRV_XDND_InsertXDNDData(types
[i
], windowsFormat
, contents
);
504 /* On Windows when there is a CF_HDROP, there are no other CF_ formats.
505 * foobar2000 relies on this (spaces -> %20's without it).
507 LIST_FOR_EACH_ENTRY(current
, &xdndData
, XDNDDATA
, entry
)
509 if (current
->cf_win
== CF_HDROP
)
517 LIST_FOR_EACH_ENTRY_SAFE(current
, next
, &xdndData
, XDNDDATA
, entry
)
519 if (current
->cf_win
!= CF_HDROP
&& current
->cf_win
< CF_MAX
)
521 list_remove(¤t
->entry
);
522 GlobalFree(current
->contents
);
523 HeapFree(GetProcessHeap(), 0, current
);
530 /**************************************************************************
531 * X11DRV_XDND_InsertXDNDData
533 * Cache available XDND property
535 static void X11DRV_XDND_InsertXDNDData(int property
, int format
, HANDLE contents
)
537 LPXDNDDATA current
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(XDNDDATA
));
541 EnterCriticalSection(&xdnd_cs
);
542 current
->cf_xdnd
= property
;
543 current
->cf_win
= format
;
544 current
->contents
= contents
;
545 list_add_tail(&xdndData
, ¤t
->entry
);
546 LeaveCriticalSection(&xdnd_cs
);
551 /**************************************************************************
552 * X11DRV_XDND_SendDropFiles
554 static void X11DRV_XDND_SendDropFiles(HWND hwnd
)
556 LPXDNDDATA current
= NULL
;
559 EnterCriticalSection(&xdnd_cs
);
561 /* Find CF_HDROP type if any */
562 LIST_FOR_EACH_ENTRY(current
, &xdndData
, XDNDDATA
, entry
)
564 if (current
->cf_win
== CF_HDROP
)
573 HGLOBAL dropHandle
= GlobalAlloc(GMEM_FIXED
, GlobalSize(current
->contents
));
577 DROPFILES
*lpDrop
= GlobalLock(dropHandle
);
578 memcpy(lpDrop
, GlobalLock(current
->contents
), GlobalSize(current
->contents
));
579 GlobalUnlock(current
->contents
);
580 lpDrop
->pt
.x
= XDNDxy
.x
;
581 lpDrop
->pt
.y
= XDNDxy
.y
;
582 lpDrop
->fNC
= !ScreenToClient(hwnd
, &lpDrop
->pt
);
583 TRACE("Sending WM_DROPFILES: hWnd=0x%p, fNC=%d, x=%d, y=%d, files=%p(%s)\n", hwnd
,
584 lpDrop
->fNC
, lpDrop
->pt
.x
, lpDrop
->pt
.y
, ((char*)lpDrop
) + lpDrop
->pFiles
,
585 debugstr_w((WCHAR
*)(((char*)lpDrop
) + lpDrop
->pFiles
)));
586 GlobalUnlock(dropHandle
);
587 if (!PostMessageW(hwnd
, WM_DROPFILES
, (WPARAM
)dropHandle
, 0))
588 GlobalFree(dropHandle
);
592 LeaveCriticalSection(&xdnd_cs
);
596 /**************************************************************************
597 * X11DRV_XDND_FreeDragDropOp
599 static void X11DRV_XDND_FreeDragDropOp(void)
606 EnterCriticalSection(&xdnd_cs
);
608 /** Free data cache */
609 LIST_FOR_EACH_ENTRY_SAFE(current
, next
, &xdndData
, XDNDDATA
, entry
)
611 list_remove(¤t
->entry
);
612 GlobalFree(current
->contents
);
613 HeapFree(GetProcessHeap(), 0, current
);
616 XDNDxy
.x
= XDNDxy
.y
= 0;
617 XDNDLastTargetWnd
= NULL
;
618 XDNDLastDropTargetWnd
= NULL
;
619 XDNDAccepted
= FALSE
;
621 LeaveCriticalSection(&xdnd_cs
);
625 /**************************************************************************
626 * X11DRV_XDND_DescribeClipboardFormat
628 static void X11DRV_XDND_DescribeClipboardFormat(int cfFormat
, char *buffer
, int size
)
630 #define D(x) case x: lstrcpynA(buffer, #x, size); return;
653 if (CF_PRIVATEFIRST
<= cfFormat
&& cfFormat
<= CF_PRIVATELAST
)
655 lstrcpynA(buffer
, "some private object", size
);
658 if (CF_GDIOBJFIRST
<= cfFormat
&& cfFormat
<= CF_GDIOBJLAST
)
660 lstrcpynA(buffer
, "some GDI object", size
);
664 GetClipboardFormatNameA(cfFormat
, buffer
, size
);
668 /* The IDataObject singleton we feed to OLE follows */
670 static HRESULT WINAPI
XDNDDATAOBJECT_QueryInterface(IDataObject
*dataObject
,
671 REFIID riid
, void **ppvObject
)
673 TRACE("(%p, %s, %p)\n", dataObject
, debugstr_guid(riid
), ppvObject
);
674 if (IsEqualIID(riid
, &IID_IUnknown
) || IsEqualIID(riid
, &IID_IDataObject
))
676 *ppvObject
= dataObject
;
677 IDataObject_AddRef(dataObject
);
681 return E_NOINTERFACE
;
684 static ULONG WINAPI
XDNDDATAOBJECT_AddRef(IDataObject
*dataObject
)
686 TRACE("(%p)\n", dataObject
);
690 static ULONG WINAPI
XDNDDATAOBJECT_Release(IDataObject
*dataObject
)
692 TRACE("(%p)\n", dataObject
);
696 static HRESULT WINAPI
XDNDDATAOBJECT_GetData(IDataObject
*dataObject
,
697 FORMATETC
*formatEtc
,
701 char formatDesc
[1024];
703 TRACE("(%p, %p, %p)\n", dataObject
, formatEtc
, pMedium
);
704 X11DRV_XDND_DescribeClipboardFormat(formatEtc
->cfFormat
,
705 formatDesc
, sizeof(formatDesc
));
706 TRACE("application is looking for %s\n", formatDesc
);
708 hr
= IDataObject_QueryGetData(dataObject
, formatEtc
);
712 LIST_FOR_EACH_ENTRY(current
, &xdndData
, XDNDDATA
, entry
)
714 if (current
->cf_win
== formatEtc
->cfFormat
)
716 pMedium
->tymed
= TYMED_HGLOBAL
;
717 pMedium
->u
.hGlobal
= GlobalAlloc(GMEM_FIXED
| GMEM_ZEROINIT
, GlobalSize(current
->contents
));
718 if (pMedium
->u
.hGlobal
== NULL
)
719 return E_OUTOFMEMORY
;
720 memcpy(GlobalLock(pMedium
->u
.hGlobal
), GlobalLock(current
->contents
), GlobalSize(current
->contents
));
721 GlobalUnlock(pMedium
->u
.hGlobal
);
722 GlobalUnlock(current
->contents
);
723 pMedium
->pUnkForRelease
= 0;
731 static HRESULT WINAPI
XDNDDATAOBJECT_GetDataHere(IDataObject
*dataObject
,
732 FORMATETC
*formatEtc
,
735 FIXME("(%p, %p, %p): stub\n", dataObject
, formatEtc
, pMedium
);
736 return DATA_E_FORMATETC
;
739 static HRESULT WINAPI
XDNDDATAOBJECT_QueryGetData(IDataObject
*dataObject
,
740 FORMATETC
*formatEtc
)
742 char formatDesc
[1024];
745 TRACE("(%p, %p={.tymed=0x%x, .dwAspect=%d, .cfFormat=%d}\n",
746 dataObject
, formatEtc
, formatEtc
->tymed
, formatEtc
->dwAspect
, formatEtc
->cfFormat
);
747 X11DRV_XDND_DescribeClipboardFormat(formatEtc
->cfFormat
, formatDesc
, sizeof(formatDesc
));
749 if (formatEtc
->tymed
&& !(formatEtc
->tymed
& TYMED_HGLOBAL
))
751 FIXME("only HGLOBAL medium types supported right now\n");
754 if (formatEtc
->dwAspect
!= DVASPECT_CONTENT
)
756 FIXME("only the content aspect is supported right now\n");
760 LIST_FOR_EACH_ENTRY(current
, &xdndData
, XDNDDATA
, entry
)
762 if (current
->cf_win
== formatEtc
->cfFormat
)
764 TRACE("application found %s\n", formatDesc
);
768 TRACE("application didn't find %s\n", formatDesc
);
769 return DV_E_FORMATETC
;
772 static HRESULT WINAPI
XDNDDATAOBJECT_GetCanonicalFormatEtc(IDataObject
*dataObject
,
773 FORMATETC
*formatEtc
,
774 FORMATETC
*formatEtcOut
)
776 FIXME("(%p, %p, %p): stub\n", dataObject
, formatEtc
, formatEtcOut
);
777 formatEtcOut
->ptd
= NULL
;
781 static HRESULT WINAPI
XDNDDATAOBJECT_SetData(IDataObject
*dataObject
,
782 FORMATETC
*formatEtc
,
783 STGMEDIUM
*pMedium
, BOOL fRelease
)
785 FIXME("(%p, %p, %p, %s): stub\n", dataObject
, formatEtc
,
786 pMedium
, fRelease
?"TRUE":"FALSE");
790 static HRESULT WINAPI
XDNDDATAOBJECT_EnumFormatEtc(IDataObject
*dataObject
,
792 IEnumFORMATETC
**ppEnumFormatEtc
)
797 TRACE("(%p, %u, %p)\n", dataObject
, dwDirection
, ppEnumFormatEtc
);
799 if (dwDirection
!= DATADIR_GET
)
801 FIXME("only the get direction is implemented\n");
805 count
= list_count(&xdndData
);
806 formats
= HeapAlloc(GetProcessHeap(), 0, count
* sizeof(FORMATETC
));
812 LIST_FOR_EACH_ENTRY(current
, &xdndData
, XDNDDATA
, entry
)
814 formats
[i
].cfFormat
= current
->cf_win
;
815 formats
[i
].ptd
= NULL
;
816 formats
[i
].dwAspect
= DVASPECT_CONTENT
;
817 formats
[i
].lindex
= -1;
818 formats
[i
].tymed
= TYMED_HGLOBAL
;
821 hr
= SHCreateStdEnumFmtEtc(count
, formats
, ppEnumFormatEtc
);
822 HeapFree(GetProcessHeap(), 0, formats
);
826 return E_OUTOFMEMORY
;
829 static HRESULT WINAPI
XDNDDATAOBJECT_DAdvise(IDataObject
*dataObject
,
830 FORMATETC
*formatEtc
, DWORD advf
,
831 IAdviseSink
*adviseSink
,
832 DWORD
*pdwConnection
)
834 FIXME("(%p, %p, %u, %p, %p): stub\n", dataObject
, formatEtc
, advf
,
835 adviseSink
, pdwConnection
);
836 return OLE_E_ADVISENOTSUPPORTED
;
839 static HRESULT WINAPI
XDNDDATAOBJECT_DUnadvise(IDataObject
*dataObject
,
842 FIXME("(%p, %u): stub\n", dataObject
, dwConnection
);
843 return OLE_E_ADVISENOTSUPPORTED
;
846 static HRESULT WINAPI
XDNDDATAOBJECT_EnumDAdvise(IDataObject
*dataObject
,
847 IEnumSTATDATA
**pEnumAdvise
)
849 FIXME("(%p, %p): stub\n", dataObject
, pEnumAdvise
);
850 return OLE_E_ADVISENOTSUPPORTED
;
853 static IDataObjectVtbl xdndDataObjectVtbl
=
855 XDNDDATAOBJECT_QueryInterface
,
856 XDNDDATAOBJECT_AddRef
,
857 XDNDDATAOBJECT_Release
,
858 XDNDDATAOBJECT_GetData
,
859 XDNDDATAOBJECT_GetDataHere
,
860 XDNDDATAOBJECT_QueryGetData
,
861 XDNDDATAOBJECT_GetCanonicalFormatEtc
,
862 XDNDDATAOBJECT_SetData
,
863 XDNDDATAOBJECT_EnumFormatEtc
,
864 XDNDDATAOBJECT_DAdvise
,
865 XDNDDATAOBJECT_DUnadvise
,
866 XDNDDATAOBJECT_EnumDAdvise
869 static IDataObject XDNDDataObject
= { &xdndDataObjectVtbl
};