diff --git a/ChangeLog b/ChangeLog index 215a6377a..3917e071b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2010-06-18 Wolfgang Lux + + * Source/NSAttributedString.m + (-initWithData:options:documentAttributes:error:): Attempt to auto + detect the document type if it wasn't specified by the caller. + Currently works for RTF and HTML documents. + + * Source/NSAttributedString.m (-initWithURL:documentAttributes:, + -initWithURL:options:documentAttributes:error:): Add base URL to + the document importing options only if it is not nil. + 2010-06-15 Wolfgang Lux * Source/NSMenu.m (-performKeyEquivalent:): Fix Doug's previous diff --git a/Source/NSAttributedString.m b/Source/NSAttributedString.m index 70935b662..096ea5e15 100644 --- a/Source/NSAttributedString.m +++ b/Source/NSAttributedString.m @@ -32,6 +32,7 @@ #import #import #import +#import #import #import #import @@ -765,7 +766,31 @@ create_error(int code, NSString* desc) if (type == nil) { - // FIXME: try to determine type + const void *dataBytes = [data bytes]; + + // The list of file types below was derived from Apache's conf/magic file + // FIXME extend the list + if (strncmp(dataBytes, "{\\rtf", 5) == 0) + { + type = NSRTFTextDocumentType; + } + else if (strncmp(dataBytes, "