@@ -967,218 +967,6 @@ MCPrinter *MCScreenDC::createprinter(void)
967967
968968// //////////////////////////////////////////////////////////////////////////////
969969
970- static uindex_t s_clipboard_generation = 0 ;
971- static MCPasteboard *s_local_clipboard = nil;
972-
973- bool MCConvertStyledTextToUTF8 (MCDataRef p_in, MCDataRef& r_out)
974- {
975- MCObject *t_object;
976- t_object = MCObject::unpickle (p_in, MCtemplatefield -> getstack ());
977- if (t_object != NULL )
978- {
979- MCParagraph *t_paragraphs;
980- MCAutoStringRef t_exported;
981- t_paragraphs = ((MCStyledText *)t_object) -> getparagraphs ();
982- bool t_success;
983- t_success = true ;
984-
985- // MW-2012-02-21: [[ FieldExport ]] Use the new plain text export method.
986- if (t_paragraphs != NULL )
987- {
988- t_success = MCtemplatefield -> exportasplaintext (t_paragraphs, 0 , INT32_MAX, &t_exported)
989- && MCStringEncode (*t_exported, kMCStringEncodingUTF8 , false , r_out);
990- }
991- else
992- r_out = MCValueRetain (kMCEmptyData );
993-
994- delete t_object;
995- return t_success;
996- }
997-
998- return false ;
999- }
1000-
1001- bool MCConvertUnicodeTextToUTF8 (MCDataRef p_in, MCDataRef &r_out)
1002- {
1003- MCAutoStringRef t_pivot;
1004- return MCStringDecode (p_in, kMCStringEncodingUTF16 , false , &t_pivot)
1005- && MCStringEncode (*t_pivot, kMCStringEncodingUTF8 , false , r_out);
1006- }
1007-
1008- bool MCConvertTextToUTF8 (MCDataRef p_in, MCDataRef &r_out)
1009- {
1010- MCAutoStringRef t_pivot;
1011- return MCStringDecode (p_in, kMCStringEncodingNative , false , &t_pivot)
1012- && MCStringEncode (*t_pivot, kMCStringEncodingUTF8 , false , r_out);
1013- }
1014-
1015- bool MCConvertIdentity (MCDataRef p_in, MCDataRef &r_out)
1016- {
1017- r_out = MCValueRetain (p_in);
1018- return true ;
1019- }
1020-
1021- static struct { MCTransferType type; MCPlatformPasteboardFlavor flavor; bool (*convert)(MCDataRef p_in, MCDataRef &r_out); } s_pasteboard_fetchers[] =
1022- {
1023- { TRANSFER_TYPE_STYLED_TEXT, kMCPlatformPasteboardFlavorRTF , MCConvertStyledTextToRTF },
1024- { TRANSFER_TYPE_STYLED_TEXT, kMCPlatformPasteboardFlavorUTF8 , MCConvertStyledTextToUTF8 },
1025- { TRANSFER_TYPE_UNICODE_TEXT, kMCPlatformPasteboardFlavorUTF8 , MCConvertUnicodeTextToUTF8 },
1026- { TRANSFER_TYPE_TEXT, kMCPlatformPasteboardFlavorUTF8 , MCConvertTextToUTF8 },
1027- { TRANSFER_TYPE_IMAGE, kMCPlatformPasteboardFlavorPNG , MCConvertIdentity },
1028- { TRANSFER_TYPE_IMAGE, kMCPlatformPasteboardFlavorGIF , MCConvertIdentity },
1029- { TRANSFER_TYPE_IMAGE, kMCPlatformPasteboardFlavorJPEG , MCConvertIdentity },
1030- { TRANSFER_TYPE_FILES, kMCPlatformPasteboardFlavorFiles , MCConvertIdentity },
1031- { TRANSFER_TYPE_OBJECTS, kMCPlatformPasteboardFlavorObjects , MCConvertIdentity },
1032- };
1033-
1034- static bool fetch_pasteboard (MCPasteboard *p_pasteboard, MCPlatformPasteboardFlavor p_flavor, void *& r_data, size_t & r_data_size)
1035- {
1036- MCTransferType *t_types;
1037- size_t t_type_count;
1038- if (!p_pasteboard -> Query (t_types, t_type_count))
1039- return false ;
1040-
1041- for (uindex_t i = 0 ; i < sizeof (s_pasteboard_fetchers) / sizeof (s_pasteboard_fetchers[0 ]); i++)
1042- for (uindex_t j = 0 ; j < t_type_count; j++)
1043- if (s_pasteboard_fetchers[i] . type == t_types[j] && s_pasteboard_fetchers[i] . flavor == p_flavor)
1044- {
1045- MCAutoDataRef t_data;
1046- if (!p_pasteboard -> Fetch (t_types[j], &t_data))
1047- return false ;
1048-
1049- bool t_success;
1050- t_success = false ;
1051-
1052- MCAutoDataRef t_new_data;
1053- if (s_pasteboard_fetchers[i] . convert (*t_data, &t_new_data))
1054- {
1055- if (MCMemoryAllocateCopy (MCDataGetBytePtr (*t_new_data), MCDataGetLength (*t_new_data), r_data))
1056- {
1057- r_data_size = MCDataGetLength (*t_new_data);
1058- t_success = true ;
1059- }
1060- }
1061-
1062- return t_success;
1063- }
1064-
1065- return true ;
1066- }
1067-
1068- static bool fetch_clipboard (MCPlatformPasteboardFlavor p_flavor, void *& r_data, size_t & r_data_size)
1069- {
1070- if (s_local_clipboard == nil)
1071- return false ;
1072-
1073- return fetch_pasteboard (s_local_clipboard, p_flavor, r_data, r_data_size);
1074- }
1075-
1076- void MCScreenDC::flushclipboard (void )
1077- {
1078- }
1079-
1080- bool MCScreenDC::ownsclipboard (void )
1081- {
1082- MCPlatformPasteboardRef t_pasteboard;
1083- MCPlatformGetClipboard (t_pasteboard);
1084- if (MCPlatformPasteboardGetGeneration (t_pasteboard) == s_clipboard_generation)
1085- return true ;
1086-
1087- if (s_local_clipboard != nil)
1088- {
1089- s_local_clipboard -> Release ();
1090- s_local_clipboard = nil;
1091- }
1092-
1093- return false ;
1094- }
1095-
1096- bool MCScreenDC::setclipboard (MCPasteboard *p_pasteboard)
1097- {
1098- MCPlatformPasteboardRef t_clipboard;
1099- MCPlatformGetClipboard (t_clipboard);
1100-
1101- MCPlatformPasteboardClear (t_clipboard);
1102- if (s_local_clipboard != nil)
1103- {
1104- s_local_clipboard -> Release ();
1105- s_local_clipboard = nil;
1106- }
1107-
1108- MCTransferType *t_types;
1109- size_t t_type_count;
1110- if (!p_pasteboard -> Query (t_types, t_type_count))
1111- return false ;
1112-
1113- // We must set the pasteboard here as we might get our data callback invoked
1114- // whilst setting data.
1115- s_local_clipboard = p_pasteboard;
1116- s_local_clipboard -> Retain ();
1117-
1118- for (uindex_t i = 0 ; i < t_type_count; i++)
1119- {
1120- MCPlatformPasteboardFlavor t_flavors[2 ];
1121- uindex_t t_flavor_count;
1122- t_flavor_count = 0 ;
1123-
1124- switch (t_types[i])
1125- {
1126- case TRANSFER_TYPE_TEXT:
1127- case TRANSFER_TYPE_UNICODE_TEXT:
1128- t_flavors[t_flavor_count++] = kMCPlatformPasteboardFlavorUTF8 ;
1129- break ;
1130- case TRANSFER_TYPE_STYLED_TEXT:
1131- t_flavors[t_flavor_count++] = kMCPlatformPasteboardFlavorRTF ;
1132- t_flavors[t_flavor_count++] = kMCPlatformPasteboardFlavorUTF8 ;
1133- break ;
1134- case TRANSFER_TYPE_IMAGE:
1135- {
1136- MCAutoDataRef t_data;
1137- if (p_pasteboard -> Fetch (TRANSFER_TYPE_IMAGE, &t_data))
1138- {
1139- if (MCImageDataIsPNG (*t_data))
1140- t_flavors[t_flavor_count++] = kMCPlatformPasteboardFlavorPNG ;
1141- if (MCImageDataIsGIF (*t_data))
1142- t_flavors[t_flavor_count++] = kMCPlatformPasteboardFlavorGIF ;
1143- if (MCImageDataIsJPEG (*t_data))
1144- t_flavors[t_flavor_count++] = kMCPlatformPasteboardFlavorJPEG ;
1145- }
1146- }
1147- break ;
1148- case TRANSFER_TYPE_FILES:
1149- t_flavors[t_flavor_count++] = kMCPlatformPasteboardFlavorFiles ;
1150- break ;
1151- case TRANSFER_TYPE_OBJECTS:
1152- t_flavors[t_flavor_count++] = kMCPlatformPasteboardFlavorObjects ;
1153- break ;
1154- case TRANSFER_TYPE_PRIVATE:
1155- break ;
1156- }
1157-
1158- if (t_flavor_count != 0 )
1159- MCPlatformPasteboardStore (t_clipboard, t_flavors, t_flavor_count, (void *)fetch_clipboard);
1160- }
1161-
1162- s_clipboard_generation = MCPlatformPasteboardGetGeneration (t_clipboard);
1163-
1164- return true ;
1165- }
1166-
1167- MCPasteboard *MCScreenDC::getclipboard (void )
1168- {
1169- MCPlatformPasteboardRef t_pasteboard;
1170- MCPlatformGetClipboard (t_pasteboard);
1171-
1172- MCPasteboard *t_clipboard;
1173- t_clipboard = new MCSystemPasteboard (t_pasteboard);
1174-
1175- MCPlatformPasteboardRelease (t_pasteboard);
1176-
1177- return t_clipboard;
1178- }
1179-
1180- // //////////////////////////////////////////////////////////////////////////////
1181-
1182970// TD-2013-07-01: [[ DynamicFonts ]]
1183971bool MCScreenDC::loadfont (MCStringRef p_path, bool p_globally, void *& r_loaded_font_handle)
1184972{
@@ -1252,16 +1040,6 @@ MCScriptEnvironment *MCScreenDC::createscriptenvironment(MCStringRef p_language)
12521040
12531041// //////////////////////////////////////////////////////////////////////////////
12541042
1255- static MCPasteboard *s_local_dragboard = nil;
1256-
1257- static bool fetch_dragboard (MCPlatformPasteboardFlavor p_flavor, void *& r_data, size_t & r_data_size)
1258- {
1259- if (s_local_dragboard == nil)
1260- return false ;
1261-
1262- return fetch_pasteboard (s_local_dragboard, p_flavor, r_data, r_data_size);
1263- }
1264-
12651043MCDragAction MCScreenDC::dodragdrop (Window w, MCDragActionSet p_allowed_actions, MCImage *p_image, const MCPoint* p_image_offset)
12661044{
12671045 MCPlatformAllowedDragOperations t_operations;
0 commit comments