+bool wxClipboard::AddData( wxDataObject *data )
+{
+ wxCHECK_MSG( m_open, FALSE, wxT("clipboard not open") );
+
+ wxCHECK_MSG( data, FALSE, wxT("data is invalid") );
+
+ /* we can only store one wxDataObject */
+ Clear();
+
+ m_data = data;
+
+ /* get formats from wxDataObjects */
+ wxDataFormat *array = new wxDataFormat[ m_data->GetFormatCount() ];
+ m_data->GetAllFormats( array );
+
+ for (size_t i = 0; i < m_data->GetFormatCount(); i++)
+ {
+ wxLogTrace( TRACE_CLIPBOARD,
+ wxT("wxClipboard now supports atom %s"),
+ array[i].GetId().c_str() );
+
+ size_t sz = data->GetDataSize( array[i] ) ;
+ void* buf = malloc( sz + 1 ) ;
+ if ( buf )
+ {
+ data->GetDataHere( array[i] , buf ) ;
+ OSType mactype = 0 ;
+ switch ( array[i].GetType() )
+ {
+ case wxDF_TEXT:
+ case wxDF_OEMTEXT:
+ mactype = kScrapFlavorTypeText ;
+ break ;
+ #if wxUSE_UNICODE
+ case wxDF_UNICODETEXT :
+ mactype = kScrapFlavorTypeUnicode ;
+ break ;
+ #endif
+ #if wxUSE_DRAG_AND_DROP
+ case wxDF_METAFILE:
+ mactype = kScrapFlavorTypePicture ;
+ break ;
+ #endif
+ case wxDF_BITMAP:
+ case wxDF_DIB:
+ mactype = kScrapFlavorTypePicture ;
+ break ;
+ default:
+ break ;
+ }
+ UMAPutScrap( sz , mactype , buf ) ;
+ free( buf ) ;
+ }
+ }