///////////////////////////////////////////////////////////////////////////////
-// Name: msw/ole/dataobj.cpp
+// Name: src/msw/ole/dataobj.cpp
// Purpose: implementation of wx[I]DataObject class
// Author: Vadim Zeitlin
// Modified by:
wxBitmap bitmap(bmp.bmWidth, bmp.bmHeight, bmp.bmPlanes);
bitmap.SetHBITMAP((WXHBITMAP)hbmp);
- if ( !bitmap.Ok() ) {
+ if ( !bitmap.IsOk() ) {
wxFAIL_MSG(wxT("pasting/dropping invalid bitmap"));
return false;
bool wxBitmapDataObject::GetDataHere(const wxDataFormat& format,
void *pBuf) const
{
- wxASSERT_MSG( m_bitmap.Ok(), wxT("copying invalid bitmap") );
+ wxASSERT_MSG( m_bitmap.IsOk(), wxT("copying invalid bitmap") );
HBITMAP hbmp = (HBITMAP)m_bitmap.GetHBITMAP();
if ( format.GetFormatId() == CF_DIB )
m_bitmap.SetHBITMAP((WXHBITMAP)hbmp);
- wxASSERT_MSG( m_bitmap.Ok(), wxT("pasting invalid bitmap") );
+ wxASSERT_MSG( m_bitmap.IsOk(), wxT("pasting invalid bitmap") );
return true;
}
return buffer;
}
-#if wxUSE_UNICODE
- virtual bool GetDataHere( void* buffer ) const
- {
- // CFSTR_SHELLURL is _always_ ANSI!
- wxCharBuffer char_buffer( GetDataSize() );
- wxCustomDataObject::GetDataHere( (void*)char_buffer.data() );
- wxString unicode_buffer( char_buffer, wxConvLibc );
- memcpy( buffer, unicode_buffer.c_str(),
- ( unicode_buffer.length() + 1 ) * sizeof(wxChar) );
-
- return true;
- }
- virtual bool GetDataHere(const wxDataFormat& WXUNUSED(format),
- void *buf) const
- { return GetDataHere(buf); }
-#endif
-
wxDECLARE_NO_COPY_CLASS(CFSTR_SHELLURLDataObject);
};
wxString url;
wxCHECK_MSG( m_dataObjectLast, url, wxT("no data in wxURLDataObject") );
- size_t len = m_dataObjectLast->GetDataSize();
+ if ( m_dataObjectLast->GetPreferredFormat() == CFSTR_SHELLURL )
+ {
+ const size_t len = m_dataObjectLast->GetDataSize();
+ if ( !len )
+ return wxString();
- m_dataObjectLast->GetDataHere(wxStringBuffer(url, len));
+ // CFSTR_SHELLURL is always ANSI so we need to convert it from it in
+ // Unicode build
+#if wxUSE_UNICODE
+ wxCharBuffer buf(len);
+
+ if ( m_dataObjectLast->GetDataHere(buf.data()) )
+ url = buf;
+#else // !wxUSE_UNICODE
+ // in ANSI build no conversion is necessary
+ m_dataObjectLast->GetDataHere(wxStringBuffer(url, len));
+#endif // wxUSE_UNICODE/!wxUSE_UNICODE
+ }
+ else // must be wxTextDataObject
+ {
+ url = static_cast<wxTextDataObject *>(m_dataObjectLast)->GetText();
+ }
return url;
}