+2005-02-04 Chris Blumenberg <cblu@apple.com>
+
+ Fixed: <rdar://problem/3802781> rtf->html pasteboard conversion using xhtml
+
+ Reviewed by kocienda.
+
+ * WebView.subproj/WebHTMLView.m:
+ (+[WebHTMLView _excludedElementsForAttributedStringConversion]): new
+ (-[WebHTMLView _documentFragmentFromPasteboard:allowPlainText:]): call _excludedElementsForAttributedStringConversion
+
2005-02-04 Chris Blumenberg <cblu@apple.com>
Fixed: <rdar://problem/3832973> copy text from PowerPoint, paste into Blot (or presumably Mail) and get a single missing image icon
return [fragment firstChild] != nil ? fragment : nil;
}
++ (NSArray *)_excludedElementsForAttributedStringConversion
+{
+ static NSArray *elements = nil;
+ if (elements == nil) {
+ elements = [[NSArray alloc] initWithObjects:
+ // Omit style since we want style to be inline so the fragment can be easily inserted.
+ @"style",
+ // Omit xml so the result is not XHTML.
+ @"xml",
+ // Omit tags that will get stripped when converted to a fragment anyway.
+ @"doctype", @"html", @"head", @"body",
+ // Omit deprecated tags.
+ @"applet", @"basefont", @"center", @"dir", @"font", @"isindex", @"menu", @"s", @"strike", @"u",
+ // Omit object so no file attachments are part of the fragment.
+ @"object", nil];
+ }
+ return elements;
+}
+
- (DOMDocumentFragment *)_documentFragmentFromPasteboard:(NSPasteboard *)pasteboard allowPlainText:(BOOL)allowPlainText
{
NSArray *types = [pasteboard types];
string = [[NSAttributedString alloc] initWithRTF:[pasteboard dataForType:NSRTFPboardType] documentAttributes:NULL];
}
if (string != nil) {
- NSArray *elements = [[NSArray alloc] initWithObjects:
- // Omit style since we want style to be inline so the fragment can be easily inserted.
- @"style", nil];
NSDictionary *documentAttributes = [[NSDictionary alloc] initWithObjectsAndKeys:
- elements, NSExcludedElementsDocumentAttribute,
+ [[self class] _excludedElementsForAttributedStringConversion], NSExcludedElementsDocumentAttribute,
self, @"WebResourceHandler", nil];
- [elements release];
NSArray *subresources;
DOMDocumentFragment *fragment = [string _documentFromRange:NSMakeRange(0, [string length])
document:[[self _bridge] DOMDocument]