xref: /reactos/dll/win32/shell32/CIDLDataObj.cpp (revision 63935f85)
1c2c66affSColin Finck /*
2730a99c8SMark Jansen  * PROJECT:     shell32
3730a99c8SMark Jansen  * LICENSE:     LGPL-2.1-or-later (https://spdx.org/licenses/LGPL-2.1-or-later)
4730a99c8SMark Jansen  * PURPOSE:     IEnumFORMATETC, IDataObject implementation
5730a99c8SMark Jansen  * COPYRIGHT:   Copyright 1998, 1999 <juergen.schmied@metronet.de>
6730a99c8SMark Jansen  *              Copyright 2019 Mark Jansen (mark.jansen@reactos.org)
7c2c66affSColin Finck  */
8c2c66affSColin Finck 
9c2c66affSColin Finck #include "precomp.h"
10c2c66affSColin Finck 
11c2c66affSColin Finck WINE_DEFAULT_DEBUG_CHANNEL(shell);
12c2c66affSColin Finck 
13c2c66affSColin Finck /***********************************************************************
14c2c66affSColin Finck *   IEnumFORMATETC implementation
15c2c66affSColin Finck */
16c2c66affSColin Finck 
17c2c66affSColin Finck class IEnumFORMATETCImpl :
18c2c66affSColin Finck     public CComObjectRootEx<CComMultiThreadModelNoCS>,
19c2c66affSColin Finck     public IEnumFORMATETC
20c2c66affSColin Finck {
21c2c66affSColin Finck private:
22c2c66affSColin Finck     UINT                        posFmt;
23c2c66affSColin Finck     UINT                        countFmt;
24c2c66affSColin Finck     LPFORMATETC                    pFmt;
25c2c66affSColin Finck public:
26c2c66affSColin Finck     IEnumFORMATETCImpl();
27c2c66affSColin Finck     ~IEnumFORMATETCImpl();
28c2c66affSColin Finck     HRESULT WINAPI Initialize(UINT cfmt, const FORMATETC afmt[]);
29c2c66affSColin Finck 
30c2c66affSColin Finck     // *****************
3149b2b1daSKatayama Hirofumi MZ     STDMETHOD(Next)(ULONG celt, FORMATETC *rgelt, ULONG *pceltFethed) override;
3249b2b1daSKatayama Hirofumi MZ     STDMETHOD(Skip)(ULONG celt) override;
3349b2b1daSKatayama Hirofumi MZ     STDMETHOD(Reset)() override;
3449b2b1daSKatayama Hirofumi MZ     STDMETHOD(Clone)(LPENUMFORMATETC* ppenum) override;
35c2c66affSColin Finck 
36c2c66affSColin Finck BEGIN_COM_MAP(IEnumFORMATETCImpl)
37c2c66affSColin Finck     COM_INTERFACE_ENTRY_IID(IID_IEnumFORMATETC, IEnumFORMATETC)
38c2c66affSColin Finck END_COM_MAP()
39c2c66affSColin Finck };
40c2c66affSColin Finck 
IEnumFORMATETCImpl()41c2c66affSColin Finck IEnumFORMATETCImpl::IEnumFORMATETCImpl()
42c2c66affSColin Finck {
43c2c66affSColin Finck     posFmt = 0;
44c2c66affSColin Finck     countFmt = 0;
45c2c66affSColin Finck     pFmt = NULL;
46c2c66affSColin Finck }
47c2c66affSColin Finck 
~IEnumFORMATETCImpl()48c2c66affSColin Finck IEnumFORMATETCImpl::~IEnumFORMATETCImpl()
49c2c66affSColin Finck {
50c2c66affSColin Finck }
51c2c66affSColin Finck 
Initialize(UINT cfmt,const FORMATETC afmt[])52c2c66affSColin Finck HRESULT WINAPI IEnumFORMATETCImpl::Initialize(UINT cfmt, const FORMATETC afmt[])
53c2c66affSColin Finck {
54c2c66affSColin Finck     DWORD size;
55c2c66affSColin Finck 
56c2c66affSColin Finck     size = cfmt * sizeof(FORMATETC);
57c2c66affSColin Finck     countFmt = cfmt;
58c2c66affSColin Finck     pFmt = (LPFORMATETC)SHAlloc(size);
59c2c66affSColin Finck     if (pFmt == NULL)
60c2c66affSColin Finck         return E_OUTOFMEMORY;
61c2c66affSColin Finck 
62c2c66affSColin Finck     memcpy(pFmt, afmt, size);
63c2c66affSColin Finck     return S_OK;
64c2c66affSColin Finck }
65c2c66affSColin Finck 
Next(ULONG celt,FORMATETC * rgelt,ULONG * pceltFethed)66c2c66affSColin Finck HRESULT WINAPI IEnumFORMATETCImpl::Next(ULONG celt, FORMATETC *rgelt, ULONG *pceltFethed)
67c2c66affSColin Finck {
68c2c66affSColin Finck     UINT i;
69c2c66affSColin Finck 
70c2c66affSColin Finck     TRACE("(%p)->(%u,%p)\n", this, celt, rgelt);
71c2c66affSColin Finck 
72730a99c8SMark Jansen     if (!pFmt)
73730a99c8SMark Jansen         return S_FALSE;
74730a99c8SMark Jansen     if (!rgelt)
75730a99c8SMark Jansen         return E_INVALIDARG;
76730a99c8SMark Jansen     if (pceltFethed)
77730a99c8SMark Jansen         *pceltFethed = 0;
78c2c66affSColin Finck 
79c2c66affSColin Finck     for (i = 0; posFmt < countFmt && celt > i; i++)
80c2c66affSColin Finck     {
81c2c66affSColin Finck         *rgelt++ = pFmt[posFmt++];
82c2c66affSColin Finck     }
83c2c66affSColin Finck 
84730a99c8SMark Jansen     if (pceltFethed)
85730a99c8SMark Jansen         *pceltFethed = i;
86c2c66affSColin Finck 
87c2c66affSColin Finck     return ((i == celt) ? S_OK : S_FALSE);
88c2c66affSColin Finck }
89c2c66affSColin Finck 
Skip(ULONG celt)90c2c66affSColin Finck HRESULT WINAPI IEnumFORMATETCImpl::Skip(ULONG celt)
91c2c66affSColin Finck {
92c2c66affSColin Finck     TRACE("(%p)->(num=%u)\n", this, celt);
93c2c66affSColin Finck 
94730a99c8SMark Jansen     if (posFmt + celt >= countFmt)
95730a99c8SMark Jansen         return S_FALSE;
96c2c66affSColin Finck     posFmt += celt;
97c2c66affSColin Finck     return S_OK;
98c2c66affSColin Finck }
99c2c66affSColin Finck 
Reset()100c2c66affSColin Finck HRESULT WINAPI IEnumFORMATETCImpl::Reset()
101c2c66affSColin Finck {
102c2c66affSColin Finck     TRACE("(%p)->()\n", this);
103c2c66affSColin Finck 
104c2c66affSColin Finck     posFmt = 0;
105c2c66affSColin Finck     return S_OK;
106c2c66affSColin Finck }
107c2c66affSColin Finck 
Clone(LPENUMFORMATETC * ppenum)108c2c66affSColin Finck HRESULT WINAPI IEnumFORMATETCImpl::Clone(LPENUMFORMATETC* ppenum)
109c2c66affSColin Finck {
110c2c66affSColin Finck     HRESULT hResult;
111c2c66affSColin Finck 
112c2c66affSColin Finck     TRACE("(%p)->(ppenum=%p)\n", this, ppenum);
113c2c66affSColin Finck 
114c2c66affSColin Finck     if (!ppenum) return E_INVALIDARG;
115c2c66affSColin Finck     hResult = IEnumFORMATETC_Constructor(countFmt, pFmt, ppenum);
116730a99c8SMark Jansen     if (FAILED_UNEXPECTEDLY(hResult))
117c2c66affSColin Finck         return hResult;
118c2c66affSColin Finck     return (*ppenum)->Skip(posFmt);
119c2c66affSColin Finck }
120c2c66affSColin Finck 
IEnumFORMATETC_Constructor(UINT cfmt,const FORMATETC afmt[],IEnumFORMATETC ** ppFormat)121c2c66affSColin Finck HRESULT IEnumFORMATETC_Constructor(UINT cfmt, const FORMATETC afmt[], IEnumFORMATETC **ppFormat)
122c2c66affSColin Finck {
123c2c66affSColin Finck     return ShellObjectCreatorInit<IEnumFORMATETCImpl>(cfmt, afmt, IID_PPV_ARG(IEnumFORMATETC, ppFormat));
124c2c66affSColin Finck }
125c2c66affSColin Finck 
126c2c66affSColin Finck 
127c2c66affSColin Finck /***********************************************************************
128c2c66affSColin Finck *   IDataObject implementation
129730a99c8SMark Jansen *   For now (2019-10-12) it's compatible with 2k3's data object
130730a99c8SMark Jansen *   See shell32_apitest!CIDLData for changes between versions
131c2c66affSColin Finck */
132c2c66affSColin Finck 
133c2c66affSColin Finck class CIDLDataObj :
134c2c66affSColin Finck     public CComObjectRootEx<CComMultiThreadModelNoCS>,
135c2c66affSColin Finck     public IDataObject,
136c2c66affSColin Finck     public IAsyncOperation
137c2c66affSColin Finck {
138c2c66affSColin Finck private:
139730a99c8SMark Jansen     CSimpleArray<FORMATETC> m_Formats;
140730a99c8SMark Jansen     CSimpleArray<STGMEDIUM> m_Storage;
141730a99c8SMark Jansen     UINT m_cfShellIDList;
142730a99c8SMark Jansen     BOOL m_doasync;
143*63935f85SWhindmar Saksit     bool m_FailGetHDrop;
144c2c66affSColin Finck public:
145c2c66affSColin Finck     CIDLDataObj();
146c2c66affSColin Finck     ~CIDLDataObj();
147c3132711SMark Jansen     HRESULT WINAPI Initialize(HWND hwndOwner, PCIDLIST_ABSOLUTE pMyPidl, PCUIDLIST_RELATIVE_ARRAY apidlx, UINT cidlx, BOOL bAddAdditionalFormats);
148c2c66affSColin Finck 
149730a99c8SMark Jansen     // *** IDataObject methods ***
15049b2b1daSKatayama Hirofumi MZ     STDMETHOD(GetData)(LPFORMATETC pformatetcIn, STGMEDIUM *pmedium) override;
15149b2b1daSKatayama Hirofumi MZ     STDMETHOD(GetDataHere)(LPFORMATETC pformatetc, STGMEDIUM *pmedium) override;
15249b2b1daSKatayama Hirofumi MZ     STDMETHOD(QueryGetData)(LPFORMATETC pformatetc) override;
15349b2b1daSKatayama Hirofumi MZ     STDMETHOD(GetCanonicalFormatEtc)(LPFORMATETC pformatectIn, LPFORMATETC pformatetcOut) override;
15449b2b1daSKatayama Hirofumi MZ     STDMETHOD(SetData)(LPFORMATETC pformatetc, STGMEDIUM *pmedium, BOOL fRelease) override;
15549b2b1daSKatayama Hirofumi MZ     STDMETHOD(EnumFormatEtc)(DWORD dwDirection, IEnumFORMATETC **ppenumFormatEtc) override;
15649b2b1daSKatayama Hirofumi MZ     STDMETHOD(DAdvise)(FORMATETC *pformatetc, DWORD advf, IAdviseSink *pAdvSink, DWORD *pdwConnection) override;
15749b2b1daSKatayama Hirofumi MZ     STDMETHOD(DUnadvise)(DWORD dwConnection) override;
15849b2b1daSKatayama Hirofumi MZ     STDMETHOD(EnumDAdvise)(IEnumSTATDATA **ppenumAdvise) override;
159730a99c8SMark Jansen 
160730a99c8SMark Jansen     // *** IAsyncOperation methods ***
16149b2b1daSKatayama Hirofumi MZ     STDMETHOD(SetAsyncMode)(BOOL fDoOpAsync) override;
16249b2b1daSKatayama Hirofumi MZ     STDMETHOD(GetAsyncMode)(BOOL *pfIsOpAsync) override;
16349b2b1daSKatayama Hirofumi MZ     STDMETHOD(StartOperation)(IBindCtx *pbcReserved) override;
16449b2b1daSKatayama Hirofumi MZ     STDMETHOD(InOperation)(BOOL *pfInAsyncOp) override;
16549b2b1daSKatayama Hirofumi MZ     STDMETHOD(EndOperation)(HRESULT hResult, IBindCtx *pbcReserved, DWORD dwEffects) override;
166c2c66affSColin Finck 
167c2c66affSColin Finck BEGIN_COM_MAP(CIDLDataObj)
168c2c66affSColin Finck     COM_INTERFACE_ENTRY_IID(IID_IDataObject, IDataObject)
169c2c66affSColin Finck     COM_INTERFACE_ENTRY_IID(IID_IAsyncOperation,  IAsyncOperation)
170c2c66affSColin Finck END_COM_MAP()
171c2c66affSColin Finck };
172c2c66affSColin Finck 
CIDLDataObj()173c2c66affSColin Finck CIDLDataObj::CIDLDataObj()
174c2c66affSColin Finck {
175730a99c8SMark Jansen     m_cfShellIDList = 0;
176730a99c8SMark Jansen     m_doasync = FALSE;
177*63935f85SWhindmar Saksit     m_FailGetHDrop = false;
178c2c66affSColin Finck }
179c2c66affSColin Finck 
~CIDLDataObj()180c2c66affSColin Finck CIDLDataObj::~CIDLDataObj()
181c2c66affSColin Finck {
182c2c66affSColin Finck     TRACE(" destroying IDataObject(%p)\n", this);
183730a99c8SMark Jansen 
184730a99c8SMark Jansen     for (int n = 0; n < m_Storage.GetSize(); ++n)
185730a99c8SMark Jansen     {
186730a99c8SMark Jansen         ReleaseStgMedium(&m_Storage[n]);
187730a99c8SMark Jansen     }
188730a99c8SMark Jansen     m_Formats.RemoveAll();
189730a99c8SMark Jansen     m_Storage.RemoveAll();
190c2c66affSColin Finck }
191c2c66affSColin Finck 
Initialize(HWND hwndOwner,PCIDLIST_ABSOLUTE pMyPidl,PCUIDLIST_RELATIVE_ARRAY apidlx,UINT cidlx,BOOL bAddAdditionalFormats)192c3132711SMark Jansen HRESULT WINAPI CIDLDataObj::Initialize(HWND hwndOwner, PCIDLIST_ABSOLUTE pMyPidl, PCUIDLIST_RELATIVE_ARRAY apidlx, UINT cidlx, BOOL bAddAdditionalFormats)
193c2c66affSColin Finck {
194730a99c8SMark Jansen     HGLOBAL hida = RenderSHELLIDLIST((LPITEMIDLIST)pMyPidl, (LPITEMIDLIST*)apidlx, cidlx);
195730a99c8SMark Jansen     if (!hida)
196c2c66affSColin Finck     {
197730a99c8SMark Jansen         ERR("Failed to render " CFSTR_SHELLIDLISTA "\n");
198730a99c8SMark Jansen         return E_OUTOFMEMORY;
199c2c66affSColin Finck     }
200c2c66affSColin Finck 
201730a99c8SMark Jansen     m_cfShellIDList = RegisterClipboardFormatW(CFSTR_SHELLIDLIST);
202730a99c8SMark Jansen 
203c3132711SMark Jansen     FORMATETC Format = { (CLIPFORMAT)m_cfShellIDList, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL };
204730a99c8SMark Jansen     STGMEDIUM medium = {0};
205730a99c8SMark Jansen     medium.tymed = TYMED_HGLOBAL;
206730a99c8SMark Jansen     medium.hGlobal = hida;
207c3132711SMark Jansen     HRESULT hr = SetData(&Format, &medium, TRUE);
208c3132711SMark Jansen     if (!FAILED_UNEXPECTEDLY(hr) && bAddAdditionalFormats)
209c3132711SMark Jansen     {
210*63935f85SWhindmar Saksit         /* The Windows default shell IDataObject::GetData fails with DV_E_CLIPFORMAT if the desktop is present.
211*63935f85SWhindmar Saksit          * Windows does return HDROP in EnumFormatEtc and does not fail until GetData is called.
212*63935f85SWhindmar Saksit          * Failing GetData causes 7-Zip 23.01 to not add its menu to the desktop folder. */
213*63935f85SWhindmar Saksit         for (UINT i = 0; i < cidlx; ++i)
214*63935f85SWhindmar Saksit         {
215*63935f85SWhindmar Saksit             if (ILIsEmpty(apidlx[i]) && ILIsEmpty(pMyPidl))
216*63935f85SWhindmar Saksit                 m_FailGetHDrop = true;
217*63935f85SWhindmar Saksit         }
218*63935f85SWhindmar Saksit 
219c3132711SMark Jansen         Format.cfFormat = CF_HDROP;
220c3132711SMark Jansen         medium.hGlobal = RenderHDROP((LPITEMIDLIST)pMyPidl, (LPITEMIDLIST*)apidlx, cidlx);
221c3132711SMark Jansen         hr = SetData(&Format, &medium, TRUE);
222c3132711SMark Jansen         if (FAILED_UNEXPECTEDLY(hr))
223c3132711SMark Jansen             return hr;
224730a99c8SMark Jansen 
225c3132711SMark Jansen         Format.cfFormat = RegisterClipboardFormatA(CFSTR_FILENAMEA);
226c3132711SMark Jansen         medium.hGlobal = RenderFILENAMEA((LPITEMIDLIST)pMyPidl, (LPITEMIDLIST*)apidlx, cidlx);
227c3132711SMark Jansen         hr = SetData(&Format, &medium, TRUE);
228c3132711SMark Jansen         if (FAILED_UNEXPECTEDLY(hr))
229c3132711SMark Jansen             return hr;
230c3132711SMark Jansen 
231c3132711SMark Jansen         Format.cfFormat = RegisterClipboardFormatW(CFSTR_FILENAMEW);
232c3132711SMark Jansen         medium.hGlobal = RenderFILENAMEW((LPITEMIDLIST)pMyPidl, (LPITEMIDLIST*)apidlx, cidlx);
233c3132711SMark Jansen         hr = SetData(&Format, &medium, TRUE);
234c3132711SMark Jansen         if (FAILED_UNEXPECTEDLY(hr))
235c3132711SMark Jansen             return hr;
236c3132711SMark Jansen     }
237c3132711SMark Jansen 
238c3132711SMark Jansen     return hr;
239730a99c8SMark Jansen }
240730a99c8SMark Jansen 
241730a99c8SMark Jansen 
GetData(LPFORMATETC pformatetcIn,STGMEDIUM * pmedium)242c2c66affSColin Finck HRESULT WINAPI CIDLDataObj::GetData(LPFORMATETC pformatetcIn, STGMEDIUM *pmedium)
243c2c66affSColin Finck {
244730a99c8SMark Jansen     if (TRACE_ON(shell))
245730a99c8SMark Jansen     {
246730a99c8SMark Jansen         char szTemp[256] = {0};
247c2c66affSColin Finck         GetClipboardFormatNameA (pformatetcIn->cfFormat, szTemp, 256);
248c2c66affSColin Finck         TRACE("(%p)->(%p %p format=%s)\n", this, pformatetcIn, pmedium, szTemp);
249c2c66affSColin Finck     }
2506a6a28b6SMark Jansen     pmedium->hGlobal = NULL;
2516a6a28b6SMark Jansen     pmedium->pUnkForRelease = NULL;
252730a99c8SMark Jansen     for (int n = 0; n < m_Formats.GetSize(); ++n)
253c2c66affSColin Finck     {
254730a99c8SMark Jansen         const FORMATETC& fmt = m_Formats[n];
255730a99c8SMark Jansen         if (fmt.cfFormat == pformatetcIn->cfFormat &&
256730a99c8SMark Jansen             fmt.dwAspect == pformatetcIn->dwAspect &&
257730a99c8SMark Jansen             fmt.tymed == pformatetcIn->tymed)
258c2c66affSColin Finck         {
259*63935f85SWhindmar Saksit             if (m_FailGetHDrop && fmt.cfFormat == CF_HDROP)
260*63935f85SWhindmar Saksit                 return DV_E_CLIPFORMAT;
261*63935f85SWhindmar Saksit 
262730a99c8SMark Jansen             if (pformatetcIn->tymed != TYMED_HGLOBAL)
263c2c66affSColin Finck             {
264730a99c8SMark Jansen                 UNIMPLEMENTED;
265730a99c8SMark Jansen                 return E_INVALIDARG;
266c2c66affSColin Finck             }
267c2c66affSColin Finck             else
268c2c66affSColin Finck             {
269730a99c8SMark Jansen                 *pmedium = m_Storage[n];
270730a99c8SMark Jansen                 return QueryInterface(IID_PPV_ARG(IUnknown, &pmedium->pUnkForRelease));
271c2c66affSColin Finck             }
272c2c66affSColin Finck         }
273730a99c8SMark Jansen     }
274730a99c8SMark Jansen 
275730a99c8SMark Jansen     return E_INVALIDARG;
276c2c66affSColin Finck }
277c2c66affSColin Finck 
GetDataHere(LPFORMATETC pformatetc,STGMEDIUM * pmedium)278c2c66affSColin Finck HRESULT WINAPI CIDLDataObj::GetDataHere(LPFORMATETC pformatetc, STGMEDIUM *pmedium)
279c2c66affSColin Finck {
280c2c66affSColin Finck     FIXME("(%p)->()\n", this);
281c2c66affSColin Finck     return E_NOTIMPL;
282c2c66affSColin Finck }
283c2c66affSColin Finck 
QueryGetData(LPFORMATETC pformatetc)284c2c66affSColin Finck HRESULT WINAPI CIDLDataObj::QueryGetData(LPFORMATETC pformatetc)
285c2c66affSColin Finck {
286c2c66affSColin Finck     TRACE("(%p)->(fmt=0x%08x tym=0x%08x)\n", this, pformatetc->cfFormat, pformatetc->tymed);
287c2c66affSColin Finck 
288730a99c8SMark Jansen     for (int n = 0; n < m_Formats.GetSize(); ++n)
289c2c66affSColin Finck     {
290730a99c8SMark Jansen         const FORMATETC& fmt = m_Formats[n];
291730a99c8SMark Jansen         if (fmt.cfFormat == pformatetc->cfFormat &&
292730a99c8SMark Jansen             fmt.dwAspect == pformatetc->dwAspect &&
293730a99c8SMark Jansen             fmt.tymed == pformatetc->tymed)
294c2c66affSColin Finck         {
295c2c66affSColin Finck             return S_OK;
296c2c66affSColin Finck         }
297c2c66affSColin Finck     }
298c2c66affSColin Finck 
299730a99c8SMark Jansen     return S_FALSE;
300c2c66affSColin Finck }
301c2c66affSColin Finck 
GetCanonicalFormatEtc(LPFORMATETC pformatectIn,LPFORMATETC pformatetcOut)302c2c66affSColin Finck HRESULT WINAPI CIDLDataObj::GetCanonicalFormatEtc(LPFORMATETC pformatectIn, LPFORMATETC pformatetcOut)
303c2c66affSColin Finck {
304730a99c8SMark Jansen     //FIXME("(%p)->()\n", this);
305730a99c8SMark Jansen     return DATA_S_SAMEFORMATETC;
306c2c66affSColin Finck }
307c2c66affSColin Finck 
SetData(LPFORMATETC pformatetc,STGMEDIUM * pmedium,BOOL fRelease)308c2c66affSColin Finck HRESULT WINAPI CIDLDataObj::SetData(LPFORMATETC pformatetc, STGMEDIUM *pmedium, BOOL fRelease)
309c2c66affSColin Finck {
310730a99c8SMark Jansen     if (!fRelease)
311730a99c8SMark Jansen         return E_INVALIDARG;
312730a99c8SMark Jansen 
313730a99c8SMark Jansen     for (int n = 0; n < m_Formats.GetSize(); ++n)
314c2c66affSColin Finck     {
315730a99c8SMark Jansen         const FORMATETC& fmt = m_Formats[n];
316730a99c8SMark Jansen         if (fmt.cfFormat == pformatetc->cfFormat &&
317730a99c8SMark Jansen             fmt.dwAspect == pformatetc->dwAspect &&
318730a99c8SMark Jansen             fmt.tymed == pformatetc->tymed)
319c2c66affSColin Finck         {
320730a99c8SMark Jansen             ReleaseStgMedium(&m_Storage[n]);
321730a99c8SMark Jansen             m_Storage[n] = *pmedium;
322c2c66affSColin Finck             return S_OK;
323c2c66affSColin Finck         }
324c2c66affSColin Finck     }
325c2c66affSColin Finck 
326730a99c8SMark Jansen     m_Formats.Add(*pformatetc);
327730a99c8SMark Jansen     m_Storage.Add(*pmedium);
328730a99c8SMark Jansen 
329730a99c8SMark Jansen     return S_OK;
330c2c66affSColin Finck }
331c2c66affSColin Finck 
EnumFormatEtc(DWORD dwDirection,IEnumFORMATETC ** ppenumFormatEtc)332c2c66affSColin Finck HRESULT WINAPI CIDLDataObj::EnumFormatEtc(DWORD dwDirection, IEnumFORMATETC **ppenumFormatEtc)
333c2c66affSColin Finck {
334c2c66affSColin Finck     TRACE("(%p)->()\n", this);
335c2c66affSColin Finck     *ppenumFormatEtc = NULL;
336c2c66affSColin Finck 
337c2c66affSColin Finck     /* only get data */
338c2c66affSColin Finck     if (DATADIR_GET == dwDirection)
339c2c66affSColin Finck     {
340730a99c8SMark Jansen         return IEnumFORMATETC_Constructor(m_Formats.GetSize(), m_Formats.GetData(), ppenumFormatEtc);
341c2c66affSColin Finck     }
342c2c66affSColin Finck 
343c2c66affSColin Finck     return E_NOTIMPL;
344c2c66affSColin Finck }
345c2c66affSColin Finck 
DAdvise(FORMATETC * pformatetc,DWORD advf,IAdviseSink * pAdvSink,DWORD * pdwConnection)346c2c66affSColin Finck HRESULT WINAPI CIDLDataObj::DAdvise(FORMATETC *pformatetc, DWORD advf, IAdviseSink *pAdvSink, DWORD *pdwConnection)
347c2c66affSColin Finck {
348730a99c8SMark Jansen     return OLE_E_ADVISENOTSUPPORTED;
349c2c66affSColin Finck }
350c2c66affSColin Finck 
DUnadvise(DWORD dwConnection)351c2c66affSColin Finck HRESULT WINAPI CIDLDataObj::DUnadvise(DWORD dwConnection)
352c2c66affSColin Finck {
353730a99c8SMark Jansen     return OLE_E_ADVISENOTSUPPORTED;
354c2c66affSColin Finck }
355c2c66affSColin Finck 
EnumDAdvise(IEnumSTATDATA ** ppenumAdvise)356c2c66affSColin Finck HRESULT WINAPI CIDLDataObj::EnumDAdvise(IEnumSTATDATA **ppenumAdvise)
357c2c66affSColin Finck {
358730a99c8SMark Jansen     return OLE_E_ADVISENOTSUPPORTED;
359c2c66affSColin Finck }
360c2c66affSColin Finck 
GetAsyncMode(BOOL * pfIsOpAsync)361c2c66affSColin Finck HRESULT WINAPI CIDLDataObj::GetAsyncMode(BOOL *pfIsOpAsync)
362c2c66affSColin Finck {
363c2c66affSColin Finck     TRACE("(%p)->()\n", this);
364730a99c8SMark Jansen     *pfIsOpAsync = m_doasync;
365c2c66affSColin Finck     return S_OK;
366c2c66affSColin Finck }
InOperation(BOOL * pfInAsyncOp)367c2c66affSColin Finck HRESULT WINAPI CIDLDataObj::InOperation(BOOL *pfInAsyncOp)
368c2c66affSColin Finck {
369c2c66affSColin Finck     FIXME("(%p)->()\n", this);
370c2c66affSColin Finck     return E_NOTIMPL;
371c2c66affSColin Finck }
SetAsyncMode(BOOL fDoOpAsync)372c2c66affSColin Finck HRESULT WINAPI CIDLDataObj::SetAsyncMode(BOOL fDoOpAsync)
373c2c66affSColin Finck {
374c2c66affSColin Finck     TRACE("(%p)->()\n", this);
375730a99c8SMark Jansen     m_doasync = fDoOpAsync;
376c2c66affSColin Finck     return S_OK;
377c2c66affSColin Finck }
378c2c66affSColin Finck 
StartOperation(IBindCtx * pbcReserved)379c2c66affSColin Finck HRESULT WINAPI CIDLDataObj::StartOperation(IBindCtx *pbcReserved)
380c2c66affSColin Finck {
381c2c66affSColin Finck     TRACE("(%p)->()\n", this);
382c2c66affSColin Finck     return E_NOTIMPL;
383c2c66affSColin Finck }
EndOperation(HRESULT hResult,IBindCtx * pbcReserved,DWORD dwEffects)384c2c66affSColin Finck HRESULT WINAPI CIDLDataObj::EndOperation(HRESULT hResult, IBindCtx *pbcReserved, DWORD dwEffects)
385c2c66affSColin Finck {
386c2c66affSColin Finck     TRACE("(%p)->()\n", this);
387c2c66affSColin Finck     return E_NOTIMPL;
388c2c66affSColin Finck }
389c2c66affSColin Finck 
390c2c66affSColin Finck 
391c2c66affSColin Finck 
392c2c66affSColin Finck /**************************************************************************
393c2c66affSColin Finck  *  IDataObject_Constructor
394c2c66affSColin Finck  */
IDataObject_Constructor(HWND hwndOwner,PCIDLIST_ABSOLUTE pMyPidl,PCUIDLIST_RELATIVE_ARRAY apidl,UINT cidl,BOOL bExtendedObject,IDataObject ** dataObject)395c3132711SMark Jansen HRESULT IDataObject_Constructor(HWND hwndOwner, PCIDLIST_ABSOLUTE pMyPidl, PCUIDLIST_RELATIVE_ARRAY apidl, UINT cidl, BOOL bExtendedObject, IDataObject **dataObject)
396c2c66affSColin Finck {
397ae2a85d0SHermès Bélusca-Maïto     if (!dataObject)
398ae2a85d0SHermès Bélusca-Maïto         return E_INVALIDARG;
399c3132711SMark Jansen     return ShellObjectCreatorInit<CIDLDataObj>(hwndOwner, pMyPidl, apidl, cidl, bExtendedObject, IID_PPV_ARG(IDataObject, dataObject));
400c2c66affSColin Finck }
401c2c66affSColin Finck 
402c2c66affSColin Finck /*************************************************************************
403c2c66affSColin Finck  * SHCreateDataObject            [SHELL32.@]
404c2c66affSColin Finck  *
405c2c66affSColin Finck  */
406c2c66affSColin Finck 
SHCreateDataObject(PCIDLIST_ABSOLUTE pidlFolder,UINT cidl,PCUITEMID_CHILD_ARRAY apidl,IDataObject * pdtInner,REFIID riid,void ** ppv)407c2c66affSColin Finck HRESULT WINAPI SHCreateDataObject(PCIDLIST_ABSOLUTE pidlFolder, UINT cidl, PCUITEMID_CHILD_ARRAY apidl, IDataObject *pdtInner, REFIID riid, void **ppv)
408c2c66affSColin Finck {
409c2c66affSColin Finck     if (IsEqualIID(riid, IID_IDataObject))
410c2c66affSColin Finck     {
411730a99c8SMark Jansen         if (pdtInner)
412730a99c8SMark Jansen             UNIMPLEMENTED;
413c3132711SMark Jansen         return IDataObject_Constructor(NULL, pidlFolder, apidl, cidl, TRUE, (IDataObject **)ppv);
414c2c66affSColin Finck     }
415c2c66affSColin Finck     return E_FAIL;
416c2c66affSColin Finck }
417d59f5ae2SMark Jansen 
418d59f5ae2SMark Jansen /*************************************************************************
419d59f5ae2SMark Jansen  * SHCreateFileDataObject       [SHELL32.740]
420d59f5ae2SMark Jansen  *
421d59f5ae2SMark Jansen  */
422d59f5ae2SMark Jansen 
SHCreateFileDataObject(PCIDLIST_ABSOLUTE pidlFolder,UINT cidl,PCUITEMID_CHILD_ARRAY apidl,IDataObject * pDataInner,IDataObject ** ppDataObj)423d59f5ae2SMark Jansen HRESULT WINAPI SHCreateFileDataObject(PCIDLIST_ABSOLUTE pidlFolder, UINT cidl, PCUITEMID_CHILD_ARRAY apidl, IDataObject* pDataInner, IDataObject** ppDataObj)
424d59f5ae2SMark Jansen {
425d59f5ae2SMark Jansen     if (pDataInner)
426d59f5ae2SMark Jansen         UNIMPLEMENTED;
427d59f5ae2SMark Jansen     return IDataObject_Constructor(NULL, pidlFolder, apidl, cidl, TRUE, ppDataObj);
428d59f5ae2SMark Jansen }
429