X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/8b4457965a0c0d0ef828dbf7cca3d2f947083054..a2d6d210991fb1d29570a46e0f26c7a4b9cf89ff:/src/common/dobjcmn.cpp diff --git a/src/common/dobjcmn.cpp b/src/common/dobjcmn.cpp index 5ecf2fc088..1dbe454bc0 100644 --- a/src/common/dobjcmn.cpp +++ b/src/common/dobjcmn.cpp @@ -18,13 +18,12 @@ #if wxUSE_DATAOBJ +#include "wx/dataobj.h" + #ifndef WX_PRECOMP #include "wx/app.h" - #include "wx/debug.h" #endif -#include "wx/dataobj.h" - // ---------------------------------------------------------------------------- // lists // ---------------------------------------------------------------------------- @@ -86,6 +85,7 @@ bool wxDataObjectBase::IsSupported(const wxDataFormat& format, wxDataObjectComposite::wxDataObjectComposite() { m_preferred = 0; + m_receivedFormat = wxFormatInvalid; } wxDataObjectComposite::~wxDataObjectComposite() @@ -120,6 +120,11 @@ void wxDataObjectComposite::Add(wxDataObjectSimple *dataObject, bool preferred) m_dataObjects.Append( dataObject ); } +wxDataFormat wxDataObjectComposite::GetReceivedFormat() const +{ + return m_receivedFormat; +} + wxDataFormat wxDataObjectComposite::GetPreferredFormat(Direction WXUNUSED(dir)) const { @@ -219,6 +224,7 @@ bool wxDataObjectComposite::SetData(const wxDataFormat& format, wxCHECK_MSG( dataObj, false, wxT("unsupported format in wxDataObjectComposite")); + m_receivedFormat = format; return dataObj->SetData( len, buf ); } @@ -238,19 +244,20 @@ size_t wxTextDataObject::GetDataSize(const wxDataFormat& format) const { wxCharBuffer buffer = GetConv(format).cWX2MB( GetText().c_str() ); - return buffer ? strlen( buffer ) + 1 : 0; + return buffer ? strlen( buffer ) : 0; } bool wxTextDataObject::GetDataHere(const wxDataFormat& format, void *buf) const { - if ( buf == NULL ) + if ( !buf ) return false; wxCharBuffer buffer = GetConv(format).cWX2MB( GetText().c_str() ); - if ( buffer == NULL ) + if ( !buffer ) return false; - strcpy( (char*)buf, buffer ); + memcpy( (char*) buf, buffer, GetDataSize(format) ); + // strcpy( (char*) buf, buffer ); return true; } @@ -262,8 +269,6 @@ bool wxTextDataObject::SetData(const wxDataFormat& format, return false; wxWCharBuffer buffer = GetConv(format).cMB2WX( (const char*)buf ); - if ( buffer == NULL ) - return false; SetText( buffer );