[gnumeric] xlsx: use "valAx" for a surface chart's X axis.



commit 21ca8de072b9e76a2cc025db35d44f46263b6a53
Author: Morten Welinder <terra gnome org>
Date:   Thu Oct 26 13:43:22 2017 -0400

    xlsx: use "valAx" for a surface chart's X axis.

 plugins/excel/ChangeLog            |    5 +++++
 plugins/excel/xlsx-write-drawing.c |   34 +++++++++++++++++++++++++---------
 2 files changed, 30 insertions(+), 9 deletions(-)
---
diff --git a/plugins/excel/ChangeLog b/plugins/excel/ChangeLog
index db7aeba..ed505f6 100644
--- a/plugins/excel/ChangeLog
+++ b/plugins/excel/ChangeLog
@@ -1,3 +1,8 @@
+2017-10-26  Morten Welinder  <terra gnome org>
+
+       * xlsx-write-drawing.c (xlsx_write_axis): Make axis tag for
+       surface charts match what XL wants.  Even if it isn't obvious why.
+
 2017-10-24  Morten Welinder  <terra gnome org>
 
        * xlsx-write-drawing.c (xlsx_write_axis): Write a pseudo-3d axis
diff --git a/plugins/excel/xlsx-write-drawing.c b/plugins/excel/xlsx-write-drawing.c
index 22583e9..2d5d905 100644
--- a/plugins/excel/xlsx-write-drawing.c
+++ b/plugins/excel/xlsx-write-drawing.c
@@ -727,7 +727,8 @@ xlsx_get_axid (XLSXWriteState *state, GogAxis *axis)
 
 
 static void
-xlsx_write_axis (XLSXWriteState *state, GsfXMLOut *xml, GogPlot *plot, GogAxis *axis)
+xlsx_write_axis (XLSXWriteState *state, GsfXMLOut *xml,
+                GogPlot *plot, XLSXPlotType plot_type, GogAxis *axis)
 {
        GogAxisType at = gog_axis_get_atype (axis);
        GogAxis *crossed = gog_axis_base_get_crossed_axis_for_plot (GOG_AXIS_BASE (axis), plot);
@@ -738,7 +739,7 @@ xlsx_write_axis (XLSXWriteState *state, GsfXMLOut *xml, GogPlot *plot, GogAxis *
        double d;
        gboolean user_defined;
        char *map_name;
-       const char *axis_tag;
+       const char *axis_tag = NULL;
 
 #ifdef DEBUG_AXIS
        g_printerr ("Writing axis %s [id=%d].  (discrete = %d)\n",
@@ -752,12 +753,25 @@ xlsx_write_axis (XLSXWriteState *state, GsfXMLOut *xml, GogPlot *plot, GogAxis *
                      "map-name", &map_name,
                      NULL);
 
-       if (gog_axis_get_atype (axis) == GOG_AXIS_PSEUDO_3D)
-               axis_tag = "c:serAx";
-       else if (gog_axis_is_discrete (axis))
-               axis_tag = "c:catAx";
-       else
-               axis_tag = "c:valAx";
+       switch (plot_type) {
+       case XLSX_PT_GOGCONTOURPLOT:
+       case XLSX_PT_XLCONTOURPLOT:
+               // Both X and Y axes are discrete, but XL wants valAx for the
+               // X axis.
+               switch (at) {
+               case GOG_AXIS_X: axis_tag = "c:valAx"; break;
+               case GOG_AXIS_Y: axis_tag = "c:catAx"; break;
+               case GOG_AXIS_PSEUDO_3D: axis_tag = "c:serAx"; break;
+               default: g_assert_not_reached ();
+               }
+               break;
+       default:
+               break;
+       }
+
+       if (!axis_tag)
+               axis_tag = gog_axis_is_discrete (axis) ? "c:catAx" : "c:valAx";
+
        gsf_xml_out_start_element (xml, axis_tag);
        xlsx_write_chart_uint (xml, "c:axId", xlsx_get_axid (state, axis));
 
@@ -1246,7 +1260,9 @@ xlsx_write_plots (XLSXWriteState *state, GsfXMLOut *xml, GogObject const *chart,
        for (l = axes; l; l = l->next) {
                GogAxis *axis = l->data;
                GogPlot *plot = g_hash_table_lookup (axis_to_plot, axis);
-               xlsx_write_axis (state, xml, plot, axis);
+               const char *plot_type_name = G_OBJECT_TYPE_NAME (plot);
+               XLSXPlotType plot_type = xlsx_plottype_from_type_name (plot_type_name);
+               xlsx_write_axis (state, xml, plot, plot_type, axis);
        }
        g_slist_free (axes);
        g_hash_table_destroy (axis_to_plot);


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