* Asks the user about file specifics. * guessedDefinition the definition the file most likely is (as returned by guessDefinition()) */
| 1080 | * guessedDefinition the definition the file most likely is (as returned by guessDefinition()) |
| 1081 | */ |
| 1082 | CsvDefinition CsvApplication::setTypeByUser(CsvDefinition guessedDefinition, std::istream *input, std::string buttonText) { |
| 1083 | Fl_Choice *delChoice; |
| 1084 | Fl_Choice *escChoice; |
| 1085 | Fl_Choice *quoteChoice = nullptr; |
| 1086 | |
| 1087 | My_Fl_Button *but; |
| 1088 | CsvTable *table = nullptr; |
| 1089 | CsvGrid *grid = nullptr; |
| 1090 | std::string output; |
| 1091 | int encDefault = 0; |
| 1092 | int delDefault = 0; |
| 1093 | int quoteDefault = 0; |
| 1094 | int escDefault = 0; |
| 1095 | CsvDefinition definition = guessedDefinition; |
| 1096 | struct previewTableStruct previewTable; |
| 1097 | app.setTypeByUserCancelled = false; |
| 1098 | |
| 1099 | // when no encoding could be guessed, show as UTF8 – otherwise `CsvParser::parseCsvStream` would return a (0,0) table for preview |
| 1100 | if( definition.encoding == CsvDefinition::ENC_NONE ) { |
| 1101 | definition.encoding = CsvDefinition::ENC_UTF8; |
| 1102 | } |
| 1103 | |
| 1104 | // set guessed encoding as start value |
| 1105 | switch( definition.encoding ) { |
| 1106 | case CsvDefinition::ENC_UTF8: |
| 1107 | encDefault = 1; |
| 1108 | break; |
| 1109 | case CsvDefinition::ENC_Latin1: |
| 1110 | encDefault = 2; |
| 1111 | break; |
| 1112 | case CsvDefinition::ENC_Win1252: |
| 1113 | encDefault = 3; |
| 1114 | break; |
| 1115 | case CsvDefinition::ENC_UTF16LE: |
| 1116 | encDefault = 4; |
| 1117 | break; |
| 1118 | case CsvDefinition::ENC_UTF16BE: |
| 1119 | encDefault = 5; |
| 1120 | break; |
| 1121 | default: |
| 1122 | encDefault = 0; |
| 1123 | break; |
| 1124 | } |
| 1125 | |
| 1126 | // set guessed delimiter as start value |
| 1127 | switch( definition.delimiter ) { |
| 1128 | case ',': |
| 1129 | delDefault = 0; |
| 1130 | break; |
| 1131 | case ';': |
| 1132 | delDefault = 1; |
| 1133 | break; |
| 1134 | case '\t': |
| 1135 | delDefault = 2; |
| 1136 | break; |
| 1137 | case '|': |
| 1138 | delDefault = 3; |
| 1139 | break; |
nothing calls this directly
no test coverage detected