[gnumeric] xlsx: fix import/export of min/max/ticks settings.
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] xlsx: fix import/export of min/max/ticks settings.
- Date: Tue, 27 Jan 2015 01:50:50 +0000 (UTC)
commit cf15f97bd3783e417e5b9be70f213256a62dc335
Author: Morten Welinder <terra gnome org>
Date: Mon Jan 26 20:49:21 2015 -0500
xlsx: fix import/export of min/max/ticks settings.
NEWS | 1 +
plugins/excel/xlsx-read-drawing.c | 22 ++++++++++++++++++----
plugins/excel/xlsx-read.c | 3 +++
plugins/excel/xlsx-write-drawing.c | 12 +++++++++++-
4 files changed, 33 insertions(+), 5 deletions(-)
---
diff --git a/NEWS b/NEWS
index 674ed79..e823e8b 100644
--- a/NEWS
+++ b/NEWS
@@ -9,6 +9,7 @@ Morten:
* xlsx import/export trend line names.
* Fix gda plugin compilation. [#743506]
* Fix xlsx export problem with auto markers.
+ * Import/export xlsx chart axis min/max/steps.
--------------------------------------------------------------------------
Gnumeric 1.12.19
diff --git a/plugins/excel/xlsx-read-drawing.c b/plugins/excel/xlsx-read-drawing.c
index 99d854c..ea539cc 100644
--- a/plugins/excel/xlsx-read-drawing.c
+++ b/plugins/excel/xlsx-read-drawing.c
@@ -764,10 +764,12 @@ xlsx_axis_bound (GsfXMLIn *xin, xmlChar const **attrs)
{
XLSXReadState *state = (XLSXReadState *)xin->user_state;
gnm_float val;
- if (state->axis.info && simple_float (xin, attrs, &val))
- gog_dataset_set_dim (GOG_DATASET (state->axis.obj),
- xin->node->user_data.v_int,
- go_data_scalar_val_new (val), NULL);
+ GogAxisElemType et = xin->node->user_data.v_int;
+
+ if (state->axis.info && simple_float (xin, attrs, &val)) {
+ state->axis.info->axis_elements[et] = val;
+ state->axis.info->axis_element_set[et] = TRUE;
+ }
}
static void
@@ -851,6 +853,18 @@ xlsx_axis_end (GsfXMLIn *xin, G_GNUC_UNUSED GsfXMLBlob *blob)
if (NULL != state->axis.info) {
GSList *ptr, *children;
GogAxis *axis = state->axis.obj;
+ GogAxisElemType et;
+
+ for (et = GOG_AXIS_ELEM_MIN; et < GOG_AXIS_ELEM_MAX_ENTRY; et++) {
+ if (state->axis.info->axis_element_set[et]) {
+ double d = state->axis.info->axis_elements[et];
+ GnmExprTop const *te = gnm_expr_top_new_constant (value_new_float (d));
+ gog_dataset_set_dim (GOG_DATASET (axis),
+ et,
+ gnm_go_data_scalar_new_expr (state->sheet, te),
+ NULL);
+ }
+ }
for (ptr = state->axis.info->plots; ptr != NULL ; ptr = ptr->next) {
GogPlot *plot = ptr->data;
diff --git a/plugins/excel/xlsx-read.c b/plugins/excel/xlsx-read.c
index 3e97d22..dcb6e79 100644
--- a/plugins/excel/xlsx-read.c
+++ b/plugins/excel/xlsx-read.c
@@ -122,6 +122,9 @@ typedef struct {
gnm_float cross_value;
gboolean invert_axis;
+ double axis_elements[GOG_AXIS_ELEM_MAX_ENTRY];
+ guint8 axis_element_set[GOG_AXIS_ELEM_MAX_ENTRY];
+
gboolean deleted;
} XLSXAxisInfo;
diff --git a/plugins/excel/xlsx-write-drawing.c b/plugins/excel/xlsx-write-drawing.c
index 3c54e0e..e4a68b4 100644
--- a/plugins/excel/xlsx-write-drawing.c
+++ b/plugins/excel/xlsx-write-drawing.c
@@ -381,6 +381,8 @@ xlsx_write_axis (XLSXWriteState *state, GsfXMLOut *xml, GogAxis *axis, GogAxisTy
GogGridLine *grid;
GogObject *label;
GOFormat *format;
+ double d;
+ gboolean user_defined;
#ifdef DEBUG_AXIS
g_printerr ("Writing axis %s. (discrete = %d)\n",
@@ -395,7 +397,10 @@ xlsx_write_axis (XLSXWriteState *state, GsfXMLOut *xml, GogAxis *axis, GogAxisTy
xlsx_write_chart_uint (xml, "c:axId", 0, xlsx_get_axid (state, axis));
gsf_xml_out_start_element (xml, "c:scaling");
xlsx_write_chart_cstr_unchecked (xml, "c:orientation", gog_axis_is_inverted (axis)? "maxMin":
"minMax");
- // TODO: export min, max, an others
+ d = gog_axis_get_entry (axis, GOG_AXIS_ELEM_MAX, &user_defined);
+ if (user_defined) xlsx_write_chart_float (xml, "c:max", go_nan, d);
+ d = gog_axis_get_entry (axis, GOG_AXIS_ELEM_MIN, &user_defined);
+ if (user_defined) xlsx_write_chart_float (xml, "c:min", go_nan, d);
gsf_xml_out_end_element (xml);
/* FIXME position might be "t" or "r" */
xlsx_write_chart_cstr_unchecked (xml, "c:axPos", (at == GOG_AXIS_X || at == GOG_AXIS_CIRCULAR)? "b":
"l");
@@ -454,6 +459,11 @@ xlsx_write_axis (XLSXWriteState *state, GsfXMLOut *xml, GogAxis *axis, GogAxisTy
break;
}
+ d = gog_axis_get_entry (axis, GOG_AXIS_ELEM_MAJOR_TICK, &user_defined);
+ if (user_defined) xlsx_write_chart_float (xml, "c:majorUnit", go_nan, d);
+ d = gog_axis_get_entry (axis, GOG_AXIS_ELEM_MINOR_TICK, &user_defined);
+ if (user_defined) xlsx_write_chart_float (xml, "c:minorUnit", go_nan, d);
+
/* finished with axis */
gsf_xml_out_end_element (xml);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]