From 05f1612cbb7e33cf9135a346fc2505cc0e87e853 Mon Sep 17 00:00:00 2001 From: rowanbeentje Date: Thu, 23 Feb 2012 02:13:56 +0000 Subject: Warning: this branch commit is largely untested, and known to throw exceptions as database structure retrieval is currently missing! Further work on SPMySQLFramework integration: - Improve SPMySQL framework build settings including correct ppc builds and a Distribution configuration for the build distributions to match - Add new convenience querying and result methods to the framework - Amend Sequel Pro source to use the new SPMySQL.framework methods everywhere, replacing MCPKit methods where they differ and improving some functions - Remove MCPKit from the source - Fix a number of warnings on Release-style builds --- Source/SPCopyTable.m | 36 ++++++++++++++++-------------------- 1 file changed, 16 insertions(+), 20 deletions(-) (limited to 'Source/SPCopyTable.m') diff --git a/Source/SPCopyTable.m b/Source/SPCopyTable.m index 78773412..b5137935 100644 --- a/Source/SPCopyTable.m +++ b/Source/SPCopyTable.m @@ -22,11 +22,6 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -#import -#ifndef SP_REFACTOR /* headers */ -#import "MCPGeometryData.h" -#endif - #import "SPCopyTable.h" #import "SPTableContent.h" #import "SPTableTriggers.h" @@ -41,6 +36,7 @@ #import "SPBundleEditorController.h" #import "SPAppController.h" #import "SPTablesList.h" +#import "SPMySQL.h" NSInteger SPEditMenuCopy = 2001; NSInteger SPEditMenuCopyWithColumns = 2002; @@ -157,7 +153,7 @@ static const NSInteger kBlobAsImageFile = 4; // Loop through the rows, adding their descriptive contents NSUInteger rowIndex = [selectedRows firstIndex]; NSString *nullString = [prefs objectForKey:SPNullValue]; - Class mcpGeometryData = [MCPGeometryData class]; + Class spmysqlGeometryData = [SPMySQLGeometryData class]; NSUInteger rowCounter = 0; if((withBlobHandling == kBlobAsFile || withBlobHandling == kBlobAsImageFile) && tmpBlobFileDirectory && [tmpBlobFileDirectory length]) { @@ -210,7 +206,7 @@ static const NSInteger kBlobAsImageFile = 4; [result appendString:@"BLOB\t"]; } } - else if ([cellData isKindOfClass:mcpGeometryData]) { + else if ([cellData isKindOfClass:spmysqlGeometryData]) { if((withBlobHandling == kBlobAsFile || withBlobHandling == kBlobAsImageFile) && tmpBlobFileDirectory && [tmpBlobFileDirectory length]) { NSString *fp = [NSString stringWithFormat:@"%@/%ld_%ld.pdf", tmpBlobFileDirectory, rowCounter, c]; SPGeometryDataView *v = [[SPGeometryDataView alloc] initWithCoordinates:[cellData coordinates]]; @@ -295,7 +291,7 @@ static const NSInteger kBlobAsImageFile = 4; // Loop through the rows, adding their descriptive contents NSUInteger rowIndex = [selectedRows firstIndex]; NSString *nullString = [prefs objectForKey:SPNullValue]; - Class mcpGeometryData = [MCPGeometryData class]; + Class spmysqlGeometryData = [SPMySQLGeometryData class]; NSUInteger rowCounter = 0; @@ -349,7 +345,7 @@ static const NSInteger kBlobAsImageFile = 4; [result appendString:@"\"BLOB\","]; } } - else if ([cellData isKindOfClass:mcpGeometryData]) { + else if ([cellData isKindOfClass:spmysqlGeometryData]) { if((withBlobHandling == kBlobAsFile || withBlobHandling == kBlobAsImageFile) && tmpBlobFileDirectory && [tmpBlobFileDirectory length]) { NSString *fp = [NSString stringWithFormat:@"%@/%ld_%ld.pdf", tmpBlobFileDirectory, rowCounter, c]; SPGeometryDataView *v = [[SPGeometryDataView alloc] initWithCoordinates:[cellData coordinates]]; @@ -511,15 +507,15 @@ static const NSInteger kBlobAsImageFile = 4; case 1: case 2: if ([cellData isKindOfClass:nsDataClass]) { - [value appendFormat:@"X'%@', ", [mySQLConnection prepareBinaryData:cellData]]; + [value appendString:[mySQLConnection escapeAndQuoteData:cellData]]; } else { - [value appendFormat:@"'%@', ", [mySQLConnection prepareString:[cellData description]]]; + [value appendString:[mySQLConnection escapeAndQuoteString:[cellData description]]]; } break; // GEOMETRY case 3: - [value appendFormat:@"X'%@', ", [mySQLConnection prepareBinaryData:[cellData data]]]; + [value appendString:[mySQLConnection escapeAndQuoteData:[cellData data]]]; break; // Unhandled cases - abort default: @@ -617,7 +613,7 @@ static const NSInteger kBlobAsImageFile = 4; NSUInteger rowIndex = [selectedRows firstIndex]; NSString *nullString = [prefs objectForKey:SPNullValue]; Class nsDataClass = [NSData class]; - Class mcpGeometryData = [MCPGeometryData class]; + Class spmysqlGeometryData = [SPMySQLGeometryData class]; NSStringEncoding connectionEncoding = [mySQLConnection stringEncoding]; while ( rowIndex != NSNotFound ) { @@ -639,7 +635,7 @@ static const NSInteger kBlobAsImageFile = 4; [displayString release]; } } - else if ([cellData isKindOfClass:mcpGeometryData]) { + else if ([cellData isKindOfClass:spmysqlGeometryData]) { [result appendFormat:@"%@\t", [cellData wktString]]; } else [result appendFormat:@"%@\t", [cellData description]]; @@ -705,7 +701,7 @@ static const NSInteger kBlobAsImageFile = 4; // Determine the available size NSScrollView *parentScrollView = (NSScrollView*)[[self superview] superview]; - CGFloat visibleTableWidth = [parentScrollView bounds].size.width - [NSScroller scrollerWidth] - [columnDefinitions count] * 3.5; + CGFloat visibleTableWidth = [parentScrollView bounds].size.width - [NSScroller scrollerWidth] - [columnDefinitions count] * 3.5f; for (NSDictionary *columnDefinition in columnDefinitions) { if ([[NSThread currentThread] isCancelled]) return nil; @@ -735,7 +731,7 @@ static const NSInteger kBlobAsImageFile = 4; for (NSString *columnIdentifier in columnIdentifiers) { columnWidth = [[columnWidths objectForKey:columnIdentifier] integerValue]; if (columnWidth > SP_MAX_CELL_WIDTH_MULTICOLUMN) { - columnWidth -= ceil((double)(columnWidth - SP_MAX_CELL_WIDTH_MULTICOLUMN) / availableWidthToReduce * widthToReduce); + columnWidth -= ceilf((double)(columnWidth - SP_MAX_CELL_WIDTH_MULTICOLUMN) / availableWidthToReduce * widthToReduce); [columnWidths setObject:[NSNumber numberWithUnsignedInteger:columnWidth] forKey:columnIdentifier]; } } @@ -764,13 +760,13 @@ static const NSInteger kBlobAsImageFile = 4; #endif NSUInteger columnIndex = (NSUInteger)[[columnDefinition objectForKey:@"datacolumnindex"] integerValue]; NSDictionary *stringAttributes = [NSDictionary dictionaryWithObject:tableFont forKey:NSFontAttributeName]; - Class mcpGeometryData = [MCPGeometryData class]; + Class spmysqlGeometryData = [SPMySQLGeometryData class]; // Check the number of rows available to check, sampling every n rows if ([tableStorage count] < rowsToCheck) rowStep = 1; else - rowStep = floor([tableStorage count] / rowsToCheck); + rowStep = floorf([tableStorage count] / rowsToCheck); rowsToCheck = [tableStorage count]; @@ -784,8 +780,8 @@ static const NSInteger kBlobAsImageFile = 4; // Retrieve the cell's content contentString = [tableStorage cellDataAtRow:i column:columnIndex]; - // Get WKT string out of the MCPGeometryData for calculation - if ([contentString isKindOfClass:mcpGeometryData]) + // Get WKT string out of the SPMySQLGeometryData for calculation + if ([contentString isKindOfClass:spmysqlGeometryData]) contentString = [contentString wktString]; // Replace NULLs with their placeholder string -- cgit v1.2.3