From 6fba66073900819ff07cb486c97a15cb0fc36724 Mon Sep 17 00:00:00 2001 From: John Darrington Date: Mon, 4 Mar 2013 19:44:55 +0100 Subject: [PATCH] Make GUI open either kind of spreadsheet --- src/data/spreadsheet-reader.c | 33 ++++++++++++++++++++------------- src/data/spreadsheet-reader.h | 8 -------- 2 files changed, 20 insertions(+), 21 deletions(-) diff --git a/src/data/spreadsheet-reader.c b/src/data/spreadsheet-reader.c index da2d6ea2ae..4a85cb22dd 100644 --- a/src/data/spreadsheet-reader.c +++ b/src/data/spreadsheet-reader.c @@ -28,16 +28,6 @@ #include #include -struct spreadsheet * -spreadsheet_open (const char *filename) -{ - struct spreadsheet *ss = NULL; - - ss = ods_probe (filename, true); - - return ss; -} - void spreadsheet_close (UNUSED struct spreadsheet *spreadsheet) { @@ -47,19 +37,36 @@ spreadsheet_close (UNUSED struct spreadsheet *spreadsheet) struct casereader * spreadsheet_make_reader (struct spreadsheet *s, const struct spreadsheet_read_options *opts) { - return ods_make_reader (s, opts); + if ( s->type == SPREADSHEET_ODS) + return ods_make_reader (s, opts); + if ( s->type == SPREADSHEET_GNUMERIC) + return gnumeric_make_reader (s, opts); + + return NULL; } const char * spreadsheet_get_sheet_name (struct spreadsheet *s, int n) { - return ods_get_sheet_name (s, n); + if ( s->type == SPREADSHEET_ODS) + return ods_get_sheet_name (s, n); + + if ( s->type == SPREADSHEET_GNUMERIC) + return gnumeric_get_sheet_name (s, n); + + return NULL; } char * spreadsheet_get_sheet_range (struct spreadsheet *s, int n) { - return ods_get_sheet_range (s, n); + if ( s->type == SPREADSHEET_ODS) + return ods_get_sheet_range (s, n); + + if ( s->type == SPREADSHEET_GNUMERIC) + return gnumeric_get_sheet_range (s, n); + + return NULL; } diff --git a/src/data/spreadsheet-reader.h b/src/data/spreadsheet-reader.h index a3fc9b4184..5cfd81d7e1 100644 --- a/src/data/spreadsheet-reader.h +++ b/src/data/spreadsheet-reader.h @@ -79,14 +79,6 @@ char * spreadsheet_get_sheet_range (struct spreadsheet *s, int n); char *create_cell_ref (int col0, int row0, int coli, int rowi); -/* - Attempt to open the file called FILENAME as a spreadsheet. - It is not known a priori, what type of spreadsheet FILENAME is, or - even if it is a spreadsheet at all. - If it fails to open, then it will return NULL without any error or - warning messages. - */ -struct spreadsheet * spreadsheet_open (const char *filename); void spreadsheet_close (struct spreadsheet *); -- 2.30.2