From 91c2f021d4a8e323872cc733becbdfc19870ceb7 Mon Sep 17 00:00:00 2001 From: rowanbeentje Date: Thu, 26 Aug 2010 01:22:52 +0000 Subject: Exporter: - Enable alternating table lines in the export table view - this addresses Issue #797 - Reconnect GZIp & BZIP2 compression functionality (TODO: not currently working for file overwrites; to be discussed) --- Source/SPExportFile.h | 2 +- Source/SPExportFile.m | 16 ++++++++++++++++ Source/SPExportInitializer.m | 5 ++++- Source/SPSQLExporter.m | 2 +- 4 files changed, 22 insertions(+), 3 deletions(-) (limited to 'Source') diff --git a/Source/SPExportFile.h b/Source/SPExportFile.h index fb61eef2..946f6aec 100644 --- a/Source/SPExportFile.h +++ b/Source/SPExportFile.h @@ -82,5 +82,5 @@ - (BOOL)delete; - (void)writeData:(NSData *)data; - (SPExportFileHandleStatus)createExportFileHandle:(BOOL)overwrite; - +- (void)setCompressionFormat:(SPFileCompressionFormat)fileCompressionFormat; @end diff --git a/Source/SPExportFile.m b/Source/SPExportFile.m index e102b28e..1f09157f 100644 --- a/Source/SPExportFile.m +++ b/Source/SPExportFile.m @@ -168,6 +168,22 @@ return exportFileHandleStatus; } +/** + * Sets the compression level on the newly created file. Throws an exception + * if attempting to set the compression level when no file handle exists. + * + * @param fileCompressionFormat The compression level to support, from the SPFileCompressionFormat enum. + */ +- (void)setCompressionFormat:(SPFileCompressionFormat)fileCompressionFormat +{ + if (![self exportFileHandle]) { + [NSException raise:NSInternalInconsistencyException format:@"Attempting to set compression level of an uninitialized file handle."]; + return; + } + + [[self exportFileHandle] setShouldWriteWithCompressionFormat:fileCompressionFormat]; +} + #pragma mark - #pragma mark Private API diff --git a/Source/SPExportInitializer.m b/Source/SPExportInitializer.m index a34f729b..4812dd82 100644 --- a/Source/SPExportInitializer.m +++ b/Source/SPExportInitializer.m @@ -397,8 +397,11 @@ // Create the actual file handles while dealing with errors (e.g. file already exists, etc) during creation for (SPExportFile *exportFile in exportFiles) - { + { if ([exportFile createExportFileHandle:NO] == SPExportFileHandleCreated) { + + // TODO: these will not currently get triggered if there's an error in creating the files - eg when the user later chooses "overwrite". + [exportFile setCompressionFormat:[exportOutputCompressionFormatPopupButton indexOfSelectedItem]]; if ([exportFile exportFileNeedsCSVHeader]) { [self writeCSVHeaderToExportFile:exportFile]; } diff --git a/Source/SPSQLExporter.m b/Source/SPSQLExporter.m index a38732cb..186243b1 100644 --- a/Source/SPSQLExporter.m +++ b/Source/SPSQLExporter.m @@ -135,7 +135,7 @@ // Clear errors [self setSqlExportErrors:@""]; - + // Copy over the selected item names into tables in preparation for iteration NSMutableArray *targetArray; -- cgit v1.2.3