diff options
author | stuconnolly <stuart02@gmail.com> | 2012-03-18 20:05:36 +0000 |
---|---|---|
committer | stuconnolly <stuart02@gmail.com> | 2012-03-18 20:05:36 +0000 |
commit | 524e8c356b4074f5be5933b0551374a130a8f6d1 (patch) | |
tree | 0dab40735f2d9484930050cd08376cbf15e4ea55 /Source/SPCopyTable.m | |
parent | be3263f8158cb6f3dfa1005f49beefa7e494b852 (diff) | |
download | sequelpro-524e8c356b4074f5be5933b0551374a130a8f6d1.tar.gz sequelpro-524e8c356b4074f5be5933b0551374a130a8f6d1.tar.bz2 sequelpro-524e8c356b4074f5be5933b0551374a130a8f6d1.zip |
Bring outline view branch up to date with trunk (r3471:r3517).
Diffstat (limited to 'Source/SPCopyTable.m')
-rw-r--r-- | Source/SPCopyTable.m | 36 |
1 files changed, 16 insertions, 20 deletions
diff --git a/Source/SPCopyTable.m b/Source/SPCopyTable.m index e13ae61e..3cdf4213 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 <MCPKit/MCPKit.h> -#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 MENU_EDIT_COPY = 2001; NSInteger MENU_EDIT_COPY_WITH_COLUMN = 2002; @@ -166,7 +162,7 @@ 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]) { @@ -219,7 +215,7 @@ 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]]; @@ -304,7 +300,7 @@ 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; @@ -358,7 +354,7 @@ 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]]; @@ -519,15 +515,15 @@ 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: @@ -620,7 +616,7 @@ 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 ) { @@ -642,7 +638,7 @@ 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]]; @@ -708,7 +704,7 @@ 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; @@ -738,7 +734,7 @@ 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]; } } @@ -767,13 +763,13 @@ 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]; @@ -787,8 +783,8 @@ 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 |