gnumeric r16481 - in branches/gnumeric-1-8: . plugins/excel plugins/openoffice plugins/sylk src test



Author: mortenw
Date: Fri Mar 28 16:59:00 2008
New Revision: 16481
URL: http://svn.gnome.org/viewvc/gnumeric?rev=16481&view=rev

Log:
2008-03-28  Morten Welinder  <terra gnome org>

	* src/expr.c (gnm_expr_top_is_array_elem): Take extra arguments
	for storing coordinates.  All callers changed.



Modified:
   branches/gnumeric-1-8/ChangeLog
   branches/gnumeric-1-8/plugins/excel/xlsx-write.c
   branches/gnumeric-1-8/plugins/openoffice/openoffice-write.c
   branches/gnumeric-1-8/plugins/sylk/sylk-write.c
   branches/gnumeric-1-8/src/cell.c
   branches/gnumeric-1-8/src/expr.c
   branches/gnumeric-1-8/src/expr.h
   branches/gnumeric-1-8/src/sheet-autofill.c
   branches/gnumeric-1-8/src/workbook-view.c
   branches/gnumeric-1-8/src/xml-sax-write.c
   branches/gnumeric-1-8/test/t8003-valgrind-pdf.pl

Modified: branches/gnumeric-1-8/plugins/excel/xlsx-write.c
==============================================================================
--- branches/gnumeric-1-8/plugins/excel/xlsx-write.c	(original)
+++ branches/gnumeric-1-8/plugins/excel/xlsx-write.c	Fri Mar 28 16:59:00 2008
@@ -411,7 +411,7 @@
 
 				if (gnm_cell_has_expr (cell)) {
 					texpr = cell->base.texpr;
-					if (!gnm_expr_top_is_array_elem (texpr)) {
+					if (!gnm_expr_top_is_array_elem (texpr, NULL, NULL)) {
 						gsf_xml_out_start_element (xml, "f");
 
 						array = gnm_expr_top_get_array_corner (texpr);

Modified: branches/gnumeric-1-8/plugins/openoffice/openoffice-write.c
==============================================================================
--- branches/gnumeric-1-8/plugins/openoffice/openoffice-write.c	(original)
+++ branches/gnumeric-1-8/plugins/openoffice/openoffice-write.c	Fri Mar 28 16:59:00 2008
@@ -309,15 +309,13 @@
 				     TABLE "number-rows-spanned", rows_spanned);
 	if (cell != NULL) {
 		char *rendered_string;
-		GnmExprArrayCorner const *ac = NULL;
 
-		if (gnm_cell_has_expr(cell)
-		    && ((NULL != (ac = gnm_expr_top_get_array_corner
-				  (cell->base.texpr)))
-			|| !gnm_expr_top_is_array_elem (cell->base.texpr))) {
+		if (gnm_cell_is_array (cell)) {
+			GnmExprArrayCorner const *ac;
 			char *formula, *eq_formula;
 			GnmParsePos pp;
 
+			ac = gnm_expr_top_get_array_corner (cell->base.texpr);
 			if (ac != NULL) {
 				gsf_xml_out_add_uint (state->xml,
 					TABLE "number-matrix-columns-spanned",
@@ -328,9 +326,9 @@
 			}
 
 			parse_pos_init_cell (&pp, cell);
-			formula = gnm_expr_as_string (cell->base.texpr->expr,
-						      &pp,
-						      state->conv);
+			formula = gnm_expr_top_as_string (cell->base.texpr,
+							  &pp,
+							  state->conv);
 			eq_formula = g_strdup_printf ("oooc:=%s", formula);
 
 #if 0

Modified: branches/gnumeric-1-8/plugins/sylk/sylk-write.c
==============================================================================
--- branches/gnumeric-1-8/plugins/sylk/sylk-write.c	(original)
+++ branches/gnumeric-1-8/plugins/sylk/sylk-write.c	Fri Mar 28 16:59:00 2008
@@ -119,7 +119,7 @@
 			gsf_output_printf (state->output, ";R%d;C%d;M",
 				iter->pp.eval.row + array->rows,
 				iter->pp.eval.col + array->cols);
-		} else if (gnm_expr_top_is_array_elem (texpr)) {
+		} else if (gnm_expr_top_is_array_elem (texpr, NULL, NULL)) {
 			gsf_output_write (state->output, 2, ";I");
 			texpr = NULL;
 		} else

Modified: branches/gnumeric-1-8/src/cell.c
==============================================================================
--- branches/gnumeric-1-8/src/cell.c	(original)
+++ branches/gnumeric-1-8/src/cell.c	Fri Mar 28 16:59:00 2008
@@ -381,6 +381,7 @@
 {
 	GnmExprTop const *texpr;
 	GnmExprArrayCorner const *array;
+	int x, y;
 
 	if (NULL == cell || !gnm_cell_has_expr (cell))
 		return FALSE;
@@ -388,10 +389,8 @@
 	g_return_val_if_fail (res != NULL, FALSE);
 
 	texpr = cell->base.texpr;
-	if (gnm_expr_top_is_array_elem (texpr)) {
-		cell = sheet_cell_get (cell->base.sheet,
-			cell->pos.col - texpr->expr->array_elem.x,
-			cell->pos.row - texpr->expr->array_elem.y);
+	if (gnm_expr_top_is_array_elem (texpr, &x, &y)) {
+		cell = sheet_cell_get (cell->base.sheet, cell->pos.col - x, cell->pos.row - y);
 
 		g_return_val_if_fail (cell != NULL, FALSE);
 		g_return_val_if_fail (gnm_cell_has_expr (cell), FALSE);
@@ -428,7 +427,7 @@
 {
 	return cell != NULL && gnm_cell_has_expr (cell) &&
 		(gnm_expr_top_is_array_corner (cell->base.texpr) ||
-		 gnm_expr_top_is_array_elem (cell->base.texpr));
+		 gnm_expr_top_is_array_elem (cell->base.texpr, NULL, NULL));
 }
 
 /**

Modified: branches/gnumeric-1-8/src/expr.c
==============================================================================
--- branches/gnumeric-1-8/src/expr.c	(original)
+++ branches/gnumeric-1-8/src/expr.c	Fri Mar 28 16:59:00 2008
@@ -2935,10 +2935,16 @@
 }
 
 gboolean
-gnm_expr_top_is_array_elem (GnmExprTop const *texpr)
+gnm_expr_top_is_array_elem (GnmExprTop const *texpr, int *x, int *y)
 {
 	g_return_val_if_fail (IS_GNM_EXPR_TOP (texpr), FALSE);
-	return GNM_EXPR_GET_OPER (texpr->expr) == GNM_EXPR_OP_ARRAY_ELEM;
+
+	if (GNM_EXPR_GET_OPER (texpr->expr) != GNM_EXPR_OP_ARRAY_ELEM)
+		return FALSE;
+
+	if (x) *x = texpr->expr->array_elem.x;
+	if (y) *y = texpr->expr->array_elem.y;
+	return TRUE;
 }
 
 GnmExprTop const *

Modified: branches/gnumeric-1-8/src/expr.h
==============================================================================
--- branches/gnumeric-1-8/src/expr.h	(original)
+++ branches/gnumeric-1-8/src/expr.h	Fri Mar 28 16:59:00 2008
@@ -117,7 +117,7 @@
 gboolean	gnm_expr_top_is_shared		(GnmExprTop const *texpr);
 gboolean	gnm_expr_top_is_err		(GnmExprTop const *texpr, GnmStdError e);
 gboolean 	gnm_expr_top_is_rangeref	(GnmExprTop const *texpr);
-gboolean	gnm_expr_top_is_array_elem	(GnmExprTop const *texpr);
+gboolean	gnm_expr_top_is_array_elem	(GnmExprTop const *texpr, int *x, int *y);
 gboolean	gnm_expr_top_is_array_corner	(GnmExprTop const *texpr);
 GnmExprArrayCorner const *gnm_expr_top_get_array_corner (GnmExprTop const *texpr);
 GnmValue       *gnm_expr_top_get_range		(GnmExprTop const *texpr);

Modified: branches/gnumeric-1-8/src/sheet-autofill.c
==============================================================================
--- branches/gnumeric-1-8/src/sheet-autofill.c	(original)
+++ branches/gnumeric-1-8/src/sheet-autofill.c	Fri Mar 28 16:59:00 2008
@@ -847,7 +847,7 @@
 		Sheet *sheet = src->base.sheet;
 
 		/* Arrays are always assigned fully at the corner.  */
-		if (gnm_expr_top_is_array_elem (src_texpr))
+		if (gnm_expr_top_is_array_elem (src_texpr, NULL, NULL))
 			return NULL;
 
 		rinfo.reloc_type = GNM_EXPR_RELOCATE_MOVE_RANGE;

Modified: branches/gnumeric-1-8/src/workbook-view.c
==============================================================================
--- branches/gnumeric-1-8/src/workbook-view.c	(original)
+++ branches/gnumeric-1-8/src/workbook-view.c	Fri Mar 28 16:59:00 2008
@@ -401,9 +401,7 @@
 				 */
 				if (gnm_expr_top_is_array_corner (texpr))
 					corner = cell;
-				else if (gnm_expr_top_is_array_elem (texpr)) {
-					x = texpr->expr->array_elem.x;
-					y = texpr->expr->array_elem.y;
+				else if (gnm_expr_top_is_array_elem (texpr, &x, &y)) {
 					corner = sheet_cell_get
 						(sheet,
 						 cell->pos.col - x,

Modified: branches/gnumeric-1-8/src/xml-sax-write.c
==============================================================================
--- branches/gnumeric-1-8/src/xml-sax-write.c	(original)
+++ branches/gnumeric-1-8/src/xml-sax-write.c	Fri Mar 28 16:59:00 2008
@@ -732,7 +732,7 @@
 		gnm_expr_top_is_shared (texpr);
 
 	/* Only the top left corner of an array needs to be saved (>= 0.53) */
-	if (texpr && gnm_expr_top_is_array_elem (texpr))
+	if (texpr && gnm_expr_top_is_array_elem (texpr, NULL, NULL))
 		return; /* DOM version would write <Cell Col= Row=/> */
 
 	gsf_xml_out_start_element (state->output, GNM "Cell");

Modified: branches/gnumeric-1-8/test/t8003-valgrind-pdf.pl
==============================================================================
--- branches/gnumeric-1-8/test/t8003-valgrind-pdf.pl	(original)
+++ branches/gnumeric-1-8/test/t8003-valgrind-pdf.pl	Fri Mar 28 16:59:00 2008
@@ -5,6 +5,12 @@
 use lib ($0 =~ m|^(.*/)| ? $1 : ".");
 use GnumericTest;
 
+# We get hit by a bitfield error on old Valgrinds.
+my $valgrind_version = `valgrind --version 2>&1`;
+my ($ma,$mi,$rv) = $valgrind_version =~ /^valgrind-?\s*(\d+)\.(\d+)\.(\d+)/;
+&GnumericTest::report_skip ("Valgrind is missing or too old")
+    unless (($ma || 0) * 1000 + ($mi || 0)) * 1000 + ($rv || 0) > 3001001;
+
 &message ("Check the pdf exporter with valgrind -- part 1.");
 my $src = "$samples/excel/statfuns.xls";
 &GnumericTest::report_skip ("file $src does not exist") unless -r $src;



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