]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/dobjcmn.cpp
don't use implicit wxString->char*/wchar_t* conversion, it will not be available...
[wxWidgets.git] / src / common / dobjcmn.cpp
index cbed32d72f9ba9c76ba6d303b6c71d540b8c6a7f..1dbe454bc0f126bf38b716475fdbed8cd23bf362 100644 (file)
 
 #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 );
 }
 
@@ -243,12 +249,15 @@ size_t wxTextDataObject::GetDataSize(const wxDataFormat& format) const
 
 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 )
+        return false;
 
-    strcpy( (char*)buf, buffer );
+    memcpy( (char*) buf, buffer, GetDataSize(format) );
+    // strcpy( (char*) buf, buffer );
 
     return true;
 }