diff options
-rw-r--r-- | Source/SPDatabaseDocument.m | 182 |
1 files changed, 91 insertions, 91 deletions
diff --git a/Source/SPDatabaseDocument.m b/Source/SPDatabaseDocument.m index b67728c2..ffca5976 100644 --- a/Source/SPDatabaseDocument.m +++ b/Source/SPDatabaseDocument.m @@ -7414,130 +7414,130 @@ static int64_t SPDatabaseDocumentInstanceCounter = 0; { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - // Set up template engine with your chosen matcher - MGTemplateEngine *engine = [MGTemplateEngine templateEngine]; - - [engine setMatcher:[ICUTemplateMatcher matcherWithTemplateEngine:engine]]; + NSMutableDictionary *connection = [NSMutableDictionary dictionary]; + NSMutableDictionary *printData = [NSMutableDictionary dictionary]; - NSMutableDictionary *connection = [self connectionInformation]; + SPMainQSync(^{ + [connection setDictionary:[self connectionInformation]]; + [printData setObject:[self columnNames] forKey:@"columns"]; + SPTableViewType view = [self currentlySelectedView]; - NSString *heading = @""; - NSArray *rows, *indexes, *indexColumns = nil; + NSString *heading = @""; - NSArray *columns = [self columnNames]; + // Table source view + if (view == SPTableViewStructure) { - NSMutableDictionary *printData = [NSMutableDictionary dictionary]; + NSDictionary *tableSource = [tableSourceInstance tableSourceForPrinting]; - SPTableViewType view = [self currentlySelectedView]; + NSInteger tableType = [tablesListInstance tableType]; - // Table source view - if (view == SPTableViewStructure) { + switch (tableType) { + case SPTableTypeTable: + heading = NSLocalizedString(@"Table Structure", @"table structure print heading"); + break; + case SPTableTypeView: + heading = NSLocalizedString(@"View Structure", @"view structure print heading"); + break; + } - NSDictionary *tableSource = [tableSourceInstance tableSourceForPrinting]; + NSArray *rows = [[NSArray alloc] initWithArray: + [[tableSource objectForKey:@"structure"] objectsAtIndexes: + [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(1, [[tableSource objectForKey:@"structure"] count] - 1)]] + ]; - NSInteger tableType = [tablesListInstance tableType]; + NSArray *indexes = [[NSArray alloc] initWithArray: + [[tableSource objectForKey:@"indexes"] objectsAtIndexes: + [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(1, [[tableSource objectForKey:@"indexes"] count] - 1)]] + ]; - switch (tableType) { - case SPTableTypeTable: - heading = NSLocalizedString(@"Table Structure", @"table structure print heading"); - break; - case SPTableTypeView: - heading = NSLocalizedString(@"View Structure", @"view structure print heading"); - break; - } + NSArray *indexColumns = [[tableSource objectForKey:@"indexes"] objectAtIndex:0]; - rows = [[NSArray alloc] initWithArray: - [[tableSource objectForKey:@"structure"] objectsAtIndexes: - [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(1, [[tableSource objectForKey:@"structure"] count] - 1)]] - ]; + [printData setObject:rows forKey:@"rows"]; + [printData setObject:indexes forKey:@"indexes"]; + [printData setObject:indexColumns forKey:@"indexColumns"]; - indexes = [[NSArray alloc] initWithArray: - [[tableSource objectForKey:@"indexes"] objectsAtIndexes: - [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(1, [[tableSource objectForKey:@"indexes"] count] - 1)]] - ]; + if ([indexes count]) [printData setObject:@1 forKey:@"hasIndexes"]; - indexColumns = [[tableSource objectForKey:@"indexes"] objectAtIndex:0]; + [rows release]; + [indexes release]; + } + // Table content view + else if (view == SPTableViewContent) { - [printData setObject:rows forKey:@"rows"]; - [printData setObject:indexes forKey:@"indexes"]; - [printData setObject:indexColumns forKey:@"indexColumns"]; + NSArray *data = [tableContentInstance currentDataResultWithNULLs:NO hideBLOBs:YES]; - if ([indexes count]) [printData setObject:@1 forKey:@"hasIndexes"]; + heading = NSLocalizedString(@"Table Content", @"table content print heading"); - [rows release]; - [indexes release]; - } - // Table content view - else if (view == SPTableViewContent) { + NSArray *rows = [[NSArray alloc] initWithArray: + [data objectsAtIndexes: + [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(1, [data count] - 1)]] + ]; - NSArray *data = [tableContentInstance currentDataResultWithNULLs:NO hideBLOBs:YES]; + [printData setObject:rows forKey:@"rows"]; + [connection setValue:[tableContentInstance usedQuery] forKey:@"query"]; - heading = NSLocalizedString(@"Table Content", @"table content print heading"); + [rows release]; + } + // Custom query view + else if (view == SPTableViewCustomQuery) { - rows = [[NSArray alloc] initWithArray: - [data objectsAtIndexes: - [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(1, [data count] - 1)]] - ]; + NSArray *data = [customQueryInstance currentResult]; - [printData setObject:rows forKey:@"rows"]; - [connection setValue:[tableContentInstance usedQuery] forKey:@"query"]; + heading = NSLocalizedString(@"Query Result", @"query result print heading"); - [rows release]; - } - // Custom query view - else if (view == SPTableViewCustomQuery) { + NSArray *rows = [[NSArray alloc] initWithArray: + [data objectsAtIndexes: + [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(1, [data count] - 1)]] + ]; - NSArray *data = [customQueryInstance currentResult]; + [printData setObject:rows forKey:@"rows"]; + [connection setValue:[customQueryInstance usedQuery] forKey:@"query"]; - heading = NSLocalizedString(@"Query Result", @"query result print heading"); + [rows release]; + } + // Table relations view + else if (view == SPTableViewRelations) { - rows = [[NSArray alloc] initWithArray: - [data objectsAtIndexes: - [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(1, [data count] - 1)]] - ]; + NSArray *data = [tableRelationsInstance relationDataForPrinting]; - [printData setObject:rows forKey:@"rows"]; - [connection setValue:[customQueryInstance usedQuery] forKey:@"query"]; + heading = NSLocalizedString(@"Table Relations", @"toolbar item label for switching to the Table Relations tab"); - [rows release]; - } - // Table relations view - else if (view == SPTableViewRelations) { + NSArray *rows = [[NSArray alloc] initWithArray: + [data objectsAtIndexes: + [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(1, ([data count] - 1))]] + ]; - NSArray *data = [tableRelationsInstance relationDataForPrinting]; + [printData setObject:rows forKey:@"rows"]; - heading = NSLocalizedString(@"Table Relations", @"toolbar item label for switching to the Table Relations tab"); + [rows release]; + } + // Table triggers view + else if (view == SPTableViewTriggers) { - rows = [[NSArray alloc] initWithArray: - [data objectsAtIndexes: - [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(1, ([data count] - 1))]] - ]; + NSArray *data = [tableTriggersInstance triggerDataForPrinting]; - [printData setObject:rows forKey:@"rows"]; + heading = NSLocalizedString(@"Table Triggers", @"toolbar item label for switching to the Table Triggers tab"); - [rows release]; - } - // Table triggers view - else if (view == SPTableViewTriggers) { + NSArray *rows = [[NSArray alloc] initWithArray: + [data objectsAtIndexes: + [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(1, ([data count] - 1))]] + ]; - NSArray *data = [tableTriggersInstance triggerDataForPrinting]; + [printData setObject:rows forKey:@"rows"]; - heading = NSLocalizedString(@"Table Triggers", @"toolbar item label for switching to the Table Triggers tab"); + [rows release]; + } - rows = [[NSArray alloc] initWithArray: - [data objectsAtIndexes: - [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(1, ([data count] - 1))]] - ]; + [printData setObject:heading forKey:@"heading"]; + }); - [printData setObject:rows forKey:@"rows"]; + // Set up template engine with your chosen matcher + MGTemplateEngine *engine = [MGTemplateEngine templateEngine]; - [rows release]; - } + [engine setMatcher:[ICUTemplateMatcher matcherWithTemplateEngine:engine]]; [engine setObject:connection forKey:@"c"]; - [printData setObject:heading forKey:@"heading"]; - [printData setObject:columns forKey:@"columns"]; [printData setObject:([prefs boolForKey:SPUseMonospacedFonts]) ? SPDefaultMonospacedFontName : @"Lucida Grande" forKey:@"font"]; [printData setObject:([prefs boolForKey:SPDisplayTableViewVerticalGridlines]) ? @"1px solid #CCCCCC" : @"none" forKey:@"gridlines"]; @@ -7643,12 +7643,12 @@ static int64_t SPDatabaseDocumentInstanceCounter = 0; */ - (NSMutableDictionary *)connectionInformation { + NSDictionary *infoDict = [[NSBundle mainBundle] infoDictionary]; NSString *versionForPrint = [NSString stringWithFormat:@"%@ %@ (%@ %@)", - [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleName"], - [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"], - NSLocalizedString(@"build", @"build label"), - [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"] - ]; + [infoDict objectForKey:@"CFBundleName"], + [infoDict objectForKey:@"CFBundleShortVersionString"], + NSLocalizedString(@"build", @"build label"), + [infoDict objectForKey:@"CFBundleVersion"]]; NSMutableDictionary *connection = [NSMutableDictionary dictionary]; |