]> git.saurik.com Git - wxWidgets.git/commitdiff
supporting promised file urls for transfer, see #14281
authorStefan Csomor <csomor@advancedconcepts.ch>
Mon, 18 Jun 2012 15:13:53 +0000 (15:13 +0000)
committerStefan Csomor <csomor@advancedconcepts.ch>
Mon, 18 Jun 2012 15:13:53 +0000 (15:13 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@71804 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/osx/carbon/dataobj.cpp

index 00bd2207aea0665a1368b04dbf0ab9816f140686..e3da7cd7ecee99c38c1c97431e28bffb43ac8817 100644 (file)
@@ -26,6 +26,7 @@
 #include "wx/mstream.h"
 #include "wx/metafile.h"
 #include "wx/tokenzr.h"
 #include "wx/mstream.h"
 #include "wx/metafile.h"
 #include "wx/tokenzr.h"
+#include "wx/filename.h"
 
 #include "wx/osx/private.h"
 
 
 #include "wx/osx/private.h"
 
@@ -33,7 +34,6 @@
     #include <QuickTime/QuickTime.h>
 #endif
 
     #include <QuickTime/QuickTime.h>
 #endif
 
-
 // ----------------------------------------------------------------------------
 // wxDataFormat
 // ----------------------------------------------------------------------------
 // ----------------------------------------------------------------------------
 // wxDataFormat
 // ----------------------------------------------------------------------------
@@ -186,7 +186,8 @@ void wxDataFormat::SetId( NativeFormat format )
     {
         m_type = wxDF_METAFILE;
     }
     {
         m_type = wxDF_METAFILE;
     }
-    else if (  UTTypeConformsTo( (CFStringRef)format, CFSTR("public.file-url") )  )
+    else if (  UTTypeConformsTo( (CFStringRef)format, CFSTR("public.file-url") ) ||
+             UTTypeConformsTo( (CFStringRef)format, kPasteboardTypeFileURLPromise))
     {
         m_type = wxDF_FILENAME;
     }
     {
         m_type = wxDF_FILENAME;
     }
@@ -424,13 +425,24 @@ bool wxDataObject::GetFromPasteboard( void * pb )
 
                     if ( dataFormat == flavorFormat )
                     {
 
                     if ( dataFormat == flavorFormat )
                     {
+                        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);
+                        }
                         err = PasteboardCopyItemFlavorData( pasteboard, itemID, flavorType , &flavorData );
                         if ( err == noErr )
                         {
                             flavorDataSize = CFDataGetLength( flavorData );
                             if (dataFormat.GetType() == wxDF_FILENAME )
                             {
                         err = PasteboardCopyItemFlavorData( pasteboard, itemID, flavorType , &flavorData );
                         if ( err == noErr )
                         {
                             flavorDataSize = CFDataGetLength( flavorData );
                             if (dataFormat.GetType() == wxDF_FILENAME )
                             {
-                                // revert the translation and decomposition to arrive at a proper utf8 string again
+                                 // revert the translation and decomposition to arrive at a proper utf8 string again
                                 CFURLRef url = CFURLCreateWithBytes( kCFAllocatorDefault, CFDataGetBytePtr( flavorData ), flavorDataSize, kCFStringEncodingUTF8, NULL );
                                 CFStringRef cfString = CFURLCopyFileSystemPath( url, kCFURLPOSIXPathStyle );
                                 CFRelease( url );
                                 CFURLRef url = CFURLCreateWithBytes( kCFAllocatorDefault, CFDataGetBytePtr( flavorData ), flavorDataSize, kCFStringEncodingUTF8, NULL );
                                 CFStringRef cfString = CFURLCopyFileSystemPath( url, kCFURLPOSIXPathStyle );
                                 CFRelease( url );