| 1 | /* $Id: dataobject.cpp,v 1.2 1999-10-05 19:33:37 phaller 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 | { TRACE("(%p)->(uStep=%u dpa=%p)\n",THIS, THIS->uStep, THIS->dpa);
|
|---|
| 350 |
|
|---|
| 351 | if (THIS->uStep == 0)
|
|---|
| 352 | {
|
|---|
| 353 | if (THIS->dpa)
|
|---|
| 354 | return(State_Init);
|
|---|
| 355 |
|
|---|
| 356 | return(State_OutOfMem);
|
|---|
| 357 | }
|
|---|
| 358 | return(State_UnInit);
|
|---|
| 359 | }
|
|---|
| 360 | static LPITEMIDLIST WINAPI IDLList_GetElement(LPIDLLIST THIS, UINT nIndex)
|
|---|
| 361 | { TRACE("(%p)->(index=%u)\n",THIS, nIndex);
|
|---|
| 362 | return((LPITEMIDLIST)pDPA_GetPtr(THIS->dpa, nIndex));
|
|---|
| 363 | }
|
|---|
| 364 | static UINT WINAPI IDLList_GetCount(LPIDLLIST THIS)
|
|---|
| 365 | { TRACE("(%p)\n",THIS);
|
|---|
| 366 | return(IDLList_GetState(THIS)==State_Init ? DPA_GetPtrCount(THIS->dpa) : 0);
|
|---|
| 367 | }
|
|---|
| 368 | static BOOL WINAPI IDLList_StoreItem(LPIDLLIST THIS, LPITEMIDLIST pidl)
|
|---|
| 369 | { TRACE("(%p)->(pidl=%p)\n",THIS, pidl);
|
|---|
| 370 | if (pidl)
|
|---|
| 371 | { if (IDLList_InitList(THIS) && pDPA_InsertPtr(THIS->dpa, 0x7fff, (LPSTR)pidl)>=0)
|
|---|
| 372 | return(TRUE);
|
|---|
| 373 | ILFree(pidl);
|
|---|
| 374 | }
|
|---|
| 375 | IDLList_CleanList(THIS);
|
|---|
| 376 | return(FALSE);
|
|---|
| 377 | }
|
|---|
| 378 | static BOOL WINAPI IDLList_AddItems(LPIDLLIST THIS, LPITEMIDLIST *apidl, UINT cidl)
|
|---|
| 379 | { INT i;
|
|---|
| 380 | TRACE("(%p)->(apidl=%p cidl=%u)\n",THIS, apidl, cidl);
|
|---|
| 381 |
|
|---|
| 382 | for (i=0; i<cidl; ++i)
|
|---|
| 383 | { if (!IDLList_StoreItem(THIS, ILClone((LPCITEMIDLIST)apidl[i])))
|
|---|
| 384 | return(FALSE);
|
|---|
| 385 | }
|
|---|
| 386 | return(TRUE);
|
|---|
| 387 | }
|
|---|
| 388 | static BOOL WINAPI IDLList_InitList(LPIDLLIST THIS)
|
|---|
| 389 | { TRACE("(%p)\n",THIS);
|
|---|
| 390 | switch (IDLList_GetState(THIS))
|
|---|
| 391 | { case State_Init:
|
|---|
| 392 | return(TRUE);
|
|---|
| 393 |
|
|---|
| 394 | case State_OutOfMem:
|
|---|
| 395 | return(FALSE);
|
|---|
| 396 |
|
|---|
| 397 | case State_UnInit:
|
|---|
| 398 | default:
|
|---|
| 399 | THIS->dpa = pDPA_Create(THIS->uStep);
|
|---|
| 400 | THIS->uStep = 0;
|
|---|
| 401 | return(IDLList_InitList(THIS));
|
|---|
| 402 | }
|
|---|
| 403 | }
|
|---|
| 404 | static void WINAPI IDLList_CleanList(LPIDLLIST THIS)
|
|---|
| 405 | { INT i;
|
|---|
| 406 | TRACE("(%p)\n",THIS);
|
|---|
| 407 |
|
|---|
| 408 | if (THIS->uStep != 0)
|
|---|
| 409 | { THIS->dpa = NULL;
|
|---|
| 410 | THIS->uStep = 0;
|
|---|
| 411 | return;
|
|---|
| 412 | }
|
|---|
| 413 |
|
|---|
| 414 | if (!THIS->dpa)
|
|---|
| 415 | { return;
|
|---|
| 416 | }
|
|---|
| 417 |
|
|---|
| 418 | for (i=DPA_GetPtrCount(THIS->dpa)-1; i>=0; --i)
|
|---|
| 419 | { ILFree(IDLList_GetElement(THIS,i));
|
|---|
| 420 | }
|
|---|
| 421 |
|
|---|
| 422 | pDPA_Destroy(THIS->dpa);
|
|---|
| 423 | THIS->dpa=NULL;
|
|---|
| 424 | }
|
|---|
| 425 |
|
|---|
| 426 |
|
|---|
| 427 | /***********************************************************************
|
|---|
| 428 | * IDataObject implementation
|
|---|
| 429 | */
|
|---|
| 430 | /* number of supported formats */
|
|---|
| 431 | #define MAX_FORMATS 1
|
|---|
| 432 |
|
|---|
| 433 | typedef struct
|
|---|
| 434 | {
|
|---|
| 435 | /* IUnknown fields */
|
|---|
| 436 | ICOM_VTABLE(IDataObject)* lpvtbl;
|
|---|
| 437 | DWORD ref;
|
|---|
| 438 |
|
|---|
| 439 | /* IDataObject fields */
|
|---|
| 440 | LPIDLLIST lpill; /* the data of the dataobject */
|
|---|
| 441 | LPITEMIDLIST pidl;
|
|---|
| 442 |
|
|---|
| 443 | FORMATETC pFormatEtc[MAX_FORMATS];
|
|---|
| 444 | UINT cfShellIDList;
|
|---|
| 445 | UINT cfFileGroupDesc;
|
|---|
| 446 | UINT cfFileContents;
|
|---|
| 447 |
|
|---|
| 448 | } IDataObjectImpl;
|
|---|
| 449 |
|
|---|
| 450 | //static struct ICOM_VTABLE(IDataObject) dtovt;
|
|---|
| 451 |
|
|---|
| 452 | /***************************************************************************
|
|---|
| 453 | * IDataObject_QueryInterface
|
|---|
| 454 | */
|
|---|
| 455 | static HRESULT WINAPI IDataObject_fnQueryInterface(LPDATAOBJECT iface, REFIID riid, LPVOID * ppvObj)
|
|---|
| 456 | {
|
|---|
| 457 | ICOM_THIS(IDataObjectImpl,iface);
|
|---|
| 458 | char xriid[50];
|
|---|
| 459 | WINE_StringFromCLSID((LPCLSID)riid,xriid);
|
|---|
| 460 | TRACE("(%p)->(\n\tIID:\t%s,%p)\n",This,xriid,ppvObj);
|
|---|
| 461 |
|
|---|
| 462 | *ppvObj = NULL;
|
|---|
| 463 |
|
|---|
| 464 | if(IsEqualIID(riid, &IID_IUnknown)) /*IUnknown*/
|
|---|
| 465 | { *ppvObj = This;
|
|---|
| 466 | }
|
|---|
| 467 | else if(IsEqualIID(riid, &IID_IDataObject)) /*IDataObject*/
|
|---|
| 468 | { *ppvObj = (IDataObject*)This;
|
|---|
| 469 | }
|
|---|
| 470 |
|
|---|
| 471 | if(*ppvObj)
|
|---|
| 472 | { IDataObject_AddRef((IDataObject*)*ppvObj);
|
|---|
| 473 | TRACE("-- Interface: (%p)->(%p)\n",ppvObj,*ppvObj);
|
|---|
| 474 | return S_OK;
|
|---|
| 475 | }
|
|---|
| 476 | TRACE("-- Interface: E_NOINTERFACE\n");
|
|---|
| 477 | return E_NOINTERFACE;
|
|---|
| 478 | }
|
|---|
| 479 | /**************************************************************************
|
|---|
| 480 | * IDataObject_AddRef
|
|---|
| 481 | */
|
|---|
| 482 | static ULONG WINAPI IDataObject_fnAddRef(LPDATAOBJECT iface)
|
|---|
| 483 | {
|
|---|
| 484 | ICOM_THIS(IDataObjectImpl,iface);
|
|---|
| 485 |
|
|---|
| 486 | TRACE("(%p)->(count=%lu)\n",This, This->ref);
|
|---|
| 487 |
|
|---|
| 488 | shell32_ObjCount++;
|
|---|
| 489 | return ++(This->ref);
|
|---|
| 490 | }
|
|---|
| 491 | /**************************************************************************
|
|---|
| 492 | * IDataObject_Release
|
|---|
| 493 | */
|
|---|
| 494 | static ULONG WINAPI IDataObject_fnRelease(LPDATAOBJECT iface)
|
|---|
| 495 | {
|
|---|
| 496 | ICOM_THIS(IDataObjectImpl,iface);
|
|---|
| 497 | TRACE("(%p)->()\n",This);
|
|---|
| 498 |
|
|---|
| 499 | shell32_ObjCount--;
|
|---|
| 500 |
|
|---|
| 501 | if (!--(This->ref))
|
|---|
| 502 | { TRACE(" destroying IDataObject(%p)\n",This);
|
|---|
| 503 | IDLList_Destructor(This->lpill);
|
|---|
| 504 | HeapFree(GetProcessHeap(),0,This);
|
|---|
| 505 | return 0;
|
|---|
| 506 | }
|
|---|
| 507 | return This->ref;
|
|---|
| 508 | }
|
|---|
| 509 |
|
|---|
| 510 | /**************************************************************************
|
|---|
| 511 | * IDataObject_fnGetData
|
|---|
| 512 | */
|
|---|
| 513 | static HRESULT WINAPI IDataObject_fnGetData(LPDATAOBJECT iface, LPFORMATETC pformatetcIn, STGMEDIUM *pmedium)
|
|---|
| 514 | {
|
|---|
| 515 | ICOM_THIS(IDataObjectImpl,iface);
|
|---|
| 516 |
|
|---|
| 517 | char szTemp[256];
|
|---|
| 518 | UINT cItems;
|
|---|
| 519 | DWORD sizeCIDA, sizePidl, nOffset, nSize;
|
|---|
| 520 | LPCIDA pcida;
|
|---|
| 521 | HGLOBAL hmem;
|
|---|
| 522 | int i;
|
|---|
| 523 | LPITEMIDLIST pidl;
|
|---|
| 524 |
|
|---|
| 525 | GetClipboardFormatNameA (pformatetcIn->cfFormat, szTemp, 256);
|
|---|
| 526 | TRACE("(%p)->(%p %p format=%s)\n", This, pformatetcIn, pmedium, szTemp);
|
|---|
| 527 |
|
|---|
| 528 | /* test expected format */
|
|---|
| 529 | if (!(pformatetcIn->cfFormat == This->cfShellIDList))
|
|---|
| 530 | {
|
|---|
| 531 | FIXME("-- clipformat not implemented\n");
|
|---|
| 532 | return (E_INVALIDARG);
|
|---|
| 533 | }
|
|---|
| 534 |
|
|---|
| 535 | if (pformatetcIn->ptd==NULL
|
|---|
| 536 | && (pformatetcIn->dwAspect & DVASPECT_CONTENT)
|
|---|
| 537 | && pformatetcIn->lindex==-1
|
|---|
| 538 | && (pformatetcIn->tymed&TYMED_HGLOBAL))
|
|---|
| 539 | {
|
|---|
| 540 | cItems = This->lpill->lpvtbl->fnGetCount(This->lpill);
|
|---|
| 541 | if (cItems < 1) return(E_UNEXPECTED);
|
|---|
| 542 |
|
|---|
| 543 | sizeCIDA = sizeof(CIDA) + sizeof (UINT)*(cItems); /* without any pidl */
|
|---|
| 544 | sizePidl = ILGetSize (This->pidl); /* add root pidl */
|
|---|
| 545 |
|
|---|
| 546 | nSize = sizeCIDA + sizePidl;
|
|---|
| 547 | hmem = GlobalAlloc(GHND|GMEM_SHARE, nSize);
|
|---|
| 548 | if (!hmem) return(E_OUTOFMEMORY);
|
|---|
| 549 | pcida = (CIDA*)GlobalLock (hmem);
|
|---|
| 550 |
|
|---|
| 551 | nOffset = sizeCIDA; /* start after the CIDA */
|
|---|
| 552 | pcida->cidl = cItems;
|
|---|
| 553 |
|
|---|
| 554 | pcida->aoffset[0] = nOffset; /* first element */
|
|---|
| 555 | memcpy(((LPBYTE)pcida)+nOffset, This->pidl, sizePidl);
|
|---|
| 556 | nOffset += sizePidl;
|
|---|
| 557 | pdump(This->pidl);
|
|---|
| 558 |
|
|---|
| 559 | for (i=0; i< cItems; i++)
|
|---|
| 560 | {
|
|---|
| 561 | pidl = This->lpill->lpvtbl->fnGetElement(This->lpill, i);
|
|---|
| 562 | sizePidl = ILGetSize (pidl);
|
|---|
| 563 | nSize += sizePidl; /* size of the structure */
|
|---|
| 564 | pdump(pidl);
|
|---|
| 565 |
|
|---|
| 566 | GlobalUnlock(hmem); /* grow memory */
|
|---|
| 567 | hmem = GlobalReAlloc(hmem, nSize, GHND|GMEM_SHARE);
|
|---|
| 568 | if (!hmem) return(E_OUTOFMEMORY);
|
|---|
| 569 | pcida = (CIDA*)GlobalLock (hmem);
|
|---|
| 570 |
|
|---|
| 571 | pcida->aoffset[i+1] = nOffset; /* copy element */
|
|---|
| 572 | memcpy(((LPBYTE)pcida)+nOffset, pidl, sizePidl);
|
|---|
| 573 | nOffset += sizePidl;
|
|---|
| 574 | }
|
|---|
| 575 |
|
|---|
| 576 | GlobalUnlock(hmem);
|
|---|
| 577 |
|
|---|
| 578 | pmedium->tymed = TYMED_HGLOBAL;
|
|---|
| 579 | pmedium->u.hGlobal = hmem;
|
|---|
| 580 | pmedium->pUnkForRelease = NULL;
|
|---|
| 581 |
|
|---|
| 582 | TRACE("(%p)->(cida at %p)\n", This, pcida);
|
|---|
| 583 | return hmem;
|
|---|
| 584 | }
|
|---|
| 585 |
|
|---|
| 586 | FIXME("-- can't serve format\n");
|
|---|
| 587 | return (E_INVALIDARG);
|
|---|
| 588 | }
|
|---|
| 589 | static HRESULT WINAPI IDataObject_fnGetDataHere(LPDATAOBJECT iface, LPFORMATETC pformatetc, STGMEDIUM *pmedium)
|
|---|
| 590 | {
|
|---|
| 591 | ICOM_THIS(IDataObjectImpl,iface);
|
|---|
| 592 | FIXME("(%p)->()\n", This);
|
|---|
| 593 | return E_NOTIMPL;
|
|---|
| 594 | }
|
|---|
| 595 | static HRESULT WINAPI IDataObject_fnQueryGetData(LPDATAOBJECT iface, LPFORMATETC pformatetc)
|
|---|
| 596 | {
|
|---|
| 597 | ICOM_THIS(IDataObjectImpl,iface);
|
|---|
| 598 | UINT i;
|
|---|
| 599 |
|
|---|
| 600 | TRACE("(%p)->(fmt=0x%08x tym=0x%08lx)\n", This, pformatetc->cfFormat, pformatetc->tymed);
|
|---|
| 601 |
|
|---|
| 602 | if(!(DVASPECT_CONTENT & pformatetc->dwAspect))
|
|---|
| 603 | return DV_E_DVASPECT;
|
|---|
| 604 |
|
|---|
| 605 | /* check our formats table what we have */
|
|---|
| 606 | for (i=0; i<MAX_FORMATS; i++)
|
|---|
| 607 | {
|
|---|
| 608 | if ((This->pFormatEtc[i].cfFormat == pformatetc->cfFormat)
|
|---|
| 609 | && (This->pFormatEtc[i].tymed == pformatetc->tymed))
|
|---|
| 610 | {
|
|---|
| 611 | return S_OK;
|
|---|
| 612 | }
|
|---|
| 613 | }
|
|---|
| 614 |
|
|---|
| 615 | return DV_E_TYMED;
|
|---|
| 616 | }
|
|---|
| 617 | static HRESULT WINAPI IDataObject_fnGetCanonicalFormatEtc(LPDATAOBJECT iface, LPFORMATETC pformatectIn, LPFORMATETC pformatetcOut)
|
|---|
| 618 | {
|
|---|
| 619 | ICOM_THIS(IDataObjectImpl,iface);
|
|---|
| 620 | FIXME("(%p)->()\n", This);
|
|---|
| 621 | return E_NOTIMPL;
|
|---|
| 622 | }
|
|---|
| 623 | static HRESULT WINAPI IDataObject_fnSetData(LPDATAOBJECT iface, LPFORMATETC pformatetc, STGMEDIUM *pmedium, BOOL fRelease)
|
|---|
| 624 | {
|
|---|
| 625 | ICOM_THIS(IDataObjectImpl,iface);
|
|---|
| 626 | FIXME("(%p)->()\n", This);
|
|---|
| 627 | return E_NOTIMPL;
|
|---|
| 628 | }
|
|---|
| 629 | static HRESULT WINAPI IDataObject_fnEnumFormatEtc(LPDATAOBJECT iface, DWORD dwDirection, IEnumFORMATETC **ppenumFormatEtc)
|
|---|
| 630 | {
|
|---|
| 631 | ICOM_THIS(IDataObjectImpl,iface);
|
|---|
| 632 |
|
|---|
| 633 | TRACE("(%p)->()\n", This);
|
|---|
| 634 | *ppenumFormatEtc=NULL;
|
|---|
| 635 |
|
|---|
| 636 | /* only get data */
|
|---|
| 637 | if (DATADIR_GET == dwDirection)
|
|---|
| 638 | {
|
|---|
| 639 | *ppenumFormatEtc = IEnumFORMATETC_Constructor(MAX_FORMATS, This->pFormatEtc);
|
|---|
| 640 | return (*ppenumFormatEtc) ? S_OK : E_FAIL;
|
|---|
| 641 | }
|
|---|
| 642 |
|
|---|
| 643 | return E_NOTIMPL;
|
|---|
| 644 | }
|
|---|
| 645 | static HRESULT WINAPI IDataObject_fnDAdvise(LPDATAOBJECT iface, FORMATETC *pformatetc, DWORD advf, IAdviseSink *pAdvSink, DWORD *pdwConnection)
|
|---|
| 646 | {
|
|---|
| 647 | ICOM_THIS(IDataObjectImpl,iface);
|
|---|
| 648 | FIXME("(%p)->()\n", This);
|
|---|
| 649 | return E_NOTIMPL;
|
|---|
| 650 | }
|
|---|
| 651 | static HRESULT WINAPI IDataObject_fnDUnadvise(LPDATAOBJECT iface, DWORD dwConnection)
|
|---|
| 652 | {
|
|---|
| 653 | ICOM_THIS(IDataObjectImpl,iface);
|
|---|
| 654 | FIXME("(%p)->()\n", This);
|
|---|
| 655 | return E_NOTIMPL;
|
|---|
| 656 | }
|
|---|
| 657 | static HRESULT WINAPI IDataObject_fnEnumDAdvise(LPDATAOBJECT iface, IEnumSTATDATA **ppenumAdvise)
|
|---|
| 658 | {
|
|---|
| 659 | ICOM_THIS(IDataObjectImpl,iface);
|
|---|
| 660 | FIXME("(%p)->()\n", This);
|
|---|
| 661 | return E_NOTIMPL;
|
|---|
| 662 | }
|
|---|
| 663 |
|
|---|
| 664 | static struct ICOM_VTABLE(IDataObject) dtovt =
|
|---|
| 665 | {
|
|---|
| 666 | ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
|
|---|
| 667 | IDataObject_fnQueryInterface,
|
|---|
| 668 | IDataObject_fnAddRef,
|
|---|
| 669 | IDataObject_fnRelease,
|
|---|
| 670 | IDataObject_fnGetData,
|
|---|
| 671 | IDataObject_fnGetDataHere,
|
|---|
| 672 | IDataObject_fnQueryGetData,
|
|---|
| 673 | IDataObject_fnGetCanonicalFormatEtc,
|
|---|
| 674 | IDataObject_fnSetData,
|
|---|
| 675 | IDataObject_fnEnumFormatEtc,
|
|---|
| 676 | IDataObject_fnDAdvise,
|
|---|
| 677 | IDataObject_fnDUnadvise,
|
|---|
| 678 | IDataObject_fnEnumDAdvise
|
|---|
| 679 | };
|
|---|
| 680 |
|
|---|
| 681 | /**************************************************************************
|
|---|
| 682 | * IDataObject_Constructor
|
|---|
| 683 | */
|
|---|
| 684 | LPDATAOBJECT IDataObject_Constructor(HWND hwndOwner, LPITEMIDLIST pMyPidl, LPITEMIDLIST * apidl, UINT cidl)
|
|---|
| 685 | {
|
|---|
| 686 | IDataObjectImpl* dto;
|
|---|
| 687 |
|
|---|
| 688 | dto = (IDataObjectImpl*)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDataObjectImpl));
|
|---|
| 689 |
|
|---|
| 690 | if (dto)
|
|---|
| 691 | {
|
|---|
| 692 | dto->ref=1;
|
|---|
| 693 | dto->lpvtbl=&dtovt;
|
|---|
| 694 | dto->pidl=ILClone(pMyPidl);
|
|---|
| 695 |
|
|---|
| 696 | /* fill the ItemID List List */
|
|---|
| 697 | dto->lpill = IDLList_Constructor (8);
|
|---|
| 698 | if (! dto->lpill )
|
|---|
| 699 | return NULL;
|
|---|
| 700 |
|
|---|
| 701 | dto->lpill->lpvtbl->fnAddItems(dto->lpill, apidl, cidl);
|
|---|
| 702 |
|
|---|
| 703 | /* */
|
|---|
| 704 | dto->cfShellIDList = RegisterClipboardFormatA(CFSTR_SHELLIDLIST);
|
|---|
| 705 | /* dto->cfFileGroupDesc = RegisterClipboardFormatA(CFSTR_FILEDESCRIPTORA);
|
|---|
| 706 | dto->cfFileContents = RegisterClipboardFormatA(CFSTR_FILECONTENTS);
|
|---|
| 707 | */
|
|---|
| 708 | InitFormatEtc(dto->pFormatEtc[0], dto->cfShellIDList, TYMED_HGLOBAL);
|
|---|
| 709 |
|
|---|
| 710 | shell32_ObjCount++;
|
|---|
| 711 | }
|
|---|
| 712 |
|
|---|
| 713 | TRACE("(%p)->(apidl=%p cidl=%u)\n",dto, apidl, cidl);
|
|---|
| 714 | return (LPDATAOBJECT)dto;
|
|---|
| 715 | }
|
|---|
| 716 |
|
|---|