diff options
author | stuconnolly <stuart02@gmail.com> | 2010-03-13 13:29:53 +0000 |
---|---|---|
committer | stuconnolly <stuart02@gmail.com> | 2010-03-13 13:29:53 +0000 |
commit | 79b24a37b45ad20b8086e481696c758a76092c4e (patch) | |
tree | bff4198c520fc90a74b8136b26edc6b6355328ba /Source/TableSource.m | |
parent | 1f296e3f0484211d33ee891f344cc6eb10c2c4ac (diff) | |
download | sequelpro-79b24a37b45ad20b8086e481696c758a76092c4e.tar.gz sequelpro-79b24a37b45ad20b8086e481696c758a76092c4e.tar.bz2 sequelpro-79b24a37b45ad20b8086e481696c758a76092c4e.zip |
Lots more printing support enhancements, including:
- The ability to print the extended table information view using a new template.
- The inclusion of NULL values diaplyed as the user's NULL value placeholder when printing a table's sturcture and indexes.
- If enabled in the user's preferences, the inclusion of vertical gridlines in the table views.
- Dynamic calculation of page margins based on the paper size of the selected printer as opposed to using hard coded values.
- Lots of other little style enhancements.
Diffstat (limited to 'Source/TableSource.m')
-rw-r--r-- | Source/TableSource.m | 46 |
1 files changed, 37 insertions, 9 deletions
diff --git a/Source/TableSource.m b/Source/TableSource.m index 05eb0c53..e6d2d170 100644 --- a/Source/TableSource.m +++ b/Source/TableSource.m @@ -1123,10 +1123,12 @@ returns a dictionary containing enum/set field names as key and possible values */ - (NSDictionary *)tableSourceForPrinting { - NSInteger i; + NSInteger i, j; NSMutableArray *tempResult = [NSMutableArray array]; NSMutableArray *tempResult2 = [NSMutableArray array]; + NSString *nullValue = [prefs stringForKey:SPNullValue]; + MCPResult *structureQueryResult = [mySQLConnection queryString:[NSString stringWithFormat:@"SHOW COLUMNS FROM %@", [selectedTable backtickQuotedString]]]; MCPResult *indexesQueryResult = [mySQLConnection queryString:[NSString stringWithFormat:@"SHOW INDEXES FROM %@", [selectedTable backtickQuotedString]]]; @@ -1138,24 +1140,52 @@ returns a dictionary containing enum/set field names as key and possible values [tempResult addObject:[structureQueryResult fetchFieldNames]]; - NSMutableArray *temp = [[[indexesQueryResult fetchFieldNames] mutableCopy] autorelease]; + NSMutableArray *temp = [[indexesQueryResult fetchFieldNames] mutableCopy]; // Remove the 'table' column [temp removeObjectAtIndex:0]; [tempResult2 addObject:temp]; - for (i = 0 ; i < [structureQueryResult numOfRows]; i++) { - [tempResult addObject:[structureQueryResult fetchRowAsArray]]; + [temp release]; + + for (i = 0; i < [structureQueryResult numOfRows]; i++) { + NSMutableArray *row = [[structureQueryResult fetchRowAsArray] mutableCopy]; + + // For every NULL value replace it with the user's NULL value placeholder so we can actually print it + for (j = 0; j < [row count]; j++) + { + if ([[row objectAtIndex:j] isNSNull]) { + + // Replace the NULL instance with an escaped version of the user's placeholder + [row replaceObjectAtIndex:j withObject:(NSString *)CFXMLCreateStringByEscapingEntities(NULL, ((CFStringRef)nullValue), NULL)]; + } + } + + [tempResult addObject:row]; + + [row release]; } - for (i = 0 ; i < [indexesQueryResult numOfRows]; i++) { - NSMutableArray *index = [[[indexesQueryResult fetchRowAsArray] mutableCopy] autorelease]; + for (i = 0; i < [indexesQueryResult numOfRows]; i++) { + NSMutableArray *index = [[indexesQueryResult fetchRowAsArray] mutableCopy]; // Remove the 'table' column values [index removeObjectAtIndex:0]; + // For every NULL value replace it with the user's NULL value placeholder so we can actually print it + for (j = 0; j < [index count]; j++) + { + if ([[index objectAtIndex:j] isNSNull]) { + + // Replace the NULL instance with an escaped version of the user's placeholder + [index replaceObjectAtIndex:j withObject:(NSString *)CFXMLCreateStringByEscapingEntities(NULL, ((CFStringRef)nullValue), NULL)]; + } + } + [tempResult2 addObject:index]; + + [index release]; } return [NSDictionary dictionaryWithObjectsAndKeys:tempResult, @"structure", tempResult2, @"indexes", nil]; @@ -1271,8 +1301,7 @@ Begin a drag and drop operation from the table - copy a single dragged row to th */ - (BOOL)tableView:(NSTableView *)aTableView writeRowsWithIndexes:(NSIndexSet *)rows toPasteboard:(NSPasteboard*)pboard { - - //make sure that the drag operation is started from the right table view + // Make sure that the drag operation is started from the right table view if (aTableView != tableSourceView) return NO; // Check whether a save of the current field row is required. @@ -1285,7 +1314,6 @@ Begin a drag and drop operation from the table - copy a single dragged row to th } else { return NO; } - } /* |