Added more coding and TODO's for nib coding/decoding.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@23030 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
gcasa 2006-06-04 16:31:30 +00:00
parent d567eebe96
commit 158514d6a4
10 changed files with 470 additions and 254 deletions

View file

@ -1,3 +1,16 @@
2006-06-04 12:28 Gregory John Casamento <greg_casamento@yahoo.com>
* Source/GSTrackingRect.m: Encode, if not a keyed archiver.
* Source/NSApplication.m: Added coding
* Source/NSDataLink.m: Added coding
* Source/NSDataLinkManager.m: Added coding
* Source/NSNib.m: Made comment use "TODO_NIB" instead of TODO, so that
it can be pulled later.
* Source/NSParagraphStyle.m: Added TODO_NIB.
* Source/NSSelection.m: Added coding.
* Source/NSSound.m: Added TODO_NIB
* Source/NSTextAttachment.m: Added TODO_NIB.
2006-06-04 01:09 Gregory John Casamento <greg_casamento@yahoo.com> 2006-06-04 01:09 Gregory John Casamento <greg_casamento@yahoo.com>
* Source/GSHbox.m: Implemented keyed coding. * Source/GSHbox.m: Implemented keyed coding.

View file

@ -115,23 +115,29 @@
*/ */
- (void) encodeWithCoder: (NSCoder*)aCoder - (void) encodeWithCoder: (NSCoder*)aCoder
{ {
BOOL inside = flags.inside; if([aCoder allowsKeyedCoding] == NO)
{
[aCoder encodeRect: rectangle]; BOOL inside = flags.inside;
[aCoder encodeValueOfObjCType: @encode(NSTrackingRectTag) at: &tag];
[aCoder encodeObject: owner]; [aCoder encodeRect: rectangle];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &inside]; [aCoder encodeValueOfObjCType: @encode(NSTrackingRectTag) at: &tag];
[aCoder encodeObject: owner];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &inside];
}
} }
- (id) initWithCoder: (NSCoder*)aDecoder - (id) initWithCoder: (NSCoder*)aDecoder
{ {
BOOL inside; if([aDecoder allowsKeyedCoding] == NO)
{
rectangle = [aDecoder decodeRect]; BOOL inside;
[aDecoder decodeValueOfObjCType: @encode(NSTrackingRectTag) at: &tag];
[aDecoder decodeValueOfObjCType: @encode(id) at: &owner]; rectangle = [aDecoder decodeRect];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &inside]; [aDecoder decodeValueOfObjCType: @encode(NSTrackingRectTag) at: &tag];
flags.inside = inside; [aDecoder decodeValueOfObjCType: @encode(id) at: &owner];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &inside];
flags.inside = inside;
}
return self; return self;
} }

View file

@ -3292,10 +3292,18 @@ image.</p><p>See Also: -applicationIconImage</p>
- (void) encodeWithCoder: (NSCoder*)aCoder - (void) encodeWithCoder: (NSCoder*)aCoder
{ {
[super encodeWithCoder: aCoder]; [super encodeWithCoder: aCoder];
if([aCoder allowsKeyedCoding])
[aCoder encodeConditionalObject: _delegate]; {
[aCoder encodeObject: _main_menu]; [aCoder encodeObject: _delegate forKey: @"NSDelegate"];
[aCoder encodeConditionalObject: _windows_menu]; [aCoder encodeObject: _main_menu forKey: @"NSMainMenu"]; // ???
[aCoder encodeObject: _windows_menu forKey: @"NSWindowsMenu"]; // ???
}
else
{
[aCoder encodeConditionalObject: _delegate];
[aCoder encodeObject: _main_menu];
[aCoder encodeConditionalObject: _windows_menu];
}
} }
- (id) initWithCoder: (NSCoder*)aDecoder - (id) initWithCoder: (NSCoder*)aDecoder
@ -3303,13 +3311,27 @@ image.</p><p>See Also: -applicationIconImage</p>
id obj; id obj;
[super initWithCoder: aDecoder]; [super initWithCoder: aDecoder];
if([aDecoder allowsKeyedCoding])
obj = [aDecoder decodeObject]; {
[self setDelegate: obj]; if([aDecoder containsValueForKey: @"NSDelegate"])
obj = [aDecoder decodeObject]; {
[self setMainMenu: obj]; obj = [aDecoder decodeObjectForKey: @"NSDelegate"];
obj = [aDecoder decodeObject]; }
[self setWindowsMenu: obj]; [self setDelegate: obj];
obj = [aDecoder decodeObjectForKey: @"NSMainMenu"]; // TODO_NIB: Verify this key!!
[self setMainMenu: obj];
obj = [aDecoder decodeObjectForKey: @"NSWindowsMenu"]; // TODO_NIB: Verify this key!!
[self setWindowsMenu: obj];
}
else
{
obj = [aDecoder decodeObject];
[self setDelegate: obj];
obj = [aDecoder decodeObject];
[self setMainMenu: obj];
obj = [aDecoder decodeObject];
[self setWindowsMenu: obj];
}
return self; return self;
} }

View file

@ -269,79 +269,154 @@
- (void) encodeWithCoder: (NSCoder*)aCoder - (void) encodeWithCoder: (NSCoder*)aCoder
{ {
BOOL flag = NO; BOOL flag = NO;
if([aCoder allowsKeyedCoding])
{
[aCoder encodeInt: linkNumber forKey: @"GSLinkNumber"];
[aCoder encodeInt: disposition forKey: @"GSUpdateMode"];
[aCoder encodeInt: updateMode forKey: @"GSLastUpdateMode"];
[aCoder encodeValueOfObjCType: @encode(int) at: &linkNumber]; [aCoder encodeObject: lastUpdateTime forKey: @"GSLastUpdateTime"];
[aCoder encodeValueOfObjCType: @encode(int) at: &disposition];
[aCoder encodeValueOfObjCType: @encode(int) at: &updateMode];
[aCoder encodeValueOfObjCType: @encode(id) at: &lastUpdateTime];
[aCoder encodeValueOfObjCType: @encode(id) at: &sourceApplicationName]; [aCoder encodeObject: sourceApplicationName forKey: @"GSSourceApplicationName"];
[aCoder encodeValueOfObjCType: @encode(id) at: &sourceFilename]; [aCoder encodeObject: sourceFilename forKey: @"GSSourceFilename"];
[aCoder encodeValueOfObjCType: @encode(id) at: &sourceSelection]; [aCoder encodeObject: sourceSelection forKey: @"GSSourceSelection"];
[aCoder encodeValueOfObjCType: @encode(id) at: &sourceManager]; [aCoder encodeObject: sourceManager forKey: @"GSSourceManager"];
[aCoder encodeValueOfObjCType: @encode(id) at: &destinationApplicationName]; [aCoder encodeObject: destinationApplicationName forKey: @"GSDestinationApplicationName"];
[aCoder encodeValueOfObjCType: @encode(id) at: &destinationFilename]; [aCoder encodeObject: destinationFilename forKey: @"GSDestinationFilename"];
[aCoder encodeValueOfObjCType: @encode(id) at: &destinationSelection]; [aCoder encodeObject: destinationSelection forKey: @"GSDestinationSelection"];
[aCoder encodeValueOfObjCType: @encode(id) at: &destinationManager]; [aCoder encodeObject: destinationManager forKey: @"GSDestinationManager"];
[aCoder encodeValueOfObjCType: @encode(id) at: &types]; [aCoder encodeObject: types forKey: @"GSTypes"];
// flags... // flags...
flag = _flags.appVerifies; flag = _flags.appVerifies;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag]; [aCoder encodeBool: flag forKey: @"GSAppVerifies"];
flag = _flags.canUpdateContinuously; flag = _flags.canUpdateContinuously;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag]; [aCoder encodeBool: flag forKey: @"GSCanUpdateContinuously"];
flag = _flags.isDirty; flag = _flags.isDirty;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag]; [aCoder encodeBool: flag forKey: @"GSIsDirty"];
flag = _flags.willOpenSource; flag = _flags.willOpenSource;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag]; [aCoder encodeBool: flag forKey: @"GSWillOpenSource"];
flag = _flags.willUpdate; flag = _flags.willUpdate;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag]; [aCoder encodeBool: flag forKey: @"GSWillUpdate"];
}
else
{
[aCoder encodeValueOfObjCType: @encode(int) at: &linkNumber];
[aCoder encodeValueOfObjCType: @encode(int) at: &disposition];
[aCoder encodeValueOfObjCType: @encode(int) at: &updateMode];
[aCoder encodeValueOfObjCType: @encode(id) at: &lastUpdateTime];
[aCoder encodeValueOfObjCType: @encode(id) at: &sourceApplicationName];
[aCoder encodeValueOfObjCType: @encode(id) at: &sourceFilename];
[aCoder encodeValueOfObjCType: @encode(id) at: &sourceSelection];
[aCoder encodeValueOfObjCType: @encode(id) at: &sourceManager];
[aCoder encodeValueOfObjCType: @encode(id) at: &destinationApplicationName];
[aCoder encodeValueOfObjCType: @encode(id) at: &destinationFilename];
[aCoder encodeValueOfObjCType: @encode(id) at: &destinationSelection];
[aCoder encodeValueOfObjCType: @encode(id) at: &destinationManager];
[aCoder encodeValueOfObjCType: @encode(id) at: &types];
// flags...
flag = _flags.appVerifies;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _flags.canUpdateContinuously;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _flags.isDirty;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _flags.willOpenSource;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _flags.willUpdate;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
}
} }
- (id) initWithCoder: (NSCoder*)aCoder - (id) initWithCoder: (NSCoder*)aCoder
{ {
int version = [aCoder versionForClassName: @"NSDataLink"]; if([aCoder allowsKeyedCoding])
if (version == 0)
{ {
BOOL flag = NO; id obj;
[aCoder decodeValueOfObjCType: @encode(int) at: &linkNumber]; linkNumber = [aCoder decodeObjectForKey: @"GSLinkNumber"];
[aCoder decodeValueOfObjCType: @encode(int) at: &disposition]; disposition = [aCoder decodeIntForKey: @"GSDisposition"];
[aCoder decodeValueOfObjCType: @encode(int) at: &updateMode]; updateMode = [aCoder decodeIntForKey: @"GSUpdateMode"];
[aCoder decodeValueOfObjCType: @encode(id) at: &sourceManager];
[aCoder encodeValueOfObjCType: @encode(id) at: &destinationManager];
[aCoder decodeValueOfObjCType: @encode(id) at: &lastUpdateTime];
[aCoder decodeValueOfObjCType: @encode(id) at: &sourceApplicationName]; obj = [aCoder decodeObjectForKey: @"GSSourceManager"];
[aCoder decodeValueOfObjCType: @encode(id) at: &sourceFilename]; ASSIGN(sourceManager,obj);
[aCoder decodeValueOfObjCType: @encode(id) at: &sourceSelection]; obj = [aCoder decodeObjectForKey: @"GSDestinationManager"];
[aCoder decodeValueOfObjCType: @encode(id) at: &sourceManager]; ASSIGN(destinationManager,obj);
obj = [aCoder decodeObjectForKey: @"GSLastUpdateTime"];
[aCoder decodeValueOfObjCType: @encode(id) at: &destinationApplicationName]; ASSIGN(lastUpdateTime, obj);
[aCoder decodeValueOfObjCType: @encode(id) at: &destinationFilename]; obj = [aCoder decodeObjectForKey: @"GSSourceApplicationName"];
[aCoder decodeValueOfObjCType: @encode(id) at: &destinationSelection]; ASSIGN(sourceApplicationName,obj);
[aCoder decodeValueOfObjCType: @encode(id) at: &destinationManager]; obj = [aCoder decodeObjectForKey: @"GSSourceFilename"];
ASSIGN(sourceFilename,obj);
[aCoder decodeValueOfObjCType: @encode(id) at: &types]; obj = [aCoder decodeObjectForKey: @"GSSourceSelection"];
ASSIGN(sourceSelection,obj);
obj = [aCoder decodeObjectForKey: @"GSSourceManager"];
ASSIGN(sourceManager,obj);
obj = [aCoder decodeObjectForKey: @"GSDestinationApplicationName"];
ASSIGN(destinationApplicationName,obj);
obj = [aCoder decodeObjectForKey: @"GSDestinationFilename"];
ASSIGN(destinationFilename,obj);
obj = [aCoder decodeObjectForKey: @"GSDestinationSelection"];
ASSIGN(destinationSelection,obj);
obj = [aCoder decodeObjectForKey: @"GSDestinationManager"];
ASSIGN(destinationManager,obj);
obj = [aCoder decodeObjectForKey: @"GSTypes"];
ASSIGN(types,obj);
// flags... // flags...
[aCoder decodeValueOfObjCType: @encode(BOOL) at: &flag]; _flags.appVerifies = [aCoder decodeBoolForKey: @"GSAppVerifies"];
_flags.appVerifies = flag; _flags.canUpdateContinuously = [aCoder decodeBoolForKey: @"GSCanUpdateContinuously"];
[aCoder decodeValueOfObjCType: @encode(BOOL) at: &flag]; _flags.isDirty = [aCoder decodeBoolForKey: @"GSIsDirty"];
_flags.canUpdateContinuously = flag; _flags.willOpenSource = [aCoder decodeBoolForKey: @"GSWillOpenSource"];
[aCoder decodeValueOfObjCType: @encode(BOOL) at: &flag]; _flags.willUpdate = [aCoder decodeBoolForKey: @"GSWillUpdate"];
_flags.isDirty = flag;
[aCoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
_flags.willOpenSource = flag;
[aCoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
_flags.willUpdate = flag;
} }
else else
{ {
return nil; int version = [aCoder versionForClassName: @"NSDataLink"];
if (version == 0)
{
BOOL flag = NO;
[aCoder decodeValueOfObjCType: @encode(int) at: &linkNumber];
[aCoder decodeValueOfObjCType: @encode(int) at: &disposition];
[aCoder decodeValueOfObjCType: @encode(int) at: &updateMode];
[aCoder decodeValueOfObjCType: @encode(id) at: &sourceManager];
[aCoder decodeValueOfObjCType: @encode(id) at: &destinationManager];
[aCoder decodeValueOfObjCType: @encode(id) at: &lastUpdateTime];
[aCoder decodeValueOfObjCType: @encode(id) at: &sourceApplicationName];
[aCoder decodeValueOfObjCType: @encode(id) at: &sourceFilename];
[aCoder decodeValueOfObjCType: @encode(id) at: &sourceSelection];
[aCoder decodeValueOfObjCType: @encode(id) at: &sourceManager];
[aCoder decodeValueOfObjCType: @encode(id) at: &destinationApplicationName];
[aCoder decodeValueOfObjCType: @encode(id) at: &destinationFilename];
[aCoder decodeValueOfObjCType: @encode(id) at: &destinationSelection];
[aCoder decodeValueOfObjCType: @encode(id) at: &destinationManager];
[aCoder decodeValueOfObjCType: @encode(id) at: &types];
// flags...
[aCoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
_flags.appVerifies = flag;
[aCoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
_flags.canUpdateContinuously = flag;
[aCoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
_flags.isDirty = flag;
[aCoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
_flags.willOpenSource = flag;
[aCoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
_flags.willUpdate = flag;
}
else
return nil;
} }
return self; return self;

View file

@ -333,46 +333,84 @@
{ {
BOOL flag = NO; BOOL flag = NO;
[aCoder encodeValueOfObjCType: @encode(id) at: &filename]; if([aCoder allowsKeyedCoding])
[aCoder encodeValueOfObjCType: @encode(id) at: &sourceLinks]; {
[aCoder encodeValueOfObjCType: @encode(id) at: &destinationLinks]; [aCoder encodeObject: filename forKey: @"GSFilename"];
[aCoder encodeObject: sourceLinks forKey: @"GSSourceLinks"];
flag = _flags.areLinkOutlinesVisible; [aCoder encodeObject: destinationLinks forKey: @"GSDestinationLinks"];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _flags.delegateVerifiesLinks; flag = _flags.areLinkOutlinesVisible;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag]; [aCoder encodeBool: flag forKey: @"GSAreLinkOutlinesVisible"];
flag = _flags.interactsWithUser; flag = _flags.delegateVerifiesLinks;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag]; [aCoder encodeBool: flag forKey: @"GSDelegateVerifiesLinks"];
flag = _flags.isEdited; flag = _flags.interactsWithUser;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag]; [aCoder encodeBool: flag forKey: @"GSInteractsWithUser"];
flag = _flags.isEdited;
[aCoder encodeBool: flag forKey: @"GSIsEdited"];
}
else
{
[aCoder encodeValueOfObjCType: @encode(id) at: &filename];
[aCoder encodeValueOfObjCType: @encode(id) at: &sourceLinks];
[aCoder encodeValueOfObjCType: @encode(id) at: &destinationLinks];
flag = _flags.areLinkOutlinesVisible;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _flags.delegateVerifiesLinks;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _flags.interactsWithUser;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _flags.isEdited;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
}
} }
- (id) initWithCoder: (NSCoder*)aCoder - (id) initWithCoder: (NSCoder*)aCoder
{ {
int version = [aCoder versionForClassName: @"NSDataLinkManager"]; if([aCoder allowsKeyedCoding])
if (version == 0)
{ {
BOOL flag = NO; BOOL flag = NO;
id obj;
obj = [aCoder decodeObjectForKey: @"GSFilename"];
ASSIGN(filename,obj);
obj = [aCoder decodeObjectForKey: @"GSSourceLinks"];
ASSIGN(sourceLinks,obj);
obj = [aCoder decodeObjectForKey: @"GSDestinationLinks"];
ASSIGN(destinationLinks,obj);
[aCoder decodeValueOfObjCType: @encode(id) at: &filename]; flag = [aCoder decodeBoolForKey: @"GSAreLinkOutlinesVisible"];
[aCoder decodeValueOfObjCType: @encode(id) at: &sourceLinks];
[aCoder decodeValueOfObjCType: @encode(id) at: &destinationLinks];
[aCoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
_flags.areLinkOutlinesVisible = flag; _flags.areLinkOutlinesVisible = flag;
[aCoder decodeValueOfObjCType: @encode(BOOL) at: &flag]; flag = [aCoder decodeBoolForKey: @"GSDelegateVerifiesLinks"];
_flags.delegateVerifiesLinks = flag; _flags.delegateVerifiesLinks = flag;
[aCoder decodeValueOfObjCType: @encode(BOOL) at: &flag]; flag = [aCoder decodeBoolForKey: @"GSInteractsWithUser"];
_flags.interactsWithUser = flag; _flags.interactsWithUser = flag;
[aCoder decodeValueOfObjCType: @encode(BOOL) at: &flag]; flag = [aCoder decodeBoolForKey: @"GSIsEdited"];
_flags.isEdited = flag; _flags.isEdited = flag;
} }
else else
{ {
return nil; int version = [aCoder versionForClassName: @"NSDataLinkManager"];
if (version == 0)
{
BOOL flag = NO;
[aCoder decodeValueOfObjCType: @encode(id) at: &filename];
[aCoder decodeValueOfObjCType: @encode(id) at: &sourceLinks];
[aCoder decodeValueOfObjCType: @encode(id) at: &destinationLinks];
[aCoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
_flags.areLinkOutlinesVisible = flag;
[aCoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
_flags.delegateVerifiesLinks = flag;
[aCoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
_flags.interactsWithUser = flag;
[aCoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
_flags.isEdited = flag;
}
else
return nil;
} }
return self; return self;
} }

View file

@ -208,7 +208,7 @@
// //
if([coder allowsKeyedCoding]) if([coder allowsKeyedCoding])
{ {
// Need to verify this key... // TODO_NIB: Need to verify this key...
ASSIGN(_nibData, [coder decodeObjectForKey: @"NSData"]); ASSIGN(_nibData, [coder decodeObjectForKey: @"NSData"]);
ASSIGN(_loader, [GSModelLoaderFactory modelLoaderForFileType: @"nib"]); ASSIGN(_loader, [GSModelLoaderFactory modelLoaderForFileType: @"nib"]);
} }
@ -227,7 +227,7 @@
{ {
if([coder allowsKeyedCoding]) if([coder allowsKeyedCoding])
{ {
// Need to verify this key... // TODO_NIB: Need to verify this key...
[coder encodeObject: _nibData [coder encodeObject: _nibData
forKey: @"NSData"]; forKey: @"NSData"];
} }

View file

@ -314,100 +314,112 @@ static NSParagraphStyle *defaultStyle = nil;
- (id) initWithCoder: (NSCoder*)aCoder - (id) initWithCoder: (NSCoder*)aCoder
{ {
unsigned count; if([aCoder allowsKeyedCoding])
[aCoder decodeValueOfObjCType: @encode(NSTextAlignment) at: &_alignment];
[aCoder decodeValueOfObjCType: @encode(NSLineBreakMode)
at: &_lineBreakMode];
[aCoder decodeValueOfObjCType: @encode(float) at: &_firstLineHeadIndent];
[aCoder decodeValueOfObjCType: @encode(float) at: &_headIndent];
[aCoder decodeValueOfObjCType: @encode(float) at: &_lineSpacing];
[aCoder decodeValueOfObjCType: @encode(float) at: &_maximumLineHeight];
[aCoder decodeValueOfObjCType: @encode(float) at: &_minimumLineHeight];
[aCoder decodeValueOfObjCType: @encode(float) at: &_paragraphSpacing];
[aCoder decodeValueOfObjCType: @encode(float) at: &_tailIndent];
/*
* Tab stops don't conform to NSCoding - so we do it the long way.
*/
[aCoder decodeValueOfObjCType: @encode(unsigned) at: &count];
_tabStops = [[NSMutableArray alloc] initWithCapacity: count];
if (count > 0)
{ {
float locations[count]; // TODO_NIB: Determine keys for NSParagraphStyle, if there are any.
NSTextTabType types[count]; }
unsigned i; else
{
[aCoder decodeArrayOfObjCType: @encode(float) unsigned count;
count: count
at: locations]; [aCoder decodeValueOfObjCType: @encode(NSTextAlignment) at: &_alignment];
[aCoder decodeArrayOfObjCType: @encode(NSTextTabType) [aCoder decodeValueOfObjCType: @encode(NSLineBreakMode)
count: count at: &_lineBreakMode];
at: types]; [aCoder decodeValueOfObjCType: @encode(float) at: &_firstLineHeadIndent];
for (i = 0; i < count; i++) [aCoder decodeValueOfObjCType: @encode(float) at: &_headIndent];
[aCoder decodeValueOfObjCType: @encode(float) at: &_lineSpacing];
[aCoder decodeValueOfObjCType: @encode(float) at: &_maximumLineHeight];
[aCoder decodeValueOfObjCType: @encode(float) at: &_minimumLineHeight];
[aCoder decodeValueOfObjCType: @encode(float) at: &_paragraphSpacing];
[aCoder decodeValueOfObjCType: @encode(float) at: &_tailIndent];
/*
* Tab stops don't conform to NSCoding - so we do it the long way.
*/
[aCoder decodeValueOfObjCType: @encode(unsigned) at: &count];
_tabStops = [[NSMutableArray alloc] initWithCapacity: count];
if (count > 0)
{ {
NSTextTab *tab; float locations[count];
NSTextTabType types[count];
tab = [NSTextTab alloc]; unsigned i;
tab = [tab initWithType: types[i] location: locations[i]];
[_tabStops addObject: tab]; [aCoder decodeArrayOfObjCType: @encode(float)
RELEASE (tab); count: count
at: locations];
[aCoder decodeArrayOfObjCType: @encode(NSTextTabType)
count: count
at: types];
for (i = 0; i < count; i++)
{
NSTextTab *tab;
tab = [NSTextTab alloc];
tab = [tab initWithType: types[i] location: locations[i]];
[_tabStops addObject: tab];
RELEASE (tab);
}
}
if ([aCoder versionForClassName: @"NSParagraphStyle"] >= 2)
{
[aCoder decodeValueOfObjCType: @encode(int) at: &_baseDirection];
} }
} }
if ([aCoder versionForClassName: @"NSParagraphStyle"] >= 2)
{
[aCoder decodeValueOfObjCType: @encode(int) at: &_baseDirection];
}
return self; return self;
} }
- (void) encodeWithCoder: (NSCoder*)aCoder - (void) encodeWithCoder: (NSCoder*)aCoder
{ {
unsigned count; if([aCoder allowsKeyedCoding])
[aCoder encodeValueOfObjCType: @encode(NSTextAlignment) at: &_alignment];
[aCoder encodeValueOfObjCType: @encode(NSLineBreakMode)
at: &_lineBreakMode];
[aCoder encodeValueOfObjCType: @encode(float) at: &_firstLineHeadIndent];
[aCoder encodeValueOfObjCType: @encode(float) at: &_headIndent];
[aCoder encodeValueOfObjCType: @encode(float) at: &_lineSpacing];
[aCoder encodeValueOfObjCType: @encode(float) at: &_maximumLineHeight];
[aCoder encodeValueOfObjCType: @encode(float) at: &_minimumLineHeight];
[aCoder encodeValueOfObjCType: @encode(float) at: &_paragraphSpacing];
[aCoder encodeValueOfObjCType: @encode(float) at: &_tailIndent];
/*
* Tab stops don't conform to NSCoding - so we do it the long way.
*/
count = [_tabStops count];
[aCoder encodeValueOfObjCType: @encode(unsigned) at: &count];
if (count > 0)
{ {
float locations[count]; // TODO_NIB: Determine keys for NSParagraphStyle, if there are any.
NSTextTabType types[count]; }
unsigned i; else
{
for (i = 0; i < count; i++) unsigned count;
{
NSTextTab *tab = [_tabStops objectAtIndex: i]; [aCoder encodeValueOfObjCType: @encode(NSTextAlignment) at: &_alignment];
[aCoder encodeValueOfObjCType: @encode(NSLineBreakMode)
locations[i] = [tab location]; at: &_lineBreakMode];
types[i] = [tab tabStopType]; [aCoder encodeValueOfObjCType: @encode(float) at: &_firstLineHeadIndent];
} [aCoder encodeValueOfObjCType: @encode(float) at: &_headIndent];
[aCoder encodeArrayOfObjCType: @encode(float) [aCoder encodeValueOfObjCType: @encode(float) at: &_lineSpacing];
count: count [aCoder encodeValueOfObjCType: @encode(float) at: &_maximumLineHeight];
at: locations]; [aCoder encodeValueOfObjCType: @encode(float) at: &_minimumLineHeight];
[aCoder encodeArrayOfObjCType: @encode(NSTextTabType) [aCoder encodeValueOfObjCType: @encode(float) at: &_paragraphSpacing];
count: count [aCoder encodeValueOfObjCType: @encode(float) at: &_tailIndent];
at: types];
/*
* Tab stops don't conform to NSCoding - so we do it the long way.
*/
count = [_tabStops count];
[aCoder encodeValueOfObjCType: @encode(unsigned) at: &count];
if (count > 0)
{
float locations[count];
NSTextTabType types[count];
unsigned i;
for (i = 0; i < count; i++)
{
NSTextTab *tab = [_tabStops objectAtIndex: i];
locations[i] = [tab location];
types[i] = [tab tabStopType];
}
[aCoder encodeArrayOfObjCType: @encode(float)
count: count
at: locations];
[aCoder encodeArrayOfObjCType: @encode(NSTextTabType)
count: count
at: types];
}
[aCoder encodeValueOfObjCType: @encode(int) at: &_baseDirection];
} }
[aCoder encodeValueOfObjCType: @encode(int) at: &_baseDirection];
} }
- (BOOL) isEqual: (id)aother - (BOOL) isEqual: (id)aother
{ {
NSParagraphStyle *other = aother; NSParagraphStyle *other = aother;

View file

@ -211,23 +211,46 @@ typedef enum
// //
- (void) encodeWithCoder: (NSCoder*)aCoder - (void) encodeWithCoder: (NSCoder*)aCoder
{ {
[aCoder encodeValueOfObjCType: @encode(BOOL) if([aCoder allowsKeyedCoding])
at: &_isWellKnownSelection]; {
[aCoder encodeValueOfObjCType: @encode(int) [aCoder encodeBool: _isWellKnownSelection
at: &_selectionType]; forKey: @"GSIsWellKnownSelection"];
[aCoder encodeValueOfObjCType: @encode(id) [aCoder encodeBool: _selectionType
at: _descriptionData]; forKey: @"GSSelectionType"];
[aCoder encodeObject: _descriptionData
forKey: @"GSDescriptionData"];
}
else
{
[aCoder encodeValueOfObjCType: @encode(BOOL)
at: &_isWellKnownSelection];
[aCoder encodeValueOfObjCType: @encode(int)
at: &_selectionType];
[aCoder encodeValueOfObjCType: @encode(id)
at: _descriptionData];
}
} }
- (id) initWithCoder: (NSCoder*)aDecoder - (id) initWithCoder: (NSCoder*)aDecoder
{ {
[super init]; [super init];
[aDecoder decodeValueOfObjCType: @encode(BOOL) if([aDecoder allowsKeyedCoding])
at: &_isWellKnownSelection]; {
[aDecoder decodeValueOfObjCType: @encode(int) _isWellKnownSelection = [aDecoder decodeBoolForKey: @"GSIsWellKnownSelection"];
at: &_selectionType]; _selectionType = [aDecoder decodeIntForKey: @"GSSelectionType"];
[aDecoder decodeValueOfObjCType: @encode(id) ASSIGN(_descriptionData, [aDecoder decodeObjectForKey: @"GSDescriptionData"]);
at: _descriptionData]; }
else
{
id obj;
[aDecoder decodeValueOfObjCType: @encode(BOOL)
at: &_isWellKnownSelection];
[aDecoder decodeValueOfObjCType: @encode(int)
at: &_selectionType];
[aDecoder decodeValueOfObjCType: @encode(id)
at: obj];
ASSIGN(_descriptionData, obj);
}
// if it's a well known selection then determine which one it is. // if it's a well known selection then determine which one it is.
if (_isWellKnownSelection) if (_isWellKnownSelection)
@ -251,7 +274,7 @@ typedef enum
break; break;
} }
} }
return self; return self;
} }

View file

@ -667,60 +667,73 @@ return NO; \
// //
- (void) encodeWithCoder: (NSCoder *)coder - (void) encodeWithCoder: (NSCoder *)coder
{ {
[coder encodeValueOfObjCType: @encode(BOOL) at: &_onlyReference]; if([coder allowsKeyedCoding])
[coder encodeObject: _name];
if (_onlyReference == YES)
{ {
return; // TODO_NIB: Determine keys for NSSound.
} }
else
if (_uniqueIdentifier != nil)
{ {
[coder encodeObject: _uniqueIdentifier]; [coder encodeValueOfObjCType: @encode(BOOL) at: &_onlyReference];
[coder encodeObject: _name];
if (_onlyReference == YES)
{
return;
}
if (_uniqueIdentifier != nil)
{
[coder encodeObject: _uniqueIdentifier];
}
[coder encodeConditionalObject: _delegate];
[coder encodeValueOfObjCType: @encode(long) at: &_dataLocation];
[coder encodeValueOfObjCType: @encode(long) at: &_dataSize];
[coder encodeValueOfObjCType: @encode(int) at: &_dataFormat];
[coder encodeValueOfObjCType: @encode(float) at: &_samplingRate];
[coder encodeValueOfObjCType: @encode(float) at: &_frameSize];
[coder encodeValueOfObjCType: @encode(long) at: &_frameCount];
[coder encodeValueOfObjCType: @encode(int) at: &_channelCount];
[coder encodeObject: _data];
} }
[coder encodeConditionalObject: _delegate];
[coder encodeValueOfObjCType: @encode(long) at: &_dataLocation];
[coder encodeValueOfObjCType: @encode(long) at: &_dataSize];
[coder encodeValueOfObjCType: @encode(int) at: &_dataFormat];
[coder encodeValueOfObjCType: @encode(float) at: &_samplingRate];
[coder encodeValueOfObjCType: @encode(float) at: &_frameSize];
[coder encodeValueOfObjCType: @encode(long) at: &_frameCount];
[coder encodeValueOfObjCType: @encode(int) at: &_channelCount];
[coder encodeObject: _data];
} }
- (id) initWithCoder: (NSCoder*)decoder - (id) initWithCoder: (NSCoder*)decoder
{ {
[decoder decodeValueOfObjCType: @encode(BOOL) at: &_onlyReference]; if([decoder allowsKeyedCoding])
if (_onlyReference == YES)
{ {
NSString *theName = [decoder decodeObject]; // TODO_NIB: Determine keys for NSSound.
}
RELEASE (self); else
self = RETAIN ([NSSound soundNamed: theName]); {
[self setName: theName]; [decoder decodeValueOfObjCType: @encode(BOOL) at: &_onlyReference];
}
else if (_onlyReference == YES)
{ {
_name = TEST_RETAIN ([decoder decodeObject]); NSString *theName = [decoder decodeObject];
_uniqueIdentifier = TEST_RETAIN ([decoder decodeObject]);
[self setDelegate: [decoder decodeObject]]; RELEASE (self);
self = RETAIN ([NSSound soundNamed: theName]);
[decoder decodeValueOfObjCType: @encode(long) at: &_dataLocation]; [self setName: theName];
[decoder decodeValueOfObjCType: @encode(long) at: &_dataSize]; }
[decoder decodeValueOfObjCType: @encode(int) at: &_dataFormat]; else
[decoder decodeValueOfObjCType: @encode(float) at: &_samplingRate]; {
[decoder decodeValueOfObjCType: @encode(float) at: &_frameSize]; _name = TEST_RETAIN ([decoder decodeObject]);
[decoder decodeValueOfObjCType: @encode(long) at: &_frameCount]; _uniqueIdentifier = TEST_RETAIN ([decoder decodeObject]);
[decoder decodeValueOfObjCType: @encode(int) at: &_channelCount]; [self setDelegate: [decoder decodeObject]];
_data = RETAIN([decoder decodeObject]); [decoder decodeValueOfObjCType: @encode(long) at: &_dataLocation];
[decoder decodeValueOfObjCType: @encode(long) at: &_dataSize];
[decoder decodeValueOfObjCType: @encode(int) at: &_dataFormat];
[decoder decodeValueOfObjCType: @encode(float) at: &_samplingRate];
[decoder decodeValueOfObjCType: @encode(float) at: &_frameSize];
[decoder decodeValueOfObjCType: @encode(long) at: &_frameCount];
[decoder decodeValueOfObjCType: @encode(int) at: &_channelCount];
_data = RETAIN([decoder decodeObject]);
}
} }
return self; return self;
} }

View file

@ -323,17 +323,31 @@
*/ */
- (void) encodeWithCoder: (NSCoder*)aCoder - (void) encodeWithCoder: (NSCoder*)aCoder
{ {
[aCoder encodeObject: _fileWrapper]; if([aCoder allowsKeyedCoding])
[aCoder encodeObject: _cell]; {
// TODO_NIB: Determine keys for NSTextAttachment.
}
else
{
[aCoder encodeObject: _fileWrapper];
[aCoder encodeObject: _cell];
}
} }
- (id) initWithCoder: (NSCoder*)aDecoder - (id) initWithCoder: (NSCoder*)aDecoder
{ {
[aDecoder decodeValueOfObjCType: @encode(id) at: &_fileWrapper]; if([aDecoder allowsKeyedCoding])
[aDecoder decodeValueOfObjCType: @encode(id) at: &_cell]; {
// TODO_NIB: Determine keys for NSTextAttachment.
// Reconnect the cell, so the cell does not have to store the attachment }
[_cell setAttachment: self]; else
{
[aDecoder decodeValueOfObjCType: @encode(id) at: &_fileWrapper];
[aDecoder decodeValueOfObjCType: @encode(id) at: &_cell];
// Reconnect the cell, so the cell does not have to store the attachment
[_cell setAttachment: self];
}
return self; return self;
} }