[gnumeric] importers: use the new array setting function.



commit 538e0672de0ad00c7668967820a5ab60a9153b8a
Author: Morten Welinder <terra gnome org>
Date:   Wed Aug 4 22:40:19 2010 -0400

    importers: use the new array setting function.

 plugins/applix/applix-read.c         |    8 +++-----
 plugins/excel/ms-excel-read.c        |   12 ++++--------
 plugins/excel/xlsx-read.c            |   10 ++++------
 plugins/openoffice/openoffice-read.c |   17 ++++++++++++-----
 plugins/sylk/sylk.c                  |   14 ++++++++++----
 5 files changed, 33 insertions(+), 28 deletions(-)
---
diff --git a/plugins/applix/applix-read.c b/plugins/applix/applix-read.c
index 89dc019..d2ca1c7 100644
--- a/plugins/applix/applix-read.c
+++ b/plugins/applix/applix-read.c
@@ -1214,11 +1214,9 @@ applix_read_cells (ApplixReadState *state)
 					parse_error_free (&perr);
 					texpr = gnm_expr_top_new_constant (value_new_string (expr_string));
 				} else if (is_array) {
-					gnm_expr_top_ref (texpr);
-					gnm_cell_set_array_formula (sheet,
-								r.start.col, r.start.row,
-								r.end.col, r.end.row,
-								texpr);
+					gnm_cell_set_array (sheet,
+							    &r,
+							    texpr);
 					gnm_cell_assign_value (cell, val);
 					/* Leak? */
 				} else {
diff --git a/plugins/excel/ms-excel-read.c b/plugins/excel/ms-excel-read.c
index f4ff80b..351c8a4 100644
--- a/plugins/excel/ms-excel-read.c
+++ b/plugins/excel/ms-excel-read.c
@@ -2644,10 +2644,8 @@ excel_formula_shared (BiffQuery *q, ExcelReadSheet *esheet, GnmCell *cell)
 					   : gnm_expr_list_prepend (args, missing);
 		}
 		texpr = gnm_expr_top_new (gnm_expr_new_funcall (gnm_func_lookup ("table", NULL), args));
-		gnm_cell_set_array_formula (esheet->sheet,
-			r.start.col, r.start.row,
-			r.end.col,   r.end.row,
-			texpr);
+		gnm_cell_set_array (esheet->sheet, &r, texpr);
+		gnm_expr_top_unref (texpr);
 		return NULL;
 	}
 
@@ -2687,10 +2685,8 @@ excel_formula_shared (BiffQuery *q, ExcelReadSheet *esheet, GnmCell *cell)
 	g_return_val_if_fail (texpr != NULL, NULL);
 
 	if (is_array) {
-		gnm_cell_set_array_formula (esheet->sheet,
-					    r.start.col, r.start.row,
-					    r.end.col,   r.end.row,
-					    texpr);
+		gnm_cell_set_array (esheet->sheet, &r, texpr);
+		gnm_expr_top_unref (texpr);
 		return NULL;
 	} else
 		return texpr;
diff --git a/plugins/excel/xlsx-read.c b/plugins/excel/xlsx-read.c
index 0733e3b..41177fe 100644
--- a/plugins/excel/xlsx-read.c
+++ b/plugins/excel/xlsx-read.c
@@ -2673,12 +2673,10 @@ xlsx_cell_end (GsfXMLIn *xin, G_GNUC_UNUSED GsfXMLBlob *blob)
 			gnm_expr_top_unref (state->texpr);
 	} else if (NULL != state->texpr) {
 		if (state->array.start.col >= 0) {
-			gnm_cell_set_array_formula (state->sheet,
-				state->array.start.col,
-				state->array.start.row,
-				state->array.end.col,
-				state->array.end.row,
-				state->texpr);
+			gnm_cell_set_array (state->sheet,
+					    &state->array,
+					    state->texpr);
+			gnm_expr_top_unref (state->texpr);
 			if (NULL != state->val)
 				gnm_cell_assign_value (cell, state->val);
 		} else if (NULL != state->val) {
diff --git a/plugins/openoffice/openoffice-read.c b/plugins/openoffice/openoffice-read.c
index 6bc91b0..34e0b85 100644
--- a/plugins/openoffice/openoffice-read.c
+++ b/plugins/openoffice/openoffice-read.c
@@ -1346,6 +1346,8 @@ oo_cell_start (GsfXMLIn *xin, xmlChar const **attrs)
 						  state->pos.eval.row);
 
 		if (array_cols > 0 || array_rows > 0) {
+			GnmRange r;
+
 			if (array_cols <= 0) {
 				array_cols = 1;
 				oo_warning (xin, _("Invalid array expression does not specify number of columns."));
@@ -1353,11 +1355,16 @@ oo_cell_start (GsfXMLIn *xin, xmlChar const **attrs)
 				array_rows = 1;
 				oo_warning (xin, _("Invalid array expression does not specify number of rows."));
 			}
-			gnm_cell_set_array_formula (state->pos.sheet,
-				state->pos.eval.col, state->pos.eval.row,
-				state->pos.eval.col + array_cols-1,
-				state->pos.eval.row + array_rows-1,
-				texpr);
+
+			r.start = state->pos.eval;
+			r.end = r.start;
+			r.end.col += array_cols - 1;
+			r.end.row += array_rows - 1;
+
+			gnm_cell_set_array (state->pos.sheet,
+					    &r,
+					    texpr);
+			gnm_expr_top_unref (texpr);
 			if (val != NULL)
 				gnm_cell_assign_value (cell, val);
 			oo_update_data_extent (state, array_cols, array_rows);
diff --git a/plugins/sylk/sylk.c b/plugins/sylk/sylk.c
index 4bbb8b7..edfceec 100644
--- a/plugins/sylk/sylk.c
+++ b/plugins/sylk/sylk.c
@@ -309,10 +309,16 @@ sylk_rtd_c_parse (SylkReader *state, char *str)
 			state->pp.eval.col, state->pp.eval.row);
 
 		if (is_array) {
-			if (NULL != texpr)
-				gnm_cell_set_array_formula (state->pp.sheet,
-					state->pp.eval.col, state->pp.eval.row,
-					c-1, r-1, texpr);
+			if (texpr) {
+				GnmRange rg;
+				rg.start = state->pp.eval;
+				rg.end.col = c - 1;
+				rg.end.row = r - 1;
+
+				gnm_cell_set_array (state->pp.sheet,
+						    &rg,
+						    texpr);
+			}
 			if (NULL != val)
 				gnm_cell_assign_value (cell, val);
 		} else if (NULL != texpr) {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]