[gnumeric] Fix axis position import from xlsx.



commit 3b41684e517cae90f1a1e1a092636a28df9cf14e
Author: Jean Brefort <jean brefort normalesup org>
Date:   Tue May 3 10:58:44 2011 +0200

    Fix axis position import from xlsx.

 plugins/excel/ChangeLog            |    6 ++++++
 plugins/excel/xlsx-read-drawing.c  |   33 +++++++++++++++++++--------------
 plugins/excel/xlsx-write-drawing.c |    2 +-
 3 files changed, 26 insertions(+), 15 deletions(-)
---
diff --git a/plugins/excel/ChangeLog b/plugins/excel/ChangeLog
index a9df9dd..8e3e9dc 100644
--- a/plugins/excel/ChangeLog
+++ b/plugins/excel/ChangeLog
@@ -1,3 +1,9 @@
+2011-05-03  Jean Brefort  <jean brefort normalesup org>
+
+	* xlsx-read-drawing.c (xlsx_style_line_start): don't crash on NULL style,
+	(cb_axis_set_position): fix axis crossing position.
+	* xlsx-write-drawing.c (xlsx_write_chart): partially fix circular axis position.
+
 2011-04-08  Jean Brefort  <jean brefort normalesup org>
 
 	* xlsx-read-drawing.c: import some legacy drwawings.
diff --git a/plugins/excel/xlsx-read-drawing.c b/plugins/excel/xlsx-read-drawing.c
index 81c2c1f..dcc1827 100644
--- a/plugins/excel/xlsx-read-drawing.c
+++ b/plugins/excel/xlsx-read-drawing.c
@@ -908,6 +908,8 @@ xlsx_style_line_start (GsfXMLIn *xin, xmlChar const **attrs)
 {
 	XLSXReadState	*state = (XLSXReadState *)xin->user_state;
 	state->sp_type |= GO_STYLE_LINE;
+	if (!state->cur_style)
+		state->cur_style = gog_style_new ();
 	state->gocolor = &state->cur_style->line.color;
 }
 
@@ -1654,6 +1656,21 @@ static void
 cb_axis_set_position (GObject *axis, XLSXAxisInfo *info,
 		      XLSXReadState *state)
 {
+	GogObject *obj = NULL;
+	if (info->cross_id) {
+		XLSXAxisInfo *cross_info = g_hash_table_lookup (state->axis.by_id, info->cross_id);
+		g_return_if_fail (cross_info != NULL);
+		obj = GOG_OBJECT (cross_info->axis);
+		if (go_finite (cross_info->cross_value)) {
+			GnmValue *value = value_new_float (cross_info->cross_value);
+			GnmExprTop const *texpr = gnm_expr_top_new_constant (value);
+			gog_dataset_set_dim (GOG_DATASET (obj), GOG_AXIS_ELEM_CROSS_POINT,
+				gnm_go_data_scalar_new_expr (state->sheet, texpr), NULL);
+		}
+		if (gog_axis_is_inverted (GOG_AXIS (axis)))
+			cross_info->cross = 2 - cross_info->cross; /* KLUDGE */
+		g_object_set (obj, "pos", cross_info->cross, "cross-axis-id", gog_object_get_id (GOG_OBJECT (axis)), NULL);
+	}
 	if (info->deleted) {
 		GSList *l = gog_chart_get_axes (state->chart, gog_axis_get_atype (GOG_AXIS (axis))), *cur;
 		GogAxis *visible = NULL;
@@ -1669,6 +1686,8 @@ cb_axis_set_position (GObject *axis, XLSXAxisInfo *info,
 		if (visible) {
 			GSList *l1, *cur1;
 
+			if (obj)
+				g_object_set (obj, "cross-axis-id", gog_object_get_id (GOG_OBJECT (visible)), NULL);
 			l1 = g_slist_copy ((GSList *) gog_axis_contributors (GOG_AXIS (axis)));
 			for (cur1 = l1; cur1; cur1 = cur1->next) {
 				if (GOG_IS_PLOT (cur1->data))
@@ -1685,20 +1704,6 @@ cb_axis_set_position (GObject *axis, XLSXAxisInfo *info,
 			}
 			g_slist_free (l1);
 		}
-	} else if (info->cross_id) {
-		XLSXAxisInfo *cross_info = g_hash_table_lookup (state->axis.by_id, info->cross_id);
-		GogObject *obj;
-		g_return_if_fail (cross_info != NULL);
-		obj = GOG_OBJECT (cross_info->axis);
-		if (go_finite (cross_info->cross_value)) {
-			GnmValue *value = value_new_float (cross_info->cross_value);
-			GnmExprTop const *texpr = gnm_expr_top_new_constant (value);
-			gog_dataset_set_dim (GOG_DATASET (obj), GOG_AXIS_ELEM_CROSS_POINT,
-				gnm_go_data_scalar_new_expr (state->sheet, texpr), NULL);
-		}
-		if (gog_axis_is_inverted (GOG_AXIS (axis)))
-			cross_info->cross = 2 - cross_info->cross; /* KLUDGE */
-		g_object_set (obj, "pos", cross_info->cross, "cross-axis-id", gog_object_get_id (GOG_OBJECT (axis)), NULL);
 	}
 }
 
diff --git a/plugins/excel/xlsx-write-drawing.c b/plugins/excel/xlsx-write-drawing.c
index a070cf6..1b50ce9 100644
--- a/plugins/excel/xlsx-write-drawing.c
+++ b/plugins/excel/xlsx-write-drawing.c
@@ -377,7 +377,7 @@ xlsx_write_chart (XLSXWriteState *state, GsfOutput *chart_part, SheetObject *so)
 				gsf_xml_out_end_element (xml);
 				xlsx_write_go_style (xml, go_styled_object_get_style (GO_STYLED_OBJECT (ptr->data)));
 				/* FIXME position might be "t" or "r" */
-				xlsx_write_chart_cstr_unchecked (xml, "c:axPos", (axis_type[i] == GOG_AXIS_X)? "b": "l");
+				xlsx_write_chart_cstr_unchecked (xml, "c:axPos", (axis_type[i] == GOG_AXIS_X || axis_type[i] == GOG_AXIS_CIRCULAR)? "b": "l");
 				xlsx_write_chart_int (xml, "c:crossAx", 0, GPOINTER_TO_UINT (crossed));
 				g_object_get (G_OBJECT (ptr->data), "pos", &pos, NULL);
 				switch (pos) {



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