+ if (( err = GetScrapFlavorFlags( scrapRef, dataFormat.GetFormatId(), &flavorFlags )) == noErr)
+ {
+ if (( err = GetScrapFlavorSize( scrapRef, dataFormat.GetFormatId(), &byteCount )) == noErr)
+ {
+ Size allocSize = byteCount ;
+ if ( dataFormat.GetType() == wxDF_TEXT )
+ allocSize += 1 ;
+ else if ( dataFormat.GetType() == wxDF_UNICODETEXT )
+ allocSize += 2 ;
+
+ data = new char[ allocSize ] ;
+
+ if (( err = GetScrapFlavorData( scrapRef, dataFormat.GetFormatId(), &byteCount , data )) == noErr )
+ {
+ *len = allocSize ;
+ if ( dataFormat.GetType() == wxDF_TEXT )
+ ((char*)data)[byteCount] = 0 ;
+ if ( dataFormat.GetType() == wxDF_UNICODETEXT )
+ {
+ // "data" format is UTF16, so 2 bytes = one character
+ // wxChar size depends on platform, so just clear last 2 bytes
+ ((char*)data)[byteCount] = 0;
+ ((char*)data)[byteCount+1] = 0;
+ }
+ }
+ else
+ {
+ delete[] ((char *)data) ;
+ data = NULL ;
+ }
+ }
+ }
+ }