Use new RTFD methods

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@6858 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Fred Kiefer 2000-07-02 16:54:20 +00:00
parent 1ab1e78975
commit 915afeecce

View file

@ -357,36 +357,31 @@ documentAttributes: (NSDictionary**)dict
- (id) initWithRTFDFileWrapper: (NSFileWrapper*)wrapper - (id) initWithRTFDFileWrapper: (NSFileWrapper*)wrapper
documentAttributes: (NSDictionary**)dict documentAttributes: (NSDictionary**)dict
{ {
if ([wrapper isRegularFile]) NSAttributedString *new = [RTFConsumer parseRTFD: wrapper
return [self initWithRTF: [wrapper regularFileContents] documentAttributes: dict];
documentAttributes: dict]; // We do not return self but the newly created object
else if ([wrapper isDirectory]) RELEASE(self);
{ return RETAIN(new);
NSDictionary *files = [wrapper fileWrappers];
NSFileWrapper *contents;
// We try to read the main file in the directory
if ((contents = [files objectForKey: @"TXT.rtf"]) != nil)
return [self initWithRTF: [contents regularFileContents]
documentAttributes: dict];
}
return nil;
} }
- (id) initWithRTFD: (NSData*)data - (id) initWithRTFD: (NSData*)data
documentAttributes: (NSDictionary**)dict documentAttributes: (NSDictionary**)dict
{ {
// FIXME: We use RTF, as there are currently no additional images NSFileWrapper *wrapper = [[NSFileWrapper alloc]
return [self initWithRTF: data initWithSerializedRepresentation: data];
documentAttributes: dict]; NSAttributedString *new = [RTFConsumer parseRTFD: wrapper
documentAttributes: dict];
// We do not return self but the newly created object
RELEASE(self);
RELEASE(wrapper);
return RETAIN(new);
} }
- (id) initWithRTF: (NSData*)data - (id) initWithRTF: (NSData*)data
documentAttributes: (NSDictionary**)dict documentAttributes: (NSDictionary**)dict
{ {
NSAttributedString *new = parseRTFintoAttributedString(data, dict); NSAttributedString *new = [RTFConsumer parseRTF: data
documentAttributes: dict];
// We do not return self but the newly created object // We do not return self but the newly created object
RELEASE(self); RELEASE(self);
return RETAIN(new); return RETAIN(new);
@ -411,40 +406,24 @@ documentAttributes: (NSDictionary**)dict
- (NSData*) RTFFromRange: (NSRange)range - (NSData*) RTFFromRange: (NSRange)range
documentAttributes: (NSDictionary*)dict documentAttributes: (NSDictionary*)dict
{ {
// FIXME: We use RTFD, as there are currently no additional images return [RTFProducer produceRTF: [self attributedSubstringFromRange: range]
return [self RTFDFromRange: range documentAttributes: dict];
documentAttributes: dict];
} }
- (NSData*) RTFDFromRange: (NSRange)range - (NSData*) RTFDFromRange: (NSRange)range
documentAttributes: (NSDictionary*)dict documentAttributes: (NSDictionary*)dict
{ {
return [RTFProducer RTFDFromAttributedString: return [[RTFProducer produceRTFD: [self attributedSubstringFromRange: range]
[self attributedSubstringFromRange: range] documentAttributes: dict] serializedRepresentation];
documentAttributes: dict];
} }
- (NSFileWrapper*) RTFDFileWrapperFromRange: (NSRange)range - (NSFileWrapper*) RTFDFileWrapperFromRange: (NSRange)range
documentAttributes: (NSDictionary*)dict documentAttributes: (NSDictionary*)dict
{ {
if ([self containsAttachments]) return [RTFProducer produceRTFD: [self attributedSubstringFromRange: range]
{ documentAttributes: dict];
NSMutableDictionary *fileDict = [NSMutableDictionary dictionary];
NSFileWrapper *txt = [[NSFileWrapper alloc]
initRegularFileWithContents:
[self RTFFromRange: range
documentAttributes: dict]];
[fileDict setObject: txt forKey: @"TXT.rtf"];
// FIXME: We have to add the attachments to the directory file wrapper
return [[NSFileWrapper alloc] initDirectoryWithFileWrappers: fileDict];
}
else
return [[NSFileWrapper alloc] initRegularFileWithContents:
[self RTFFromRange: range
documentAttributes: dict]];
} }
@end @end
@implementation NSMutableAttributedString (AppKit) @implementation NSMutableAttributedString (AppKit)