#include "ui/gui/text-data-import-dialog.h"
+#include "page-intro.h"
+#include "page-sheet-spec.h"
+#include "page-first-line.h"
+#include "page-separators.h"
+#include "page-formats.h"
+
#include <errno.h>
#include <fcntl.h>
#include <gtk-contrib/psppire-sheet.h>
ssp = ia->sheet_spec;
- init_formats_page (ia);
+ if (ia->spreadsheet)
+ {
+ ia->sheet_spec = sheet_spec_page_create (ia);
+ }
+ else
+ {
+ ia->intro = intro_page_create (ia);
+ ia->separators = separators_page_create (ia);
+ ia->first_line = first_line_page_create (ia);
+ }
+ ia->formats = formats_page_create (ia);
gtk_widget_show_all (GTK_WIDGET (ia->asst.assistant));
break;
}
- destroy_formats_page (ia);
- destroy_separators_page (ia);
+ if (ssp)
+ {
+ destroy_formats_page (ia);
+ destroy_separators_page (ia);
+ }
destroy_assistant (ia);
destroy_file (ia);
{
struct string s = DS_EMPTY_INITIALIZER;
-#if 0
- if (ssp->spreadsheet == NULL)
+ if (ia->spreadsheet == NULL)
{
- size_t var_cnt;
- size_t i;
syntax_gen_pspp (&s,
"GET DATA"
"\n /TYPE=TXT"
if (ia->file.encoding && strcmp (ia->file.encoding, "Auto"))
syntax_gen_pspp (&s, " /ENCODING=%sq\n", ia->file.encoding);
+#if 0
intro_append_syntax (ia->intro, &s);
ds_put_cstr (&s,
" /ARRANGEMENT=DELIMITED\n"
" /DELCASE=LINE\n");
+
+
if (ia->first_line->skip_lines > 0)
ds_put_format (&s, " /FIRSTCASE=%d\n", ia->first_line->skip_lines + 1);
ds_put_cstr (&s, " /DELIMITERS=\"");
i == var_cnt - 1 ? "." : "");
}
+
apply_dict (ia->formats->dict, &s);
+#endif
}
else
-
{
- const struct sheet_spec_page *ssp = ia->sheet_spec;
-
- syntax_gen_pspp (&s,
- "GET DATA"
- "\n /TYPE=%ss"
- "\n /FILE=%sq"
- "\n /SHEET=index %d"
- "\n /READNAMES=%ss",
- (ssp->spreadsheet->type == SPREADSHEET_GNUMERIC) ? "GNM" : "ODS",
- ia->file.file_name,
- ssp->opts.sheet_index,
- ssp->sri.read_names ? "ON" : "OFF");
-
-
- if ( ssp->opts.cell_range)
- {
- syntax_gen_pspp (&s,
- "\n /CELLRANGE=RANGE %sq",
- ssp->opts.cell_range);
- }
- else
- {
- syntax_gen_pspp (&s,
- "\n /CELLRANGE=FULL");
- }
-
-
- syntax_gen_pspp (&s, ".");
+ return sheet_spec_gen_syntax (ia);
}
-#endif
return ds_cstr (&s);
}
size_t row, size_t column,
char **outputp, char **tooltipp)
{
- struct substring field;
- union value val;
- struct variable *var;
const struct fmt_spec *in;
struct fmt_spec out;
char *tooltip;
bool ok;
- field = ia->columns[column].contents[row];
- var = dict_get_var (ia->formats->dict, column);
+ struct substring field = ia->columns[column].contents[row];
+ struct variable *var = dict_get_var (ia->dict, column);
+ union value val;
+
value_init (&val, var_get_width (var));
in = var_get_print_format (var);
out = fmt_for_output_from_input (in);
char *error;
error = data_in (field, "UTF-8", in->type, &val, var_get_width (var),
- dict_get_encoding (ia->formats->dict));
+ dict_get_encoding (ia->dict));
if (error != NULL)
{
tooltip = xasprintf (_("Cannot parse field content `%.*s' as "
}
if (outputp != NULL)
{
- *outputp = data_out (&val, dict_get_encoding (ia->formats->dict), &out);
+ *outputp = data_out (&val, dict_get_encoding (ia->dict), &out);
}
value_destroy (&val, var_get_width (var));
if (input)
column = &ia->columns[dict_idx];
else
- var = dict_get_var (ia->formats->dict, dict_idx);
+ var = dict_get_var (ia->dict, dict_idx);
name = escape_underscores (input ? column->name : var_get_name (var));
char_cnt = input ? column->width : var_get_print_format (var)->w;