From c073e11612e36a7f9b8d7033faf08d663dd40c1f Mon Sep 17 00:00:00 2001 From: rowanbeentje Date: Sun, 25 Jul 2010 00:02:01 +0000 Subject: - Fix positioning bug when using Import From Clipboard - Add controllable encoding support when importing CSV and SQL files, including a new default "Autodetect" option. Add UniversalDetector framework to support encoding autodetection. This should address Issue #720. --- Frameworks/UniversalDetector.framework/Headers | 1 + Frameworks/UniversalDetector.framework/Resources | 1 + .../UniversalDetector.framework/UniversalDetector | 1 + .../Versions/A/Headers/UniversalDetector.h | 26 + .../A/Resources/English.lproj/InfoPlist.strings | Bin 0 -> 204 bytes .../Versions/A/Resources/Info.plist | 22 + .../Versions/A/UniversalDetector | Bin 0 -> 553844 bytes .../UniversalDetector.framework/Versions/Current | 1 + Interfaces/English.lproj/ImportAccessory.xib | 1615 ++++++++++++++++---- Source/SPDataImport.h | 1 + Source/SPDataImport.m | 104 +- sequel-pro.xcodeproj/project.pbxproj | 6 + 12 files changed, 1478 insertions(+), 300 deletions(-) create mode 120000 Frameworks/UniversalDetector.framework/Headers create mode 120000 Frameworks/UniversalDetector.framework/Resources create mode 120000 Frameworks/UniversalDetector.framework/UniversalDetector create mode 100755 Frameworks/UniversalDetector.framework/Versions/A/Headers/UniversalDetector.h create mode 100644 Frameworks/UniversalDetector.framework/Versions/A/Resources/English.lproj/InfoPlist.strings create mode 100644 Frameworks/UniversalDetector.framework/Versions/A/Resources/Info.plist create mode 100755 Frameworks/UniversalDetector.framework/Versions/A/UniversalDetector create mode 120000 Frameworks/UniversalDetector.framework/Versions/Current diff --git a/Frameworks/UniversalDetector.framework/Headers b/Frameworks/UniversalDetector.framework/Headers new file mode 120000 index 00000000..a177d2a6 --- /dev/null +++ b/Frameworks/UniversalDetector.framework/Headers @@ -0,0 +1 @@ +Versions/Current/Headers \ No newline at end of file diff --git a/Frameworks/UniversalDetector.framework/Resources b/Frameworks/UniversalDetector.framework/Resources new file mode 120000 index 00000000..953ee36f --- /dev/null +++ b/Frameworks/UniversalDetector.framework/Resources @@ -0,0 +1 @@ +Versions/Current/Resources \ No newline at end of file diff --git a/Frameworks/UniversalDetector.framework/UniversalDetector b/Frameworks/UniversalDetector.framework/UniversalDetector new file mode 120000 index 00000000..8a32fbcc --- /dev/null +++ b/Frameworks/UniversalDetector.framework/UniversalDetector @@ -0,0 +1 @@ +Versions/Current/UniversalDetector \ No newline at end of file diff --git a/Frameworks/UniversalDetector.framework/Versions/A/Headers/UniversalDetector.h b/Frameworks/UniversalDetector.framework/Versions/A/Headers/UniversalDetector.h new file mode 100755 index 00000000..5d8d023b --- /dev/null +++ b/Frameworks/UniversalDetector.framework/Versions/A/Headers/UniversalDetector.h @@ -0,0 +1,26 @@ +#import + +@interface UniversalDetector:NSObject +{ + void *detectorPtr; + NSString *charsetName; + float confidence; +} + +-(id)init; +-(void)dealloc; + +-(void)analyzeData:(NSData *)data; +-(void)analyzeBytes:(const char *)data length:(int)len; +-(void)reset; + +-(BOOL)done; +-(NSString *)MIMECharset; +-(NSStringEncoding)encoding; +-(float)confidence; + +//-(void)debugDump; + ++(UniversalDetector *)detector; + +@end diff --git a/Frameworks/UniversalDetector.framework/Versions/A/Resources/English.lproj/InfoPlist.strings b/Frameworks/UniversalDetector.framework/Versions/A/Resources/English.lproj/InfoPlist.strings new file mode 100644 index 00000000..7080cf94 Binary files /dev/null and b/Frameworks/UniversalDetector.framework/Versions/A/Resources/English.lproj/InfoPlist.strings differ diff --git a/Frameworks/UniversalDetector.framework/Versions/A/Resources/Info.plist b/Frameworks/UniversalDetector.framework/Versions/A/Resources/Info.plist new file mode 100644 index 00000000..2e89cad2 --- /dev/null +++ b/Frameworks/UniversalDetector.framework/Versions/A/Resources/Info.plist @@ -0,0 +1,22 @@ + + + + + CFBundleDevelopmentRegion + English + CFBundleExecutable + UniversalDetector + CFBundleIdentifier + org.mozilla.universalchardet + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + UniversalDetector + CFBundlePackageType + FMWK + CFBundleSignature + ???? + CFBundleVersion + 1.0 + + diff --git a/Frameworks/UniversalDetector.framework/Versions/A/UniversalDetector b/Frameworks/UniversalDetector.framework/Versions/A/UniversalDetector new file mode 100755 index 00000000..7a63ef2a Binary files /dev/null and b/Frameworks/UniversalDetector.framework/Versions/A/UniversalDetector differ diff --git a/Frameworks/UniversalDetector.framework/Versions/Current b/Frameworks/UniversalDetector.framework/Versions/Current new file mode 120000 index 00000000..8c7e5a66 --- /dev/null +++ b/Frameworks/UniversalDetector.framework/Versions/Current @@ -0,0 +1 @@ +A \ No newline at end of file diff --git a/Interfaces/English.lproj/ImportAccessory.xib b/Interfaces/English.lproj/ImportAccessory.xib index e45046af..f39bc725 100644 --- a/Interfaces/English.lproj/ImportAccessory.xib +++ b/Interfaces/English.lproj/ImportAccessory.xib @@ -1,7 +1,7 @@ - 1060 + 1050 10F569 788 1038.29 @@ -12,6 +12,8 @@ YES + + YES @@ -38,10 +40,94 @@ NSApplication - + 274 YES + + + 264 + {{189, 76}, {156, 26}} + + YES + + -2076049856 + 2048 + + LucidaGrande + 13 + 1044 + + + 109199615 + 129 + + + 400 + 75 + + + Item 1 + + 1048576 + 2147483647 + + NSImage + NSMenuCheckmark + + + NSImage + NSMenuMixedState + + _popUpItemAction: + + + YES + + OtherViews + + YES + + + + 1 + YES + YES + 2 + + + + + 264 + {{17, 82}, {170, 17}} + + YES + + 68288064 + 71304192 + Encoding: + + + + 6 + System + controlColor + + 3 + MC42NjY2NjY2NjY3AA + + + + 6 + System + controlTextColor + + 3 + MAA + + + + 10 @@ -55,7 +141,7 @@ 264 - {{2, 63}, {411, 18}} + {{22, 54}, {411, 18}} YES @@ -82,7 +168,7 @@ 268 - {{149, 8}, {54, 22}} + {{169, 2}, {54, 22}} YES @@ -101,15 +187,7 @@ MQA - - 6 - System - controlTextColor - - 3 - MAA - - + 2 YES @@ -159,10 +237,7 @@ 6 System controlBackgroundColor - - 3 - MC42NjY2NjY2ODY1AA - + @@ -200,28 +275,23 @@ 268 - {{2, 15}, {142, 14}} + {{2, 7}, {162, 14}} YES 68288064 - 71304192 + 71435264 Fields enclosed by: - - 6 - System - controlColor - - + 265 - {{360, 35}, {54, 22}} + {{380, 27}, {54, 22}} YES @@ -303,12 +373,12 @@ 265 - {{212, 37}, {143, 17}} + {{232, 32}, {143, 14}} YES - 67239424 - 71303168 + 68288064 + 71435264 Fields escaped by: @@ -319,7 +389,7 @@ 265 - {{360, 8}, {54, 22}} + {{380, 2}, {54, 22}} YES @@ -402,12 +472,12 @@ 265 - {{212, 12}, {143, 17}} + {{232, 7}, {143, 14}} YES - 67239424 - 71303168 + 68288064 + 71435264 Lines terminated by: @@ -418,7 +488,7 @@ 268 - {{149, 36}, {54, 22}} + {{169, 27}, {54, 22}} YES @@ -503,12 +573,12 @@ 268 - {{2, 40}, {142, 14}} + {{2, 32}, {162, 14}} YES 68288064 - 71304192 + 71435264 Fields terminated by: @@ -517,11 +587,11 @@ - {416, 84} + {456, 72} - {{17, 10}, {416, 84}} + {{-3, 1}, {456, 72}} {0, 0} @@ -544,17 +614,13 @@ 264 - {{209, 101}, {100, 26}} + {{189, 104}, {156, 26}} YES -2076049856 2048 - - LucidaGrande - 13 - 1044 - + 109199615 129 @@ -569,14 +635,8 @@ 1048576 2147483647 1 - - NSImage - NSMenuCheckmark - - - NSImage - NSMenuMixedState - + + _popUpItemAction: @@ -592,8 +652,8 @@ 1048576 2147483647 - - + + _popUpItemAction: @@ -608,12 +668,12 @@ 264 - {{154, 107}, {53, 17}} + {{17, 110}, {170, 17}} YES 68288064 - 272630784 + 71304192 Format: @@ -623,6 +683,7 @@ {450, 135} + NSView @@ -634,15 +695,15 @@ 15 2 - {{131, 75}, {500, 353}} + {{131, 16}, {500, 412}} 1954022400 Window NSWindow - {3.40282e+38, 3.40282e+38} + {1.79769e+308, 1.79769e+308} {500, 353} - + 256 YES @@ -659,7 +720,7 @@ 2322 - {{0, 15}, {500, 14}} + {500, 68} @@ -738,7 +799,7 @@ - {{1, 1}, {500, 124}} + {{1, 1}, {500, 178}} @@ -770,7 +831,7 @@ 0.94565218687057495 - {{-1, 195}, {502, 126}} + {{-1, 200}, {502, 180}} 562 @@ -781,7 +842,7 @@ 289 - {{322, 7}, {82, 32}} + {{322, 12}, {82, 32}} YES @@ -801,7 +862,7 @@ 289 - {{404, 7}, {82, 32}} + {{404, 12}, {82, 32}} 1 YES @@ -831,8 +892,8 @@ YES - 301 - {{18, 6}, {448, 134}} + 293 + {{2, 3}, {480, 139}} NSView @@ -841,7 +902,7 @@ - {{7, 44}, {486, 145}} + {{7, 49}, {486, 145}} {0, 0} @@ -864,7 +925,7 @@ 269 - {{175, 329}, {146.219, 17}} + {{175, 388}, {146, 17}} YES @@ -878,11 +939,12 @@ - {500, 353} + {500, 412} + {{0, 0}, {1280, 778}} {500, 375} - {3.40282e+38, 3.40282e+38} + {1.79769e+308, 1.79769e+308} @@ -992,14 +1054,6 @@ 56 - - - nextKeyView - - - - 57 - closeSheet: @@ -1040,6 +1094,30 @@ 102 + + + nextKeyView + + + + 120 + + + + nextKeyView + + + + 122 + + + + importEncodingPopup + + + + 123 + @@ -1074,8 +1152,10 @@ YES - + + + Import CSV Accessory View @@ -1296,10 +1376,10 @@ YES - - - + + + @@ -1385,6 +1465,52 @@ + + 105 + + + YES + + + + + + 106 + + + + + 115 + + + YES + + + + + + 116 + + + YES + + + + + + 117 + + + YES + + + + + + 119 + + + @@ -1400,9 +1526,16 @@ 10.ImportedFromIB2 103.IBPluginDependency 104.IBPluginDependency + 105.IBPluginDependency + 106.IBPluginDependency 11.IBAttributePlaceholdersKey 11.IBPluginDependency 11.ImportedFromIB2 + 115.IBPluginDependency + 116.IBPluginDependency + 117.IBEditorWindowLastContentRect + 117.IBPluginDependency + 119.IBPluginDependency 12.IBPluginDependency 12.ImportedFromIB2 13.IBPluginDependency @@ -1468,6 +1601,8 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin ToolTip @@ -1479,6 +1614,11 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + {{383, 415}, {116, 20}} + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -1525,9 +1665,9 @@ com.apple.InterfaceBuilder.CocoaPlugin - {{220, 272}, {500, 353}} + {{404, 193}, {500, 412}} com.apple.InterfaceBuilder.CocoaPlugin - {{220, 272}, {500, 353}} + {{404, 193}, {500, 412}} {500, 353} @@ -1570,26 +1710,125 @@ - 104 + 123 YES - SPDataImport - NSObject + NSApplication + + IBProjectSource + Frameworks/PSMTabBar/PSMTabDragAssistant.h + + + + NSObject + + IBProjectSource + Frameworks/MCPKit/MCPFoundationKit/MCPConnection.h + + + + NSObject + + IBProjectSource + Frameworks/MCPKit/MCPFoundationKit/MCPNull.h + + + + NSObject + + IBProjectSource + Frameworks/PSMTabBar/PSMTabBarCell.h + + + + NSObject + + IBProjectSource + Frameworks/PSMTabBar/PSMTabBarControl.h + + + + NSObject + + IBProjectSource + Source/SPConnectionController.h + + + + NSObject + + IBProjectSource + Source/SPContentFilterManager.h + + + + NSObject + + IBProjectSource + Source/SPImageView.h + + + + NSObject + + IBProjectSource + Source/SPMainThreadTrampoline.h + + + + NSObject + + IBProjectSource + Source/SPNotLoaded.h + + + + NSObject + + IBProjectSource + Source/SPQueryFavoriteManager.h + + + + NSObject + + toggleCollapse: + id + + + toggleCollapse: + + toggleCollapse: + id + + + + IBProjectSource + Source/SPTablesList.h + + + + NSTextView YES YES - cancelProgressBar: - changeFormat: - closeSheet: - panelSelectionDidChange: - reloadTables: - selectTables: - switchInput: - switchTab: + doDecomposedStringWithCanonicalMapping: + doDecomposedStringWithCompatibilityMapping: + doPrecomposedStringWithCanonicalMapping: + doPrecomposedStringWithCompatibilityMapping: + doRemoveDiacritics: + doSelectionLowerCase: + doSelectionTitleCase: + doSelectionUpperCase: + doTranspose: + insertNULLvalue: + selectCurrentLine: + selectCurrentWord: + selectEnclosingBrackets: YES @@ -1601,92 +1840,163 @@ id id id + id + id + id + id + id YES YES - cancelProgressBar: - changeFormat: - closeSheet: - panelSelectionDidChange: - reloadTables: - selectTables: - switchInput: - switchTab: + doDecomposedStringWithCanonicalMapping: + doDecomposedStringWithCompatibilityMapping: + doPrecomposedStringWithCanonicalMapping: + doPrecomposedStringWithCompatibilityMapping: + doRemoveDiacritics: + doSelectionLowerCase: + doSelectionTitleCase: + doSelectionUpperCase: + doTranspose: + insertNULLvalue: + selectCurrentLine: + selectCurrentWord: + selectEnclosingBrackets: YES - cancelProgressBar: + doDecomposedStringWithCanonicalMapping: id - changeFormat: + doDecomposedStringWithCompatibilityMapping: id - closeSheet: + doPrecomposedStringWithCanonicalMapping: id - panelSelectionDidChange: + doPrecomposedStringWithCompatibilityMapping: id - reloadTables: + doRemoveDiacritics: id - selectTables: + doSelectionLowerCase: id - switchInput: + doSelectionTitleCase: id - switchTab: + doSelectionUpperCase: + id + + + doTranspose: + id + + + insertNULLvalue: + id + + + selectCurrentLine: + id + + + selectCurrentWord: + id + + + selectEnclosingBrackets: id - + + IBProjectSource + Source/SPTextViewAdditions.h + + + + NSWindow + + IBProjectSource + Source/SPWindowAdditions.h + + + + SPDataImport + NSObject + YES YES - addCreateTableSwitch - addDropTableSwitch - addErrorsSwitch + cancelProgressBar: + changeFormat: + closeSheet: + panelSelectionDidChange: + + + YES + id + id + id + id + + + + YES + + YES + cancelProgressBar: + changeFormat: + closeSheet: + panelSelectionDidChange: + + + YES + + cancelProgressBar: + id + + + changeFormat: + id + + + closeSheet: + id + + + panelSelectionDidChange: + id + + + + + YES + + YES + addCreateTableSwitch + addDropTableSwitch + addErrorsSwitch addTableContentSwitch csvFullStreamingSwitch customQueryInstance errorsSheet errorsView - exportCSVView - exportDumpTableView - exportDumpView - exportFieldNamesSwitch - exportFieldsEnclosedField - exportFieldsEscapedField - exportFieldsTerminatedField - exportLinesTerminatedField - exportMultipleCSVTableView - exportMultipleCSVView - exportMultipleFieldNamesSwitch - exportMultipleFieldsEnclosedField - exportMultipleFieldsEscapedField - exportMultipleFieldsTerminatedField - exportMultipleLinesTerminatedField - exportMultipleXMLTableView - exportMultipleXMLView - exportTabBar - exportTableList - exportToolbar - exportWindow importCSVBox importCSVView + importEncodingPopup importFieldMapperSheetWindow importFieldNamesSwitch importFieldsEnclosedField @@ -1703,12 +2013,12 @@ singleProgressSheet singleProgressText singleProgressTitle + sqlCompressionSwitch sqlFullStreamingSwitch tableContentInstance tableDataInstance tableDocumentInstance tableSourceInstance - tableWindow tablesListInstance @@ -1723,27 +2033,7 @@ id id id - id - id - id - id - id - id - id - id - id - id - id - id - id - id - id - id - id - id - id - id - id + NSPopUpButton id id id @@ -1781,29 +2071,9 @@ customQueryInstance errorsSheet errorsView - exportCSVView - exportDumpTableView - exportDumpView - exportFieldNamesSwitch - exportFieldsEnclosedField - exportFieldsEscapedField - exportFieldsTerminatedField - exportLinesTerminatedField - exportMultipleCSVTableView - exportMultipleCSVView - exportMultipleFieldNamesSwitch - exportMultipleFieldsEnclosedField - exportMultipleFieldsEscapedField - exportMultipleFieldsTerminatedField - exportMultipleLinesTerminatedField - exportMultipleXMLTableView - exportMultipleXMLView - exportTabBar - exportTableList - exportToolbar - exportWindow importCSVBox importCSVView + importEncodingPopup importFieldMapperSheetWindow importFieldNamesSwitch importFieldsEnclosedField @@ -1820,12 +2090,12 @@ singleProgressSheet singleProgressText singleProgressTitle + sqlCompressionSwitch sqlFullStreamingSwitch tableContentInstance tableDataInstance tableDocumentInstance tableSourceInstance - tableWindow tablesListInstance @@ -1862,90 +2132,6 @@ errorsView id - - exportCSVView - id - - - exportDumpTableView - id - - - exportDumpView - id - - - exportFieldNamesSwitch - id - - - exportFieldsEnclosedField - id - - - exportFieldsEscapedField - id - - - exportFieldsTerminatedField - id - - - exportLinesTerminatedField - id - - - exportMultipleCSVTableView - id - - - exportMultipleCSVView - id - - - exportMultipleFieldNamesSwitch - id - - - exportMultipleFieldsEnclosedField - id - - - exportMultipleFieldsEscapedField - id - - - exportMultipleFieldsTerminatedField - id - - - exportMultipleLinesTerminatedField - id - - - exportMultipleXMLTableView - id - - - exportMultipleXMLView - id - - - exportTabBar - id - - - exportTableList - id - - - exportToolbar - id - - - exportWindow - id - importCSVBox id @@ -1954,6 +2140,10 @@ importCSVView id + + importEncodingPopup + NSPopUpButton + importFieldMapperSheetWindow id @@ -2018,6 +2208,10 @@ singleProgressTitle id + + sqlCompressionSwitch + id + sqlFullStreamingSwitch id @@ -2038,10 +2232,6 @@ tableSourceInstance id - - tableWindow - id - tablesListInstance id @@ -2049,20 +2239,895 @@ - IBUserSource - + IBProjectSource + Source/SPDataImport.h - - - 0 - IBCocoaFramework + + SPDataImport + NSObject + + YES + + YES + reloadTables: + selectTables: + switchInput: + switchTab: + + + YES + id + id + id + id + + + + YES + + YES + reloadTables: + selectTables: + switchInput: + switchTab: + + + YES + + reloadTables: + id + + + selectTables: + id + + + switchInput: + id + + + switchTab: + id + + + + + YES + + YES + exportCSVView + exportDumpTableView + exportDumpView + exportFieldNamesSwitch + exportFieldsEnclosedField + exportFieldsEscapedField + exportFieldsTerminatedField + exportLinesTerminatedField + exportMultipleCSVTableView + exportMultipleCSVView + exportMultipleFieldNamesSwitch + exportMultipleFieldsEnclosedField + exportMultipleFieldsEscapedField + exportMultipleFieldsTerminatedField + exportMultipleLinesTerminatedField + exportMultipleXMLTableView + exportMultipleXMLView + exportTabBar + exportTableList + exportToolbar + exportWindow + tableWindow + + + YES + id + id + id + id + id + id + id + id + id + id + id + id + id + id + id + id + id + id + id + id + id + id + + + + YES + + YES + exportCSVView + exportDumpTableView + exportDumpView + exportFieldNamesSwitch + exportFieldsEnclosedField + exportFieldsEscapedField + exportFieldsTerminatedField + exportLinesTerminatedField + exportMultipleCSVTableView + exportMultipleCSVView + exportMultipleFieldNamesSwitch + exportMultipleFieldsEnclosedField + exportMultipleFieldsEscapedField + exportMultipleFieldsTerminatedField + exportMultipleLinesTerminatedField + exportMultipleXMLTableView + exportMultipleXMLView + exportTabBar + exportTableList + exportToolbar + exportWindow + tableWindow + + + YES + + exportCSVView + id + + + exportDumpTableView + id + + + exportDumpView + id + + + exportFieldNamesSwitch + id + + + exportFieldsEnclosedField + id + + + exportFieldsEscapedField + id + + + exportFieldsTerminatedField + id + + + exportLinesTerminatedField + id + + + exportMultipleCSVTableView + id + + + exportMultipleCSVView + id + + + exportMultipleFieldNamesSwitch + id + + + exportMultipleFieldsEnclosedField + id + + + exportMultipleFieldsEscapedField + id + + + exportMultipleFieldsTerminatedField + id + + + exportMultipleLinesTerminatedField + id + + + exportMultipleXMLTableView + id + + + exportMultipleXMLView + id + + + exportTabBar + id + + + exportTableList + id + + + exportToolbar + id + + + exportWindow + id + + + tableWindow + id + + + + + IBUserSource + + + + + + YES + + NSActionCell + NSCell + + IBFrameworkSource + AppKit.framework/Headers/NSActionCell.h + + + + NSApplication + NSResponder + + IBFrameworkSource + AppKit.framework/Headers/NSApplication.h + + + + NSApplication + + IBFrameworkSource + AppKit.framework/Headers/NSApplicationScripting.h + + + + NSApplication + + IBFrameworkSource + AppKit.framework/Headers/NSColorPanel.h + + + + NSApplication + + IBFrameworkSource + AppKit.framework/Headers/NSHelpManager.h + + + + NSApplication + + IBFrameworkSource + AppKit.framework/Headers/NSPageLayout.h + + + + NSApplication + + IBFrameworkSource + AppKit.framework/Headers/NSUserInterfaceItemSearching.h + + + + NSApplication + + IBFrameworkSource + BWToolkitFramework.framework/Headers/NSApplication+BWAdditions.h + + + + NSBox + NSView + + IBFrameworkSource + AppKit.framework/Headers/NSBox.h + + + + NSButton + NSControl + + IBFrameworkSource + AppKit.framework/Headers/NSButton.h + + + + NSButtonCell + NSActionCell + + IBFrameworkSource + AppKit.framework/Headers/NSButtonCell.h + + + + NSCell + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSCell.h + + + + NSComboBox + NSTextField + + IBFrameworkSource + AppKit.framework/Headers/NSComboBox.h + + + + NSComboBoxCell + NSTextFieldCell + + IBFrameworkSource + AppKit.framework/Headers/NSComboBoxCell.h + + + + NSControl + NSView + + IBFrameworkSource + AppKit.framework/Headers/NSControl.h + + + + NSController + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSController.h + + + + NSFormatter + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSFormatter.h + + + + NSMenu + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSMenu.h + + + + NSMenuItem + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSMenuItem.h + + + + NSMenuItemCell + NSButtonCell + + IBFrameworkSource + AppKit.framework/Headers/NSMenuItemCell.h + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSAccessibility.h + + + + NSObject + + + + NSObject + + + + NSObject + + + + NSObject + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSDictionaryController.h + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSDragging.h + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSFontManager.h + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSFontPanel.h + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSKeyValueBinding.h + + + + NSObject + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSNibLoading.h + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSOutlineView.h + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSPasteboard.h + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSSavePanel.h + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSTableView.h + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSToolbarItem.h + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSView.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSArchiver.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSClassDescription.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSError.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSFileManager.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSKeyValueCoding.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSKeyValueObserving.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSKeyedArchiver.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSObject.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSObjectScripting.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSPortCoder.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSRunLoop.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSScriptClassDescription.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSScriptKeyValueCoding.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSScriptObjectSpecifiers.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSScriptWhoseTests.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSThread.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSURL.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSURLConnection.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSURLDownload.h + + + + NSObject + + IBFrameworkSource + Growl.framework/Headers/GrowlApplicationBridge.h + + + + NSObject + + IBFrameworkSource + Print.framework/Headers/PDEPluginInterface.h + + + + NSObject + + IBFrameworkSource + Sparkle.framework/Headers/SUAppcast.h + + + + NSObject + + IBFrameworkSource + Sparkle.framework/Headers/SUUpdater.h + + + + NSObject + + IBFrameworkSource + WebKit.framework/Headers/WebDownload.h + + + + NSObject + + IBFrameworkSource + WebKit.framework/Headers/WebEditingDelegate.h + + + + NSObject + + IBFrameworkSource + WebKit.framework/Headers/WebFrameLoadDelegate.h + + + + NSObject + + IBFrameworkSource + WebKit.framework/Headers/WebJavaPlugIn.h + + + + NSObject + + IBFrameworkSource + WebKit.framework/Headers/WebPlugin.h + + + + NSObject + + IBFrameworkSource + WebKit.framework/Headers/WebPluginContainer.h + + + + NSObject + + IBFrameworkSource + WebKit.framework/Headers/WebPolicyDelegate.h + + + + NSObject + + IBFrameworkSource + WebKit.framework/Headers/WebResourceLoadDelegate.h + + + + NSObject + + IBFrameworkSource + WebKit.framework/Headers/WebScriptObject.h + + + + NSObject + + IBFrameworkSource + WebKit.framework/Headers/WebUIDelegate.h + + + + NSPopUpButton + NSButton + + IBFrameworkSource + AppKit.framework/Headers/NSPopUpButton.h + + + + NSPopUpButtonCell + NSMenuItemCell + + IBFrameworkSource + AppKit.framework/Headers/NSPopUpButtonCell.h + + + + NSResponder + + IBFrameworkSource + AppKit.framework/Headers/NSInterfaceStyle.h + + + + NSResponder + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSResponder.h + + + + NSScrollView + NSView + + IBFrameworkSource + AppKit.framework/Headers/NSScrollView.h + + + + NSScroller + NSControl + + IBFrameworkSource + AppKit.framework/Headers/NSScroller.h + + + + NSText + NSView + + IBFrameworkSource + AppKit.framework/Headers/NSText.h + + + + NSTextField + NSControl + + IBFrameworkSource + AppKit.framework/Headers/NSTextField.h + + + + NSTextFieldCell + NSActionCell + + IBFrameworkSource + AppKit.framework/Headers/NSTextFieldCell.h + + + + NSTextView + NSText + + IBFrameworkSource + AppKit.framework/Headers/NSTextView.h + + + + NSUserDefaultsController + NSController + + IBFrameworkSource + AppKit.framework/Headers/NSUserDefaultsController.h + + + + NSView + + IBFrameworkSource + AppKit.framework/Headers/NSClipView.h + + + + NSView + + + + NSView + + IBFrameworkSource + AppKit.framework/Headers/NSRulerView.h + + + + NSView + NSResponder + + + + NSView + + IBFrameworkSource + BWToolkitFramework.framework/Headers/NSView+BWAdditions.h + + + + NSWindow + + IBFrameworkSource + AppKit.framework/Headers/NSDrawer.h + + + + NSWindow + NSResponder + + IBFrameworkSource + AppKit.framework/Headers/NSWindow.h + + + + NSWindow + + IBFrameworkSource + AppKit.framework/Headers/NSWindowScripting.h + + + + NSWindow + + IBFrameworkSource + BWToolkitFramework.framework/Headers/NSWindow+BWAdditions.h + + + + + 0 + IBCocoaFramework + + com.apple.InterfaceBuilder.CocoaPlugin.macosx + + com.apple.InterfaceBuilder.CocoaPlugin.InterfaceBuilder3 YES - + ../../sequel-pro.xcodeproj 3 YES diff --git a/Source/SPDataImport.h b/Source/SPDataImport.h index 14dcdedd..9a9dedf5 100644 --- a/Source/SPDataImport.h +++ b/Source/SPDataImport.h @@ -47,6 +47,7 @@ IBOutlet id importFieldMapperSheetWindow; IBOutlet NSPopUpButton *importFormatPopup; + IBOutlet NSPopUpButton *importEncodingPopup; IBOutlet id importFromClipboardSheet; IBOutlet id importFromClipboardAccessoryView; diff --git a/Source/SPDataImport.m b/Source/SPDataImport.m index b82bf1bb..6b20787a 100644 --- a/Source/SPDataImport.m +++ b/Source/SPDataImport.m @@ -42,6 +42,8 @@ #import "SPMainThreadTrampoline.h" #import "SPNotLoaded.h" #import "SPFileHandle.h" +#import "SPEncodingPopupAccessory.h" +#import @interface SPDataImport (PrivateAPI) @@ -99,6 +101,16 @@ [nibLoader instantiateNibWithOwner:self topLevelObjects:&importAccessoryTopLevelObjects]; [nibObjectsToRelease addObjectsFromArray:importAccessoryTopLevelObjects]; [nibLoader release]; + + // Set up the encodings menu + NSMutableArray *encodings = [NSMutableArray arrayWithArray:[SPEncodingPopupAccessory enabledEncodings]]; + [importEncodingPopup removeAllItems]; + [importEncodingPopup addItemWithTitle:NSLocalizedString(@"Autodetect", @"Encoding autodetect menu item")]; + [[importEncodingPopup menu] addItem:[NSMenuItem separatorItem]]; + for (NSNumber *encodingNumber in encodings) { + [importEncodingPopup addItemWithTitle:[NSString localizedNameOfStringEncoding:[encodingNumber unsignedIntegerValue]]]; + [[importEncodingPopup lastItem] setTag:[encodingNumber unsignedIntegerValue]]; + } } #pragma mark - @@ -176,7 +188,15 @@ [importFieldsEscapedField setStringValue:[prefs objectForKey:SPCSVImportFieldEscapeCharacter]]; [importFieldsEnclosedField setStringValue:[prefs objectForKey:SPCSVImportFieldEnclosedBy]]; [importFieldNamesSwitch setState:[[prefs objectForKey:SPCSVImportFirstLineIsHeader] boolValue]]; + + // Reset and disable the encoding menu + [importEncodingPopup selectItemWithTag:NSUTF8StringEncoding]; + [importEncodingPopup setEnabled:NO]; + + // Add the view, and resize it to fit the accessory view size [importFromClipboardAccessoryView addSubview:importCSVView]; + NSRect accessoryViewRect = [importFromClipboardAccessoryView frame]; + [importCSVView setFrame:NSMakeRect(0, 0, accessoryViewRect.size.width, accessoryViewRect.size.height)]; [NSApp beginSheet:importFromClipboardSheet modalForWindow:[tableDocumentInstance parentWindow] @@ -375,6 +395,22 @@ [tableDocumentInstance setQueryMode:SPImportExportQueryMode]; + // Determine the file encoding. The first item in the encoding menu is "Autodetect"; if + // this is selected, attempt to detect the encoding of the file (using first 2.5MB). + if (![importEncodingPopup indexOfSelectedItem]) { + SPFileHandle *detectorFileHandle = [SPFileHandle fileHandleForReadingAtPath:filename]; + if (detectorFileHandle) { + UniversalDetector *fileEncodingDetector = [[UniversalDetector alloc] init]; + [fileEncodingDetector analyzeData:[detectorFileHandle readDataOfLength:2500000]]; + sqlEncoding = [fileEncodingDetector encoding]; + [fileEncodingDetector release]; + } + + // Otherwise, get the encoding to use from the menu + } else { + sqlEncoding = [importEncodingPopup selectedTag]; + } + // Read in the file in a loop sqlParser = [[SPSQLParser alloc] init]; [sqlParser setDelimiterSupport:YES]; @@ -427,31 +463,27 @@ } // Try to generate a NSString with the resulting data - if (importSQLAsUTF8) { - sqlString = [[NSString alloc] initWithData:[sqlDataBuffer subdataWithRange:NSMakeRange(dataBufferLastQueryEndPosition, dataBufferPosition - dataBufferLastQueryEndPosition)] - encoding:NSUTF8StringEncoding]; - if (!sqlString) { - importSQLAsUTF8 = NO; - sqlEncoding = [MCPConnection encodingForMySQLEncoding:[[tableDocumentInstance connectionEncoding] UTF8String]]; - } - } - if (!importSQLAsUTF8) { - sqlString = [[NSString alloc] initWithData:[sqlDataBuffer subdataWithRange:NSMakeRange(dataBufferLastQueryEndPosition, dataBufferPosition - dataBufferLastQueryEndPosition)] - encoding:[MCPConnection encodingForMySQLEncoding:[[tableDocumentInstance connectionEncoding] UTF8String]]]; - if (!sqlString) { - [self closeAndStopProgressSheet]; - SPBeginAlertSheet(NSLocalizedString(@"File read error", @"SQL read error title"), - NSLocalizedString(@"OK", @"OK button"), - nil, nil, [tableDocumentInstance parentWindow], self, nil, nil, - [NSString stringWithFormat:NSLocalizedString(@"An error occurred when reading the file, as it could not be read in either UTF-8 or the current connection encoding (%@).\n\nOnly %ld queries were executed.", @"SQL encoding read error"), [tableDocumentInstance connectionEncoding], (long)queriesPerformed]); - [sqlParser release]; - [sqlDataBuffer release]; - [importPool drain]; - [tableDocumentInstance setQueryMode:SPInterfaceQueryMode]; - if([filename hasPrefix:SPImportClipboardTempFileNamePrefix]) - [[NSFileManager defaultManager] removeItemAtPath:filename error:nil]; - return; + sqlString = [[NSString alloc] initWithData:[sqlDataBuffer subdataWithRange:NSMakeRange(dataBufferLastQueryEndPosition, dataBufferPosition - dataBufferLastQueryEndPosition)] + encoding:sqlEncoding]; + if (!sqlString) { + [self closeAndStopProgressSheet]; + NSString *displayEncoding; + if (![importEncodingPopup indexOfSelectedItem]) { + displayEncoding = [NSString stringWithFormat:@"%@ - %@", [importEncodingPopup titleOfSelectedItem], [NSString localizedNameOfStringEncoding:sqlEncoding]]; + } else { + displayEncoding = [NSString localizedNameOfStringEncoding:sqlEncoding]; } + SPBeginAlertSheet(NSLocalizedString(@"File read error", @"SQL read error title"), + NSLocalizedString(@"OK", @"OK button"), + nil, nil, [tableDocumentInstance parentWindow], self, nil, nil, + [NSString stringWithFormat:NSLocalizedString(@"An error occurred when reading the file, as it could not be read in the encoding you selected (%@).\n\nOnly %ld queries were executed.", @"SQL encoding read error"), displayEncoding, (long)queriesPerformed]); + [sqlParser release]; + [sqlDataBuffer release]; + [importPool drain]; + [tableDocumentInstance setQueryMode:SPInterfaceQueryMode]; + if([filename hasPrefix:SPImportClipboardTempFileNamePrefix]) + [[NSFileManager defaultManager] removeItemAtPath:filename error:nil]; + return; } // Add the NSString segment to the SQL parser and release it @@ -660,6 +692,22 @@ [tableDocumentInstance setQueryMode:SPImportExportQueryMode]; + // Determine the file encoding. The first item in the encoding menu is "Autodetect"; if + // this is selected, attempt to detect the encoding of the file (using first 2.5MB). + if (![importEncodingPopup indexOfSelectedItem]) { + SPFileHandle *detectorFileHandle = [SPFileHandle fileHandleForReadingAtPath:filename]; + if (detectorFileHandle) { + UniversalDetector *fileEncodingDetector = [[UniversalDetector alloc] init]; + [fileEncodingDetector analyzeData:[detectorFileHandle readDataOfLength:2500000]]; + csvEncoding = [fileEncodingDetector encoding]; + [fileEncodingDetector release]; + } + + // Otherwise, get the encoding to use from the menu + } else { + csvEncoding = [importEncodingPopup selectedTag]; + } + // Read in the file in a loop. The loop actually needs to perform three tasks: read in // CSV data and parse them into row arrays; present the field mapping interface once it // has some data to show within the interface; and use the field mapping data to construct @@ -736,10 +784,16 @@ csvString = [[NSString alloc] initWithData:[csvDataBuffer subdataWithRange:NSMakeRange(dataBufferLastQueryEndPosition, dataBufferPosition - dataBufferLastQueryEndPosition)] encoding:csvEncoding]; if (!csvString) { [self closeAndStopProgressSheet]; + NSString *displayEncoding; + if (![importEncodingPopup indexOfSelectedItem]) { + displayEncoding = [NSString stringWithFormat:@"%@ - %@", [importEncodingPopup titleOfSelectedItem], [NSString localizedNameOfStringEncoding:csvEncoding]]; + } else { + displayEncoding = [NSString localizedNameOfStringEncoding:csvEncoding]; + } SPBeginAlertSheet(NSLocalizedString(@"File read error", @"CSV read error title"), NSLocalizedString(@"OK", @"OK button"), nil, nil, [tableDocumentInstance parentWindow], self, nil, nil, - [NSString stringWithFormat:NSLocalizedString(@"An error occurred when reading the file, as it could not be read using the connection encoding (%@).\n\nOnly %ld rows were imported.", @"CSV encoding read error"), [tableDocumentInstance connectionEncoding], (long)rowsImported]); + [NSString stringWithFormat:NSLocalizedString(@"An error occurred when reading the file, as it could not be read using the encoding you selected (%@).\n\nOnly %ld rows were imported.", @"CSV encoding read error"), displayEncoding, (long)rowsImported]); [csvParser release]; [csvDataBuffer release]; [parsedRows release]; diff --git a/sequel-pro.xcodeproj/project.pbxproj b/sequel-pro.xcodeproj/project.pbxproj index fe304ea9..ca412ecf 100644 --- a/sequel-pro.xcodeproj/project.pbxproj +++ b/sequel-pro.xcodeproj/project.pbxproj @@ -245,6 +245,8 @@ 58C4593910D0674E00E6E13E /* sqlicon.icns in Resources */ = {isa = PBXBuildFile; fileRef = 58C4593710D0674D00E6E13E /* sqlicon.icns */; }; 58C56EF50F438E120035701E /* SPDataCellFormatter.m in Sources */ = {isa = PBXBuildFile; fileRef = 58C56EF40F438E120035701E /* SPDataCellFormatter.m */; }; 58C61CFA11960312003BAA5D /* SPAlertSheets.m in Sources */ = {isa = PBXBuildFile; fileRef = 584095181107CB6600260CFD /* SPAlertSheets.m */; }; + 58C6C71611FBB17200A3F5E9 /* UniversalDetector.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 58C6C71511FBB17200A3F5E9 /* UniversalDetector.framework */; }; + 58C6C71F11FBB18000A3F5E9 /* UniversalDetector.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = 58C6C71511FBB17200A3F5E9 /* UniversalDetector.framework */; }; 58CB20ED0F79A75D005EA204 /* button_edit_mode_selected.tiff in Resources */ = {isa = PBXBuildFile; fileRef = 58CB20EC0F79A75D005EA204 /* button_edit_mode_selected.tiff */; }; 58CDB3300FCE138D00F8ACA3 /* SPSSHTunnel.m in Sources */ = {isa = PBXBuildFile; fileRef = 58CDB32F0FCE138D00F8ACA3 /* SPSSHTunnel.m */; }; 58CDB3400FCE13EF00F8ACA3 /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B5EAC0FC0EC87FF900CC579C /* Security.framework */; }; @@ -400,6 +402,7 @@ 4DECC48F0EC2B436008D359E /* Sparkle.framework in CopyFiles */, B52ECE1410DDAD01009DC3E8 /* BWToolkitFramework.framework in CopyFiles */, 586EBD5D11418D9400B3DE45 /* FeedbackReporter.framework in CopyFiles */, + 58C6C71F11FBB18000A3F5E9 /* UniversalDetector.framework in CopyFiles */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -813,6 +816,7 @@ 58C4593710D0674D00E6E13E /* sqlicon.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = sqlicon.icns; sourceTree = ""; }; 58C56EF30F438E120035701E /* SPDataCellFormatter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SPDataCellFormatter.h; sourceTree = ""; }; 58C56EF40F438E120035701E /* SPDataCellFormatter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SPDataCellFormatter.m; sourceTree = ""; }; + 58C6C71511FBB17200A3F5E9 /* UniversalDetector.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UniversalDetector.framework; path = Frameworks/UniversalDetector.framework; sourceTree = ""; }; 58CB20EC0F79A75D005EA204 /* button_edit_mode_selected.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; path = button_edit_mode_selected.tiff; sourceTree = ""; }; 58CDB32E0FCE138D00F8ACA3 /* SPSSHTunnel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SPSSHTunnel.h; sourceTree = ""; }; 58CDB32F0FCE138D00F8ACA3 /* SPSSHTunnel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SPSSHTunnel.m; sourceTree = ""; }; @@ -1001,6 +1005,7 @@ B52ECDDC10DDACE9009DC3E8 /* BWToolkitFramework.framework in Frameworks */, 586EBD2411418D7C00B3DE45 /* FeedbackReporter.framework in Frameworks */, 179ECECA11F265FC009C6A40 /* libbz2.dylib in Frameworks */, + 58C6C71611FBB17200A3F5E9 /* UniversalDetector.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1018,6 +1023,7 @@ 296DC89E0F8FD336002A3258 /* WebKit.framework */, 586EBD2311418D7C00B3DE45 /* FeedbackReporter.framework */, 580E8EDC11EBE2A4000D8427 /* SystemConfiguration.framework */, + 58C6C71511FBB17200A3F5E9 /* UniversalDetector.framework */, 296DC8BE0F9091DF002A3258 /* libicucore.dylib */, 17B7B58F1016028F00F057DE /* libcrypto.dylib */, 179ECEC611F265EE009C6A40 /* libbz2.dylib */, -- cgit v1.2.3