2 * IEnumFORMATETC, IDataObject
4 * selecting and droping objects within the shell and/or common dialogs
6 * Copyright 1998 <juergen.schmied@metronet.de>
11 #include "shell32_main.h"
12 /***********************************************************************
13 * IEnumFORMATETC implementation
15 static HRESULT WINAPI IEnumFORMATETC_QueryInterface (LPENUMFORMATETC this, REFIID riid, LPVOID * ppvObj);
16 static ULONG WINAPI IEnumFORMATETC_AddRef (LPENUMFORMATETC this);
17 static ULONG WINAPI IEnumFORMATETC_Release (LPENUMFORMATETC this);
18 static HRESULT WINAPI IEnumFORMATETC_Next(LPENUMFORMATETC this, ULONG celt, FORMATETC32 *rgelt, ULONG *pceltFethed);
19 static HRESULT WINAPI IEnumFORMATETC_Skip(LPENUMFORMATETC this, ULONG celt);
20 static HRESULT WINAPI IEnumFORMATETC_Reset(LPENUMFORMATETC this);
21 static HRESULT WINAPI IEnumFORMATETC_Clone(LPENUMFORMATETC this, LPENUMFORMATETC* ppenum);
23 static struct IEnumFORMATETC_VTable efvt =
24 { IEnumFORMATETC_QueryInterface,
25 IEnumFORMATETC_AddRef,
26 IEnumFORMATETC_Release,
33 extern LPENUMFORMATETC IEnumFORMATETC_Constructor(UINT32 cfmt, const FORMATETC32 afmt[])
35 DWORD size=cfmt * sizeof(FORMATETC32);
37 ef=(LPENUMFORMATETC)HeapAlloc(GetProcessHeap(),0,sizeof(IEnumFORMATETC));
43 ef->pFmt = SHAlloc (size);
46 { memcpy(ef->pFmt, afmt, size);
49 TRACE(shell,"(%p)->()\n",ef);
52 static HRESULT WINAPI IEnumFORMATETC_QueryInterface (LPENUMFORMATETC this, REFIID riid, LPVOID * ppvObj)
54 WINE_StringFromCLSID((LPCLSID)riid,xriid);
55 TRACE(shell,"(%p)->(\n\tIID:\t%s,%p)\n",this,xriid,ppvObj);
59 if(IsEqualIID(riid, &IID_IUnknown))
62 else if(IsEqualIID(riid, &IID_IEnumFORMATETC))
63 { *ppvObj = (IDataObject*)this;
67 { (*(LPENUMFORMATETC*)ppvObj)->lpvtbl->fnAddRef(this);
68 TRACE(shell,"-- Interface: (%p)->(%p)\n",ppvObj,*ppvObj);
71 TRACE(shell,"-- Interface: E_NOINTERFACE\n");
75 static ULONG WINAPI IEnumFORMATETC_AddRef (LPENUMFORMATETC this)
76 { TRACE(shell,"(%p)->(count=%lu)\n",this,(this->ref)+1);
79 static ULONG WINAPI IEnumFORMATETC_Release (LPENUMFORMATETC this)
80 { TRACE(shell,"(%p)->()\n",this);
82 { TRACE(shell," destroying IEnumFORMATETC(%p)\n",this);
84 { SHFree (this->pFmt);
86 HeapFree(GetProcessHeap(),0,this);
91 static HRESULT WINAPI IEnumFORMATETC_Next(LPENUMFORMATETC this, ULONG celt, FORMATETC32 *rgelt, ULONG *pceltFethed)
93 HRESULT hres = S_FALSE;
95 TRACE (shell, "(%p)->()\n", this);
97 if (this->posFmt < this->countFmt)
98 { cfetch = this->countFmt - this->posFmt;
103 memcpy(rgelt, &this->pFmt[this->posFmt], cfetch * sizeof(FORMATETC32));
104 this->posFmt += cfetch;
111 { *pceltFethed = cfetch;
116 static HRESULT WINAPI IEnumFORMATETC_Skip(LPENUMFORMATETC this, ULONG celt)
117 { FIXME (shell, "(%p)->(num=%lu)\n", this, celt);
119 this->posFmt += celt;
120 if (this->posFmt > this->countFmt)
121 { this->posFmt = this->countFmt;
126 static HRESULT WINAPI IEnumFORMATETC_Reset(LPENUMFORMATETC this)
127 { FIXME (shell, "(%p)->()\n", this);
132 static HRESULT WINAPI IEnumFORMATETC_Clone(LPENUMFORMATETC this, LPENUMFORMATETC* ppenum)
133 { FIXME (shell, "(%p)->(ppenum=%p)\n", this, ppenum);
137 /***********************************************************************
138 * IDataObject implementation
141 static HRESULT WINAPI IDataObject_QueryInterface (LPDATAOBJECT, REFIID riid, LPVOID * ppvObj);
142 static ULONG WINAPI IDataObject_AddRef (LPDATAOBJECT);
143 static ULONG WINAPI IDataObject_Release (LPDATAOBJECT);
144 static HRESULT WINAPI IDataObject_GetData (LPDATAOBJECT, LPFORMATETC32 pformatetcIn, STGMEDIUM32 *pmedium);
145 static HRESULT WINAPI IDataObject_GetDataHere(LPDATAOBJECT, LPFORMATETC32 pformatetc, STGMEDIUM32 *pmedium);
146 static HRESULT WINAPI IDataObject_QueryGetData(LPDATAOBJECT, LPFORMATETC32 pformatetc);
147 static HRESULT WINAPI IDataObject_GetCanonicalFormatEtc(LPDATAOBJECT, LPFORMATETC32 pformatectIn, LPFORMATETC32 pformatetcOut);
148 static HRESULT WINAPI IDataObject_SetData(LPDATAOBJECT, LPFORMATETC32 pformatetc, STGMEDIUM32 *pmedium, BOOL32 fRelease);
149 static HRESULT WINAPI IDataObject_EnumFormatEtc(LPDATAOBJECT, DWORD dwDirection, IEnumFORMATETC **ppenumFormatEtc);
150 static HRESULT WINAPI IDataObject_DAdvise (LPDATAOBJECT, LPFORMATETC32 *pformatetc, DWORD advf, IAdviseSink *pAdvSink, DWORD *pdwConnection);
151 static HRESULT WINAPI IDataObject_DUnadvise(LPDATAOBJECT, DWORD dwConnection);
152 static HRESULT WINAPI IDataObject_EnumDAdvise(LPDATAOBJECT, IEnumSTATDATA **ppenumAdvise);
154 static struct IDataObject_VTable dtovt =
155 { IDataObject_QueryInterface,
159 IDataObject_GetDataHere,
160 IDataObject_QueryGetData,
161 IDataObject_GetCanonicalFormatEtc,
163 IDataObject_EnumFormatEtc,
165 IDataObject_DUnadvise,
166 IDataObject_EnumDAdvise
169 /**************************************************************************
170 * IDataObject_Constructor
172 LPDATAOBJECT IDataObject_Constructor(HWND32 hwndOwner, LPSHELLFOLDER pcf, LPITEMIDLIST * apit, UINT32 cpit)
174 dto=(LPDATAOBJECT)HeapAlloc(GetProcessHeap(),0,sizeof(IDataObject));
177 TRACE(shell,"(%p)->()\n",dto);
180 /***************************************************************************
181 * IDataObject_QueryInterface
183 static HRESULT WINAPI IDataObject_QueryInterface (LPDATAOBJECT this, REFIID riid, LPVOID * ppvObj)
185 WINE_StringFromCLSID((LPCLSID)riid,xriid);
186 TRACE(shell,"(%p)->(\n\tIID:\t%s,%p)\n",this,xriid,ppvObj);
190 if(IsEqualIID(riid, &IID_IUnknown)) /*IUnknown*/
193 else if(IsEqualIID(riid, &IID_IDataObject)) /*IDataObject*/
194 { *ppvObj = (IDataObject*)this;
198 { (*(LPDATAOBJECT*)ppvObj)->lpvtbl->fnAddRef(this);
199 TRACE(shell,"-- Interface: (%p)->(%p)\n",ppvObj,*ppvObj);
202 TRACE(shell,"-- Interface: E_NOINTERFACE\n");
203 return E_NOINTERFACE;
205 /**************************************************************************
208 static ULONG WINAPI IDataObject_AddRef(LPDATAOBJECT this)
209 { TRACE(shell,"(%p)->(count=%lu)\n",this,(this->ref)+1);
210 return ++(this->ref);
212 /**************************************************************************
213 * IDataObject_Release
215 static ULONG WINAPI IDataObject_Release(LPDATAOBJECT this)
216 { TRACE(shell,"(%p)->()\n",this);
218 { TRACE(shell," destroying IDataObject(%p)\n",this);
219 HeapFree(GetProcessHeap(),0,this);
224 static HRESULT WINAPI IDataObject_GetData (LPDATAOBJECT this, LPFORMATETC32 pformatetcIn, STGMEDIUM32 *pmedium)
225 { FIXME (shell, "(%p)->()\n", this);
228 static HRESULT WINAPI IDataObject_GetDataHere(LPDATAOBJECT this, LPFORMATETC32 pformatetc, STGMEDIUM32 *pmedium)
229 { FIXME (shell, "(%p)->()\n", this);
232 static HRESULT WINAPI IDataObject_QueryGetData(LPDATAOBJECT this, LPFORMATETC32 pformatetc)
233 { FIXME (shell, "(%p)->()\n", this);
236 static HRESULT WINAPI IDataObject_GetCanonicalFormatEtc(LPDATAOBJECT this, LPFORMATETC32 pformatectIn, LPFORMATETC32 pformatetcOut)
237 { FIXME (shell, "(%p)->()\n", this);
240 static HRESULT WINAPI IDataObject_SetData(LPDATAOBJECT this, LPFORMATETC32 pformatetc, STGMEDIUM32 *pmedium, BOOL32 fRelease)
241 { FIXME (shell, "(%p)->()\n", this);
244 static HRESULT WINAPI IDataObject_EnumFormatEtc(LPDATAOBJECT this, DWORD dwDirection, IEnumFORMATETC **ppenumFormatEtc)
245 { FIXME (shell, "(%p)->()\n", this);
248 static HRESULT WINAPI IDataObject_DAdvise (LPDATAOBJECT this, LPFORMATETC32 *pformatetc, DWORD advf, IAdviseSink *pAdvSink, DWORD *pdwConnection)
249 { FIXME (shell, "(%p)->()\n", this);
252 static HRESULT WINAPI IDataObject_DUnadvise(LPDATAOBJECT this, DWORD dwConnection)
253 { FIXME (shell, "(%p)->()\n", this);
256 static HRESULT WINAPI IDataObject_EnumDAdvise(LPDATAOBJECT this, IEnumSTATDATA **ppenumAdvise)
257 { FIXME (shell, "(%p)->()\n", this);