#if !GNM_SUPPORT
struct casereader *
-gnumeric_open_reader (struct spreadsheet_read_info *gri, struct spreadsheet_read_options *opts, struct dictionary **dict)
+gnumeric_open_reader (const struct spreadsheet_read_options *opts, struct dictionary **dict)
{
msg (ME, _("Support for %s files was not compiled into this installation of PSPP"), "Gnumeric");
struct casereader *
gnumeric_make_reader (struct spreadsheet *spreadsheet,
- const struct spreadsheet_read_info *gri,
const struct spreadsheet_read_options *opts)
{
int x = 0;
n_cases = MIN (n_cases, r->stop_row - r->start_row + 1);
}
- if ( gri->read_names )
+ if ( opts->read_names )
{
r->start_row++;
n_cases --;
if ( r->row < r->start_row)
{
- if ( gri->read_names )
+ if ( opts->read_names )
{
var_spec [idx].name = xstrdup (text);
}
var_spec [idx].first_value = xmlStrdup (value);
if (-1 == var_spec [idx].width )
- var_spec [idx].width = (gri->asw == -1) ?
- ROUND_UP (strlen(text), SPREADSHEET_DEFAULT_WIDTH) : gri->asw;
+ var_spec [idx].width = (opts->asw == -1) ?
+ ROUND_UP (strlen(text), SPREADSHEET_DEFAULT_WIDTH) : opts->asw;
}
free (value);
void gnumeric_destroy (struct spreadsheet *);
struct casereader * gnumeric_make_reader (struct spreadsheet *spreadsheet,
- const struct spreadsheet_read_info *gri,
const struct spreadsheet_read_options *opts);
#if !ODF_READ_SUPPORT
struct casereader *
-ods_open_reader (const struct spreadsheet_read_info *gri, struct spreadsheet_read_options *opts,
+ods_open_reader (const struct spreadsheet_read_options *opts,
struct dictionary **dict)
{
msg (ME, _("Support for %s files was not compiled into this installation of PSPP"), "OpenDocument");
struct casereader *
ods_make_reader (struct spreadsheet *spreadsheet,
- const struct spreadsheet_read_info *gri,
const struct spreadsheet_read_options *opts)
{
intf ret = 0;
xmlChar *val_string = NULL;
assert (r);
- r->read_names = gri->read_names;
+ r->read_names = opts->read_names;
ds_init_empty (&r->ods_errs);
if ( opts->cell_range )
goto error;
}
- if ( gri->read_names)
+ if ( opts->read_names)
{
while (1 == (ret = xmlTextReaderRead (r->xtr)))
{
{
int idx;
process_node (r);
- if ( r->row >= r->start_row + 1 + gri->read_names)
+ if ( r->row >= r->start_row + 1 + opts->read_names)
break;
if ( r->col < r->start_col)
struct fmt_spec fmt;
struct variable *var = NULL;
char *name = dict_make_unique_var_name (r->dict, var_spec[i].name, &vstart);
- int width = xmv_to_width (&var_spec[i].firstval, gri->asw);
+ int width = xmv_to_width (&var_spec[i].firstval, opts->asw);
dict_create_var (r->dict, name, width);
free (name);
struct spreadsheet *ods_probe (const char *filename, bool report_errors);
struct casereader * ods_make_reader (struct spreadsheet *spreadsheet,
- const struct spreadsheet_read_info *gri,
const struct spreadsheet_read_options *opts);
const char *sheet_name ; /* The name of the sheet to open (in UTF-8) */
int sheet_index ; /* The index of the sheet to open (only used if sheet_name is NULL) */
const char *cell_range ; /* The cell range (in UTF-8) */
-};
-
-struct spreadsheet_read_info
-{
bool read_names ; /* True if the first row is to be used as the names of the variables */
int asw ; /* The width of string variables in the created dictionary */
};
#define _(msgid) gettext (msgid)
#define N_(msgid) (msgid)
-static bool parse_spreadsheet (struct lexer *lexer, char **filename, struct spreadsheet_read_info *sri,
+static bool parse_spreadsheet (struct lexer *lexer, char **filename,
struct spreadsheet_read_options *opts);
static void destroy_spreadsheet_read_info (struct spreadsheet_read_info *, struct spreadsheet_read_options *);
char *filename = NULL;
struct casereader *reader = NULL;
struct dictionary *dict = NULL;
- struct spreadsheet_read_info sri;
struct spreadsheet_read_options opts;
- if (!parse_spreadsheet (lexer, &filename, &sri, &opts))
+ if (!parse_spreadsheet (lexer, &filename, &opts))
goto error;
if ( 0 == strncasecmp (tok, "GNM", 3))
{
struct spreadsheet *spreadsheet = gnumeric_probe (filename, true);
- reader = gnumeric_make_reader (spreadsheet, &sri, &opts);
+ reader = gnumeric_make_reader (spreadsheet, &opts);
dict = spreadsheet->dict;
}
else if (0 == strncasecmp (tok, "ODS", 3))
{
struct spreadsheet *spreadsheet = ods_probe (filename, true);
- reader = ods_make_reader (spreadsheet, &sri, &opts);
+ reader = ods_make_reader (spreadsheet, &opts);
dict = spreadsheet->dict;
}
{
dataset_set_dict (ds, dict);
dataset_set_source (ds, reader);
- destroy_spreadsheet_read_info (&sri, &opts);
free (tok);
return CMD_SUCCESS;
}
- destroy_spreadsheet_read_info (&sri, &opts);
}
else
msg (SE, _("Unsupported TYPE %s."), tok);
}
static bool
-parse_spreadsheet (struct lexer *lexer, char **filename, struct spreadsheet_read_info *sri,
+parse_spreadsheet (struct lexer *lexer, char **filename,
struct spreadsheet_read_options *opts)
{
opts->sheet_index = 1;
opts->sheet_name = NULL;
opts->cell_range = NULL;
- sri->read_names = true;
- sri->asw = -1;
+ opts->read_names = true;
+ opts->asw = -1;
lex_force_match (lexer, T_SLASH);
if ( lex_match_id (lexer, "ASSUMEDSTRWIDTH"))
{
lex_match (lexer, T_EQUALS);
- sri->asw = lex_integer (lexer);
+ opts->asw = lex_integer (lexer);
lex_get (lexer);
}
else if (lex_match_id (lexer, "SHEET"))
if ( lex_match_id (lexer, "ON"))
{
- sri->read_names = true;
+ opts->read_names = true;
}
else if (lex_match_id (lexer, "OFF"))
{
- sri->read_names = false;
+ opts->read_names = false;
}
else
{
return true;
error:
- destroy_spreadsheet_read_info (sri, opts);
return false;
}
{
enum { MAX_LINE_LEN = 16384 }; /* Max length of an acceptable line. */
struct file *file = &ia->file;
- struct spreadsheet_read_info sri;
struct spreadsheet_read_options opts;
file->lines = NULL;
opts.cell_range = NULL;
opts.sheet_index = 1;
- sri.read_names = true;
- sri.asw = -1;
+ opts.read_names = true;
+ opts.asw = -1;
printf ("%s:%d %p\n", __FILE__, __LINE__, ia->spreadsheet);
struct casereader *reader;
struct dictionary *dict;
- struct spreadsheet_read_info sri;
struct spreadsheet_read_options opts;
};
(ia->spreadsheet->type == SPREADSHEET_GNUMERIC) ? "GNM" : "ODS",
ia->file.file_name,
ssp->opts.sheet_index,
- ssp->sri.read_names ? "ON" : "OFF");
+ ssp->opts.read_names ? "ON" : "OFF");
if (range && 0 != strcmp ("", range))
ssp->opts.cell_range = range;
}
- ssp->sri.read_names = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (readnames_checkbox));
- ssp->sri.asw = -1;
+ ssp->opts.read_names = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (readnames_checkbox));
+ ssp->opts.asw = -1;
switch (ia->spreadsheet->type)
{
case SPREADSHEET_ODS:
{
- creader = ods_make_reader (ia->spreadsheet, &ssp->sri, &ssp->opts);
+ creader = ods_make_reader (ia->spreadsheet, &ssp->opts);
dict = ia->spreadsheet->dict;
}
break;
case SPREADSHEET_GNUMERIC:
{
- creader = gnumeric_make_reader (ia->spreadsheet, &ssp->sri, &ssp->opts);
+ creader = gnumeric_make_reader (ia->spreadsheet, &ssp->opts);
dict = ia->spreadsheet->dict;
}
break;
struct ccase *c;
gint x = gtk_combo_box_get_active (GTK_COMBO_BOX (combo_box));
struct casereader *reader ;
- struct spreadsheet_read_info ri;
struct spreadsheet_read_options opts;
g_print( "%s %d\n", __FUNCTION__, x);
opts.sheet_index = x + 1;
opts.cell_range = NULL;
opts.sheet_name = NULL;
+ opts.read_names = TRUE;
+ opts.asw = -1;
- ri.read_names = TRUE;
- ri.asw = -1;
-
- reader = gnumeric_make_reader (sp, &ri, &opts);
+ reader = gnumeric_make_reader (sp, &opts);
for (;
(c = casereader_read (reader)) != NULL; case_unref (c))
{