]> git.saurik.com Git - wxWidgets.git/blame - src/msw/ole/dataobj.cpp
In wxApp::OnIdle() check to see if there is not a current menubar and if
[wxWidgets.git] / src / msw / ole / dataobj.cpp
CommitLineData
269a5a34
VZ
1///////////////////////////////////////////////////////////////////////////////
2// Name: msw/ole/dataobj.cpp
3// Purpose: implementation of wx[I]DataObject class
4// Author: Vadim Zeitlin
3f4a0c5b 5// Modified by:
269a5a34
VZ
6// Created: 10.05.98
7// RCS-ID: $Id$
8// Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
6c9a19aa 9// Licence: wxWindows licence
269a5a34
VZ
10///////////////////////////////////////////////////////////////////////////////
11
12// ============================================================================
13// declarations
14// ============================================================================
15
16// ----------------------------------------------------------------------------
17// headers
18// ----------------------------------------------------------------------------
19
20#ifdef __GNUG__
0d0512bd 21 #pragma implementation "dataobj.h"
269a5a34
VZ
22#endif
23
24// For compilers that support precompilation, includes "wx.h".
25#include "wx/wxprec.h"
26
27#if defined(__BORLANDC__)
0d0512bd 28 #pragma hdrstop
269a5a34 29#endif
0d0512bd 30
7dee726c 31#ifndef WX_PRECOMP
0d0512bd
VZ
32 #include "wx/intl.h"
33 #include "wx/log.h"
7dee726c 34#endif
5260b1c5 35
3f480da3 36#include "wx/dataobj.h"
17b74d79 37
21709999
JS
38#if wxUSE_OLE && defined(__WIN32__) && !defined(__GNUWIN32_OLD__)
39
0d0512bd
VZ
40#include "wx/msw/private.h" // includes <windows.h>
41
a7b4607f
VZ
42// for some compilers, the entire ole2.h must be included, not only oleauto.h
43#if wxUSE_NORLANDER_HEADERS || defined(__WATCOMC__)
7dee726c
RS
44 #include <ole2.h>
45#endif
269a5a34 46
a7b4607f 47#include <oleauto.h>
8b85d24e
VZ
48#include <shlobj.h>
49
0d0512bd
VZ
50#include "wx/msw/ole/oleutils.h"
51
52#include "wx/msw/dib.h"
17b74d79 53
dcbd7ce2
VS
54#ifndef CFSTR_SHELLURL
55#define CFSTR_SHELLURL _T("UniformResourceLocator")
56#endif
57
269a5a34
VZ
58// ----------------------------------------------------------------------------
59// functions
60// ----------------------------------------------------------------------------
61
8e193f38 62#ifdef __WXDEBUG__
d59ceba5 63 static const wxChar *GetTymedName(DWORD tymed);
1e8335b0 64#else // !Debug
c5639a87 65 #define GetTymedName(tymed) _T("")
1e8335b0 66#endif // Debug/!Debug
269a5a34
VZ
67
68// ----------------------------------------------------------------------------
69// wxIEnumFORMATETC interface implementation
70// ----------------------------------------------------------------------------
8e193f38 71
269a5a34
VZ
72class wxIEnumFORMATETC : public IEnumFORMATETC
73{
74public:
8e193f38 75 wxIEnumFORMATETC(const wxDataFormat* formats, ULONG nCount);
33ac7e6f 76 virtual ~wxIEnumFORMATETC() { delete [] m_formats; }
269a5a34 77
8e193f38 78 DECLARE_IUNKNOWN_METHODS;
269a5a34 79
8e193f38
VZ
80 // IEnumFORMATETC
81 STDMETHODIMP Next(ULONG celt, FORMATETC *rgelt, ULONG *pceltFetched);
82 STDMETHODIMP Skip(ULONG celt);
83 STDMETHODIMP Reset();
84 STDMETHODIMP Clone(IEnumFORMATETC **ppenum);
269a5a34
VZ
85
86private:
8e193f38
VZ
87 CLIPFORMAT *m_formats; // formats we can provide data in
88 ULONG m_nCount, // number of formats we support
89 m_nCurrent; // current enum position
22f3361e
VZ
90
91 DECLARE_NO_COPY_CLASS(wxIEnumFORMATETC)
269a5a34
VZ
92};
93
94// ----------------------------------------------------------------------------
95// wxIDataObject implementation of IDataObject interface
96// ----------------------------------------------------------------------------
8e193f38 97
269a5a34
VZ
98class wxIDataObject : public IDataObject
99{
100public:
8e193f38 101 wxIDataObject(wxDataObject *pDataObject);
33ac7e6f 102 virtual ~wxIDataObject();
d59ceba5
VZ
103
104 // normally, wxDataObject controls our lifetime (i.e. we're deleted when it
105 // is), but in some cases, the situation is inversed, that is we delete it
106 // when this object is deleted - setting this flag enables such logic
107 void SetDeleteFlag() { m_mustDelete = TRUE; }
269a5a34 108
8e193f38 109 DECLARE_IUNKNOWN_METHODS;
269a5a34 110
8e193f38
VZ
111 // IDataObject
112 STDMETHODIMP GetData(FORMATETC *pformatetcIn, STGMEDIUM *pmedium);
113 STDMETHODIMP GetDataHere(FORMATETC *pformatetc, STGMEDIUM *pmedium);
114 STDMETHODIMP QueryGetData(FORMATETC *pformatetc);
115 STDMETHODIMP GetCanonicalFormatEtc(FORMATETC *In, FORMATETC *pOut);
116 STDMETHODIMP SetData(FORMATETC *pfetc, STGMEDIUM *pmedium, BOOL fRelease);
117 STDMETHODIMP EnumFormatEtc(DWORD dwDirection, IEnumFORMATETC **ppenumFEtc);
118 STDMETHODIMP DAdvise(FORMATETC *pfetc, DWORD ad, IAdviseSink *p, DWORD *pdw);
119 STDMETHODIMP DUnadvise(DWORD dwConnection);
120 STDMETHODIMP EnumDAdvise(IEnumSTATDATA **ppenumAdvise);
269a5a34
VZ
121
122private:
8e193f38 123 wxDataObject *m_pDataObject; // pointer to C++ class we belong to
d59ceba5
VZ
124
125 bool m_mustDelete;
22f3361e
VZ
126
127 DECLARE_NO_COPY_CLASS(wxIDataObject)
d59ceba5
VZ
128};
129
269a5a34
VZ
130// ============================================================================
131// implementation
132// ============================================================================
133
3f480da3
VZ
134// ----------------------------------------------------------------------------
135// wxDataFormat
136// ----------------------------------------------------------------------------
137
138void wxDataFormat::SetId(const wxChar *format)
139{
33ac7e6f 140 m_format = (wxDataFormat::NativeFormat)::RegisterClipboardFormat(format);
3f480da3
VZ
141 if ( !m_format )
142 {
143 wxLogError(_("Couldn't register clipboard format '%s'."), format);
144 }
145}
146
147wxString wxDataFormat::GetId() const
148{
149 static const int max = 256;
150
151 wxString s;
152
153 wxCHECK_MSG( !IsStandard(), s,
223d09f6 154 wxT("name of predefined format cannot be retrieved") );
3f480da3
VZ
155
156 int len = ::GetClipboardFormatName(m_format, s.GetWriteBuf(max), max);
157 s.UngetWriteBuf();
158
159 if ( !len )
160 {
161 wxLogError(_("The clipboard format '%d' doesn't exist."), m_format);
162 }
163
164 return s;
165}
166
269a5a34
VZ
167// ----------------------------------------------------------------------------
168// wxIEnumFORMATETC
169// ----------------------------------------------------------------------------
170
171BEGIN_IID_TABLE(wxIEnumFORMATETC)
8e193f38
VZ
172 ADD_IID(Unknown)
173 ADD_IID(EnumFORMATETC)
269a5a34
VZ
174END_IID_TABLE;
175
176IMPLEMENT_IUNKNOWN_METHODS(wxIEnumFORMATETC)
177
8e193f38 178wxIEnumFORMATETC::wxIEnumFORMATETC(const wxDataFormat *formats, ULONG nCount)
269a5a34 179{
8e193f38
VZ
180 m_nCurrent = 0;
181 m_nCount = nCount;
182 m_formats = new CLIPFORMAT[nCount];
183 for ( ULONG n = 0; n < nCount; n++ ) {
184 m_formats[n] = formats[n].GetFormatId();
185 }
269a5a34
VZ
186}
187
188STDMETHODIMP wxIEnumFORMATETC::Next(ULONG celt,
189 FORMATETC *rgelt,
33ac7e6f 190 ULONG *WXUNUSED(pceltFetched))
269a5a34 191{
8e193f38 192 wxLogTrace(wxTRACE_OleCalls, wxT("wxIEnumFORMATETC::Next"));
269a5a34 193
8e193f38
VZ
194 if ( celt > 1 ) {
195 // we only return 1 element at a time - mainly because I'm too lazy to
196 // implement something which you're never asked for anyhow
197 return S_FALSE;
198 }
269a5a34 199
8e193f38
VZ
200 if ( m_nCurrent < m_nCount ) {
201 FORMATETC format;
202 format.cfFormat = m_formats[m_nCurrent++];
203 format.ptd = NULL;
204 format.dwAspect = DVASPECT_CONTENT;
205 format.lindex = -1;
206 format.tymed = TYMED_HGLOBAL;
207 *rgelt = format;
269a5a34 208
8e193f38
VZ
209 return S_OK;
210 }
211 else {
212 // bad index
213 return S_FALSE;
214 }
269a5a34
VZ
215}
216
217STDMETHODIMP wxIEnumFORMATETC::Skip(ULONG celt)
218{
8e193f38
VZ
219 wxLogTrace(wxTRACE_OleCalls, wxT("wxIEnumFORMATETC::Skip"));
220
221 m_nCurrent += celt;
222 if ( m_nCurrent < m_nCount )
223 return S_OK;
269a5a34 224
8e193f38
VZ
225 // no, can't skip this many elements
226 m_nCurrent -= celt;
269a5a34 227
8e193f38 228 return S_FALSE;
269a5a34
VZ
229}
230
231STDMETHODIMP wxIEnumFORMATETC::Reset()
232{
8e193f38 233 wxLogTrace(wxTRACE_OleCalls, wxT("wxIEnumFORMATETC::Reset"));
269a5a34 234
8e193f38 235 m_nCurrent = 0;
269a5a34 236
8e193f38 237 return S_OK;
269a5a34
VZ
238}
239
240STDMETHODIMP wxIEnumFORMATETC::Clone(IEnumFORMATETC **ppenum)
241{
8e193f38
VZ
242 wxLogTrace(wxTRACE_OleCalls, wxT("wxIEnumFORMATETC::Clone"));
243
244 // unfortunately, we can't reuse the code in ctor - types are different
245 wxIEnumFORMATETC *pNew = new wxIEnumFORMATETC(NULL, 0);
246 pNew->m_nCount = m_nCount;
247 pNew->m_formats = new CLIPFORMAT[m_nCount];
248 for ( ULONG n = 0; n < m_nCount; n++ ) {
249 pNew->m_formats[n] = m_formats[n];
250 }
251 pNew->AddRef();
252 *ppenum = pNew;
269a5a34 253
8e193f38 254 return S_OK;
269a5a34
VZ
255}
256
257// ----------------------------------------------------------------------------
258// wxIDataObject
259// ----------------------------------------------------------------------------
260
261BEGIN_IID_TABLE(wxIDataObject)
8e193f38
VZ
262 ADD_IID(Unknown)
263 ADD_IID(DataObject)
269a5a34
VZ
264END_IID_TABLE;
265
266IMPLEMENT_IUNKNOWN_METHODS(wxIDataObject)
267
268wxIDataObject::wxIDataObject(wxDataObject *pDataObject)
269{
8e193f38 270 m_pDataObject = pDataObject;
d59ceba5
VZ
271 m_mustDelete = FALSE;
272}
273
274wxIDataObject::~wxIDataObject()
275{
276 if ( m_mustDelete )
277 {
278 delete m_pDataObject;
279 }
269a5a34
VZ
280}
281
282// get data functions
283STDMETHODIMP wxIDataObject::GetData(FORMATETC *pformatetcIn, STGMEDIUM *pmedium)
284{
8e193f38 285 wxLogTrace(wxTRACE_OleCalls, wxT("wxIDataObject::GetData"));
269a5a34 286
8e193f38
VZ
287 // is data is in our format?
288 HRESULT hr = QueryGetData(pformatetcIn);
289 if ( FAILED(hr) )
290 return hr;
269a5a34 291
8e193f38
VZ
292 // for the bitmaps and metafiles we use the handles instead of global memory
293 // to pass the data
f4d0cce0 294 wxDataFormat format = (wxDataFormat::NativeFormat)pformatetcIn->cfFormat;
269a5a34 295
8e193f38
VZ
296 switch ( format )
297 {
298 case wxDF_BITMAP:
299 pmedium->tymed = TYMED_GDI;
300 break;
301
d9317fd4
VZ
302 case wxDF_ENHMETAFILE:
303 pmedium->tymed = TYMED_ENHMF;
304 break;
305
8e193f38 306 case wxDF_METAFILE:
265b0c07
VZ
307 pmedium->hGlobal = GlobalAlloc(GMEM_MOVEABLE | GMEM_SHARE,
308 sizeof(METAFILEPICT));
309 if ( !pmedium->hGlobal ) {
f6bcfd97 310 wxLogLastError(wxT("GlobalAlloc"));
265b0c07
VZ
311 return E_OUTOFMEMORY;
312 }
8e193f38
VZ
313 pmedium->tymed = TYMED_MFPICT;
314 break;
315
316 default:
317 // alloc memory
318 size_t size = m_pDataObject->GetDataSize(format);
319 if ( !size ) {
320 // it probably means that the method is just not implemented
321 wxLogDebug(wxT("Invalid data size - can't be 0"));
322
323 return DV_E_FORMATETC;
324 }
325
9e2896e5
VZ
326 if ( !format.IsStandard() ) {
327 // for custom formats, put the size with the data - alloc the
328 // space for it
e1b435af
MB
329 // MB: not completely sure this is correct,
330 // even if I can't figure out what's wrong
331 size += m_pDataObject->GetBufferOffset( format );
9e2896e5
VZ
332 }
333
8e193f38
VZ
334 HGLOBAL hGlobal = GlobalAlloc(GMEM_MOVEABLE | GMEM_SHARE, size);
335 if ( hGlobal == NULL ) {
f6bcfd97 336 wxLogLastError(wxT("GlobalAlloc"));
8e193f38
VZ
337 return E_OUTOFMEMORY;
338 }
339
340 // copy data
341 pmedium->tymed = TYMED_HGLOBAL;
342 pmedium->hGlobal = hGlobal;
343 }
269a5a34 344
8e193f38
VZ
345 pmedium->pUnkForRelease = NULL;
346
347 // do copy the data
348 hr = GetDataHere(pformatetcIn, pmedium);
349 if ( FAILED(hr) ) {
350 // free resources we allocated
265b0c07 351 if ( pmedium->tymed & (TYMED_HGLOBAL | TYMED_MFPICT) ) {
8e193f38
VZ
352 GlobalFree(pmedium->hGlobal);
353 }
354
355 return hr;
356 }
269a5a34 357
8e193f38 358 return S_OK;
269a5a34
VZ
359}
360
361STDMETHODIMP wxIDataObject::GetDataHere(FORMATETC *pformatetc,
362 STGMEDIUM *pmedium)
363{
8e193f38 364 wxLogTrace(wxTRACE_OleCalls, wxT("wxIDataObject::GetDataHere"));
269a5a34 365
8e193f38
VZ
366 // put data in caller provided medium
367 switch ( pmedium->tymed )
368 {
369 case TYMED_GDI:
d59ceba5
VZ
370 if ( !m_pDataObject->GetDataHere(wxDF_BITMAP, &pmedium->hBitmap) )
371 return E_UNEXPECTED;
8e193f38
VZ
372 break;
373
d9317fd4
VZ
374 case TYMED_ENHMF:
375 if ( !m_pDataObject->GetDataHere(wxDF_ENHMETAFILE,
376 &pmedium->hEnhMetaFile) )
377 return E_UNEXPECTED;
378 break;
379
8e193f38 380 case TYMED_MFPICT:
d9317fd4
VZ
381 // fall through - we pass METAFILEPICT through HGLOBAL
382
8e193f38
VZ
383 case TYMED_HGLOBAL:
384 {
385 // copy data
9e2896e5
VZ
386 HGLOBAL hGlobal = pmedium->hGlobal;
387 void *pBuf = GlobalLock(hGlobal);
8e193f38
VZ
388 if ( pBuf == NULL ) {
389 wxLogLastError(wxT("GlobalLock"));
390 return E_OUTOFMEMORY;
391 }
392
e1b435af
MB
393 wxDataFormat format = pformatetc->cfFormat;
394 if ( !format.IsStandard() ) {
9e2896e5 395 // for custom formats, put the size with the data
e1b435af 396 pBuf = m_pDataObject->SetSizeInBuffer( pBuf, GlobalSize(hGlobal), format );
9e2896e5
VZ
397 }
398
d59ceba5
VZ
399 if ( !m_pDataObject->GetDataHere(format, pBuf) )
400 return E_UNEXPECTED;
8e193f38 401
9e2896e5 402 GlobalUnlock(hGlobal);
8e193f38
VZ
403 }
404 break;
405
406 default:
407 return DV_E_TYMED;
408 }
269a5a34 409
8e193f38 410 return S_OK;
269a5a34
VZ
411}
412
d26fad77 413
9e2896e5 414// set data functions
269a5a34
VZ
415STDMETHODIMP wxIDataObject::SetData(FORMATETC *pformatetc,
416 STGMEDIUM *pmedium,
417 BOOL fRelease)
418{
d59ceba5 419 wxLogTrace(wxTRACE_OleCalls, wxT("wxIDataObject::SetData"));
8e193f38 420
d59ceba5
VZ
421 switch ( pmedium->tymed )
422 {
423 case TYMED_GDI:
9e2896e5 424 m_pDataObject->SetData(wxDF_BITMAP, 0, &pmedium->hBitmap);
d59ceba5
VZ
425 break;
426
d9317fd4
VZ
427 case TYMED_ENHMF:
428 m_pDataObject->SetData(wxDF_ENHMETAFILE, 0, &pmedium->hEnhMetaFile);
429 break;
430
d59ceba5 431 case TYMED_MFPICT:
d9317fd4 432 // fall through - we pass METAFILEPICT through HGLOBAL
d59ceba5
VZ
433 case TYMED_HGLOBAL:
434 {
51edda6a
VZ
435 wxDataFormat format = pformatetc->cfFormat;
436
437 // this is quite weird, but for file drag and drop, explorer
438 // calls our SetData() with the formats we do *not* support!
439 //
440 // as we can't fix this bug in explorer (it's a bug because it
441 // should only use formats returned by EnumFormatEtc), do the
442 // check here
5015e022 443 if ( !m_pDataObject->IsSupported(format, wxDataObject::Set) ) {
51edda6a
VZ
444 // go away!
445 return DV_E_FORMATETC;
446 }
447
d59ceba5 448 // copy data
e1b435af 449 const void *pBuf = GlobalLock(pmedium->hGlobal);
d59ceba5 450 if ( pBuf == NULL ) {
f6bcfd97 451 wxLogLastError(wxT("GlobalLock"));
d59ceba5
VZ
452
453 return E_OUTOFMEMORY;
454 }
455
9e2896e5
VZ
456 // we've got a problem with SetData() here because the base
457 // class version requires the size parameter which we don't
458 // have anywhere in OLE data transfer - so we need to
459 // synthetise it for known formats and we suppose that all data
460 // in custom formats starts with a DWORD containing the size
461 size_t size;
51edda6a 462 switch ( format )
9e2896e5
VZ
463 {
464 case CF_TEXT:
465 case CF_OEMTEXT:
466 size = strlen((const char *)pBuf);
467 break;
790ad94f 468#if !defined(__WATCOMC__) && ! (defined(__BORLANDC__) && (__BORLANDC__ < 0x500))
9e2896e5 469 case CF_UNICODETEXT:
de85a884
VZ
470#if ( defined(__BORLANDC__) && (__BORLANDC__ > 0x530) ) \
471 || ( defined(__MWERKS__) && defined(__WXMSW__) )
e1b435af 472 size = std::wcslen((const wchar_t *)pBuf) * sizeof(wchar_t);
d834f22c 473#else
17ebae65 474 size = wxWcslen((const wchar_t *)pBuf) * sizeof(wchar_t);
d834f22c 475#endif
9e2896e5 476 break;
4d85bcd1 477#endif
9e2896e5
VZ
478 case CF_BITMAP:
479 case CF_HDROP:
480 // these formats don't use size at all, anyhow (but
481 // pass data by handle, which is always a single DWORD)
482 size = 0;
483 break;
484
8ee9d618
VZ
485 case CF_DIB:
486 // the handler will calculate size itself (it's too
487 // complicated to do it here)
488 size = 0;
489 break;
490
265b0c07
VZ
491 case CF_METAFILEPICT:
492 size = sizeof(METAFILEPICT);
493 break;
494
9e2896e5
VZ
495 default:
496 {
497 // we suppose that the size precedes the data
e1b435af 498 pBuf = m_pDataObject->GetSizeFromBuffer( pBuf, &size, format );
f0c5ebdc
RD
499 if (! format.IsStandard() ) {
500 // see GetData for coresponding increment
e1b435af 501 size -= m_pDataObject->GetBufferOffset( format );
f0c5ebdc 502 }
9e2896e5
VZ
503 }
504 }
505
9e2896e5 506 bool ok = m_pDataObject->SetData(format, size, pBuf);
d59ceba5
VZ
507
508 GlobalUnlock(pmedium->hGlobal);
9e2896e5
VZ
509
510 if ( !ok ) {
511 return E_UNEXPECTED;
512 }
d59ceba5
VZ
513 }
514 break;
515
516 default:
517 return DV_E_TYMED;
518 }
519
520 if ( fRelease ) {
265b0c07
VZ
521 // we own the medium, so we must release it - but do *not* free any
522 // data we pass by handle because we have copied it elsewhere
523 switch ( pmedium->tymed )
d59ceba5 524 {
265b0c07
VZ
525 case TYMED_GDI:
526 pmedium->hBitmap = 0;
527 break;
528
529 case TYMED_MFPICT:
530 pmedium->hMetaFilePict = 0;
531 break;
d9317fd4
VZ
532
533 case TYMED_ENHMF:
534 pmedium->hEnhMetaFile = 0;
535 break;
d59ceba5
VZ
536 }
537
538 ReleaseStgMedium(pmedium);
539 }
540
541 return S_OK;
269a5a34
VZ
542}
543
544// information functions
545STDMETHODIMP wxIDataObject::QueryGetData(FORMATETC *pformatetc)
546{
d59ceba5
VZ
547 // do we accept data in this format?
548 if ( pformatetc == NULL ) {
549 wxLogTrace(wxTRACE_OleCalls,
550 wxT("wxIDataObject::QueryGetData: invalid ptr."));
8e193f38 551
d59ceba5
VZ
552 return E_INVALIDARG;
553 }
269a5a34 554
d59ceba5
VZ
555 // the only one allowed by current COM implementation
556 if ( pformatetc->lindex != -1 ) {
557 wxLogTrace(wxTRACE_OleCalls,
9b601c24 558 wxT("wxIDataObject::QueryGetData: bad lindex %ld"),
d59ceba5 559 pformatetc->lindex);
269a5a34 560
d59ceba5
VZ
561 return DV_E_LINDEX;
562 }
269a5a34 563
d59ceba5
VZ
564 // we don't support anything other (THUMBNAIL, ICON, DOCPRINT...)
565 if ( pformatetc->dwAspect != DVASPECT_CONTENT ) {
566 wxLogTrace(wxTRACE_OleCalls,
9b601c24 567 wxT("wxIDataObject::QueryGetData: bad dwAspect %ld"),
d59ceba5
VZ
568 pformatetc->dwAspect);
569
570 return DV_E_DVASPECT;
571 }
572
573 // and now check the type of data requested
9e2896e5 574 wxDataFormat format = pformatetc->cfFormat;
d59ceba5 575 if ( m_pDataObject->IsSupportedFormat(format) ) {
d59ceba5 576 wxLogTrace(wxTRACE_OleCalls, wxT("wxIDataObject::QueryGetData: %s ok"),
1e8335b0 577 wxGetFormatName(format));
d59ceba5
VZ
578 }
579 else {
580 wxLogTrace(wxTRACE_OleCalls,
581 wxT("wxIDataObject::QueryGetData: %s unsupported"),
1e8335b0 582 wxGetFormatName(format));
9e2896e5 583
d59ceba5
VZ
584 return DV_E_FORMATETC;
585 }
586
587 // we only transfer data by global memory, except for some particular cases
588 DWORD tymed = pformatetc->tymed;
589 if ( (format == wxDF_BITMAP && !(tymed & TYMED_GDI)) &&
590 !(tymed & TYMED_HGLOBAL) ) {
591 // it's not what we're waiting for
d59ceba5
VZ
592 wxLogTrace(wxTRACE_OleCalls,
593 wxT("wxIDataObject::QueryGetData: %s != %s"),
594 GetTymedName(tymed),
595 GetTymedName(format == wxDF_BITMAP ? TYMED_GDI
596 : TYMED_HGLOBAL));
d59ceba5
VZ
597
598 return DV_E_TYMED;
599 }
600
269a5a34 601 return S_OK;
269a5a34
VZ
602}
603
33ac7e6f 604STDMETHODIMP wxIDataObject::GetCanonicalFormatEtc(FORMATETC *WXUNUSED(pFormatetcIn),
269a5a34
VZ
605 FORMATETC *pFormatetcOut)
606{
8e193f38
VZ
607 wxLogTrace(wxTRACE_OleCalls, wxT("wxIDataObject::GetCanonicalFormatEtc"));
608
609 // TODO we might want something better than this trivial implementation here
610 if ( pFormatetcOut != NULL )
611 pFormatetcOut->ptd = NULL;
269a5a34 612
8e193f38 613 return DATA_S_SAMEFORMATETC;
269a5a34
VZ
614}
615
9e2896e5 616STDMETHODIMP wxIDataObject::EnumFormatEtc(DWORD dwDir,
269a5a34
VZ
617 IEnumFORMATETC **ppenumFormatEtc)
618{
8e193f38 619 wxLogTrace(wxTRACE_OleCalls, wxT("wxIDataObject::EnumFormatEtc"));
269a5a34 620
9e2896e5
VZ
621 wxDataObject::Direction dir = dwDir == DATADIR_GET ? wxDataObject::Get
622 : wxDataObject::Set;
269a5a34 623
9e2896e5 624 size_t nFormatCount = m_pDataObject->GetFormatCount(dir);
33ac7e6f 625 wxDataFormat format;
c5639a87 626 wxDataFormat *formats;
9e2896e5
VZ
627 formats = nFormatCount == 1 ? &format : new wxDataFormat[nFormatCount];
628 m_pDataObject->GetAllFormats(formats, dir);
8e193f38
VZ
629
630 wxIEnumFORMATETC *pEnum = new wxIEnumFORMATETC(formats, nFormatCount);
631 pEnum->AddRef();
632 *ppenumFormatEtc = pEnum;
633
634 if ( formats != &format ) {
635 delete [] formats;
636 }
269a5a34 637
8e193f38 638 return S_OK;
269a5a34
VZ
639}
640
9e2896e5 641// ----------------------------------------------------------------------------
269a5a34 642// advise sink functions (not implemented)
9e2896e5
VZ
643// ----------------------------------------------------------------------------
644
33ac7e6f
KB
645STDMETHODIMP wxIDataObject::DAdvise(FORMATETC *WXUNUSED(pformatetc),
646 DWORD WXUNUSED(advf),
647 IAdviseSink *WXUNUSED(pAdvSink),
648 DWORD *WXUNUSED(pdwConnection))
269a5a34
VZ
649{
650 return OLE_E_ADVISENOTSUPPORTED;
651}
652
33ac7e6f 653STDMETHODIMP wxIDataObject::DUnadvise(DWORD WXUNUSED(dwConnection))
269a5a34
VZ
654{
655 return OLE_E_ADVISENOTSUPPORTED;
656}
657
33ac7e6f 658STDMETHODIMP wxIDataObject::EnumDAdvise(IEnumSTATDATA **WXUNUSED(ppenumAdvise))
269a5a34
VZ
659{
660 return OLE_E_ADVISENOTSUPPORTED;
661}
662
663// ----------------------------------------------------------------------------
664// wxDataObject
665// ----------------------------------------------------------------------------
666
667wxDataObject::wxDataObject()
668{
d59ceba5
VZ
669 m_pIDataObject = new wxIDataObject(this);
670 m_pIDataObject->AddRef();
269a5a34
VZ
671}
672
673wxDataObject::~wxDataObject()
674{
d59ceba5
VZ
675 ReleaseInterface(m_pIDataObject);
676}
677
678void wxDataObject::SetAutoDelete()
679{
680 ((wxIDataObject *)m_pIDataObject)->SetDeleteFlag();
681 m_pIDataObject->Release();
682
683 // so that the dtor doesnt' crash
684 m_pIDataObject = NULL;
269a5a34
VZ
685}
686
574c939e 687size_t wxDataObject::GetBufferOffset( const wxDataFormat& WXUNUSED(format) )
e1b435af
MB
688{
689 return sizeof(size_t);
690}
691
692const void* wxDataObject::GetSizeFromBuffer( const void* buffer, size_t* size,
574c939e 693 const wxDataFormat& WXUNUSED(format) )
e1b435af
MB
694{
695 size_t* p = (size_t*)buffer;
696 *size = *p;
697
698 return p + 1;
699}
700
701void* wxDataObject::SetSizeInBuffer( void* buffer, size_t size,
574c939e 702 const wxDataFormat& WXUNUSED(format) )
e1b435af
MB
703{
704 size_t* p = (size_t*)buffer;
705 *p = size;
706
707 return p + 1;
708}
709
d9317fd4 710#ifdef __WXDEBUG__
8e193f38 711
f6bcfd97 712const wxChar *wxDataObject::GetFormatName(wxDataFormat format)
d9317fd4
VZ
713{
714 // case 'xxx' is not a valid value for switch of enum 'wxDataFormat'
715 #ifdef __VISUALC__
716 #pragma warning(disable:4063)
717 #endif // VC++
718
f6bcfd97 719 static wxChar s_szBuf[256];
d9317fd4 720 switch ( format ) {
f6bcfd97
BP
721 case CF_TEXT: return wxT("CF_TEXT");
722 case CF_BITMAP: return wxT("CF_BITMAP");
723 case CF_METAFILEPICT: return wxT("CF_METAFILEPICT");
724 case CF_SYLK: return wxT("CF_SYLK");
725 case CF_DIF: return wxT("CF_DIF");
726 case CF_TIFF: return wxT("CF_TIFF");
727 case CF_OEMTEXT: return wxT("CF_OEMTEXT");
728 case CF_DIB: return wxT("CF_DIB");
729 case CF_PALETTE: return wxT("CF_PALETTE");
730 case CF_PENDATA: return wxT("CF_PENDATA");
731 case CF_RIFF: return wxT("CF_RIFF");
732 case CF_WAVE: return wxT("CF_WAVE");
733 case CF_UNICODETEXT: return wxT("CF_UNICODETEXT");
734 case CF_ENHMETAFILE: return wxT("CF_ENHMETAFILE");
735 case CF_HDROP: return wxT("CF_HDROP");
736 case CF_LOCALE: return wxT("CF_LOCALE");
8e193f38 737
d9317fd4 738 default:
c77ae1d9 739 if ( !::GetClipboardFormatName(format, s_szBuf, WXSIZEOF(s_szBuf)) )
d9317fd4
VZ
740 {
741 // it must be a new predefined format we don't know the name of
f6bcfd97 742 wxSprintf(s_szBuf, wxT("unknown CF (0x%04x)"), format.GetFormatId());
d9317fd4 743 }
8e193f38 744
d9317fd4 745 return s_szBuf;
8e193f38 746 }
1e8335b0 747
d9317fd4
VZ
748 #ifdef __VISUALC__
749 #pragma warning(default:4063)
750 #endif // VC++
269a5a34
VZ
751}
752
1e8335b0
VZ
753#endif // Debug
754
3f480da3 755// ----------------------------------------------------------------------------
9e2896e5 756// wxBitmapDataObject supports CF_DIB format
3f480da3
VZ
757// ----------------------------------------------------------------------------
758
9e2896e5 759size_t wxBitmapDataObject::GetDataSize() const
3f480da3 760{
22be0335 761 return wxDIB::ConvertFromBitmap(NULL, GetHbitmapOf(GetBitmap()));
3f480da3
VZ
762}
763
9e2896e5 764bool wxBitmapDataObject::GetDataHere(void *buf) const
3f480da3 765{
22be0335
VZ
766 BITMAPINFO * const pbi = (BITMAPINFO *)buf;
767
768 return wxDIB::ConvertFromBitmap(pbi, GetHbitmapOf(GetBitmap())) != 0;
3f480da3
VZ
769}
770
33ac7e6f 771bool wxBitmapDataObject::SetData(size_t WXUNUSED(len), const void *buf)
3f480da3 772{
22be0335 773 const BITMAPINFO * const pbmi = (const BITMAPINFO *)buf;
9e2896e5 774
22be0335 775 HBITMAP hbmp = wxDIB::ConvertToBitmap(pbmi);
3f480da3 776
22be0335
VZ
777 wxCHECK_MSG( hbmp, FALSE, wxT("pasting/dropping invalid bitmap") );
778
779 const BITMAPINFOHEADER * const pbmih = &pbmi->bmiHeader;
780 wxBitmap bitmap(pbmih->biWidth, pbmih->biHeight, pbmih->biBitCount);
781 bitmap.SetHBITMAP((WXHBITMAP)hbmp);
782
783 // TODO: create wxPalette if the bitmap has any
9e2896e5
VZ
784
785 SetBitmap(bitmap);
3f480da3 786
9e2896e5 787 return TRUE;
3f480da3
VZ
788}
789
9e2896e5
VZ
790// ----------------------------------------------------------------------------
791// wxBitmapDataObject2 supports CF_BITMAP format
792// ----------------------------------------------------------------------------
793
794// the bitmaps aren't passed by value as other types of data (i.e. by copying
795// the data into a global memory chunk and passing it to the clipboard or
796// another application or whatever), but by handle, so these generic functions
797// don't make much sense to them.
798
799size_t wxBitmapDataObject2::GetDataSize() const
3f480da3 800{
9e2896e5 801 return 0;
3f480da3
VZ
802}
803
9e2896e5 804bool wxBitmapDataObject2::GetDataHere(void *pBuf) const
3f480da3 805{
9e2896e5
VZ
806 // we put a bitmap handle into pBuf
807 *(WXHBITMAP *)pBuf = GetBitmap().GetHBITMAP();
808
809 return TRUE;
3f480da3
VZ
810}
811
265b0c07 812bool wxBitmapDataObject2::SetData(size_t WXUNUSED(len), const void *pBuf)
3f480da3 813{
9e2896e5 814 HBITMAP hbmp = *(HBITMAP *)pBuf;
3f480da3 815
9e2896e5
VZ
816 BITMAP bmp;
817 if ( !GetObject(hbmp, sizeof(BITMAP), &bmp) )
818 {
f6bcfd97 819 wxLogLastError(wxT("GetObject(HBITMAP)"));
9e2896e5 820 }
8e193f38 821
9e2896e5
VZ
822 wxBitmap bitmap(bmp.bmWidth, bmp.bmHeight, bmp.bmPlanes);
823 bitmap.SetHBITMAP((WXHBITMAP)hbmp);
d59ceba5 824
9e2896e5
VZ
825 if ( !bitmap.Ok() ) {
826 wxFAIL_MSG(wxT("pasting/dropping invalid bitmap"));
827
828 return FALSE;
829 }
830
831 SetBitmap(bitmap);
832
833 return TRUE;
d59ceba5
VZ
834}
835
9e2896e5 836#if 0
8e193f38
VZ
837
838size_t wxBitmapDataObject::GetDataSize(const wxDataFormat& format) const
839{
d59ceba5
VZ
840 if ( format.GetFormatId() == CF_DIB )
841 {
842 // create the DIB
843 ScreenHDC hdc;
844
845 // shouldn't be selected into a DC or GetDIBits() would fail
846 wxASSERT_MSG( !m_bitmap.GetSelectedInto(),
847 wxT("can't copy bitmap selected into wxMemoryDC") );
848
849 // first get the info
850 BITMAPINFO bi;
851 if ( !GetDIBits(hdc, (HBITMAP)m_bitmap.GetHBITMAP(), 0, 0,
852 NULL, &bi, DIB_RGB_COLORS) )
853 {
f6bcfd97 854 wxLogLastError(wxT("GetDIBits(NULL)"));
d59ceba5
VZ
855
856 return 0;
857 }
858
859 return sizeof(BITMAPINFO) + bi.bmiHeader.biSizeImage;
860 }
861 else // CF_BITMAP
862 {
863 // no data to copy - we don't pass HBITMAP via global memory
864 return 0;
865 }
8e193f38
VZ
866}
867
d59ceba5 868bool wxBitmapDataObject::GetDataHere(const wxDataFormat& format,
8e193f38
VZ
869 void *pBuf) const
870{
d59ceba5
VZ
871 wxASSERT_MSG( m_bitmap.Ok(), wxT("copying invalid bitmap") );
872
873 HBITMAP hbmp = (HBITMAP)m_bitmap.GetHBITMAP();
874 if ( format.GetFormatId() == CF_DIB )
875 {
876 // create the DIB
877 ScreenHDC hdc;
878
879 // shouldn't be selected into a DC or GetDIBits() would fail
880 wxASSERT_MSG( !m_bitmap.GetSelectedInto(),
881 wxT("can't copy bitmap selected into wxMemoryDC") );
882
883 // first get the info
884 BITMAPINFO *pbi = (BITMAPINFO *)pBuf;
885 if ( !GetDIBits(hdc, hbmp, 0, 0, NULL, pbi, DIB_RGB_COLORS) )
886 {
f6bcfd97 887 wxLogLastError(wxT("GetDIBits(NULL)"));
d59ceba5
VZ
888
889 return 0;
890 }
891
892 // and now copy the bits
893 if ( !GetDIBits(hdc, hbmp, 0, pbi->bmiHeader.biHeight, pbi + 1,
894 pbi, DIB_RGB_COLORS) )
895 {
f6bcfd97 896 wxLogLastError(wxT("GetDIBits"));
d59ceba5
VZ
897
898 return FALSE;
899 }
900 }
901 else // CF_BITMAP
902 {
903 // we put a bitmap handle into pBuf
904 *(HBITMAP *)pBuf = hbmp;
905 }
906
907 return TRUE;
908}
909
9e2896e5
VZ
910bool wxBitmapDataObject::SetData(const wxDataFormat& format,
911 size_t size, const void *pBuf)
d59ceba5
VZ
912{
913 HBITMAP hbmp;
914 if ( format.GetFormatId() == CF_DIB )
915 {
916 // here we get BITMAPINFO struct followed by the actual bitmap bits and
917 // BITMAPINFO starts with BITMAPINFOHEADER followed by colour info
918 ScreenHDC hdc;
919
920 BITMAPINFO *pbmi = (BITMAPINFO *)pBuf;
921 BITMAPINFOHEADER *pbmih = &pbmi->bmiHeader;
922 hbmp = CreateDIBitmap(hdc, pbmih, CBM_INIT,
923 pbmi + 1, pbmi, DIB_RGB_COLORS);
924 if ( !hbmp )
925 {
f6bcfd97 926 wxLogLastError(wxT("CreateDIBitmap"));
d59ceba5
VZ
927 }
928
929 m_bitmap.SetWidth(pbmih->biWidth);
930 m_bitmap.SetHeight(pbmih->biHeight);
931 }
932 else // CF_BITMAP
933 {
934 // it's easy with bitmaps: we pass them by handle
935 hbmp = *(HBITMAP *)pBuf;
936
937 BITMAP bmp;
938 if ( !GetObject(hbmp, sizeof(BITMAP), &bmp) )
939 {
f6bcfd97 940 wxLogLastError(wxT("GetObject(HBITMAP)"));
d59ceba5
VZ
941 }
942
943 m_bitmap.SetWidth(bmp.bmWidth);
944 m_bitmap.SetHeight(bmp.bmHeight);
945 m_bitmap.SetDepth(bmp.bmPlanes);
946 }
947
948 m_bitmap.SetHBITMAP((WXHBITMAP)hbmp);
949
950 wxASSERT_MSG( m_bitmap.Ok(), wxT("pasting invalid bitmap") );
951
952 return TRUE;
8e193f38
VZ
953}
954
9e2896e5
VZ
955#endif // 0
956
957// ----------------------------------------------------------------------------
958// wxFileDataObject
959// ----------------------------------------------------------------------------
960
961bool wxFileDataObject::SetData(size_t WXUNUSED(size), const void *pData)
962{
963 m_filenames.Empty();
964
965 // the documentation states that the first member of DROPFILES structure is
966 // a "DWORD offset of double NUL terminated file list". What they mean by
967 // this (I wonder if you see it immediately) is that the list starts at
968 // ((char *)&(pDropFiles.pFiles)) + pDropFiles.pFiles. We're also advised
969 // to use DragQueryFile to work with this structure, but not told where and
970 // how to get HDROP.
971 HDROP hdrop = (HDROP)pData; // NB: it works, but I'm not sure about it
972
973 // get number of files (magic value -1)
974 UINT nFiles = ::DragQueryFile(hdrop, (unsigned)-1, NULL, 0u);
975
51edda6a
VZ
976 wxCHECK_MSG ( nFiles != (UINT)-1, FALSE, wxT("wrong HDROP handle") );
977
9e2896e5
VZ
978 // for each file get the length, allocate memory and then get the name
979 wxString str;
980 UINT len, n;
981 for ( n = 0; n < nFiles; n++ ) {
982 // +1 for terminating NUL
983 len = ::DragQueryFile(hdrop, n, NULL, 0) + 1;
984
985 UINT len2 = ::DragQueryFile(hdrop, n, str.GetWriteBuf(len), len);
986 str.UngetWriteBuf();
987 m_filenames.Add(str);
988
989 if ( len2 != len - 1 ) {
f6bcfd97
BP
990 wxLogDebug(wxT("In wxFileDropTarget::OnDrop DragQueryFile returned\
991 %d characters, %d expected."), len2, len - 1);
9e2896e5
VZ
992 }
993 }
994
995 return TRUE;
996}
997
8b85d24e
VZ
998void wxFileDataObject::AddFile(const wxString& file)
999{
1000 // just add file to filenames array
1001 // all useful data (such as DROPFILES struct) will be
1002 // created later as necessary
1003 m_filenames.Add(file);
1004}
1005
1006size_t wxFileDataObject::GetDataSize() const
1007{
1008 // size returned will be the size of the DROPFILES structure,
1009 // plus the list of filesnames (null byte separated), plus
1010 // a double null at the end
1011
1012 // if no filenames in list, size is 0
dd10a646
VZ
1013 if ( m_filenames.GetCount() == 0 )
1014 return 0;
8b85d24e
VZ
1015
1016 // inital size of DROPFILES struct + null byte
1017 size_t sz = sizeof(DROPFILES) + 1;
1018
dd10a646
VZ
1019 size_t count = m_filenames.GetCount();
1020 for ( size_t i = 0; i < count; i++ )
8b85d24e
VZ
1021 {
1022 // add filename length plus null byte
1023 sz += m_filenames[i].Len() + 1;
1024 }
dd10a646 1025
8b85d24e
VZ
1026 return sz;
1027}
1028
1029bool wxFileDataObject::GetDataHere(void *pData) const
1030{
1031 // pData points to an externally allocated memory block
1032 // created using the size returned by GetDataSize()
1033
1034 // if pData is NULL, or there are no files, return
dd10a646
VZ
1035 if ( !pData || m_filenames.GetCount() == 0 )
1036 return FALSE;
8b85d24e
VZ
1037
1038 // convert data pointer to a DROPFILES struct pointer
1039 LPDROPFILES pDrop = (LPDROPFILES) pData;
1040
1041 // initialize DROPFILES struct
1042 pDrop->pFiles = sizeof(DROPFILES);
dd10a646
VZ
1043 pDrop->fNC = FALSE; // not non-client coords
1044#if wxUSE_UNICODE
1045 pDrop->fWide = TRUE;
1046#else // ANSI
8b85d24e 1047 pDrop->fWide = FALSE;
dd10a646 1048#endif // Unicode/Ansi
8b85d24e
VZ
1049
1050 // set start of filenames list (null separated)
51babd09 1051 wxChar *pbuf = (wxChar*) ((BYTE *)pDrop + sizeof(DROPFILES));
8b85d24e 1052
dd10a646
VZ
1053 size_t count = m_filenames.GetCount();
1054 for (size_t i = 0; i < count; i++ )
8b85d24e
VZ
1055 {
1056 // copy filename to pbuf and add null terminator
1057 size_t len = m_filenames[i].Len();
1058 memcpy(pbuf, m_filenames[i], len);
1059 pbuf += len;
dd10a646 1060 *pbuf++ = wxT('\0');
8b85d24e 1061 }
dd10a646 1062
c5639a87
VZ
1063 // add final null terminator
1064 *pbuf = wxT('\0');
8b85d24e
VZ
1065
1066 return TRUE;
1067}
1068
444ad3a7
VZ
1069// ----------------------------------------------------------------------------
1070// wxURLDataObject
1071// ----------------------------------------------------------------------------
1072
4a09bc4e 1073class CFSTR_SHELLURLDataObject : public wxCustomDataObject
e1b435af
MB
1074{
1075public:
1076 CFSTR_SHELLURLDataObject() : wxCustomDataObject(CFSTR_SHELLURL) {}
1077protected:
574c939e 1078 virtual size_t GetBufferOffset( const wxDataFormat& WXUNUSED(format) )
e1b435af
MB
1079 {
1080 return 0;
1081 }
1082
1083 virtual const void* GetSizeFromBuffer( const void* buffer, size_t* size,
574c939e 1084 const wxDataFormat& WXUNUSED(format) )
e1b435af
MB
1085 {
1086 // CFSTR_SHELLURL is _always_ ANSI text
1087 *size = strlen( (const char*)buffer );
1088
1089 return buffer;
1090 }
1091
574c939e
KB
1092 virtual void* SetSizeInBuffer( void* buffer, size_t WXUNUSED(size),
1093 const wxDataFormat& WXUNUSED(format) )
e1b435af
MB
1094 {
1095 return buffer;
1096 }
4a09bc4e 1097
e1b435af
MB
1098#if wxUSE_UNICODE
1099 virtual bool GetDataHere( void* buffer ) const
1100 {
1101 // CFSTR_SHELLURL is _always_ ANSI!
1102 wxCharBuffer char_buffer( GetDataSize() );
1103 wxCustomDataObject::GetDataHere( (void*)char_buffer.data() );
2b5f62a0 1104 wxString unicode_buffer( char_buffer, wxConvLibc );
e1b435af
MB
1105 memcpy( buffer, unicode_buffer.c_str(),
1106 ( unicode_buffer.length() + 1 ) * sizeof(wxChar) );
1107
1108 return TRUE;
1109 }
1110#endif
1111};
1112
4a09bc4e
RD
1113
1114
444ad3a7
VZ
1115wxURLDataObject::wxURLDataObject()
1116{
1117 // we support CF_TEXT and CFSTR_SHELLURL formats which are basicly the same
e1b435af 1118 // but it seems that some browsers only provide one of them so we have to
444ad3a7 1119 // support both
444ad3a7 1120 Add(new wxTextDataObject);
e6d318c2 1121 Add(new CFSTR_SHELLURLDataObject());
444ad3a7
VZ
1122
1123 // we don't have any data yet
1124 m_dataObjectLast = NULL;
1125}
1126
1127bool wxURLDataObject::SetData(const wxDataFormat& format,
1128 size_t len,
1129 const void *buf)
1130{
1131 m_dataObjectLast = GetObject(format);
1132
1133 wxCHECK_MSG( m_dataObjectLast, FALSE,
1134 wxT("unsupported format in wxURLDataObject"));
1135
1136 return m_dataObjectLast->SetData(len, buf);
1137}
1138
1139wxString wxURLDataObject::GetURL() const
1140{
1141 wxString url;
1142 wxCHECK_MSG( m_dataObjectLast, url, _T("no data in wxURLDataObject") );
1143
1144 size_t len = m_dataObjectLast->GetDataSize();
1145
e6d318c2 1146 m_dataObjectLast->GetDataHere(url.GetWriteBuf(len));
444ad3a7
VZ
1147 url.UngetWriteBuf();
1148
1149 return url;
1150}
1151
e6d318c2
RD
1152void wxURLDataObject::SetURL(const wxString& url)
1153{
4a09bc4e
RD
1154 SetData(wxDataFormat(wxUSE_UNICODE ? wxDF_UNICODETEXT : wxDF_TEXT),
1155 url.Length()+1, url.c_str());
1156
1157 // CFSTR_SHELLURL is always supposed to be ANSI...
1158 wxWX2MBbuf urlA = (wxWX2MBbuf)url.mbc_str();
1159 size_t len = strlen(urlA);
1160 SetData(wxDataFormat(CFSTR_SHELLURL), len+1, (const char*)urlA);
e6d318c2
RD
1161}
1162
269a5a34
VZ
1163// ----------------------------------------------------------------------------
1164// private functions
1165// ----------------------------------------------------------------------------
8e193f38
VZ
1166
1167#ifdef __WXDEBUG__
1168
d59ceba5
VZ
1169static const wxChar *GetTymedName(DWORD tymed)
1170{
1171 static wxChar s_szBuf[128];
1172 switch ( tymed ) {
1173 case TYMED_HGLOBAL: return wxT("TYMED_HGLOBAL");
1174 case TYMED_FILE: return wxT("TYMED_FILE");
1175 case TYMED_ISTREAM: return wxT("TYMED_ISTREAM");
1176 case TYMED_ISTORAGE: return wxT("TYMED_ISTORAGE");
1177 case TYMED_GDI: return wxT("TYMED_GDI");
1178 case TYMED_MFPICT: return wxT("TYMED_MFPICT");
1179 case TYMED_ENHMF: return wxT("TYMED_ENHMF");
1180 default:
dfd2e675 1181 wxSprintf(s_szBuf, wxT("type of media format %ld (unknown)"), tymed);
d59ceba5
VZ
1182 return s_szBuf;
1183 }
269a5a34 1184}
5260b1c5 1185
8e193f38 1186#endif // Debug
2845ddc2 1187
21709999
JS
1188#else // not using OLE at all
1189// ----------------------------------------------------------------------------
1190// wxDataObject
1191// ----------------------------------------------------------------------------
1192
1193wxDataObject::wxDataObject()
1194{
1195}
1196
1197wxDataObject::~wxDataObject()
1198{
1199}
1200
1201void wxDataObject::SetAutoDelete()
1202{
1203}
1204
bd52bee1 1205#ifdef __WXDEBUG__
21709999
JS
1206const wxChar *wxDataObject::GetFormatName(wxDataFormat format)
1207{
1208 return NULL;
1209}
bd52bee1 1210#endif
21709999
JS
1211
1212#endif
5260b1c5 1213