Changeset 16240
- Timestamp:
- 06/15/2006 02:32:11 PM (2 years ago)
- Files:
-
- trunk/Frameworks/Adium Framework/AIMessageEntryTextView.m (modified) (5 diffs)
- trunk/Resources/MainMenu.nib/classes.nib (modified) (2 diffs)
- trunk/Resources/MainMenu.nib/keyedobjects.nib (modified) (previous)
- trunk/Source/AIInterfaceController.h (modified) (1 diff)
- trunk/Source/AIInterfaceController.m (modified) (2 diffs)
- trunk/Source/AIMenuController.h (modified) (1 diff)
- trunk/Source/AIMenuController.m (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/Frameworks/Adium Framework/AIMessageEntryTextView.m
r15751 r16240 57 57 - (void)addAttachmentOfImage:(NSImage *)inImage; 58 58 - (void)addAttachmentsFromPasteboard:(NSPasteboard *)pasteboard; 59 @end 60 61 @interface NSMutableAttributedString (AIMessageEntryTextViewAdditions) 62 - (void)convertForPasteWithTraits; 59 63 @end 60 64 … … 371 375 } 372 376 373 - (BOOL)handledPasteAsRichText 377 #pragma mark Pasting 378 379 - (BOOL)handlePasteAsRichText 374 380 { 375 381 NSPasteboard *generalPasteboard = [NSPasteboard generalPasteboard]; … … 404 410 NSDictionary *attributes = [[self typingAttributes] copy]; 405 411 406 if (![self handle dPasteAsRichText]) {412 if (![self handlePasteAsRichText]) { 407 413 [super paste:sender]; 408 414 } … … 414 420 [attributes release]; 415 421 } 422 423 - (void)pasteAsPlainTextWithTraits:(id)sender 424 { 425 NSDictionary *attributes = [[self typingAttributes] copy]; 426 427 NSPasteboard *generalPasteboard = [NSPasteboard generalPasteboard]; 428 NSEnumerator *enumerator = [[generalPasteboard types] objectEnumerator]; 429 NSString *type; 430 BOOL handledPaste = NO; 431 432 //Types is ordered by the preference for handling of the data; enumerating it lets us allow the sending application's hints to be followed. 433 while ((type = [enumerator nextObject]) && !handledPaste) { 434 NSLog(@"Looking at type %@",type); 435 if ([type isEqualToString:NSRTFPboardType] || 436 [type isEqualToString:NSRTFDPboardType] || 437 [type isEqualToString:NSHTMLPboardType]) { 438 NSData *data = [generalPasteboard dataForType:type]; 439 NSMutableAttributedString *attributedString; 440 441 if ([type isEqualToString:NSRTFPboardType]) { 442 attributedString = [[NSMutableAttributedString alloc] initWithRTF:data 443 documentAttributes:NULL]; 444 } else if ([type isEqualToString:NSRTFDPboardType]) { 445 attributedString = [[NSMutableAttributedString alloc] initWithRTFD:data 446 documentAttributes:NULL]; 447 } else /* NSHTMLPboardType */ { 448 attributedString = [[NSMutableAttributedString alloc] initWithHTML:data 449 documentAttributes:NULL]; 450 } 451 452 [attributedString convertForPasteWithTraits]; 453 [[self textStorage] replaceCharactersInRange:[self selectedRange] 454 withAttributedString:attributedString]; 455 [attributedString release]; 456 457 handledPaste = YES; 458 459 } else if ([type isEqualToString:NSStringPboardType]) { 460 //Paste a plain text string directly 461 [super paste:sender]; 462 handledPaste = YES; 463 464 } else if ([type isEqualToString:NSFilenamesPboardType]) { 465 [self addAttachmentsFromPasteboard:generalPasteboard]; 466 handledPaste = YES; 467 468 } else if ([type isEqualToString:NSURLPboardType]) { 469 //Paste a URL directly 470 [super paste:sender]; 471 handledPaste = YES; 472 } 473 } 474 475 //If we didn't handle it yet, let super try to deal with it 476 if (!handledPaste) { 477 [super paste:sender]; 478 } 479 480 if (attributes) { 481 [self setTypingAttributes:attributes]; 482 } 483 484 [attributes release]; 485 } 486 487 #pragma mark Deletion 416 488 417 489 - (void)deleteBackward:(id)sender … … 1004 1076 1005 1077 @end 1078 1079 @implementation NSMutableAttributedString (AIMessageEntryTextViewAdditions) 1080 - (void)convertForPasteWithTraits 1081 { 1082 NSRange fullRange = NSMakeRange(0, [self length]); 1083 1084 //Remove non-trait attributes 1085 [self removeAttribute:NSBackgroundColorAttributeName range:fullRange]; 1086 [self removeAttribute:NSBaselineOffsetAttributeName range:fullRange]; 1087 [self removeAttribute:NSCursorAttributeName range:fullRange]; 1088 [self removeAttribute:NSExpansionAttributeName range:fullRange]; 1089 [self removeAttribute:NSForegroundColorAttributeName range:fullRange]; 1090 [self removeAttribute:NSKernAttributeName range:fullRange]; 1091 [self removeAttribute:NSLigatureAttributeName range:fullRange]; 1092 [self removeAttribute:NSObliquenessAttributeName range:fullRange]; 1093 [self removeAttribute:NSParagraphStyleAttributeName range:fullRange]; 1094 [self removeAttribute:NSShadowAttributeName range:fullRange]; 1095 [self removeAttribute:NSStrokeWidthAttributeName range:fullRange]; 1096 1097 //Replace attachments with nothing! Absolutely nothing! 1098 [self convertAttachmentsToStringsUsingPlaceholder:@""]; 1099 } 1100 @end trunk/Resources/MainMenu.nib/classes.nib
r16194 r16240 30 30 paste = id; 31 31 pasteAndMatchStyle = id; 32 pasteWithImagesAndColors = id; 32 33 previousMessage = id; 33 34 runToolbarCustomizationPalette = id; … … 103 104 "menuItem_pasteAndMatchStyle" = NSMenuItem; 104 105 "menuItem_pasteStyle" = NSMenuItem; 106 "menuItem_pasteWithImagesAndColors" = NSMenuItem; 105 107 "menuItem_preferences" = NSMenuItem; 106 108 "menuItem_print" = NSMenuItem; trunk/Source/AIInterfaceController.h
r16222 r16240 253 253 - (IBAction)paste:(id)sender; 254 254 - (IBAction)pasteAndMatchStyle:(id)sender; 255 - (IBAction)pasteWithImagesAndColors:(id)sender; 255 256 256 257 //Custom printing trunk/Source/AIInterfaceController.m
r16221 r16240 1223 1223 - (IBAction)paste:(id)sender 1224 1224 { 1225 [self _pasteWithPreferredSelector:@selector(pasteAs RichText:) sender:sender];1225 [self _pasteWithPreferredSelector:@selector(pasteAsPlainTextWithTraits:) sender:sender]; 1226 1226 } 1227 1227 … … 1230 1230 { 1231 1231 [self _pasteWithPreferredSelector:@selector(pasteAsPlainText:) sender:sender]; 1232 } 1233 1234 - (IBAction)pasteWithImagesAndColors:(id)sender 1235 { 1236 [self _pasteWithPreferredSelector:@selector(pasteAsRichText:) sender:sender]; 1232 1237 } 1233 1238 trunk/Source/AIMenuController.h
r15752 r16240 118 118 IBOutlet NSMenuItem *menuItem_copy; 119 119 IBOutlet NSMenuItem *menuItem_paste; 120 IBOutlet NSMenuItem *menuItem_pasteWithImagesAndColors; 120 121 IBOutlet NSMenuItem *menuItem_pasteAndMatchStyle; 121 122 IBOutlet NSMenuItem *menuItem_clear; trunk/Source/AIMenuController.m
r15752 r16240 340 340 [menuItem_copy setTitle:AILocalizedString(@"Copy",nil)]; 341 341 [menuItem_paste setTitle:AILocalizedString(@"Paste",nil)]; 342 [menuItem_pasteWithImagesAndColors setTitle:AILocalizedString(@"Paste with Images and Colors",nil)]; 342 343 [menuItem_pasteAndMatchStyle setTitle:AILocalizedString(@"Paste and Match Style",nil)]; 343 344 [menuItem_clear setTitle:AILocalizedString(@"Clear",nil)];