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