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