1 | /* $Id: dataobject.cpp,v 1.2 2000-03-24 17:17:26 cbratschi Exp $ */
|
---|
2 |
|
---|
3 | /*
|
---|
4 | * Win32 SHELL32 for OS/2
|
---|
5 | *
|
---|
6 | * Copyright 1999 Patrick Haller (haller@zebra.fh-weingarten.de)
|
---|
7 | * Project Odin Software License can be found in LICENSE.TXT
|
---|
8 | *
|
---|
9 | */
|
---|
10 |
|
---|
11 | /*
|
---|
12 | * IEnumFORMATETC, IDataObject
|
---|
13 | *
|
---|
14 | * selecting and droping objects within the shell and/or common dialogs
|
---|
15 | *
|
---|
16 | * Copyright 1998, 1999 <juergen.schmied@metronet.de>
|
---|
17 | */
|
---|
18 |
|
---|
19 |
|
---|
20 | /*****************************************************************************
|
---|
21 | * Includes *
|
---|
22 | *****************************************************************************/
|
---|
23 |
|
---|
24 | #include <stdlib.h>
|
---|
25 | #include <string.h>
|
---|
26 | #include <odin.h>
|
---|
27 | #include <odinwrap.h>
|
---|
28 | #include <os2sel.h>
|
---|
29 |
|
---|
30 | #define ICOM_CINTERFACE 1
|
---|
31 | #define CINTERFACE 1
|
---|
32 |
|
---|
33 | #include "winerror.h"
|
---|
34 | #include "debugtools.h"
|
---|
35 |
|
---|
36 | #include "oleidl.h"
|
---|
37 | #include "pidl.h"
|
---|
38 | #include "winerror.h"
|
---|
39 | #include "shell32_main.h"
|
---|
40 | #include "debugtools.h"
|
---|
41 | #include "wine/undocshell.h"
|
---|
42 | #include "wine/obj_dataobject.h"
|
---|
43 |
|
---|
44 | #include <misc.h>
|
---|
45 |
|
---|
46 |
|
---|
47 | ODINDEBUGCHANNEL(shell32-dataobject)
|
---|
48 |
|
---|
49 |
|
---|
50 | /***********************************************************************
|
---|
51 | * IEnumFORMATETC implementation
|
---|
52 | */
|
---|
53 |
|
---|
54 | typedef struct
|
---|
55 | {
|
---|
56 | /* IUnknown fields */
|
---|
57 | ICOM_VTABLE(IEnumFORMATETC)* lpvtbl;
|
---|
58 | DWORD ref;
|
---|
59 | /* IEnumFORMATETC fields */
|
---|
60 | UINT posFmt;
|
---|
61 | UINT countFmt;
|
---|
62 | LPFORMATETC pFmt;
|
---|
63 | } IEnumFORMATETCImpl;
|
---|
64 |
|
---|
65 | static HRESULT WINAPI IEnumFORMATETC_fnQueryInterface(LPENUMFORMATETC iface, REFIID riid, LPVOID* ppvObj);
|
---|
66 | static ULONG WINAPI IEnumFORMATETC_fnAddRef(LPENUMFORMATETC iface);
|
---|
67 | static ULONG WINAPI IEnumFORMATETC_fnRelease(LPENUMFORMATETC iface);
|
---|
68 | static HRESULT WINAPI IEnumFORMATETC_fnNext(LPENUMFORMATETC iface, ULONG celt, FORMATETC* rgelt, ULONG* pceltFethed);
|
---|
69 | static HRESULT WINAPI IEnumFORMATETC_fnSkip(LPENUMFORMATETC iface, ULONG celt);
|
---|
70 | static HRESULT WINAPI IEnumFORMATETC_fnReset(LPENUMFORMATETC iface);
|
---|
71 | static HRESULT WINAPI IEnumFORMATETC_fnClone(LPENUMFORMATETC iface, LPENUMFORMATETC* ppenum);
|
---|
72 |
|
---|
73 | static struct ICOM_VTABLE(IEnumFORMATETC) efvt =
|
---|
74 | {
|
---|
75 | ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
|
---|
76 | IEnumFORMATETC_fnQueryInterface,
|
---|
77 | IEnumFORMATETC_fnAddRef,
|
---|
78 | IEnumFORMATETC_fnRelease,
|
---|
79 | IEnumFORMATETC_fnNext,
|
---|
80 | IEnumFORMATETC_fnSkip,
|
---|
81 | IEnumFORMATETC_fnReset,
|
---|
82 | IEnumFORMATETC_fnClone
|
---|
83 | };
|
---|
84 |
|
---|
85 | LPENUMFORMATETC IEnumFORMATETC_Constructor(UINT cfmt, const FORMATETC afmt[])
|
---|
86 | {
|
---|
87 | IEnumFORMATETCImpl* ef;
|
---|
88 | DWORD size=cfmt * sizeof(FORMATETC);
|
---|
89 |
|
---|
90 | dprintf(("SHELL32:dataobject:IEnumFORMATETC_Constructor(%08xh,%08xh)\n",
|
---|
91 | cfmt,
|
---|
92 | afmt));
|
---|
93 |
|
---|
94 | ef=(IEnumFORMATETCImpl*)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IEnumFORMATETCImpl));
|
---|
95 |
|
---|
96 | if(ef)
|
---|
97 | {
|
---|
98 | ef->ref=1;
|
---|
99 | ef->lpvtbl=&efvt;
|
---|
100 |
|
---|
101 | ef->countFmt = cfmt;
|
---|
102 | ef->pFmt = (FORMATETC*)SHAlloc (size);
|
---|
103 |
|
---|
104 | if (ef->pFmt)
|
---|
105 | {
|
---|
106 | memcpy(ef->pFmt, afmt, size);
|
---|
107 | }
|
---|
108 |
|
---|
109 | shell32_ObjCount++;
|
---|
110 | }
|
---|
111 |
|
---|
112 | TRACE("(%p)->()\n",ef);
|
---|
113 | return (LPENUMFORMATETC)ef;
|
---|
114 | }
|
---|
115 |
|
---|
116 |
|
---|
117 | static HRESULT WINAPI IEnumFORMATETC_fnQueryInterface(LPENUMFORMATETC iface, REFIID riid, LPVOID* ppvObj)
|
---|
118 | {
|
---|
119 | ICOM_THIS(IEnumFORMATETCImpl,iface);
|
---|
120 | char xriid[50];
|
---|
121 | WINE_StringFromCLSID((LPCLSID)riid,xriid);
|
---|
122 |
|
---|
123 | dprintf(("SHELL32:dataobject:IEnumFORMATETC_fnQueryInterface(%08xh,%08xh,%08xh)\n",
|
---|
124 | This,
|
---|
125 | riid,
|
---|
126 | xriid));
|
---|
127 |
|
---|
128 | *ppvObj = NULL;
|
---|
129 |
|
---|
130 | if(IsEqualIID(riid, &IID_IUnknown))
|
---|
131 | { *ppvObj = This;
|
---|
132 | }
|
---|
133 | else if(IsEqualIID(riid, &IID_IEnumFORMATETC))
|
---|
134 | { *ppvObj = (IDataObject*)This;
|
---|
135 | }
|
---|
136 |
|
---|
137 | if(*ppvObj)
|
---|
138 | { IEnumFORMATETC_AddRef((IEnumFORMATETC*)*ppvObj);
|
---|
139 | TRACE("-- Interface: (%p)->(%p)\n",ppvObj,*ppvObj);
|
---|
140 | return S_OK;
|
---|
141 | }
|
---|
142 | TRACE("-- Interface: E_NOINTERFACE\n");
|
---|
143 | return E_NOINTERFACE;
|
---|
144 |
|
---|
145 | }
|
---|
146 |
|
---|
147 |
|
---|
148 | static ULONG WINAPI IEnumFORMATETC_fnAddRef(LPENUMFORMATETC iface)
|
---|
149 | {
|
---|
150 | ICOM_THIS(IEnumFORMATETCImpl,iface);
|
---|
151 |
|
---|
152 | dprintf(("SHELL32:dataobject:IEnumFORMATETC_fnAddRef(%08xh,%08xh)\n",
|
---|
153 | This,
|
---|
154 | This->ref));
|
---|
155 |
|
---|
156 | shell32_ObjCount++;
|
---|
157 | return ++(This->ref);
|
---|
158 | }
|
---|
159 |
|
---|
160 |
|
---|
161 | static ULONG WINAPI IEnumFORMATETC_fnRelease(LPENUMFORMATETC iface)
|
---|
162 | {
|
---|
163 | ICOM_THIS(IEnumFORMATETCImpl,iface);
|
---|
164 |
|
---|
165 | dprintf(("SHELL32:dataobject:IEnumFORMATETC_fnRelease(%08xh)\n",
|
---|
166 | This));
|
---|
167 |
|
---|
168 | shell32_ObjCount--;
|
---|
169 |
|
---|
170 | if (!--(This->ref))
|
---|
171 | { TRACE(" destroying IEnumFORMATETC(%p)\n",This);
|
---|
172 | if (This->pFmt)
|
---|
173 | { SHFree (This->pFmt);
|
---|
174 | }
|
---|
175 | HeapFree(GetProcessHeap(),0,This);
|
---|
176 | return 0;
|
---|
177 | }
|
---|
178 | return This->ref;
|
---|
179 | }
|
---|
180 |
|
---|
181 |
|
---|
182 | static HRESULT WINAPI IEnumFORMATETC_fnNext(LPENUMFORMATETC iface, ULONG celt, FORMATETC *rgelt, ULONG *pceltFethed)
|
---|
183 | {
|
---|
184 | ICOM_THIS(IEnumFORMATETCImpl,iface);
|
---|
185 | UINT cfetch;
|
---|
186 | HRESULT hres = S_FALSE;
|
---|
187 |
|
---|
188 | dprintf(("SHELL32:dataobject:IEnumFORMATETC_fnNext(%08xh,%08xh,%08xh,%08xh)\n",
|
---|
189 | This,
|
---|
190 | celt,
|
---|
191 | rgelt,
|
---|
192 | pceltFethed));
|
---|
193 |
|
---|
194 | if (This->posFmt < This->countFmt)
|
---|
195 | {
|
---|
196 | cfetch = This->countFmt - This->posFmt;
|
---|
197 | if (cfetch >= celt)
|
---|
198 | {
|
---|
199 | cfetch = celt;
|
---|
200 | hres = S_OK;
|
---|
201 | }
|
---|
202 | memcpy(rgelt, &This->pFmt[This->posFmt], cfetch * sizeof(FORMATETC));
|
---|
203 | This->posFmt += cfetch;
|
---|
204 | }
|
---|
205 | else
|
---|
206 | {
|
---|
207 | cfetch = 0;
|
---|
208 | }
|
---|
209 |
|
---|
210 | if (pceltFethed)
|
---|
211 | {
|
---|
212 | *pceltFethed = cfetch;
|
---|
213 | }
|
---|
214 |
|
---|
215 | return hres;
|
---|
216 | }
|
---|
217 |
|
---|
218 |
|
---|
219 | static HRESULT WINAPI IEnumFORMATETC_fnSkip(LPENUMFORMATETC iface, ULONG celt)
|
---|
220 | {
|
---|
221 | ICOM_THIS(IEnumFORMATETCImpl,iface);
|
---|
222 |
|
---|
223 | dprintf(("SHELL32:dataobject:IEnumFORMATETC_fnSkip(%08xh,%08xh) to be fixed\n",
|
---|
224 | This,
|
---|
225 | celt));
|
---|
226 |
|
---|
227 | This->posFmt += celt;
|
---|
228 | if (This->posFmt > This->countFmt)
|
---|
229 | {
|
---|
230 | This->posFmt = This->countFmt;
|
---|
231 | return S_FALSE;
|
---|
232 | }
|
---|
233 | return S_OK;
|
---|
234 | }
|
---|
235 | static HRESULT WINAPI IEnumFORMATETC_fnReset(LPENUMFORMATETC iface)
|
---|
236 | {
|
---|
237 | ICOM_THIS(IEnumFORMATETCImpl,iface);
|
---|
238 |
|
---|
239 | dprintf(("SHELL32:dataobject:IEnumFORMATETC_fnReset(%08xh) to be fixed\n",
|
---|
240 | This));
|
---|
241 |
|
---|
242 | This->posFmt = 0;
|
---|
243 | return S_OK;
|
---|
244 | }
|
---|
245 |
|
---|
246 |
|
---|
247 | static HRESULT WINAPI IEnumFORMATETC_fnClone(LPENUMFORMATETC iface, LPENUMFORMATETC* ppenum)
|
---|
248 | {
|
---|
249 | ICOM_THIS(IEnumFORMATETCImpl,iface);
|
---|
250 |
|
---|
251 | dprintf(("SHELL32:dataobject:IEnumFORMATETC_fnClone(%08xh) not implemented\n",
|
---|
252 | This,
|
---|
253 | ppenum));
|
---|
254 |
|
---|
255 | return E_NOTIMPL;
|
---|
256 | }
|
---|
257 |
|
---|
258 | /**************************************************************************
|
---|
259 | * IDLList "Item ID List List"
|
---|
260 | *
|
---|
261 | * NOTES
|
---|
262 | * interal data holder for IDataObject
|
---|
263 | */
|
---|
264 | #define STDMETHOD(xfn) HRESULT (CALLBACK *fn##xfn)
|
---|
265 | #define STDMETHOD_(type,xfn) type (CALLBACK *fn##xfn)
|
---|
266 | #define THIS_ THIS,
|
---|
267 |
|
---|
268 | typedef struct tagLPIDLLIST *LPIDLLIST, IDLList;
|
---|
269 |
|
---|
270 | #define THIS LPIDLLIST me
|
---|
271 | typedef enum
|
---|
272 | { State_UnInit=1,
|
---|
273 | State_Init=2,
|
---|
274 | State_OutOfMem=3
|
---|
275 | } IDLListState;
|
---|
276 |
|
---|
277 | typedef struct IDLList_VTable
|
---|
278 | { STDMETHOD_(UINT, GetState)(THIS);
|
---|
279 | STDMETHOD_(LPITEMIDLIST, GetElement)(THIS_ UINT nIndex);
|
---|
280 | STDMETHOD_(UINT, GetCount)(THIS);
|
---|
281 | STDMETHOD_(BOOL, StoreItem)(THIS_ LPITEMIDLIST pidl);
|
---|
282 | STDMETHOD_(BOOL, AddItems)(THIS_ LPITEMIDLIST *apidl, UINT cidl);
|
---|
283 | STDMETHOD_(BOOL, InitList)(THIS);
|
---|
284 | STDMETHOD_(void, CleanList)(THIS);
|
---|
285 | } IDLList_VTable,*LPIDLLIST_VTABLE;
|
---|
286 |
|
---|
287 | struct tagLPIDLLIST
|
---|
288 | { LPIDLLIST_VTABLE lpvtbl;
|
---|
289 | HDPA dpa;
|
---|
290 | UINT uStep;
|
---|
291 | };
|
---|
292 |
|
---|
293 | extern LPIDLLIST IDLList_Constructor (UINT uStep);
|
---|
294 | extern void IDLList_Destructor(LPIDLLIST me);
|
---|
295 | #undef THIS
|
---|
296 |
|
---|
297 |
|
---|
298 |
|
---|
299 | /**************************************************************************
|
---|
300 | * IDLList "Item ID List List"
|
---|
301 | *
|
---|
302 | */
|
---|
303 | static UINT WINAPI IDLList_GetState(LPIDLLIST THIS);
|
---|
304 | static LPITEMIDLIST WINAPI IDLList_GetElement(LPIDLLIST THIS, UINT nIndex);
|
---|
305 | static UINT WINAPI IDLList_GetCount(LPIDLLIST THIS);
|
---|
306 | static BOOL WINAPI IDLList_StoreItem(LPIDLLIST THIS, LPITEMIDLIST pidl);
|
---|
307 | static BOOL WINAPI IDLList_AddItems(LPIDLLIST THIS, LPITEMIDLIST *apidl, UINT cidl);
|
---|
308 | static BOOL WINAPI IDLList_InitList(LPIDLLIST THIS);
|
---|
309 | static void WINAPI IDLList_CleanList(LPIDLLIST THIS);
|
---|
310 |
|
---|
311 | static IDLList_VTable idllvt =
|
---|
312 | { IDLList_GetState,
|
---|
313 | IDLList_GetElement,
|
---|
314 | IDLList_GetCount,
|
---|
315 | IDLList_StoreItem,
|
---|
316 | IDLList_AddItems,
|
---|
317 | IDLList_InitList,
|
---|
318 | IDLList_CleanList
|
---|
319 | };
|
---|
320 |
|
---|
321 | LPIDLLIST IDLList_Constructor (UINT uStep)
|
---|
322 | {
|
---|
323 | LPIDLLIST lpidll;
|
---|
324 | lpidll = (LPIDLLIST)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDLList));
|
---|
325 |
|
---|
326 | dprintf(("SHELL32:dataobject:IDLList_Constructor(%08xh, %08xh) not implemented\n",
|
---|
327 | lpidll,
|
---|
328 | uStep));
|
---|
329 |
|
---|
330 | if (lpidll)
|
---|
331 | {
|
---|
332 | lpidll->lpvtbl=&idllvt;
|
---|
333 | lpidll->uStep=uStep;
|
---|
334 | }
|
---|
335 |
|
---|
336 | return lpidll;
|
---|
337 | }
|
---|
338 |
|
---|
339 |
|
---|
340 | void IDLList_Destructor(LPIDLLIST THIS)
|
---|
341 | {
|
---|
342 | dprintf(("SHELL32:dataobject:IDLList_Destructor(%08xh) not implemented\n",
|
---|
343 | THIS));
|
---|
344 |
|
---|
345 | IDLList_CleanList(THIS);
|
---|
346 | }
|
---|
347 |
|
---|
348 | static UINT WINAPI IDLList_GetState(LPIDLLIST THIS)
|
---|
349 | {
|
---|
350 | dprintf(("SHELL32:dataobject:IDLList_GetState((%p)->(uStep=%u dpa=%p)\n",
|
---|
351 | THIS,
|
---|
352 | THIS->uStep,
|
---|
353 | THIS->dpa));
|
---|
354 |
|
---|
355 | if (THIS->uStep == 0)
|
---|
356 | {
|
---|
357 | if (THIS->dpa)
|
---|
358 | return(State_Init);
|
---|
359 |
|
---|
360 | return(State_OutOfMem);
|
---|
361 | }
|
---|
362 | return(State_UnInit);
|
---|
363 | }
|
---|
364 |
|
---|
365 |
|
---|
366 | static LPITEMIDLIST WINAPI IDLList_GetElement(LPIDLLIST THIS, UINT nIndex)
|
---|
367 | {
|
---|
368 | dprintf(("SHELL32:dataobject:IDLList_GetElement((%p)->(index=%u)\n",
|
---|
369 | THIS,
|
---|
370 | nIndex));
|
---|
371 |
|
---|
372 | return((LPITEMIDLIST)pDPA_GetPtr(THIS->dpa, nIndex));
|
---|
373 | }
|
---|
374 |
|
---|
375 |
|
---|
376 | static UINT WINAPI IDLList_GetCount(LPIDLLIST THIS)
|
---|
377 | {
|
---|
378 | dprintf(("SHELL32:dataobject:IDLList_GetCount(%p)\n",
|
---|
379 | THIS));
|
---|
380 |
|
---|
381 | return(IDLList_GetState(THIS)==State_Init ? DPA_GetPtrCount(THIS->dpa) : 0);
|
---|
382 | }
|
---|
383 |
|
---|
384 |
|
---|
385 | static BOOL WINAPI IDLList_StoreItem(LPIDLLIST THIS, LPITEMIDLIST pidl)
|
---|
386 | {
|
---|
387 | dprintf(("SHELL32:dataobject:IDLList_StoreItem((%p)->(pidl=%p)\n",
|
---|
388 | THIS,
|
---|
389 | pidl));
|
---|
390 |
|
---|
391 | if (pidl)
|
---|
392 | { if (IDLList_InitList(THIS) && pDPA_InsertPtr(THIS->dpa, 0x7fff, (LPSTR)pidl)>=0)
|
---|
393 | return(TRUE);
|
---|
394 | ILFree(pidl);
|
---|
395 | }
|
---|
396 | IDLList_CleanList(THIS);
|
---|
397 | return(FALSE);
|
---|
398 | }
|
---|
399 |
|
---|
400 |
|
---|
401 | static BOOL WINAPI IDLList_AddItems(LPIDLLIST THIS, LPITEMIDLIST *apidl, UINT cidl)
|
---|
402 | {
|
---|
403 | INT i;
|
---|
404 |
|
---|
405 | dprintf(("SHELL32:dataobject:IDLList_AddItems((%p)->(apidl=%p cidl=%u)\n",
|
---|
406 | THIS,
|
---|
407 | apidl,
|
---|
408 | cidl));
|
---|
409 |
|
---|
410 | for (i=0; i<cidl; ++i)
|
---|
411 | { if (!IDLList_StoreItem(THIS, ILClone((LPCITEMIDLIST)apidl[i])))
|
---|
412 | return(FALSE);
|
---|
413 | }
|
---|
414 | return(TRUE);
|
---|
415 | }
|
---|
416 |
|
---|
417 |
|
---|
418 | static BOOL WINAPI IDLList_InitList(LPIDLLIST THIS)
|
---|
419 | {
|
---|
420 | dprintf(("SHELL32:dataobject:IDLList_InitList(%p)\n",
|
---|
421 | THIS));
|
---|
422 |
|
---|
423 | switch (IDLList_GetState(THIS))
|
---|
424 | { case State_Init:
|
---|
425 | return(TRUE);
|
---|
426 |
|
---|
427 | case State_OutOfMem:
|
---|
428 | return(FALSE);
|
---|
429 |
|
---|
430 | case State_UnInit:
|
---|
431 | default:
|
---|
432 | THIS->dpa = pDPA_Create(THIS->uStep);
|
---|
433 | THIS->uStep = 0;
|
---|
434 | return(IDLList_InitList(THIS));
|
---|
435 | }
|
---|
436 | }
|
---|
437 |
|
---|
438 |
|
---|
439 | static void WINAPI IDLList_CleanList(LPIDLLIST THIS)
|
---|
440 | {
|
---|
441 | INT i;
|
---|
442 |
|
---|
443 | dprintf(("SHELL32:dataobject:IDLList_CleanList(%p)\n",
|
---|
444 | THIS));
|
---|
445 |
|
---|
446 | if (THIS->uStep != 0)
|
---|
447 | { THIS->dpa = NULL;
|
---|
448 | THIS->uStep = 0;
|
---|
449 | return;
|
---|
450 | }
|
---|
451 |
|
---|
452 | if (!THIS->dpa)
|
---|
453 | { return;
|
---|
454 | }
|
---|
455 |
|
---|
456 | for (i=DPA_GetPtrCount(THIS->dpa)-1; i>=0; --i)
|
---|
457 | { ILFree(IDLList_GetElement(THIS,i));
|
---|
458 | }
|
---|
459 |
|
---|
460 | pDPA_Destroy(THIS->dpa);
|
---|
461 | THIS->dpa=NULL;
|
---|
462 | }
|
---|
463 |
|
---|
464 |
|
---|
465 | /***********************************************************************
|
---|
466 | * IDataObject implementation
|
---|
467 | */
|
---|
468 | /* number of supported formats */
|
---|
469 | #define MAX_FORMATS 1
|
---|
470 |
|
---|
471 | typedef struct
|
---|
472 | {
|
---|
473 | /* IUnknown fields */
|
---|
474 | ICOM_VTABLE(IDataObject)* lpvtbl;
|
---|
475 | DWORD ref;
|
---|
476 |
|
---|
477 | /* IDataObject fields */
|
---|
478 | LPIDLLIST lpill; /* the data of the dataobject */
|
---|
479 | LPITEMIDLIST pidl;
|
---|
480 |
|
---|
481 | FORMATETC pFormatEtc[MAX_FORMATS];
|
---|
482 | UINT cfShellIDList;
|
---|
483 | UINT cfFileGroupDesc;
|
---|
484 | UINT cfFileContents;
|
---|
485 |
|
---|
486 | } IDataObjectImpl;
|
---|
487 |
|
---|
488 | //static struct ICOM_VTABLE(IDataObject) dtovt;
|
---|
489 |
|
---|
490 | /***************************************************************************
|
---|
491 | * IDataObject_QueryInterface
|
---|
492 | */
|
---|
493 | static HRESULT WINAPI IDataObject_fnQueryInterface(LPDATAOBJECT iface, REFIID riid, LPVOID * ppvObj)
|
---|
494 | {
|
---|
495 | ICOM_THIS(IDataObjectImpl,iface);
|
---|
496 | char xriid[50];
|
---|
497 | WINE_StringFromCLSID((LPCLSID)riid,xriid);
|
---|
498 |
|
---|
499 | dprintf(("SHELL32:dataobject:IDataObject_fnQueryInterface((%p)->(\n\tIID:\t%s,%p)\n",
|
---|
500 | This,
|
---|
501 | xriid,
|
---|
502 | ppvObj));
|
---|
503 |
|
---|
504 | *ppvObj = NULL;
|
---|
505 |
|
---|
506 | if(IsEqualIID(riid, &IID_IUnknown)) /*IUnknown*/
|
---|
507 | { *ppvObj = This;
|
---|
508 | }
|
---|
509 | else if(IsEqualIID(riid, &IID_IDataObject)) /*IDataObject*/
|
---|
510 | { *ppvObj = (IDataObject*)This;
|
---|
511 | }
|
---|
512 |
|
---|
513 | if(*ppvObj)
|
---|
514 | { IDataObject_AddRef((IDataObject*)*ppvObj);
|
---|
515 | TRACE("-- Interface: (%p)->(%p)\n",ppvObj,*ppvObj);
|
---|
516 | return S_OK;
|
---|
517 | }
|
---|
518 | TRACE("-- Interface: E_NOINTERFACE\n");
|
---|
519 | return E_NOINTERFACE;
|
---|
520 | }
|
---|
521 | /**************************************************************************
|
---|
522 | * IDataObject_AddRef
|
---|
523 | */
|
---|
524 | static ULONG WINAPI IDataObject_fnAddRef(LPDATAOBJECT iface)
|
---|
525 | {
|
---|
526 | ICOM_THIS(IDataObjectImpl,iface);
|
---|
527 |
|
---|
528 | dprintf(("SHELL32:dataobject:IDataObject_fnAddRef((%p)->(count=%lu)\n",
|
---|
529 | This,
|
---|
530 | This->ref));
|
---|
531 |
|
---|
532 | shell32_ObjCount++;
|
---|
533 | return ++(This->ref);
|
---|
534 | }
|
---|
535 | /**************************************************************************
|
---|
536 | * IDataObject_Release
|
---|
537 | */
|
---|
538 | static ULONG WINAPI IDataObject_fnRelease(LPDATAOBJECT iface)
|
---|
539 | {
|
---|
540 | ICOM_THIS(IDataObjectImpl,iface);
|
---|
541 | dprintf(("SHELL32:dataobject:IDataObject_fnRelease(%p)\n",
|
---|
542 | This));
|
---|
543 | shell32_ObjCount--;
|
---|
544 |
|
---|
545 | if (!--(This->ref))
|
---|
546 | { TRACE(" destroying IDataObject(%p)\n",This);
|
---|
547 | IDLList_Destructor(This->lpill);
|
---|
548 | HeapFree(GetProcessHeap(),0,This);
|
---|
549 | return 0;
|
---|
550 | }
|
---|
551 | return This->ref;
|
---|
552 | }
|
---|
553 |
|
---|
554 | /**************************************************************************
|
---|
555 | * IDataObject_fnGetData
|
---|
556 | */
|
---|
557 | static HRESULT WINAPI IDataObject_fnGetData(LPDATAOBJECT iface, LPFORMATETC pformatetcIn, STGMEDIUM *pmedium)
|
---|
558 | {
|
---|
559 | ICOM_THIS(IDataObjectImpl,iface);
|
---|
560 |
|
---|
561 | char szTemp[256];
|
---|
562 | UINT cItems;
|
---|
563 | DWORD sizeCIDA, sizePidl, nOffset, nSize;
|
---|
564 | LPCIDA pcida;
|
---|
565 | HGLOBAL hmem;
|
---|
566 | int i;
|
---|
567 | LPITEMIDLIST pidl;
|
---|
568 |
|
---|
569 | GetClipboardFormatNameA (pformatetcIn->cfFormat, szTemp, 256);
|
---|
570 |
|
---|
571 | dprintf(("SHELL32:dataobject:IDataObject_fnGetData(%p)->(%p %p format=%s)\n",
|
---|
572 | This,
|
---|
573 | pformatetcIn,
|
---|
574 | pmedium,
|
---|
575 | szTemp));
|
---|
576 |
|
---|
577 | /* test expected format */
|
---|
578 | if (!(pformatetcIn->cfFormat == This->cfShellIDList))
|
---|
579 | {
|
---|
580 | FIXME("-- clipformat not implemented\n");
|
---|
581 | return (E_INVALIDARG);
|
---|
582 | }
|
---|
583 |
|
---|
584 | if (pformatetcIn->ptd==NULL
|
---|
585 | && (pformatetcIn->dwAspect & DVASPECT_CONTENT)
|
---|
586 | && pformatetcIn->lindex==-1
|
---|
587 | && (pformatetcIn->tymed&TYMED_HGLOBAL))
|
---|
588 | {
|
---|
589 | cItems = This->lpill->lpvtbl->fnGetCount(This->lpill);
|
---|
590 | if (cItems < 1) return(E_UNEXPECTED);
|
---|
591 |
|
---|
592 | sizeCIDA = sizeof(CIDA) + sizeof (UINT)*(cItems); /* without any pidl */
|
---|
593 | sizePidl = ILGetSize (This->pidl); /* add root pidl */
|
---|
594 |
|
---|
595 | nSize = sizeCIDA + sizePidl;
|
---|
596 | hmem = GlobalAlloc(GHND|GMEM_SHARE, nSize);
|
---|
597 | if (!hmem) return(E_OUTOFMEMORY);
|
---|
598 | pcida = (CIDA*)GlobalLock (hmem);
|
---|
599 |
|
---|
600 | nOffset = sizeCIDA; /* start after the CIDA */
|
---|
601 | pcida->cidl = cItems;
|
---|
602 |
|
---|
603 | pcida->aoffset[0] = nOffset; /* first element */
|
---|
604 | memcpy(((LPBYTE)pcida)+nOffset, This->pidl, sizePidl);
|
---|
605 | nOffset += sizePidl;
|
---|
606 | pdump(This->pidl);
|
---|
607 |
|
---|
608 | for (i=0; i< cItems; i++)
|
---|
609 | {
|
---|
610 | pidl = This->lpill->lpvtbl->fnGetElement(This->lpill, i);
|
---|
611 | sizePidl = ILGetSize (pidl);
|
---|
612 | nSize += sizePidl; /* size of the structure */
|
---|
613 | pdump(pidl);
|
---|
614 |
|
---|
615 | GlobalUnlock(hmem); /* grow memory */
|
---|
616 | hmem = GlobalReAlloc(hmem, nSize, GHND|GMEM_SHARE);
|
---|
617 | if (!hmem) return(E_OUTOFMEMORY);
|
---|
618 | pcida = (CIDA*)GlobalLock (hmem);
|
---|
619 |
|
---|
620 | pcida->aoffset[i+1] = nOffset; /* copy element */
|
---|
621 | memcpy(((LPBYTE)pcida)+nOffset, pidl, sizePidl);
|
---|
622 | nOffset += sizePidl;
|
---|
623 | }
|
---|
624 |
|
---|
625 | GlobalUnlock(hmem);
|
---|
626 |
|
---|
627 | pmedium->tymed = TYMED_HGLOBAL;
|
---|
628 | pmedium->u.hGlobal = hmem;
|
---|
629 | pmedium->pUnkForRelease = NULL;
|
---|
630 |
|
---|
631 | TRACE("(%p)->(cida at %p)\n", This, pcida);
|
---|
632 | return S_OK;
|
---|
633 | }
|
---|
634 |
|
---|
635 | FIXME("-- can't serve format\n");
|
---|
636 | return (E_INVALIDARG);
|
---|
637 | }
|
---|
638 |
|
---|
639 |
|
---|
640 | static HRESULT WINAPI IDataObject_fnGetDataHere(LPDATAOBJECT iface, LPFORMATETC pformatetc, STGMEDIUM *pmedium)
|
---|
641 | {
|
---|
642 | ICOM_THIS(IDataObjectImpl,iface);
|
---|
643 | dprintf(("SHELL32:dataobject:IDataObject_fnGetDataHere(%p)->(%p %p) not implemented\n",
|
---|
644 | This,
|
---|
645 | pformatetc,
|
---|
646 | pmedium));
|
---|
647 |
|
---|
648 | return E_NOTIMPL;
|
---|
649 | }
|
---|
650 |
|
---|
651 |
|
---|
652 | static HRESULT WINAPI IDataObject_fnQueryGetData(LPDATAOBJECT iface, LPFORMATETC pformatetc)
|
---|
653 | {
|
---|
654 | ICOM_THIS(IDataObjectImpl,iface);
|
---|
655 | UINT i;
|
---|
656 |
|
---|
657 | dprintf(("SHELL32:dataobject:IDataObject_fnQueryGetData((%p)->(fmt=0x%08x tym=0x%08lx)\n",
|
---|
658 | This,
|
---|
659 | pformatetc->cfFormat,
|
---|
660 | pformatetc->tymed));
|
---|
661 |
|
---|
662 | if(!(DVASPECT_CONTENT & pformatetc->dwAspect))
|
---|
663 | return DV_E_DVASPECT;
|
---|
664 |
|
---|
665 | /* check our formats table what we have */
|
---|
666 | for (i=0; i<MAX_FORMATS; i++)
|
---|
667 | {
|
---|
668 | if ((This->pFormatEtc[i].cfFormat == pformatetc->cfFormat)
|
---|
669 | && (This->pFormatEtc[i].tymed == pformatetc->tymed))
|
---|
670 | {
|
---|
671 | return S_OK;
|
---|
672 | }
|
---|
673 | }
|
---|
674 |
|
---|
675 | return DV_E_TYMED;
|
---|
676 | }
|
---|
677 |
|
---|
678 |
|
---|
679 | static HRESULT WINAPI IDataObject_fnGetCanonicalFormatEtc(LPDATAOBJECT iface, LPFORMATETC pformatetcIn, LPFORMATETC pformatetcOut)
|
---|
680 | {
|
---|
681 | ICOM_THIS(IDataObjectImpl,iface);
|
---|
682 |
|
---|
683 | dprintf(("SHELL32:dataobject:IDataObject_fnGetCanonicalFormatEtc((%p)->(%p %p) not implemented\n",
|
---|
684 | This,
|
---|
685 | pformatetcIn,
|
---|
686 | pformatetcOut));
|
---|
687 |
|
---|
688 | return E_NOTIMPL;
|
---|
689 | }
|
---|
690 |
|
---|
691 |
|
---|
692 | static HRESULT WINAPI IDataObject_fnSetData(LPDATAOBJECT iface, LPFORMATETC pformatetc, STGMEDIUM *pmedium, BOOL fRelease)
|
---|
693 | {
|
---|
694 | ICOM_THIS(IDataObjectImpl,iface);
|
---|
695 | dprintf(("SHELL32:dataobject:IDataObject_fnSetData((%p)->(%p %p %08xh) not implemented\n",
|
---|
696 | This,
|
---|
697 | pformatetc,
|
---|
698 | pmedium,
|
---|
699 | fRelease));
|
---|
700 | return E_NOTIMPL;
|
---|
701 | }
|
---|
702 |
|
---|
703 |
|
---|
704 | static HRESULT WINAPI IDataObject_fnEnumFormatEtc(LPDATAOBJECT iface, DWORD dwDirection, IEnumFORMATETC **ppenumFormatEtc)
|
---|
705 | {
|
---|
706 | ICOM_THIS(IDataObjectImpl,iface);
|
---|
707 |
|
---|
708 | dprintf(("SHELL32:dataobject:IDataObject_fnEnumFormatEtc((%p)->(%08xh %p)\n",
|
---|
709 | This,
|
---|
710 | dwDirection,
|
---|
711 | ppenumFormatEtc));
|
---|
712 |
|
---|
713 | *ppenumFormatEtc=NULL;
|
---|
714 |
|
---|
715 | /* only get data */
|
---|
716 | if (DATADIR_GET == dwDirection)
|
---|
717 | {
|
---|
718 | *ppenumFormatEtc = IEnumFORMATETC_Constructor(MAX_FORMATS, This->pFormatEtc);
|
---|
719 | return (*ppenumFormatEtc) ? S_OK : E_FAIL;
|
---|
720 | }
|
---|
721 |
|
---|
722 | return E_NOTIMPL;
|
---|
723 | }
|
---|
724 | static HRESULT WINAPI IDataObject_fnDAdvise(LPDATAOBJECT iface, FORMATETC *pformatetc, DWORD advf, IAdviseSink *pAdvSink, DWORD *pdwConnection)
|
---|
725 | {
|
---|
726 | ICOM_THIS(IDataObjectImpl,iface);
|
---|
727 | dprintf(("SHELL32:dataobject:IDataObject_fnDAdvise((%p)->(%p %08xh %p %p) not implemented.\n",
|
---|
728 | This,
|
---|
729 | pformatetc,
|
---|
730 | advf,
|
---|
731 | pAdvSink,
|
---|
732 | pdwConnection));
|
---|
733 |
|
---|
734 | return E_NOTIMPL;
|
---|
735 | }
|
---|
736 |
|
---|
737 |
|
---|
738 | static HRESULT WINAPI IDataObject_fnDUnadvise(LPDATAOBJECT iface, DWORD dwConnection)
|
---|
739 | {
|
---|
740 | ICOM_THIS(IDataObjectImpl,iface);
|
---|
741 | dprintf(("SHELL32:dataobject:IDataObject_fnDUnadvise((%p)->(%08xh) not implemented.\n",
|
---|
742 | This,
|
---|
743 | dwConnection));
|
---|
744 | return E_NOTIMPL;
|
---|
745 | }
|
---|
746 | static HRESULT WINAPI IDataObject_fnEnumDAdvise(LPDATAOBJECT iface, IEnumSTATDATA **ppenumAdvise)
|
---|
747 | {
|
---|
748 | ICOM_THIS(IDataObjectImpl,iface);
|
---|
749 | dprintf(("SHELL32:dataobject:IDataObject_fnEnumDAdvise((%p)->(%p) not implemented.\n",
|
---|
750 | This,
|
---|
751 | ppenumAdvise));
|
---|
752 |
|
---|
753 | return E_NOTIMPL;
|
---|
754 | }
|
---|
755 |
|
---|
756 | static struct ICOM_VTABLE(IDataObject) dtovt =
|
---|
757 | {
|
---|
758 | ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
|
---|
759 | IDataObject_fnQueryInterface,
|
---|
760 | IDataObject_fnAddRef,
|
---|
761 | IDataObject_fnRelease,
|
---|
762 | IDataObject_fnGetData,
|
---|
763 | IDataObject_fnGetDataHere,
|
---|
764 | IDataObject_fnQueryGetData,
|
---|
765 | IDataObject_fnGetCanonicalFormatEtc,
|
---|
766 | IDataObject_fnSetData,
|
---|
767 | IDataObject_fnEnumFormatEtc,
|
---|
768 | IDataObject_fnDAdvise,
|
---|
769 | IDataObject_fnDUnadvise,
|
---|
770 | IDataObject_fnEnumDAdvise
|
---|
771 | };
|
---|
772 |
|
---|
773 | /**************************************************************************
|
---|
774 | * IDataObject_Constructor
|
---|
775 | */
|
---|
776 | LPDATAOBJECT IDataObject_Constructor(HWND hwndOwner, LPITEMIDLIST pMyPidl, LPITEMIDLIST * apidl, UINT cidl)
|
---|
777 | {
|
---|
778 | IDataObjectImpl* dto;
|
---|
779 |
|
---|
780 | dto = (IDataObjectImpl*)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDataObjectImpl));
|
---|
781 |
|
---|
782 | if (dto)
|
---|
783 | {
|
---|
784 | dto->ref=1;
|
---|
785 | dto->lpvtbl=&dtovt;
|
---|
786 | dto->pidl=ILClone(pMyPidl);
|
---|
787 |
|
---|
788 | /* fill the ItemID List List */
|
---|
789 | dto->lpill = IDLList_Constructor (8);
|
---|
790 | if (! dto->lpill )
|
---|
791 | return NULL;
|
---|
792 |
|
---|
793 | dto->lpill->lpvtbl->fnAddItems(dto->lpill, apidl, cidl);
|
---|
794 |
|
---|
795 | /* */
|
---|
796 | dto->cfShellIDList = RegisterClipboardFormatA(CFSTR_SHELLIDLIST);
|
---|
797 | /* dto->cfFileGroupDesc = RegisterClipboardFormatA(CFSTR_FILEDESCRIPTORA);
|
---|
798 | dto->cfFileContents = RegisterClipboardFormatA(CFSTR_FILECONTENTS);
|
---|
799 | */
|
---|
800 | InitFormatEtc(dto->pFormatEtc[0], dto->cfShellIDList, TYMED_HGLOBAL);
|
---|
801 |
|
---|
802 | shell32_ObjCount++;
|
---|
803 | }
|
---|
804 |
|
---|
805 | dprintf(("SHELL32:dataobject:IDataObject_Constructor((%p)->(apidl=%p cidl=%u)\n",
|
---|
806 | dto,
|
---|
807 | apidl,
|
---|
808 | cidl));
|
---|
809 | return (LPDATAOBJECT)dto;
|
---|
810 | }
|
---|
811 |
|
---|