From fb35086d8cb6fc7eff3fdb0b3d604f8eb92339b4 Mon Sep 17 00:00:00 2001 From: Stefan Csomor Date: Mon, 18 Jun 2012 15:13:53 +0000 Subject: [PATCH] supporting promised file urls for transfer, see #14281 git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@71804 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/osx/carbon/dataobj.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/osx/carbon/dataobj.cpp b/src/osx/carbon/dataobj.cpp index 00bd2207ae..e3da7cd7ec 100644 --- a/src/osx/carbon/dataobj.cpp +++ b/src/osx/carbon/dataobj.cpp @@ -26,6 +26,7 @@ #include "wx/mstream.h" #include "wx/metafile.h" #include "wx/tokenzr.h" +#include "wx/filename.h" #include "wx/osx/private.h" @@ -33,7 +34,6 @@ #include #endif - // ---------------------------------------------------------------------------- // wxDataFormat // ---------------------------------------------------------------------------- @@ -186,7 +186,8 @@ void wxDataFormat::SetId( NativeFormat format ) { 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; } @@ -424,13 +425,24 @@ bool wxDataObject::GetFromPasteboard( void * pb ) 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 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 ) { - // 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 ); -- 2.45.2