From f5db876ed61f115b35907b90f128adab43312612 Mon Sep 17 00:00:00 2001 From: John Darrington Date: Tue, 7 May 2013 15:52:44 +0200 Subject: [PATCH] Spreadsheetreader: new function create_cell_ref and rename existing function with that name. Rename convert_cell_ref to convert_cell_range which is a more accurate description of the function, and add a new function, with the original name of the function we've just renamed. The new function (create_cell_ref) does just that. --- src/data/gnumeric-reader.c | 2 +- src/data/ods-reader.c | 2 +- src/data/spreadsheet-reader.c | 27 ++++++++++++++++++--------- src/data/spreadsheet-reader.h | 3 ++- 4 files changed, 22 insertions(+), 12 deletions(-) diff --git a/src/data/gnumeric-reader.c b/src/data/gnumeric-reader.c index 27ba9d4cd2..e85a4cf92d 100644 --- a/src/data/gnumeric-reader.c +++ b/src/data/gnumeric-reader.c @@ -203,7 +203,7 @@ gnumeric_get_sheet_range (struct spreadsheet *s, int n) process_node (gr, &gr->msd); } - return create_cell_ref ( + return create_cell_range ( gr->sheets[n].start_col, gr->sheets[n].start_row, gr->sheets[n].stop_col, diff --git a/src/data/ods-reader.c b/src/data/ods-reader.c index 39e82e5cae..553babd19f 100644 --- a/src/data/ods-reader.c +++ b/src/data/ods-reader.c @@ -241,7 +241,7 @@ ods_get_sheet_range (struct spreadsheet *s, int n) process_node (r, or); } - return create_cell_ref ( + return create_cell_range ( r->sheets[n].start_col, r->sheets[n].start_row, r->sheets[n].stop_col, diff --git a/src/data/spreadsheet-reader.c b/src/data/spreadsheet-reader.c index fc1dfa8dd5..02e5c2d3c0 100644 --- a/src/data/spreadsheet-reader.c +++ b/src/data/spreadsheet-reader.c @@ -169,25 +169,34 @@ int_to_ps26 (int i) return ret; } + char * -create_cell_ref (int col0, int row0, int coli, int rowi) +create_cell_ref (int col0, int row0) { char *cs0 ; - char *csi ; char *s ; if ( col0 < 0) return NULL; - if ( rowi < 0) return NULL; - if ( coli < 0) return NULL; if ( row0 < 0) return NULL; cs0 = int_to_ps26 (col0); - csi = int_to_ps26 (coli); - s = c_xasprintf ("%s%d:%s%d", - cs0, row0 + 1, - csi, rowi + 1); + s = c_xasprintf ("%s%d", cs0, row0 + 1); + free (cs0); - free (csi); + + return s; +} + +char * +create_cell_range (int col0, int row0, int coli, int rowi) +{ + char *s0 = create_cell_ref (col0, row0); + char *si = create_cell_ref (coli, rowi); + + char *s = c_xasprintf ("%s:%s", s0, si); + + free (s0); + free (si); return s; } diff --git a/src/data/spreadsheet-reader.h b/src/data/spreadsheet-reader.h index 9a46b35e9e..e9656ab12d 100644 --- a/src/data/spreadsheet-reader.h +++ b/src/data/spreadsheet-reader.h @@ -77,7 +77,8 @@ const char * spreadsheet_get_sheet_name (struct spreadsheet *s, int n); char * spreadsheet_get_sheet_range (struct spreadsheet *s, int n); -char *create_cell_ref (int col0, int row0, int coli, int rowi); +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 *); -- 2.30.2