[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
NSTextStorage (actually, RTF) problem, with patch
From: |
Jeff Teunissen |
Subject: |
NSTextStorage (actually, RTF) problem, with patch |
Date: |
Thu, 06 Jun 2002 07:12:21 -0400 |
Because of the class cluster architecture, RTF consumers need to vary
their return type based on what class is asking for data. Attached is a
(trivial, really) patch implementing this.
I left the current methods defined in the protocol, for binary
compatibility. This may or may not be important, so I leave that up to
you. :)
This solves most of TextEdit's problems. There's still another one
somewhere else in the text network, which surfaces when an app has to
create the layout manager itself.
--
| Jeff Teunissen -=- Pres., Dusk To Dawn Computing -=- deek @ d2dc.net
| GPG: 1024D/9840105A 7102 808A 7733 C2F3 097B 161B 9222 DAB8 9840 105A
| Core developer, The QuakeForge Project http://www.quakeforge.net/
| Specializing in Debian GNU/Linux http://www.d2dc.net/~deek/
Index: gui/Headers/gnustep/gui/GSTextConverter.h
===================================================================
RCS file:
/cvsroot/gnustep/gnustep/core/gui/Headers/gnustep/gui/GSTextConverter.h,v
retrieving revision 1.1
diff -u -r1.1 GSTextConverter.h
--- gui/Headers/gnustep/gui/GSTextConverter.h 18 Aug 2001 22:02:18 -0000
1.1
+++ gui/Headers/gnustep/gui/GSTextConverter.h 6 Jun 2002 10:57:04 -0000
@@ -49,6 +49,12 @@
documentAttributes: (NSDictionary **)dict;
+ (NSAttributedString*) parseFile: (NSFileWrapper *)aFile
documentAttributes: (NSDictionary **)dict;
++ (NSAttributedString*) parseData: (NSData *)aData
+ documentAttributes: (NSDictionary **)dict
+ class: (Class)aClass;
++ (NSAttributedString*) parseFile: (NSFileWrapper *)aFile
+ documentAttributes: (NSDictionary **)dict
+ class: (Class)aClass;
@end
#endif // _GNUstep_H_GSTextConverter
Index: gui/Source/NSAttributedString.m
===================================================================
RCS file: /cvsroot/gnustep/gnustep/core/gui/Source/NSAttributedString.m,v
retrieving revision 1.41
diff -u -r1.41 NSAttributedString.m
--- gui/Source/NSAttributedString.m 8 Feb 2002 01:53:18 -0000 1.41
+++ gui/Source/NSAttributedString.m 6 Jun 2002 10:57:04 -0000
@@ -585,7 +585,8 @@
new = [converter_class(@"RTFD", NO)
parseFile: wrapper
- documentAttributes: dict];
+ documentAttributes: dict
+ class: [self class]];
// We do not return self but the newly created object
RELEASE (self);
return RETAIN (new);
@@ -604,7 +605,8 @@
new = [converter_class(@"RTFD", NO)
parseData: data
- documentAttributes: dict];
+ documentAttributes: dict
+ class: [self class]];
// We do not return self but the newly created object
RELEASE (self);
return RETAIN (new);
@@ -623,7 +625,8 @@
new = [converter_class(@"RTF", NO)
parseData: data
- documentAttributes: dict];
+ documentAttributes: dict
+ class: [self class]];
// We do not return self but the newly created object
RELEASE (self);
return RETAIN (new);
Index: gui/TextConverters/RTF/RTFConsumer.h
===================================================================
RCS file: /cvsroot/gnustep/gnustep/core/gui/TextConverters/RTF/RTFConsumer.h,v
retrieving revision 1.1
diff -u -r1.1 RTFConsumer.h
--- gui/TextConverters/RTF/RTFConsumer.h 21 Aug 2001 14:52:00 -0000
1.1
+++ gui/TextConverters/RTF/RTFConsumer.h 6 Jun 2002 10:57:04 -0000
@@ -40,6 +40,7 @@
NSMutableArray *colours;
NSMutableArray *attrs;
NSMutableAttributedString *result;
+ Class _class;
int ignore;
}
Index: gui/TextConverters/RTF/RTFConsumer.m
===================================================================
RCS file: /cvsroot/gnustep/gnustep/core/gui/TextConverters/RTF/RTFConsumer.m,v
retrieving revision 1.1
diff -u -r1.1 RTFConsumer.m
--- gui/TextConverters/RTF/RTFConsumer.m 21 Aug 2001 14:52:00 -0000
1.1
+++ gui/TextConverters/RTF/RTFConsumer.m 6 Jun 2002 10:57:04 -0000
@@ -214,7 +214,8 @@
@interface RTFConsumer (Private)
- (NSAttributedString*) parseRTF: (NSData *)rtfData
- documentAttributes: (NSDictionary **)dict;
+ documentAttributes: (NSDictionary **)dict
+ class: (Class)class;
- (NSDictionary*) documentAttributes;
- (NSAttributedString*) result;
@@ -250,6 +251,7 @@
+ (NSAttributedString*) parseFile: (NSFileWrapper *)wrapper
documentAttributes: (NSDictionary **)dict
+ class: (Class)class;
{
RTFConsumer *consumer = [RTFConsumer new];
NSAttributedString *text = nil;
@@ -257,7 +259,8 @@
if ([wrapper isRegularFile])
{
text = [consumer parseRTF: [wrapper regularFileContents]
- documentAttributes: dict];
+ documentAttributes: dict
+ class: class];
}
else if ([wrapper isDirectory])
{
@@ -269,7 +272,8 @@
if ((contents = [files objectForKey: @"TXT.rtf"]) != nil)
{
text = [consumer parseRTF: [contents regularFileContents]
- documentAttributes: dict];
+ documentAttributes: dict
+ class: class];
}
}
@@ -278,19 +282,33 @@
return text;
}
++ (NSAttributedString*) parseFile: (NSFileWrapper *)wrapper
+ documentAttributes: (NSDictionary **)dict
+{
+ return [self parseFile: wrapper documentAttributes: dict class:
[NSAttributedString class]];
+}
+
+ (NSAttributedString*) parseData: (NSData *)rtfData
- documentAttributes: (NSDictionary **)dict
+ documentAttributes: (NSDictionary **)dict
+ class: (Class)class
{
RTFConsumer *consumer = [RTFConsumer new];
NSAttributedString *text;
text = [consumer parseRTF: rtfData
- documentAttributes: dict];
+ documentAttributes: dict
+ class: class];
RELEASE(consumer);
return text;
}
++ (NSAttributedString*) parseData: (NSData *)rtfData
+ documentAttributes: (NSDictionary **)dict
+{
+ return [self parseData: rtfData documentAttributes: dict class:
[NSAttributedString class]];
+}
+
- (id) init
{
ignore = 0;
@@ -299,6 +317,7 @@
fonts = nil;
attrs = nil;
colours = nil;
+ _class = Nil;
return self;
}
@@ -353,7 +372,7 @@
ignore = 0;
DESTROY(result);
- result = [[NSMutableAttributedString alloc] init];
+ result = [[_class alloc] init];
ASSIGN(documentAttributes, [NSMutableDictionary dictionary]);
ASSIGN(fonts, [NSMutableDictionary dictionary]);
ASSIGN(attrs, [NSMutableArray array]);
@@ -389,6 +408,7 @@
- (NSAttributedString*) parseRTF: (NSData *)rtfData
documentAttributes: (NSDictionary **)dict
+ class: (Class) class
{
CREATE_AUTORELEASE_POOL(pool);
RTFscannerCtxt scanner;
@@ -400,6 +420,7 @@
encoding: NSASCIIStringEncoding];
// Reset this RFTConsumer, as it might already have been used!
+ _class = class;
[self reset];
initStringContext(&stringCtxt, rtfString);
- NSTextStorage (actually, RTF) problem, with patch,
Jeff Teunissen <=