Commit 680c30a2 authored by Morten Welinder's avatar Morten Welinder

xlsx: export multiple plots in one chart.

There still seems to be some problems with axis positioning.
parent 6c955f3a
......@@ -2,6 +2,7 @@ Gnumeric 1.12.22
Morten:
* xlsx import/export of log axis.
* xlsx export of multiple plots in chart.
--------------------------------------------------------------------------
Gnumeric 1.12.21
......
2015-03-07 Morten Welinder <terra@gnome.org>
* xlsx-write-drawing.c (xlsx_write_plots): Write all plots, not
just the first one.
* xlsx-write.c: Use new go_xml_out_add_double.
* xlsx-write-drawing.c: Use new go_xml_out_add_double.
......
......@@ -708,7 +708,7 @@ xlsx_axis_start (GsfXMLIn *xin, G_GNUC_UNUSED xmlChar const **attrs)
/* Push dummy object for now until we can deduce the role. */
xlsx_chart_push_obj (state, NULL);
#ifdef DEBUG_AXIS
g_printerr ("Create dummy object for axis\n");
g_printerr ("Create NULL object for axis\n");
#endif
}
......@@ -805,6 +805,18 @@ xlsx_create_axis_object (XLSXReadState *state)
if (state->cur_obj)
return;
if (state->axis.info && state->axis.info->axis) {
axis = GOG_OBJECT (state->axis.obj = state->axis.info->axis);
/* Replace dummy object. */
xlsx_chart_pop_obj (state);
xlsx_chart_push_obj (state, axis);
#ifdef DEBUG_AXIS
g_printerr ("Re-using axis object %s with role %s\n",
gog_object_get_name (axis), role);
#endif
return;
}
dummy = (!state->axis.info || !state->axis.info->plots);
if (dummy) {
plot = NULL;
......
......@@ -66,7 +66,7 @@ xlsx_write_chart_float (GsfXMLOut *xml, char const *name, double val)
}
static void
xlsx_write_plot_1_5_type (GsfXMLOut *xml, GogObject const *plot, gboolean is_barcol)
xlsx_write_plot_1_5_type (GsfXMLOut *xml, GogPlot const *plot, gboolean is_barcol)
{
char *type;
const char *gtype;
......@@ -774,7 +774,7 @@ xlsx_write_axis (XLSXWriteState *state, GsfXMLOut *xml, GogPlot *plot, GogAxis *
static void
xlsx_write_one_plot (XLSXWriteState *state, GsfXMLOut *xml, GogObject const *chart, GogObject const *plot)
xlsx_write_one_plot (XLSXWriteState *state, GsfXMLOut *xml, GogObject const *chart, GogPlot *plot)
{
double explosion = 0.;
gboolean vary_by_element;
......@@ -1102,18 +1102,12 @@ xlsx_write_one_plot (XLSXWriteState *state, GsfXMLOut *xml, GogObject const *cha
static void
xlsx_write_plots (XLSXWriteState *state, GsfXMLOut *xml, GogObject const *chart)
{
GSList *plots;
GogObject const *plot;
plots = gog_object_get_children
(GOG_OBJECT (chart),
gog_object_find_role_by_name (GOG_OBJECT (chart), "Plot"));
if (plots != NULL && plots->data != NULL) {
plot = plots->data;
if (plots->next != NULL) {
int n = g_slist_length (plots) - 1;
g_warning ("Dropping %d plots from a chart.", n);
}
GSList *plots, *l;
GogObjectRole const *role = gog_object_find_role_by_name (GOG_OBJECT (chart), "Plot");
plots = gog_object_get_children (GOG_OBJECT (chart), role);
for (l = plots; l; l = l->next) {
GogPlot *plot = l->data;
xlsx_write_one_plot (state, xml, chart, plot);
}
g_slist_free (plots);
......@@ -1180,7 +1174,7 @@ xlsx_write_chart (XLSXWriteState *state, GsfOutput *chart_part, SheetObject *so)
xlsx_write_one_chart (state, xml, chart1);
if (charts->next)
g_warning ("Dropping %d charts on the floor!",
g_slist_length (charts));
g_slist_length (charts->next));
g_slist_free (charts);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment