X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/d26fad77f7e50e7fda9b9172e05db8413d991cb4..e4a8a172020d5e3ee08660420142e702799c7878:/src/msw/ole/dataobj.cpp?ds=sidebyside diff --git a/src/msw/ole/dataobj.cpp b/src/msw/ole/dataobj.cpp index b5c4b6f593..6a4ef30670 100644 --- a/src/msw/ole/dataobj.cpp +++ b/src/msw/ole/dataobj.cpp @@ -17,7 +17,7 @@ // headers // ---------------------------------------------------------------------------- -#ifdef __GNUG__ +#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) #pragma implementation "dataobj.h" #endif @@ -39,8 +39,12 @@ #include "wx/msw/private.h" // includes +#ifdef __WXWINCE__ +#include +#endif + // for some compilers, the entire ole2.h must be included, not only oleauto.h -#if wxUSE_NORLANDER_HEADERS || defined(__WATCOMC__) +#if wxUSE_NORLANDER_HEADERS || defined(__WATCOMC__) || defined(__WXWINCE__) #include #endif @@ -62,7 +66,7 @@ #ifdef __WXDEBUG__ static const wxChar *GetTymedName(DWORD tymed); #else // !Debug - #define GetTymedName(tymed) _T("") + #define GetTymedName(tymed) wxEmptyString #endif // Debug/!Debug // ---------------------------------------------------------------------------- @@ -153,8 +157,7 @@ wxString wxDataFormat::GetId() const wxCHECK_MSG( !IsStandard(), s, wxT("name of predefined format cannot be retrieved") ); - int len = ::GetClipboardFormatName(m_format, s.GetWriteBuf(max), max); - s.UngetWriteBuf(); + int len = ::GetClipboardFormatName(m_format, wxStringBuffer(s, max), max); if ( !len ) { @@ -187,31 +190,27 @@ wxIEnumFORMATETC::wxIEnumFORMATETC(const wxDataFormat *formats, ULONG nCount) STDMETHODIMP wxIEnumFORMATETC::Next(ULONG celt, FORMATETC *rgelt, - ULONG *WXUNUSED(pceltFetched)) + ULONG *pceltFetched) { wxLogTrace(wxTRACE_OleCalls, wxT("wxIEnumFORMATETC::Next")); - if ( celt > 1 ) { - // we only return 1 element at a time - mainly because I'm too lazy to - // implement something which you're never asked for anyhow - return S_FALSE; - } - - if ( m_nCurrent < m_nCount ) { + ULONG numFetched = 0; + while (m_nCurrent < m_nCount && numFetched < celt) { FORMATETC format; format.cfFormat = m_formats[m_nCurrent++]; format.ptd = NULL; format.dwAspect = DVASPECT_CONTENT; format.lindex = -1; format.tymed = TYMED_HGLOBAL; - *rgelt = format; - return S_OK; - } - else { - // bad index - return S_FALSE; + *rgelt++ = format; + numFetched++; } + + if (pceltFetched) + *pceltFetched = numFetched; + + return numFetched == celt ? S_OK : S_FALSE; } STDMETHODIMP wxIEnumFORMATETC::Skip(ULONG celt) @@ -303,6 +302,7 @@ STDMETHODIMP wxIDataObject::GetData(FORMATETC *pformatetcIn, STGMEDIUM *pmedium) pmedium->tymed = TYMED_ENHMF; break; +#ifndef __WXWINCE__ case wxDF_METAFILE: pmedium->hGlobal = GlobalAlloc(GMEM_MOVEABLE | GMEM_SHARE, sizeof(METAFILEPICT)); @@ -312,7 +312,7 @@ STDMETHODIMP wxIDataObject::GetData(FORMATETC *pformatetcIn, STGMEDIUM *pmedium) } pmedium->tymed = TYMED_MFPICT; break; - +#endif default: // alloc memory size_t size = m_pDataObject->GetDataSize(format); @@ -410,19 +410,6 @@ STDMETHODIMP wxIDataObject::GetDataHere(FORMATETC *pformatetc, return S_OK; } -#ifdef __DIGITALMARS__ -extern "C" -size_t wxDataObjectComposite::GetBufferOffset( const wxDataFormat& format ); - -extern "C" -const void* wxDataObjectComposite::GetSizeFromBuffer( const void* buffer, - size_t* size, - const wxDataFormat& format ) ; -extern "C" -void* wxDataObjectComposite::SetSizeInBuffer( void* buffer, size_t size, - const wxDataFormat& format ) ; - -#endif // set data functions STDMETHODIMP wxIDataObject::SetData(FORMATETC *pformatetc, @@ -489,11 +476,13 @@ STDMETHODIMP wxIDataObject::SetData(FORMATETC *pformatetc, break; #endif case CF_BITMAP: +#ifndef __WXWINCE__ case CF_HDROP: // these formats don't use size at all, anyhow (but // pass data by handle, which is always a single DWORD) size = 0; break; +#endif case CF_DIB: // the handler will calculate size itself (it's too @@ -501,10 +490,11 @@ STDMETHODIMP wxIDataObject::SetData(FORMATETC *pformatetc, size = 0; break; +#ifndef __WXWINCE__ case CF_METAFILEPICT: size = sizeof(METAFILEPICT); break; - +#endif default: { // we suppose that the size precedes the data @@ -771,18 +761,27 @@ const wxChar *wxDataObject::GetFormatName(wxDataFormat format) size_t wxBitmapDataObject::GetDataSize() const { +#if wxUSE_WXDIB return wxDIB::ConvertFromBitmap(NULL, GetHbitmapOf(GetBitmap())); +#else + return 0; +#endif } bool wxBitmapDataObject::GetDataHere(void *buf) const { +#if wxUSE_WXDIB BITMAPINFO * const pbi = (BITMAPINFO *)buf; return wxDIB::ConvertFromBitmap(pbi, GetHbitmapOf(GetBitmap())) != 0; +#else + return FALSE; +#endif } bool wxBitmapDataObject::SetData(size_t WXUNUSED(len), const void *buf) { +#if wxUSE_WXDIB const BITMAPINFO * const pbmi = (const BITMAPINFO *)buf; HBITMAP hbmp = wxDIB::ConvertToBitmap(pbmi); @@ -798,6 +797,9 @@ bool wxBitmapDataObject::SetData(size_t WXUNUSED(len), const void *buf) SetBitmap(bitmap); return TRUE; +#else + return FALSE; +#endif } // ---------------------------------------------------------------------------- @@ -973,12 +975,7 @@ bool wxBitmapDataObject::SetData(const wxDataFormat& format, bool wxFileDataObject::SetData(size_t WXUNUSED(size), const void *pData) { -//FIX ME __DIGITALMARS__ -#if defined (__DIGITALMARS__) - //DragQueryFile not in any library - wxLogDebug(wxT("In wxFileDataObject::SetData code not executed - no Digital Mars library ")); - return FALSE; -#endif +#ifndef __WXWINCE__ m_filenames.Empty(); // the documentation states that the first member of DROPFILES structure is @@ -1001,8 +998,7 @@ bool wxFileDataObject::SetData(size_t WXUNUSED(size), const void *pData) // +1 for terminating NUL len = ::DragQueryFile(hdrop, n, NULL, 0) + 1; - UINT len2 = ::DragQueryFile(hdrop, n, str.GetWriteBuf(len), len); - str.UngetWriteBuf(); + UINT len2 = ::DragQueryFile(hdrop, n, wxStringBuffer(str, len), len); m_filenames.Add(str); if ( len2 != len - 1 ) { @@ -1012,6 +1008,9 @@ bool wxFileDataObject::SetData(size_t WXUNUSED(size), const void *pData) } return TRUE; +#else + return FALSE; +#endif } void wxFileDataObject::AddFile(const wxString& file) @@ -1024,6 +1023,7 @@ void wxFileDataObject::AddFile(const wxString& file) size_t wxFileDataObject::GetDataSize() const { +#ifndef __WXWINCE__ // size returned will be the size of the DROPFILES structure, // plus the list of filesnames (null byte separated), plus // a double null at the end @@ -1043,10 +1043,14 @@ size_t wxFileDataObject::GetDataSize() const } return sz; +#else + return 0; +#endif } bool wxFileDataObject::GetDataHere(void *pData) const { +#ifndef __WXWINCE__ // pData points to an externally allocated memory block // created using the size returned by GetDataSize() @@ -1083,6 +1087,9 @@ bool wxFileDataObject::GetDataHere(void *pData) const *pbuf = wxT('\0'); return TRUE; +#else + return FALSE; +#endif } // ---------------------------------------------------------------------------- @@ -1126,7 +1133,12 @@ protected: return TRUE; } + virtual bool GetDataHere(const wxDataFormat& WXUNUSED(format), + void *buf) const + { return GetDataHere(buf); } #endif + + DECLARE_NO_COPY_CLASS(CFSTR_SHELLURLDataObject) }; @@ -1162,8 +1174,7 @@ wxString wxURLDataObject::GetURL() const size_t len = m_dataObjectLast->GetDataSize(); - m_dataObjectLast->GetDataHere(url.GetWriteBuf(len)); - url.UngetWriteBuf(); + m_dataObjectLast->GetDataHere(wxStringBuffer(url, len)); return url; }