]> git.saurik.com Git - wxWidgets.git/blobdiff - src/osx/carbon/dataobj.cpp
make sure we have a default handling the quit command, see #12402
[wxWidgets.git] / src / osx / carbon / dataobj.cpp
index f270fb06a09ace2af88749d4981f6f61460fd997..e02e880b1a8e594d049abf41049f127672d3b743 100644 (file)
@@ -394,13 +394,15 @@ bool wxDataObject::IsFormatInPasteboard( void * pb, const wxDataFormat &dataForm
 bool wxDataObject::GetFromPasteboard( void * pb )
 {
     PasteboardRef pasteboard = (PasteboardRef) pb;
 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 ];
     wxDataFormat *array = new wxDataFormat[ formatcount ];
-    array[0] = GetPreferredFormat();
-    GetAllFormats( &array[1] );
+    GetAllFormats(array, wxDataObject::Set);
+    
     ItemCount itemCount = 0;
     wxString filenamesPassed;
     bool transferred = false;
     ItemCount itemCount = 0;
     wxString filenamesPassed;
     bool transferred = false;
+    bool pastelocationset = false;
 
     // we synchronize here once again, so we don't mind which flags get returned
     PasteboardSynchronize( pasteboard );
 
     // we synchronize here once again, so we don't mind which flags get returned
     PasteboardSynchronize( pasteboard );
@@ -444,14 +446,18 @@ bool wxDataObject::GetFromPasteboard( void * pb )
                     {
                         if ( UTTypeConformsTo( (CFStringRef)flavorType, kPasteboardTypeFileURLPromise) )
                         {
                     {
                         if ( UTTypeConformsTo( (CFStringRef)flavorType, kPasteboardTypeFileURLPromise) )
                         {
-                            wxString tempdir = wxFileName::GetTempDir() + wxFILE_SEP_PATH + "wxtemp.XXXXXX";
-                            char* result = mkdtemp((char*)tempdir.fn_str().data());
-                            
-                            if (!result)
-                                continue;
-                            
-                            wxCFRef<CFURLRef> dest(CFURLCreateFromFileSystemRepresentation(NULL,(const UInt8*)result,strlen(result),true));
-                            PasteboardSetPasteLocation(pasteboard, dest);
+                            if ( !pastelocationset )
+                            {
+                                wxString tempdir = wxFileName::GetTempDir() + wxFILE_SEP_PATH + "wxtemp.XXXXXX";
+                                char* result = mkdtemp((char*)tempdir.fn_str().data());
+                                
+                                if (!result)
+                                    continue;
+                                
+                                wxCFRef<CFURLRef> dest(CFURLCreateFromFileSystemRepresentation(NULL,(const UInt8*)result,strlen(result),true));
+                                PasteboardSetPasteLocation(pasteboard, dest);
+                                pastelocationset = true;
+                           }
                         }
                         else if ( flavorFormat.GetType() != wxDF_PRIVATE )
                         {
                         }
                         else if ( flavorFormat.GetType() != wxDF_PRIVATE )
                         {
@@ -533,10 +539,9 @@ bool wxDataObject::GetFromPasteboard( void * pb )
 bool wxDataObject::HasDataInPasteboard( void * pb )
 {
     PasteboardRef pasteboard = (PasteboardRef) 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 ];
     wxDataFormat *array = new wxDataFormat[ formatcount ];
-    array[0] = GetPreferredFormat();
-    GetAllFormats( &array[1] );
+    GetAllFormats(array, wxDataObject::Set);
     ItemCount itemCount = 0;
     bool hasData = false;
 
     ItemCount itemCount = 0;
     bool hasData = false;
 
@@ -589,6 +594,51 @@ bool wxDataObject::HasDataInPasteboard( void * pb )
     return hasData;
 }
 
     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
 // ----------------------------------------------------------------------------
 // ----------------------------------------------------------------------------
 // wxTextDataObject
 // ----------------------------------------------------------------------------
@@ -597,8 +647,8 @@ bool wxDataObject::HasDataInPasteboard( void * pb )
 void wxTextDataObject::GetAllFormats(wxDataFormat *formats,
                                      wxDataObjectBase::Direction WXUNUSED(dir)) const
 {
 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
 
 }
 #endif