X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fui%2Fgui%2Fpage-file.c;h=a781fcad2edddde6f7226d1773b9d51476a2ee4b;hb=1509c6773d7302a2753c4f47b3e52fc5e3cca185;hp=9ac69e86856db98fe049a4824a1e76377b99086b;hpb=5c210c96542db2a357cf1aa6b690ef2ea88a54b1;p=pspp diff --git a/src/ui/gui/page-file.c b/src/ui/gui/page-file.c index 9ac69e8685..a781fcad2e 100644 --- a/src/ui/gui/page-file.c +++ b/src/ui/gui/page-file.c @@ -66,63 +66,8 @@ struct import_assistant; /* Choose a file */ static char *choose_file (GtkWindow *parent_window, gchar **encodingp); -enum { MAX_PREVIEW_LINES = 1000 }; /* Max number of lines to read. */ -/* - Update IA according to the contents of DICT and CREADER. - CREADER will be destroyed by this function. -*/ -void -update_assistant (struct import_assistant *ia) -{ - struct sheet_spec_page *ssp = &ia->sheet_spec; - - struct file *file = &ia->file; - struct separators_page *sepp = &ia->separators; - int rows = 0; - if (ssp->dict) - { - struct ccase *c; - int col; - - - sepp->column_cnt = dict_get_var_cnt (ssp->dict); - sepp->columns = xcalloc (sepp->column_cnt, sizeof (*sepp->columns)); - for (col = 0; col < sepp->column_cnt ; ++col) - { - const struct variable *var = dict_get_var (ssp->dict, col); - sepp->columns[col].name = xstrdup (var_get_name (var)); - sepp->columns[col].contents = NULL; - } - - for (; (c = casereader_read (ssp->reader)) != NULL; case_unref (c)) - { - rows++; - for (col = 0; col < sepp->column_cnt ; ++col) - { - char *ss; - const struct variable *var = dict_get_var (ssp->dict, col); - - sepp->columns[col].contents = xrealloc (sepp->columns[col].contents, - sizeof (struct substring) * rows); - - ss = data_out (case_data (c, var), dict_get_encoding (ssp->dict), - var_get_print_format (var)); - - sepp->columns[col].contents[rows - 1] = ss_cstr (ss); - } - - if (rows > MAX_PREVIEW_LINES) - { - case_unref (c); - break; - } - } - } - - file->line_cnt = rows; -} /* Obtains the file to import from the user and initializes IA's @@ -136,7 +81,6 @@ init_file (struct import_assistant *ia, GtkWindow *parent_window) { enum { MAX_LINE_LEN = 16384 }; /* Max length of an acceptable line. */ struct file *file = &ia->file; - struct sheet_spec_page *ssp = &ia->sheet_spec; struct spreadsheet_read_info sri; struct spreadsheet_read_options opts; @@ -149,29 +93,23 @@ init_file (struct import_assistant *ia, GtkWindow *parent_window) opts.cell_range = NULL; opts.sheet_index = 1; - sri.file_name = file->file_name; sri.read_names = true; sri.asw = -1; - if (ssp->spreadsheet == NULL) - ssp->spreadsheet = gnumeric_probe (sri.file_name); - - printf ("%s:%d %p %d\n", __FILE__, __LINE__, ssp->spreadsheet, ssp->spreadsheet->type); - - if (ssp->spreadsheet == NULL) - ssp->spreadsheet = ods_probe (sri.file_name); + printf ("%s:%d %p\n", __FILE__, __LINE__, ia->spreadsheet); - printf ("%s:%d %p %d\n", __FILE__, __LINE__, ssp->spreadsheet, ssp->spreadsheet->type); + if (ia->spreadsheet == NULL) + ia->spreadsheet = gnumeric_probe (file->file_name); - if (ssp->spreadsheet) - { - - // update_assistant (ia); - } - else - { - printf ("%s:%d %p\n", __FILE__, __LINE__, ssp->spreadsheet); + printf ("%s:%d %p\n", __FILE__, __LINE__, ia->spreadsheet); + + if (ia->spreadsheet == NULL) + ia->spreadsheet = ods_probe (file->file_name); + printf ("%s:%d %p\n", __FILE__, __LINE__, ia->spreadsheet); + + if (ia->spreadsheet == NULL) + { struct string input; struct line_reader *reader = line_reader_for_file (file->encoding, file->file_name, O_RDONLY); if (reader == NULL)