X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fdata%2Fspreadsheet-reader.h;h=d5d9a5f4c1bf9997267106383c8e347e0746cd46;hb=3c6287003e07308c727d9ca13f759bfce33e0693;hp=6edd705067a27adc7c7cf2b8cda1bffa4760cd93;hpb=2f7b367bf796c63c595ac837b716cce535ffd5bf;p=pspp diff --git a/src/data/spreadsheet-reader.h b/src/data/spreadsheet-reader.h index 6edd705067..d5d9a5f4c1 100644 --- a/src/data/spreadsheet-reader.h +++ b/src/data/spreadsheet-reader.h @@ -22,17 +22,25 @@ /* Default width of string variables. */ #define SPREADSHEET_DEFAULT_WIDTH 8 +/* These elements are read/write. + They may be passed in NULL (for pointers) or negative for integers, in which + case they will be filled in be the function. +*/ +struct spreadsheet_read_options +{ + 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 { - char *sheet_name ; /* In UTF-8. */ - char *file_name ; /* In filename encoding. */ - char *cell_range ; /* In UTF-8. */ - int sheet_index ; - bool read_names ; - int asw ; + 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 */ }; -int pseudo_base26 (const char *str); +int ps26_to_int (const char *str); +char * int_to_ps26 (int); bool convert_cell_ref (const char *ref, int *col0, int *row0, @@ -43,5 +51,43 @@ bool convert_cell_ref (const char *ref, #define _xmlchar_to_int(X) (atoi(CHAR_CAST (const char *, X))) +enum spreadsheet_type + { + SPREADSHEET_NONE, + SPREADSHEET_GNUMERIC, + SPREADSHEET_ODS + }; + +struct spreadsheet +{ + const char *file_name; + + enum spreadsheet_type type; + + /* The total number of sheets in the "workbook" */ + int n_sheets; + + /* The dictionary */ + struct dictionary *dict; +}; + + +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 *); + +struct casereeader; +struct casereader * spreadsheet_make_reader (struct spreadsheet *s); + + +#define SPREADSHEET_CAST(X) ((struct spreadsheet *)(X)) #endif