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;
if (r->proto)
caseproto_unref (r->proto);
- gnumeric_destroy (&r->spreadsheet);
+ gnumeric_unref (&r->spreadsheet);
}
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
struct casereader * gnumeric_make_reader (struct spreadsheet *spreadsheet,
const struct spreadsheet_read_options *opts);
-void gnumeric_destroy (struct spreadsheet *r);
+void gnumeric_unref (struct spreadsheet *r);
#endif
{
struct spreadsheet spreadsheet;
struct zip_reader *zreader;
- int ref_cnt;
+
int target_sheet_index;
xmlChar *target_sheet_name;
};
void
-ods_destroy (struct spreadsheet *s)
+ods_unref (struct spreadsheet *s)
{
struct ods_reader *r = (struct ods_reader *) s;
- if (--r->ref_cnt == 0)
+ if (--s->ref_cnt == 0)
{
int i;
r->target_sheet_name = NULL;
- ods_destroy (&r->spreadsheet);
+ ods_unref (&r->spreadsheet);
}
sheet_count = get_sheet_count (zr);
r->zreader = zr;
- r->ref_cnt = 1;
+ r->spreadsheet.ref_cnt = 1;
xtr = init_reader (r, report_errors);
if (xtr == NULL)
assert (r);
r->read_names = opts->read_names;
ds_init_empty (&r->ods_errs);
- ++r->ref_cnt;
+ ++r->spreadsheet.ref_cnt;
xtr = init_reader (r, true);
if ( xtr == NULL)
struct casereader * ods_make_reader (struct spreadsheet *spreadsheet,
const struct spreadsheet_read_options *opts);
-void ods_destroy (struct spreadsheet *s);
+void ods_unref (struct spreadsheet *s);
#endif
#endif
void
-spreadsheet_destroy (struct spreadsheet *s)
+spreadsheet_ref (struct spreadsheet *s)
+{
+ s->ref_cnt++;
+}
+
+void
+spreadsheet_unref (struct spreadsheet *s)
{
switch (s->type)
{
case SPREADSHEET_ODS:
assert (ODF_READING_SUPPORTED);
- ods_destroy (s);
+ ods_unref (s);
break;
case SPREADSHEET_GNUMERIC:
assert (GNM_READING_SUPPORTED);
- gnumeric_destroy (s);
+ gnumeric_unref (s);
break;
default:
NOT_REACHED ();
/* The dictionary */
struct dictionary *dict;
+
+ int ref_cnt;
};
char * create_cell_ref (int col0, int row0);
char *create_cell_range (int col0, int row0, int coli, int rowi);
-void spreadsheet_destroy (struct spreadsheet *);
+void spreadsheet_unref (struct spreadsheet *);
+void spreadsheet_ref (struct spreadsheet *);
goto error;
reader = gnumeric_make_reader (spreadsheet, &opts);
dict = spreadsheet->dict;
- gnumeric_destroy (spreadsheet);
+ gnumeric_unref (spreadsheet);
}
else if ( odf_read_support && 0 == strncasecmp (tok, "ODS", 3))
{
goto error;
reader = ods_make_reader (spreadsheet, &opts);
dict = spreadsheet->dict;
- ods_destroy (spreadsheet);
+ ods_unref (spreadsheet);
}
free (filename);
gtk_main ();
- spreadsheet_destroy (stuff.sp);
+ spreadsheet_unref (stuff.sp);
return 0;
}