Try to better key encode the contents of the cell.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@25305 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
fredkiefer 2007-07-04 15:54:40 +00:00
parent 1b0f4ef79a
commit 25280ce01a
2 changed files with 98 additions and 80 deletions

View file

@ -1,3 +1,8 @@
2007-07-04 Fred Kiefer <FredKiefer@gmx.de>
* Source/NSCell.m (-encodeWithCoder:): Try to better key encode
the contents of the cell.
2007-07-04 Fred Kiefer <FredKiefer@gmx.de> 2007-07-04 Fred Kiefer <FredKiefer@gmx.de>
* Source/NSPrintOperation.m (NSView-_displayPageInRect:withInfo:), * Source/NSPrintOperation.m (NSView-_displayPageInRect:withInfo:),

View file

@ -2319,9 +2319,22 @@ static NSColor *shadowCol;
{ {
unsigned long cFlags = 0; unsigned long cFlags = 0;
unsigned int cFlags2 = 0; unsigned int cFlags2 = 0;
id contents;
// encode contents // encode contents
[aCoder encodeObject: [self objectValue] forKey: @"NSContents"]; if (_cell.type == NSTextCellType)
{
contents = _contents;
}
else if (_cell.type == NSImageCellType)
{
contents = _cell_image;
}
else
{
contents = [self objectValue];
}
[aCoder encodeObject: contents forKey: @"NSContents"];
// flags // flags
cFlags |= [self focusRingType]; cFlags |= [self focusRingType];
@ -2356,21 +2369,21 @@ static NSColor *shadowCol;
if (_cell.type == NSTextCellType) if (_cell.type == NSTextCellType)
{ {
// font and formatter. // font and formatter.
if ([self font]) if ([self font])
{ {
[aCoder encodeObject: [self font] forKey: @"NSSupport"]; [aCoder encodeObject: [self font] forKey: @"NSSupport"];
} }
if ([self formatter]) if ([self formatter])
{ {
[aCoder encodeObject: [self formatter] forKey: @"NSFormatter"]; [aCoder encodeObject: [self formatter] forKey: @"NSFormatter"];
} }
} }
else if ([self image]) else if ([self image])
{ {
[aCoder encodeObject: [self image] forKey: @"NSSupport"]; [aCoder encodeObject: [self image] forKey: @"NSSupport"];
} }
} }
else else
{ {
@ -2409,8 +2422,8 @@ static NSColor *shadowCol;
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag]; [aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
// This used to be is_continuous, which has been replaced. // This used to be is_continuous, which has been replaced.
/* Ayers 20.03.2003: But we must continue to encode it for backward /* Ayers 20.03.2003: But we must continue to encode it for backward
compatibility or current releases will have undefined behavior when compatibility or current releases will have undefined behavior when
decoding archives (i.e. .gorm files) encoded by this version. */ decoding archives (i.e. .gorm files) encoded by this version. */
flag = [self isContinuous]; flag = [self isContinuous];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag]; [aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
flag = _cell.allows_mixed_state; flag = _cell.allows_mixed_state;
@ -2459,84 +2472,84 @@ static NSColor *shadowCol;
// initialize based on content... // initialize based on content...
if ([contents isKindOfClass: [NSString class]]) if ([contents isKindOfClass: [NSString class]])
{ {
self = [self initTextCell: contents]; self = [self initTextCell: contents];
} }
else if ([contents isKindOfClass: [NSImage class]]) else if ([contents isKindOfClass: [NSImage class]])
{ {
self = [self initImageCell: contents]; self = [self initImageCell: contents];
} }
else else
{ {
self = [self init]; self = [self init];
[self setObjectValue: contents]; [self setObjectValue: contents];
} }
if ([aDecoder containsValueForKey: @"NSCellFlags"]) if ([aDecoder containsValueForKey: @"NSCellFlags"])
{ {
unsigned long cFlags; unsigned long cFlags;
unsigned long mask = 0; unsigned long mask = 0;
cFlags = [aDecoder decodeIntForKey: @"NSCellFlags"]; cFlags = [aDecoder decodeIntForKey: @"NSCellFlags"];
[self setFocusRingType: (cFlags & 0x3)]; [self setFocusRingType: (cFlags & 0x3)];
[self setShowsFirstResponder: ((cFlags & 0x4) == 0x4)]; [self setShowsFirstResponder: ((cFlags & 0x4) == 0x4)];
// This bit flag is the other way around! // This bit flag is the other way around!
if ((cFlags & 0x20) != 0x20) if ((cFlags & 0x20) != 0x20)
mask |= NSLeftMouseUpMask; mask |= NSLeftMouseUpMask;
// This bit flag is the other way around! // This bit flag is the other way around!
[self setWraps: ((cFlags & 0x40) != 0x40)]; [self setWraps: ((cFlags & 0x40) != 0x40)];
if ((cFlags & 0x100) == 0x100) if ((cFlags & 0x100) == 0x100)
mask |= NSLeftMouseDraggedMask; mask |= NSLeftMouseDraggedMask;
[self setLineBreakMode: ((cFlags & 0x7000) >> 12)]; [self setLineBreakMode: ((cFlags & 0x7000) >> 12)];
if ((cFlags & 0x40000) == 0x40000) if ((cFlags & 0x40000) == 0x40000)
mask |= NSLeftMouseDownMask; mask |= NSLeftMouseDownMask;
if ((cFlags & 0x80000) == 0x80000) if ((cFlags & 0x80000) == 0x80000)
mask |= NSPeriodicMask; mask |= NSPeriodicMask;
[self sendActionOn: mask]; [self sendActionOn: mask];
[self setScrollable: ((cFlags & 0x100000) == 0x100000)]; [self setScrollable: ((cFlags & 0x100000) == 0x100000)];
[self setSelectable: ((cFlags & 0x200000) == 0x200000)]; [self setSelectable: ((cFlags & 0x200000) == 0x200000)];
[self setBezeled: ((cFlags & 0x400000) == 0x400000)]; [self setBezeled: ((cFlags & 0x400000) == 0x400000)];
[self setBordered: ((cFlags & 0x800000) == 0x800000)]; [self setBordered: ((cFlags & 0x800000) == 0x800000)];
[self setType: ((cFlags & 0xC000000) >> 26)]; [self setType: ((cFlags & 0xC000000) >> 26)];
[self setEditable: ((cFlags & 0x10000000) == 0x10000000)]; [self setEditable: ((cFlags & 0x10000000) == 0x10000000)];
// This bit flag is the other way around! // This bit flag is the other way around!
[self setEnabled: ((cFlags & 0x20000000) != 0x20000000)]; [self setEnabled: ((cFlags & 0x20000000) != 0x20000000)];
[self setHighlighted: ((cFlags & 0x40000000) == 0x40000000)]; [self setHighlighted: ((cFlags & 0x40000000) == 0x40000000)];
[self setState: ((cFlags & 0x80000000) == 0x80000000) ? NSOnState : NSOffState]; [self setState: ((cFlags & 0x80000000) == 0x80000000) ? NSOnState : NSOffState];
} }
if ([aDecoder containsValueForKey: @"NSCellFlags2"]) if ([aDecoder containsValueForKey: @"NSCellFlags2"])
{ {
int cFlags2; int cFlags2;
cFlags2 = [aDecoder decodeIntForKey: @"NSCellFlags2"]; cFlags2 = [aDecoder decodeIntForKey: @"NSCellFlags2"];
[self setControlTint: ((cFlags2 & 0xE0) >> 5)]; [self setControlTint: ((cFlags2 & 0xE0) >> 5)];
[self setControlSize: ((cFlags2 & 0xE0000) >> 17)]; [self setControlSize: ((cFlags2 & 0xE0000) >> 17)];
[self setSendsActionOnEndEditing: (cFlags2 & 0x400000)]; [self setSendsActionOnEndEditing: (cFlags2 & 0x400000)];
[self setAllowsMixedState: ((cFlags2 & 0x1000000) == 0x1000000)]; [self setAllowsMixedState: ((cFlags2 & 0x1000000) == 0x1000000)];
[self setRefusesFirstResponder: ((cFlags2 & 0x2000000) == 0x2000000)]; [self setRefusesFirstResponder: ((cFlags2 & 0x2000000) == 0x2000000)];
[self setAlignment: ((cFlags2 & 0x1C000000) >> 26)]; [self setAlignment: ((cFlags2 & 0x1C000000) >> 26)];
[self setImportsGraphics: ((cFlags2 & 0x20000000) == 0x20000000)]; [self setImportsGraphics: ((cFlags2 & 0x20000000) == 0x20000000)];
[self setAllowsEditingTextAttributes: ((cFlags2 & 0x40000000) == 0x40000000)]; [self setAllowsEditingTextAttributes: ((cFlags2 & 0x40000000) == 0x40000000)];
} }
if ([aDecoder containsValueForKey: @"NSSupport"]) if ([aDecoder containsValueForKey: @"NSSupport"])
{ {
id support = [aDecoder decodeObjectForKey: @"NSSupport"]; id support = [aDecoder decodeObjectForKey: @"NSSupport"];
if ([support isKindOfClass: [NSFont class]]) if ([support isKindOfClass: [NSFont class]])
{ {
[self setFont: support]; [self setFont: support];
} }
else if ([support isKindOfClass: [NSImage class]]) else if ([support isKindOfClass: [NSImage class]])
{ {
[self setImage: support]; [self setImage: support];
} }
} }
if ([aDecoder containsValueForKey: @"NSFormatter"]) if ([aDecoder containsValueForKey: @"NSFormatter"])
{ {
NSFormatter *formatter = [aDecoder decodeObjectForKey: @"NSFormatter"]; NSFormatter *formatter = [aDecoder decodeObjectForKey: @"NSFormatter"];
[self setFormatter: formatter]; [self setFormatter: formatter];
} }
} }
else else
{ {