aboutsummaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorstuconnolly <stuart02@gmail.com>2010-06-06 15:04:31 +0000
committerstuconnolly <stuart02@gmail.com>2010-06-06 15:04:31 +0000
commit42781adb6cfa7f01f3763aade1b5043995930756 (patch)
treea1b38d9eab134fc59fe189f2e16cc823ef457361 /Source
parent24c1421cd5ff96d567a64903f4134f3364a3dd9c (diff)
downloadsequelpro-42781adb6cfa7f01f3763aade1b5043995930756.tar.gz
sequelpro-42781adb6cfa7f01f3763aade1b5043995930756.tar.bz2
sequelpro-42781adb6cfa7f01f3763aade1b5043995930756.zip
On the XML export dialog add the option to specify the placeholder of exported NULL values. Fixes issue #718.
Diffstat (limited to 'Source')
-rw-r--r--Source/SPExportController.h5
-rw-r--r--Source/SPExportController.m1
-rw-r--r--Source/SPExportInitializer.m2
-rw-r--r--Source/SPXMLExporter.h7
-rw-r--r--Source/SPXMLExporter.m19
5 files changed, 28 insertions, 6 deletions
diff --git a/Source/SPExportController.h b/Source/SPExportController.h
index 0865fef3..32541d19 100644
--- a/Source/SPExportController.h
+++ b/Source/SPExportController.h
@@ -70,7 +70,6 @@
IBOutlet NSButton *exportUseUTF8BOMButton;
IBOutlet NSButton *exportCompressOutputFile;
IBOutlet NSButton *exportProcessLowMemoryButton;
- IBOutlet NSTextField *exportCSVNULLValuesAsTextField;
IBOutlet BWAnchoredButtonBar *exportTableListButtonBar;
@@ -103,6 +102,10 @@
IBOutlet NSComboBox *exportCSVFieldsWrappedField;
IBOutlet NSComboBox *exportCSVFieldsEscapedField;
IBOutlet NSComboBox *exportCSVLinesTerminatedField;
+ IBOutlet NSTextField *exportCSVNULLValuesAsTextField;
+
+ // XML
+ IBOutlet NSTextField *exportXMLNULLValuesAsTextField;
// HTML
IBOutlet NSButton *exportHTMLIncludeStructureCheck;
diff --git a/Source/SPExportController.m b/Source/SPExportController.m
index cb972551..6da5b544 100644
--- a/Source/SPExportController.m
+++ b/Source/SPExportController.m
@@ -325,6 +325,7 @@
[[[exportTableList tableColumnWithIdentifier:@"content"] headerCell] setStringValue:(disable) ? @"" : @"C"];
[exportCSVNULLValuesAsTextField setStringValue:[prefs stringForKey:SPNullValue]];
+ [exportXMLNULLValuesAsTextField setStringValue:[prefs stringForKey:SPNullValue]];
}
}
diff --git a/Source/SPExportInitializer.m b/Source/SPExportInitializer.m
index ce894628..0cfa88b1 100644
--- a/Source/SPExportInitializer.m
+++ b/Source/SPExportInitializer.m
@@ -540,6 +540,8 @@
// of table and table content exports.
[xmlExporter setXmlTableName:[tablesListInstance tableName]];
+ [xmlExporter setXmlNULLString:[exportXMLNULLValuesAsTextField stringValue]];
+
// If required create separate files
if ((exportSource == SPTableExport) && exportToMultipleFiles && (exportTableCount > 0)) {
filename = [[exportPathField stringValue] stringByAppendingPathComponent:table];
diff --git a/Source/SPXMLExporter.h b/Source/SPXMLExporter.h
index a9e6c2dd..f80aacc6 100644
--- a/Source/SPXMLExporter.h
+++ b/Source/SPXMLExporter.h
@@ -51,6 +51,11 @@
* Table name
*/
NSString *xmlTableName;
+
+ /**
+ * XML NULL string
+ */
+ NSString *xmlNULLString;
}
@property(readwrite, assign) NSObject *delegate;
@@ -58,6 +63,8 @@
@property(readwrite, retain) NSArray *xmlDataArray;
@property(readwrite, retain) NSString *xmlTableName;
+@property(readwrite, retain) NSString *xmlNULLString;
+
/**
* Initialise an instance of SPXMLExporter using the supplied delegate.
*
diff --git a/Source/SPXMLExporter.m b/Source/SPXMLExporter.m
index 0c060a55..eddfabbf 100644
--- a/Source/SPXMLExporter.m
+++ b/Source/SPXMLExporter.m
@@ -37,6 +37,7 @@
@synthesize delegate;
@synthesize xmlDataArray;
@synthesize xmlTableName;
+@synthesize xmlNULLString;
/**
* Initialise an instance of SPXMLExporter using the supplied delegate.
@@ -73,7 +74,8 @@
// Check to see if we have at least a table name or data array
if ((![self xmlTableName]) && (![self xmlDataArray]) ||
- ([[self xmlTableName] isEqualToString:@""]) && ([[self xmlDataArray] count] == 0))
+ ([[self xmlTableName] length] == 0) && ([[self xmlDataArray] count] == 0) ||
+ (![self xmlNULLString]))
{
[pool release];
return;
@@ -170,19 +172,24 @@
return;
}
+ id data = NSArrayObjectAtIndex(xmlRow, i);
+
// Retrieve the contents of this tag
- if ([NSArrayObjectAtIndex(xmlRow, i) isKindOfClass:[NSData class]]) {
- dataConversionString = [[NSString alloc] initWithData:NSArrayObjectAtIndex(xmlRow, i) encoding:[self exportOutputEncoding]];
+ if ([data isKindOfClass:[NSData class]]) {
+ dataConversionString = [[NSString alloc] initWithData:data encoding:[self exportOutputEncoding]];
if (dataConversionString == nil) {
- dataConversionString = [[NSString alloc] initWithData:NSArrayObjectAtIndex(xmlRow, i) encoding:NSASCIIStringEncoding];
+ dataConversionString = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding];
}
[xmlItem setString:[NSString stringWithString:dataConversionString]];
[dataConversionString release];
}
+ else if ([data isKindOfClass:[NSNull class]]) {
+ [xmlItem setString:[self xmlNULLString]];
+ }
else {
- [xmlItem setString:[NSArrayObjectAtIndex(xmlRow, i) description]];
+ [xmlItem setString:[data description]];
}
// Add the opening and closing tag and the contents to the XML string
@@ -249,6 +256,8 @@
if (xmlDataArray) [xmlDataArray release], xmlDataArray = nil;
if (xmlTableName) [xmlTableName release], xmlTableName = nil;
+ [xmlNULLString release], xmlNULLString = nil;
+
[super dealloc];
}