/* PSPP - a program for statistical analysis.
- Copyright (C) 2007, 2009, 2010, 2011, 2012, 2013 Free Software Foundation, Inc.
+ Copyright (C) 2007, 2009, 2010, 2011, 2012, 2013, 2016 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
#include "spreadsheet-reader.h"
-#if !GNM_SUPPORT
+#if !GNM_READ_SUPPORT
struct casereader *
gnumeric_open_reader (const struct spreadsheet_read_options *opts, struct dictionary **dict)
struct gnumeric_reader
{
struct spreadsheet spreadsheet;
- int ref_cnt;
struct state_data rsd;
struct state_data msd;
void
-gnumeric_destroy (struct spreadsheet *s)
+gnumeric_unref (struct spreadsheet *s)
{
struct gnumeric_reader *r = (struct gnumeric_reader *) s;
- if (0 == --r->ref_cnt)
+ if (0 == --s->ref_cnt)
{
int i;
{
xmlFree (r->sheets[i].name);
}
-
+
+
free (r->sheets);
state_data_destroy (&r->msd);
+ dict_destroy (r->dict);
+
+ free (s->file_name);
+
free (r);
}
}
if (r->proto)
caseproto_unref (r->proto);
- gnumeric_destroy (&r->spreadsheet);
+ gnumeric_unref (&r->spreadsheet);
}
{
r = xzalloc (sizeof *r);
r->spreadsheet.n_sheets = -1;
- r->spreadsheet.file_name = filename;
+ r->spreadsheet.file_name = strdup (filename);
sd = &r->msd;
}
else
sd->row = sd->col = -1;
sd->state = STATE_PRE_INIT;
sd->xtr = xtr;
- r->ref_cnt++;
+ r->spreadsheet.ref_cnt++;
+
/* Advance to the start of the workbook.
This gives us some confidence that we are actually dealing with a gnumeric
if ( ret != 1)
{
/* Does not seem to be a gnumeric file */
- xmlFreeTextReader (sd->xtr);
- free (r);
+ gnumeric_unref (&r->spreadsheet);
return NULL;
}
gnumeric_make_reader (struct spreadsheet *spreadsheet,
const struct spreadsheet_read_options *opts)
{
+ int type = 0;
int x = 0;
struct gnumeric_reader *r = NULL;
unsigned long int vstart = 0;
n_cases --;
}
- int type = 0;
+
/* Read in the first row of cells,
including the headers if read_names was set */
while (
xmlChar *attr =
xmlTextReaderGetAttribute (r->rsd.xtr, _xml ("ValueType"));
- if ( NULL == attr || 60 != _xmlchar_to_int (attr))
+ if ( NULL == attr || VALUE_STRING != _xmlchar_to_int (attr))
var_spec [idx].width = 0;
free (attr);
}
free (var_spec);
- dict_destroy (spreadsheet->dict);
- spreadsheet->dict = NULL;
gnm_file_casereader_destroy (NULL, r);
}
-#endif /* GNM_SUPPORT */
+#endif /* GNM_READ_SUPPORT */