supporting failed data conversions
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@49037 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -283,38 +283,40 @@ void wxDataObject::AddToPasteboard( void * pb, int itemID )
|
|||||||
{
|
{
|
||||||
// empty the buffer because in some case GetDataHere does not fill buf
|
// empty the buffer because in some case GetDataHere does not fill buf
|
||||||
memset( buf, 0, sz );
|
memset( buf, 0, sz );
|
||||||
GetDataHere( array[ i ], buf );
|
if ( GetDataHere( array[ i ], buf ) )
|
||||||
int counter = 1 ;
|
|
||||||
if ( thisFormat.GetType() == wxDF_FILENAME )
|
|
||||||
{
|
{
|
||||||
// the data is D-normalized UTF8 strings of filenames delimited with \n
|
int counter = 1 ;
|
||||||
char *fname = strtok((char*) buf,"\n");
|
if ( thisFormat.GetType() == wxDF_FILENAME )
|
||||||
while (fname != NULL)
|
|
||||||
{
|
{
|
||||||
// translate the filepath into a fileurl and put that into the pasteobard
|
// the data is D-normalized UTF8 strings of filenames delimited with \n
|
||||||
CFStringRef path = CFStringCreateWithBytes(NULL,(UInt8*)fname,strlen(fname),kCFStringEncodingUTF8,false);
|
char *fname = strtok((char*) buf,"\n");
|
||||||
CFURLRef url = CFURLCreateWithFileSystemPath(NULL, path , kCFURLPOSIXPathStyle, false);
|
while (fname != NULL)
|
||||||
CFRelease(path);
|
{
|
||||||
CFDataRef data = CFURLCreateData(NULL,url,kCFStringEncodingUTF8,true);
|
// translate the filepath into a fileurl and put that into the pasteobard
|
||||||
CFRelease(url);
|
CFStringRef path = CFStringCreateWithBytes(NULL,(UInt8*)fname,strlen(fname),kCFStringEncodingUTF8,false);
|
||||||
PasteboardPutItemFlavor( pasteboard, (PasteboardItemID) counter,
|
CFURLRef url = CFURLCreateWithFileSystemPath(NULL, path , kCFURLPOSIXPathStyle, false);
|
||||||
(CFStringRef) thisFormat.GetFormatId() , data, kPasteboardFlavorNoFlags);
|
CFRelease(path);
|
||||||
CFRelease( data );
|
CFDataRef data = CFURLCreateData(NULL,url,kCFStringEncodingUTF8,true);
|
||||||
counter++;
|
CFRelease(url);
|
||||||
fname = strtok (NULL,"\n");
|
PasteboardPutItemFlavor( pasteboard, (PasteboardItemID) counter,
|
||||||
}
|
(CFStringRef) thisFormat.GetFormatId() , data, kPasteboardFlavorNoFlags);
|
||||||
|
CFRelease( data );
|
||||||
|
counter++;
|
||||||
|
fname = strtok (NULL,"\n");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
CFDataRef data = CFDataCreate( kCFAllocatorDefault, (UInt8*)buf, datasize );
|
|
||||||
if ( thisFormat.GetType() == wxDF_TEXT )
|
|
||||||
PasteboardPutItemFlavor( pasteboard, (PasteboardItemID) itemID,
|
|
||||||
CFSTR("com.apple.traditional-mac-plain-text") , data, kPasteboardFlavorNoFlags);
|
|
||||||
else
|
else
|
||||||
PasteboardPutItemFlavor( pasteboard, (PasteboardItemID) itemID,
|
{
|
||||||
(CFStringRef) thisFormat.GetFormatId() , data, kPasteboardFlavorNoFlags);
|
CFDataRef data = CFDataCreate( kCFAllocatorDefault, (UInt8*)buf, datasize );
|
||||||
CFRelease( data );
|
if ( thisFormat.GetType() == wxDF_TEXT )
|
||||||
|
PasteboardPutItemFlavor( pasteboard, (PasteboardItemID) itemID,
|
||||||
|
CFSTR("com.apple.traditional-mac-plain-text") , data, kPasteboardFlavorNoFlags);
|
||||||
|
else
|
||||||
|
PasteboardPutItemFlavor( pasteboard, (PasteboardItemID) itemID,
|
||||||
|
(CFStringRef) thisFormat.GetFormatId() , data, kPasteboardFlavorNoFlags);
|
||||||
|
CFRelease( data );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
free( buf );
|
free( buf );
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user