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
This commit is contained in:
@@ -26,6 +26,7 @@
|
|||||||
#include "wx/mstream.h"
|
#include "wx/mstream.h"
|
||||||
#include "wx/metafile.h"
|
#include "wx/metafile.h"
|
||||||
#include "wx/tokenzr.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>
|
#include <QuickTime/QuickTime.h>
|
||||||
#endif
|
#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 );
|
err = PasteboardCopyItemFlavorData( pasteboard, itemID, flavorType , &flavorData );
|
||||||
if ( err == noErr )
|
if ( err == noErr )
|
||||||
{
|
{
|
||||||
flavorDataSize = CFDataGetLength( flavorData );
|
flavorDataSize = CFDataGetLength( flavorData );
|
||||||
if (dataFormat.GetType() == wxDF_FILENAME )
|
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 );
|
CFURLRef url = CFURLCreateWithBytes( kCFAllocatorDefault, CFDataGetBytePtr( flavorData ), flavorDataSize, kCFStringEncodingUTF8, NULL );
|
||||||
CFStringRef cfString = CFURLCopyFileSystemPath( url, kCFURLPOSIXPathStyle );
|
CFStringRef cfString = CFURLCopyFileSystemPath( url, kCFURLPOSIXPathStyle );
|
||||||
CFRelease( url );
|
CFRelease( url );
|
||||||
|
Reference in New Issue
Block a user