X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/3c7037000b0570f921c73481f222fde6bc194d35..48e05747043db02c4e9d2e286eca4fdf5dee7881:/src/osx/carbon/dataobj.cpp diff --git a/src/osx/carbon/dataobj.cpp b/src/osx/carbon/dataobj.cpp index 754b6386c8..e02e880b1a 100644 --- a/src/osx/carbon/dataobj.cpp +++ b/src/osx/carbon/dataobj.cpp @@ -394,10 +394,11 @@ bool wxDataObject::IsFormatInPasteboard( void * pb, const wxDataFormat &dataForm bool wxDataObject::GetFromPasteboard( void * pb ) { PasteboardRef pasteboard = (PasteboardRef) pb; - size_t formatcount = GetFormatCount() + 1; + + size_t formatcount = GetFormatCount(wxDataObject::Set); wxDataFormat *array = new wxDataFormat[ formatcount ]; - array[0] = GetPreferredFormat(); - GetAllFormats( &array[1] ); + GetAllFormats(array, wxDataObject::Set); + ItemCount itemCount = 0; wxString filenamesPassed; bool transferred = false; @@ -538,10 +539,9 @@ bool wxDataObject::GetFromPasteboard( void * pb ) bool wxDataObject::HasDataInPasteboard( void * pb ) { PasteboardRef pasteboard = (PasteboardRef) pb; - size_t formatcount = GetFormatCount() + 1; + size_t formatcount = GetFormatCount(wxDataObject::Set); wxDataFormat *array = new wxDataFormat[ formatcount ]; - array[0] = GetPreferredFormat(); - GetAllFormats( &array[1] ); + GetAllFormats(array, wxDataObject::Set); ItemCount itemCount = 0; bool hasData = false; @@ -594,6 +594,51 @@ bool wxDataObject::HasDataInPasteboard( void * pb ) return hasData; } +#if wxOSX_USE_COCOA + +void wxDataObject::AddSupportedTypes( void* cfarray) +{ + size_t nFormats = GetFormatCount(wxDataObject::Set); + wxDataFormat *array = new wxDataFormat[nFormats]; + GetAllFormats(array, wxDataObject::Set); + + for (size_t i = 0; i < nFormats; i++) + { + wxDataFormat dataFormat = array[ i ]; + + if ( dataFormat.GetType() == wxDF_UNICODETEXT || dataFormat.GetType() == wxDF_TEXT ) + { + CFArrayAppendValue((CFMutableArrayRef)cfarray, kUTTypeUTF16PlainText); + CFArrayAppendValue((CFMutableArrayRef)cfarray, kUTTypePlainText); + } + else if ( dataFormat.GetType() == wxDF_FILENAME ) + { + CFArrayAppendValue((CFMutableArrayRef)cfarray, kUTTypeFileURL); + CFArrayAppendValue((CFMutableArrayRef)cfarray, kPasteboardTypeFileURLPromise); + } + else if ( dataFormat.GetType() == wxDF_HTML ) + { + CFArrayAppendValue((CFMutableArrayRef)cfarray, kUTTypeHTML); + } + else if ( dataFormat.GetType() == wxDF_BITMAP ) + { + CFArrayAppendValue((CFMutableArrayRef)cfarray, kUTTypeTIFF); + CFArrayAppendValue((CFMutableArrayRef)cfarray, kUTTypePICT); + } + else if ( dataFormat.GetType() == wxDF_METAFILE ) + { + CFArrayAppendValue((CFMutableArrayRef)cfarray, kUTTypePDF); + } + else if ( dataFormat.GetType() == wxDF_PRIVATE ) + { + CFArrayAppendValue((CFMutableArrayRef)cfarray, (CFStringRef) dataFormat.GetFormatId()); + } + } + delete[] array; +} + +#endif + // ---------------------------------------------------------------------------- // wxTextDataObject // ---------------------------------------------------------------------------- @@ -602,8 +647,8 @@ bool wxDataObject::HasDataInPasteboard( void * pb ) void wxTextDataObject::GetAllFormats(wxDataFormat *formats, wxDataObjectBase::Direction WXUNUSED(dir)) const { - *formats++ = wxDataFormat( wxDF_TEXT ); - *formats = wxDataFormat( wxDF_UNICODETEXT ); + *formats++ = wxDataFormat(wxDF_UNICODETEXT); + *formats = wxDataFormat(wxDF_TEXT); } #endif