From 5568af642c2fc738f175e0be4729fd3e1fe2263a Mon Sep 17 00:00:00 2001 From: Max Date: Fri, 20 Nov 2015 03:51:18 +0100 Subject: * move some duplicate code into it's own method * remove some duplicate onMainThread calls * if an exporter needs a certain charset it'll have to set that itself now --- Source/SPExportInitializer.m | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) (limited to 'Source/SPExportInitializer.m') diff --git a/Source/SPExportInitializer.m b/Source/SPExportInitializer.m index 045e5046..15e9de66 100644 --- a/Source/SPExportInitializer.m +++ b/Source/SPExportInitializer.m @@ -46,6 +46,7 @@ #import "SPExportFilenameUtilities.h" #import "SPExportFileNameTokenObject.h" #import "SPConnectionControllerDelegateProtocol.h" +#import "SPExportController+SharedPrivateAPI.h" #import @@ -74,14 +75,9 @@ contextInfo:nil]; } - // If using an export type that requires the connection to start in UTF8, cache the current connection - // encoding and then set it here. - if (exportType == SPSQLExport || exportType == SPDotExport) { - previousConnectionEncoding = [[NSString alloc] initWithString:[connection encoding]]; - previousConnectionEncodingViaLatin1 = [connection encodingUsesLatin1Transport]; - - [tableDocumentInstance setConnectionEncoding:@"utf8" reloadingViews:NO]; - } + // cache the current connection encoding so the exporter can do what it wants. + previousConnectionEncoding = [[NSString alloc] initWithString:[connection encoding]]; + previousConnectionEncodingViaLatin1 = [connection encodingUsesLatin1Transport]; // Add the first exporter to the operation queue [operationQueue addOperation:[exporters objectAtIndex:0]]; @@ -91,6 +87,23 @@ [exporters removeObjectAtIndex:0]; } +/** + * @see _queueIsEmptyAfterCancelling: + */ +- (void)exportEnded +{ + [self _hideExportProgress]; + + // Restore query mode + [tableDocumentInstance setQueryMode:SPInterfaceQueryMode]; + + // Display Growl notification + [self displayExportFinishedGrowlNotification]; + + // Restore the connection encoding to it's pre-export value + [tableDocumentInstance setConnectionEncoding:[NSString stringWithFormat:@"%@%@", previousConnectionEncoding, (previousConnectionEncodingViaLatin1) ? @"-" : @""] reloadingViews:NO]; +} + /** * Initializes the export process by analysing the selected criteria. */ -- cgit v1.2.3