gnumeric r17072 - in trunk: . plugins/excel src



Author: jbrefort
Date: Fri Jan 16 14:13:48 2009
New Revision: 17072
URL: http://svn.gnome.org/viewvc/gnumeric?rev=17072&view=rev

Log:
2009-01-16  Jean Brefort  <jean brefort normalesup org>

	* src/gnm-pane.c: (cb_sheet_object_canvas_event): do not select an
	existing sheet object when creating a new graph. [#151789]

	* ms-chart.c: (chart_write_AI): support GOData simple instances [#567953],
	(chart_write_axis_sets): do not write invalid AXESUSED field, see #567823.



Modified:
   trunk/ChangeLog
   trunk/NEWS
   trunk/plugins/excel/ChangeLog
   trunk/plugins/excel/ms-chart.c
   trunk/src/gnm-pane.c

Modified: trunk/NEWS
==============================================================================
--- trunk/NEWS	(original)
+++ trunk/NEWS	Fri Jan 16 14:13:48 2009
@@ -25,6 +25,10 @@
 	* Add widgets in the graph guru first page to allow finer selection
 	of data.
 	* Fix labels length for charts generated by the histogram tool. [#552721]
+	* Fix loss od new graphs when clicking on an existing sheet
+	object. [#151789]
+	* Do not export invalid AXESUSED data to .xls. [#567783]
+	* Fix export of simple data to xls graphs. [#567930]
 
 Jody:
 	* Display top-left when selecting a rel ref to a merged region.

Modified: trunk/plugins/excel/ms-chart.c
==============================================================================
--- trunk/plugins/excel/ms-chart.c	(original)
+++ trunk/plugins/excel/ms-chart.c	Fri Jan 16 14:13:48 2009
@@ -4137,19 +4137,28 @@
 	unsigned len;
 	GnmExprTop const *texpr = NULL;
 	GnmValue const *value = NULL;
+	gboolean need_release = FALSE;
 
 	if (dim != NULL) {
-		texpr = gnm_go_data_get_expr (dim);
-		if ((value = gnm_expr_top_get_range (texpr)) != NULL) {
-			GType const t = G_OBJECT_TYPE (dim);
-			value_release ((GnmValue*) value);
-			value = NULL;
-			/* the following condition should always be true */
-			if (t == GNM_GO_DATA_SCALAR_TYPE ||
-			    t == GNM_GO_DATA_VECTOR_TYPE)
-				ref_type = 2;
-		} else if ((value = gnm_expr_top_get_constant (texpr)))
+		if (IS_GNM_GO_DATA_SCALAR (dim) || IS_GNM_GO_DATA_VECTOR (dim)) {
+			texpr = gnm_go_data_get_expr (dim);
+			if ((value = gnm_expr_top_get_range (texpr)) != NULL) {
+				GType const t = G_OBJECT_TYPE (dim);
+				value_release ((GnmValue*) value);
+				value = NULL;
+				/* the following condition should always be true */
+				if (t == GNM_GO_DATA_SCALAR_TYPE ||
+				    t == GNM_GO_DATA_VECTOR_TYPE)
+					ref_type = 2;
+			} else if ((value = gnm_expr_top_get_constant (texpr)))
+				ref_type = 1;
+		} else {
+			char *str = go_data_as_str (dim);
 			ref_type = 1;
+			value = value_new_string (str);
+			g_free (str);
+			need_release = TRUE;
+		}
 	}
 	ms_biff_put_var_next (s->bp, BIFF_CHART_ai);
 	GSF_LE_SET_GUINT8  (buf+0, n);
@@ -4187,6 +4196,8 @@
 			excel_write_string (s->bp, STR_ONE_BYTE_LENGTH, str);
 			g_free (str);
 		}
+		if (need_release)
+			value_release ((GnmValue *) value);
 	}
 
 	ms_biff_put_commit (s->bp);
@@ -5150,8 +5161,14 @@
 	XLAxisSet *axis_set;
 	GogObject const *legend = gog_object_get_child_by_name (s->chart, "Legend");
 	GogObject const *label;
+	unsigned num = g_slist_length (sets);
+
+	if (num == 0)
+		return;
+	if (num > 2)
+		num = 2; /* excel does not support more that 2. */
 
-	ms_biff_put_2byte (s->bp, BIFF_CHART_axesused, g_slist_length (sets));
+	ms_biff_put_2byte (s->bp, BIFF_CHART_axesused, MIN (g_slist_length (sets), 2));
 	for (sptr = sets; sptr != NULL ; sptr = sptr->next) {
 		data = ms_biff_put_len_next (s->bp, BIFF_CHART_axisparent, 4*4 + 2);
 		/* pick arbitrary position, this sort of info is in the view  */

Modified: trunk/src/gnm-pane.c
==============================================================================
--- trunk/src/gnm-pane.c	(original)
+++ trunk/src/gnm-pane.c	Fri Jan 16 14:13:48 2009
@@ -2955,6 +2955,11 @@
 {
 	GnmPane	*pane = GNM_PANE (view->canvas);
 
+	if (scg_wbcg(GNM_SIMPLE_CANVAS (view->canvas)->scg)->new_object) {
+		ItemGrid *grid = GNM_PANE (view->canvas)->grid;
+		return FOO_CANVAS_ITEM_GET_CLASS (grid)->event (FOO_CANVAS_ITEM (grid), event);
+	}
+
 	g_return_val_if_fail (IS_SHEET_OBJECT (so), FALSE);
 
 	switch (event->type) {



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