From 915afeeccecad48244d0a4e621c06db67286edcb Mon Sep 17 00:00:00 2001 From: Fred Kiefer Date: Sun, 2 Jul 2000 16:54:20 +0000 Subject: [PATCH] Use new RTFD methods git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@6858 72102866-910b-0410-8b05-ffd578937521 --- Source/NSAttributedString.m | 65 +++++++++++++------------------------ 1 file changed, 22 insertions(+), 43 deletions(-) diff --git a/Source/NSAttributedString.m b/Source/NSAttributedString.m index d83436bf4..82e1ab5a0 100644 --- a/Source/NSAttributedString.m +++ b/Source/NSAttributedString.m @@ -357,36 +357,31 @@ documentAttributes: (NSDictionary**)dict - (id) initWithRTFDFileWrapper: (NSFileWrapper*)wrapper documentAttributes: (NSDictionary**)dict { - if ([wrapper isRegularFile]) - return [self initWithRTF: [wrapper regularFileContents] - documentAttributes: dict]; - else if ([wrapper isDirectory]) - { - 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; + NSAttributedString *new = [RTFConsumer parseRTFD: wrapper + documentAttributes: dict]; + // We do not return self but the newly created object + RELEASE(self); + return RETAIN(new); } - (id) initWithRTFD: (NSData*)data documentAttributes: (NSDictionary**)dict { - // FIXME: We use RTF, as there are currently no additional images - return [self initWithRTF: data - documentAttributes: dict]; + NSFileWrapper *wrapper = [[NSFileWrapper alloc] + initWithSerializedRepresentation: data]; + 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 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 RELEASE(self); return RETAIN(new); @@ -411,40 +406,24 @@ documentAttributes: (NSDictionary**)dict - (NSData*) RTFFromRange: (NSRange)range documentAttributes: (NSDictionary*)dict { - // FIXME: We use RTFD, as there are currently no additional images - return [self RTFDFromRange: range - documentAttributes: dict]; + return [RTFProducer produceRTF: [self attributedSubstringFromRange: range] + documentAttributes: dict]; } - (NSData*) RTFDFromRange: (NSRange)range documentAttributes: (NSDictionary*)dict { - return [RTFProducer RTFDFromAttributedString: - [self attributedSubstringFromRange: range] - documentAttributes: dict]; + return [[RTFProducer produceRTFD: [self attributedSubstringFromRange: range] + documentAttributes: dict] serializedRepresentation]; } - (NSFileWrapper*) RTFDFileWrapperFromRange: (NSRange)range documentAttributes: (NSDictionary*)dict { - if ([self containsAttachments]) - { - 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]]; + return [RTFProducer produceRTFD: [self attributedSubstringFromRange: range] + documentAttributes: dict]; } + @end @implementation NSMutableAttributedString (AppKit)