From a445243c4c9140556b66c8d529c1531011774911 Mon Sep 17 00:00:00 2001 From: Bibiko Date: Sun, 9 Jan 2011 23:59:38 +0000 Subject: =?UTF-8?q?=E2=80=A2=20fixed=20bug=20for=20setting=20SP=5FBUNDLE?= =?UTF-8?q?=5FINPUT=5FTABLE=5FMETADATA=20if=20user=20changed=20column=20or?= =?UTF-8?q?der=20in=20Content=20and=20Query=20Editor=20table?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Source/SPCopyTable.m | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'Source') diff --git a/Source/SPCopyTable.m b/Source/SPCopyTable.m index cb7e08c5..973dfecb 100644 --- a/Source/SPCopyTable.m +++ b/Source/SPCopyTable.m @@ -1225,11 +1225,21 @@ NSInteger kBlobAsImageFile = 4; return; } + + // Create an array of table column mappings for fast iteration + NSArray *columns = [self tableColumns]; + NSUInteger numColumns = [columns count]; + NSUInteger *columnMappings = malloc(numColumns * sizeof(NSUInteger)); + NSInteger c; + for ( c = 0; c < numColumns; c++ ) + columnMappings[c] = [[NSArrayObjectAtIndex(columns, c) identifier] unsignedIntValue]; + NSMutableString *tableMetaData = [NSMutableString string]; if([[self delegate] isKindOfClass:[SPCustomQuery class]]) { [env setObject:@"query" forKey:SPBundleShellVariableDataTableSource]; NSArray *defs = [[self delegate] dataColumnDefinitions]; - for(NSDictionary* col in defs) { + for( c = 0; c < numColumns; c++ ) { + NSDictionary *col = NSArrayObjectAtIndex(defs, columnMappings[c]); [tableMetaData appendFormat:@"%@\t", [col objectForKey:@"type"]]; [tableMetaData appendFormat:@"%@\t", [col objectForKey:@"typegrouping"]]; [tableMetaData appendFormat:@"%@\t", ([col objectForKey:@"char_length"]) ? : @""]; @@ -1242,7 +1252,8 @@ NSInteger kBlobAsImageFile = 4; else if([[self delegate] isKindOfClass:[SPTableContent class]]) { [env setObject:@"content" forKey:SPBundleShellVariableDataTableSource]; NSArray *defs = [[self delegate] dataColumnDefinitions]; - for(NSDictionary* col in defs) { + for( c = 0; c < numColumns; c++ ) { + NSDictionary *col = NSArrayObjectAtIndex(defs, columnMappings[c]); [tableMetaData appendFormat:@"%@\t", [col objectForKey:@"type"]]; [tableMetaData appendFormat:@"%@\t", [col objectForKey:@"typegrouping"]]; [tableMetaData appendFormat:@"%@\t", ([col objectForKey:@"length"]) ? : @""]; -- cgit v1.2.3