[gnumeric] xlsx: improve export of axes when multiple are present.
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] xlsx: improve export of axes when multiple are present.
- Date: Tue, 24 Feb 2015 19:11:26 +0000 (UTC)
commit 49f5c32cdac48608848b131ed2effcb7c7bb64f8
Author: Morten Welinder <terra gnome org>
Date: Tue Feb 24 14:10:51 2015 -0500
xlsx: improve export of axes when multiple are present.
plugins/excel/ChangeLog | 9 +++++++++
plugins/excel/xlsx-read-drawing.c | 11 ++++++++---
plugins/excel/xlsx-write-drawing.c | 28 +++++++++++++++-------------
3 files changed, 32 insertions(+), 16 deletions(-)
---
diff --git a/plugins/excel/ChangeLog b/plugins/excel/ChangeLog
index 7067650..e65ecb8 100644
--- a/plugins/excel/ChangeLog
+++ b/plugins/excel/ChangeLog
@@ -1,5 +1,14 @@
2015-02-24 Morten Welinder <terra gnome org>
+ * xlsx-write-drawing.c (xlsx_write_axis): Pick the crossing axis
+ within the relevant plot.
+
+ * xlsx-read-drawing.c (cb_axis_set_position): Don't use
+ g_return_if_fail for data validation.
+
+ * xlsx-write-drawing.c (xlsx_write_one_plot): Write only the axes
+ we reference.
+
* xlsx-read-drawing.c (xlsx_create_axis_object): Move setting of
"invisible" here.
diff --git a/plugins/excel/xlsx-read-drawing.c b/plugins/excel/xlsx-read-drawing.c
index e0f34bd..f9cc0d0 100644
--- a/plugins/excel/xlsx-read-drawing.c
+++ b/plugins/excel/xlsx-read-drawing.c
@@ -2672,10 +2672,11 @@ 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);
+ XLSXAxisInfo *cross_info = info->cross_id
+ ? g_hash_table_lookup (state->axis.by_id, info->cross_id)
+ : NULL;
- g_return_if_fail (cross_info != NULL);
+ if (cross_info) {
obj = GOG_OBJECT (cross_info->axis);
if (go_finite (cross_info->cross_value)) {
GnmValue *value = value_new_float (cross_info->cross_value);
@@ -2693,7 +2694,11 @@ cb_axis_set_position (GObject *axis, XLSXAxisInfo *info,
*/
if ((GogAxis*)axis != gog_axis_base_get_crossed_axis (GOG_AXIS_BASE (obj)))
g_object_set (obj, "cross-axis-id", gog_object_get_id (GOG_OBJECT (axis)), NULL);
+ } else if (info->cross_id) {
+ g_printerr ("Axis %s has invalid cross-axis id %s\n",
+ info->id, info->cross_id);
}
+
if (info->deleted) {
GSList *l = gog_chart_get_axes (state->chart, gog_axis_get_atype (GOG_AXIS (axis))), *cur;
GogAxis *visible = NULL;
diff --git a/plugins/excel/xlsx-write-drawing.c b/plugins/excel/xlsx-write-drawing.c
index 8eb1277..84b49d1 100644
--- a/plugins/excel/xlsx-write-drawing.c
+++ b/plugins/excel/xlsx-write-drawing.c
@@ -24,6 +24,8 @@
/*****************************************************************************/
+#undef DEBUG_AXIS
+
static void
xlsx_write_chart_cstr_unchecked (GsfXMLOut *xml, char const *name, char const *val)
{
@@ -649,9 +651,10 @@ xlsx_get_axid (XLSXWriteState *state, GogAxis *axis)
static void
-xlsx_write_axis (XLSXWriteState *state, GsfXMLOut *xml, GogAxis *axis, GogAxisType at)
+xlsx_write_axis (XLSXWriteState *state, GsfXMLOut *xml, GogPlot *plot, GogAxis *axis)
{
- GogAxis *crossed = gog_axis_base_get_crossed_axis (GOG_AXIS_BASE (axis));
+ GogAxisType at = gog_axis_get_atype (axis);
+ GogAxis *crossed = gog_axis_base_get_crossed_axis_for_plot (GOG_AXIS_BASE (axis), plot);
GogAxisPosition pos;
GogGridLine *grid;
GogObject *label;
@@ -660,8 +663,9 @@ xlsx_write_axis (XLSXWriteState *state, GsfXMLOut *xml, GogAxis *axis, GogAxisTy
gboolean user_defined;
#ifdef DEBUG_AXIS
- g_printerr ("Writing axis %s. (discrete = %d)\n",
+ g_printerr ("Writing axis %s [id=%d]. (discrete = %d)\n",
gog_object_get_name (GOG_OBJECT (axis)),
+ xlsx_get_axid (state, axis),
gog_axis_is_discrete (axis));
#endif
@@ -1069,10 +1073,12 @@ xlsx_write_one_plot (XLSXWriteState *state, GsfXMLOut *xml, GogObject const *cha
}
/* write axes Ids */
- for (i = 0; i < 3; i++)
- if (axis_type[i] != GOG_AXIS_UNKNOWN)
- xlsx_write_chart_uint (xml, "c:axId", 0, xlsx_get_axid (state, gog_plot_get_axis
(GOG_PLOT (plot), axis_type[i])));
-
+ for (i = 0; i < 3; i++) {
+ if (axis_type[i] != GOG_AXIS_UNKNOWN) {
+ GogAxis *axis = gog_plot_get_axis (GOG_PLOT (plot), axis_type[i]);
+ xlsx_write_chart_uint (xml, "c:axId", 0, xlsx_get_axid (state, axis));
+ }
+ }
gsf_xml_out_end_element (xml);
@@ -1081,12 +1087,8 @@ xlsx_write_one_plot (XLSXWriteState *state, GsfXMLOut *xml, GogObject const *cha
/* FIXME: might be a date axis? */
for (i = 0; i < 3; i++) {
if (axis_type[i] != GOG_AXIS_UNKNOWN) {
- GSList *axes = gog_chart_get_axes (GOG_CHART (chart), axis_type[i]), *ptr;
- for (ptr = axes; ptr; ptr = ptr->next) {
- GogAxis *axis = ptr->data;
- xlsx_write_axis (state, xml, axis, axis_type[i]);
- }
- g_slist_free (axes);
+ GogAxis *axis = gog_plot_get_axis (GOG_PLOT (plot), axis_type[i]);
+ xlsx_write_axis (state, xml, GOG_PLOT (plot), axis);
}
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]