* Source/GSXibLoader.m: Add some (currently unused) helper code

for class substitution in flattenedProperties.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@35138 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Fred Kiefer 2012-05-05 16:49:43 +00:00
parent 91954f8e3f
commit 023f0030e2
2 changed files with 72 additions and 4 deletions

View file

@ -1,3 +1,8 @@
2012-05-05 Fred Kiefer <FredKiefer@gmx.de>
* Source/GSXibLoader.m: Add some (currently unused) helper code
for class substitution in flattenedProperties.
2012-04-24 Fred Kiefer <FredKiefer@gmx.de>
* Source/NSPasteboard.m (NSURL-writeToPasteboard:): Revert the

View file

@ -612,17 +612,25 @@
{
if ([coder allowsKeyedCoding])
{
if ([coder containsValueForKey: @"connectionRecords"])
if ([coder containsValueForKey: @"sourceID"])
{
ASSIGN(connectionRecords, [coder decodeObjectForKey: @"connectionRecords"]);
ASSIGN(sourceID, [coder decodeObjectForKey: @"sourceID"]);
}
if ([coder containsValueForKey: @"maxID"])
{
maxID = [coder decodeIntForKey: @"maxID"];
}
if ([coder containsValueForKey: @"flattenedProperties"])
{
ASSIGN(flattenedProperties, [coder decodeObjectForKey: @"flattenedProperties"]);
}
if ([coder containsValueForKey: @"objectRecords"])
{
ASSIGN(objectRecords, [coder decodeObjectForKey: @"objectRecords"]);
}
if ([coder containsValueForKey: @"flattenedProperties"])
if ([coder containsValueForKey: @"connectionRecords"])
{
ASSIGN(flattenedProperties, [coder decodeObjectForKey: @"flattenedProperties"]);
ASSIGN(connectionRecords, [coder decodeObjectForKey: @"connectionRecords"]);
}
// We could load more data here, but we currently don't need it.
}
@ -686,6 +694,35 @@
return AUTORELEASE(properties);
}
/*
Returns a dictionary of the custom class names keyed on the objectIDs.
*/
- (NSDictionary*) customClassNames
{
NSMutableDictionary *properties;
int i;
properties = [[NSMutableDictionary alloc] init];
// We have special objects at -3, -2, -1 and 0
for (i = -3; i < maxID; i++)
{
NSString *idString;
id value;
idString = [NSString stringWithFormat: @"%d.CustomClassName", i];
value = [flattenedProperties objectForKey: idString];
if (value)
{
NSString *key;
key = [NSString stringWithFormat: @"%d", i];
[properties setObject: value forKey: key];
}
}
return properties;
}
- (id) nibInstantiate
{
NSEnumerator *en;
@ -1464,6 +1501,32 @@ didStartElement: (NSString*)elementName
return AUTORELEASE(dict);
}
/*
Extension method to decode the object id of an object referenced by its key.
*/
- (NSString *) decodeReferenceForKey: (NSString*)aKey
{
GSXibElement *element = [currentElement elementForKey: aKey];
NSString *objID;
if (element == nil)
return nil;
objID = [element attributeForKey: @"id"];
if (objID)
{
return objID;
}
objID = [element attributeForKey: @"ref"];
if (objID)
{
return objID;
}
return nil;
}
- (BOOL) containsValueForKey: (NSString*)aKey
{
GSXibElement *element = [currentElement elementForKey: aKey];