]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/ole/dataobj.cpp
Corrected spelling of 'unrecognized'
[wxWidgets.git] / src / msw / ole / dataobj.cpp
index 43f372295c24117044ac977521c5d63f8d2bb119..9beda808951dd59927f3f4e7cab8af540dee76a3 100644 (file)
   #pragma hdrstop
 #endif
 
-#include  <wx/defs.h>
+#include "wx/defs.h"
 
 #if defined(__WIN32__) && !defined(__GNUWIN32__)
 
-#include  <wx/log.h>
-#include  <wx/msw/ole/oleutils.h>
-#include  <wx/msw/ole/dataobj.h>
+#include "wx/log.h"
+#include "wx/dataobj.h"
+
+#include <windows.h>
+#include <oleauto.h>
 
 #ifndef __WIN32__
   #include <ole2.h>
   #include <olestd.h>
 #endif
 
+#include  "wx/msw/ole/oleutils.h"
+
 // ----------------------------------------------------------------------------
 // functions
 // ----------------------------------------------------------------------------
@@ -97,6 +101,39 @@ private:
 // implementation
 // ============================================================================
 
+// ----------------------------------------------------------------------------
+// wxDataFormat
+// ----------------------------------------------------------------------------
+
+void wxDataFormat::SetId(const wxChar *format)
+{
+    m_format = ::RegisterClipboardFormat(format);
+    if ( !m_format )
+    {
+        wxLogError(_("Couldn't register clipboard format '%s'."), format);
+    }
+}
+
+wxString wxDataFormat::GetId() const
+{
+    static const int max = 256;
+
+    wxString s;
+
+    wxCHECK_MSG( !IsStandard(), s,
+                 _T("name of predefined format cannot be retrieved") );
+
+    int len = ::GetClipboardFormatName(m_format, s.GetWriteBuf(max), max);
+    s.UngetWriteBuf();
+
+    if ( !len )
+    {
+        wxLogError(_("The clipboard format '%d' doesn't exist."), m_format);
+    }
+
+    return s;
+}
+
 // ----------------------------------------------------------------------------
 // wxIEnumFORMATETC
 // ----------------------------------------------------------------------------
@@ -280,14 +317,14 @@ STDMETHODIMP wxIDataObject::QueryGetData(FORMATETC *pformatetc)
   }
 
   // and now check the type of data requested
-  if ( m_pDataObject->IsSupportedFormat((wxDataFormatpformatetc->cfFormat) ) {
+  if ( m_pDataObject->IsSupportedFormat((wxDataFormatId)pformatetc->cfFormat) ) {
     wxLogTrace("wxIDataObject::QueryGetData: %s ok",
-               wxDataObject::GetFormatName((wxDataFormatpformatetc->cfFormat));
+               wxDataObject::GetFormatName((wxDataFormatId)pformatetc->cfFormat));
     return S_OK;
   }
   else {
     wxLogTrace("wxIDataObject::QueryGetData: %s unsupported",
-               wxDataObject::GetFormatName((wxDataFormatpformatetc->cfFormat));
+               wxDataObject::GetFormatName((wxDataFormatId)pformatetc->cfFormat));
     return DV_E_FORMATETC;
   }
 }
@@ -395,6 +432,47 @@ const char *wxDataObject::GetFormatName(wxDataFormat format)
 #endif // Debug
 }
 
+// ----------------------------------------------------------------------------
+// wxPrivateDataObject
+// ----------------------------------------------------------------------------
+
+wxPrivateDataObject::wxPrivateDataObject()
+{
+    m_size = 0;
+    m_data = NULL;
+}
+
+void wxPrivateDataObject::Free()
+{
+    if ( m_data )
+        free(m_data);
+}
+
+void wxPrivateDataObject::SetData( const void *data, size_t size )
+{
+    Free();
+
+    m_size = size;
+    m_data = malloc(size);
+
+    memcpy( m_data, data, size );
+}
+
+void wxPrivateDataObject::WriteData( void *dest ) const
+{
+    WriteData( m_data, dest );
+}
+
+size_t wxPrivateDataObject::GetSize() const
+{
+    return m_size;
+}
+
+void wxPrivateDataObject::WriteData( const void *data, void *dest ) const
+{
+    memcpy( dest, data, GetSize() );
+}
+
 // ----------------------------------------------------------------------------
 // private functions
 // ----------------------------------------------------------------------------