[gnumeric] xlsx: fix problem with inverted axis.



commit 467f8accd7d2ca7024e1304cd30b5b9b3011dcb9
Author: Morten Welinder <terra gnome org>
Date:   Tue Jan 27 14:50:19 2015 -0500

    xlsx: fix problem with inverted axis.

 NEWS                               |    1 +
 plugins/excel/ChangeLog            |    5 +++++
 plugins/excel/xlsx-read-drawing.c  |   10 ++++++----
 plugins/excel/xlsx-write-drawing.c |   11 ++++++-----
 samples/graph-tests.gnumeric       |  Bin 8503 -> 8787 bytes
 5 files changed, 18 insertions(+), 9 deletions(-)
---
diff --git a/NEWS b/NEWS
index 099e4c5..1cfb2a4 100644
--- a/NEWS
+++ b/NEWS
@@ -13,6 +13,7 @@ Morten:
        * Fix xlsx export problem with auto markers.
        * Import/export xlsx chart axis min/max/steps.
        * Export xlsx chart axis tick marks.
+       * Fix xlsx problem with inverted axis.
 
 --------------------------------------------------------------------------
 Gnumeric 1.12.19
diff --git a/plugins/excel/ChangeLog b/plugins/excel/ChangeLog
index 74c5560..2d5aaea 100644
--- a/plugins/excel/ChangeLog
+++ b/plugins/excel/ChangeLog
@@ -1,3 +1,8 @@
+2015-01-27  Morten Welinder  <terra gnome org>
+
+       * xlsx-write-drawing.c (xlsx_write_axis): Fix crossing for
+       inverted axis.
+
 2015-01-26  Morten Welinder  <terra gnome org>
 
        * xlsx-write.c (xlsx_write_sheet): Warn about dropped objects.
diff --git a/plugins/excel/xlsx-read-drawing.c b/plugins/excel/xlsx-read-drawing.c
index ea539cc..a873df8 100644
--- a/plugins/excel/xlsx-read-drawing.c
+++ b/plugins/excel/xlsx-read-drawing.c
@@ -849,15 +849,17 @@ xlsx_axis_end (GsfXMLIn *xin, G_GNUC_UNUSED GsfXMLBlob *blob)
 {
        XLSXReadState *state = (XLSXReadState *)xin->user_state;
 
-       /* Try to guess what type of axis to use */
        if (NULL != state->axis.info) {
                GSList *ptr, *children;
                GogAxis *axis = state->axis.obj;
                GogAxisElemType et;
+               XLSXAxisInfo *info = state->axis.info;
+
+               /* Apply pending attributes.  */
 
                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];
+                       if (info->axis_element_set[et]) {
+                               double d = info->axis_elements[et];
                                GnmExprTop const *te = gnm_expr_top_new_constant (value_new_float (d));
                                gog_dataset_set_dim (GOG_DATASET (axis),
                                                     et,
@@ -866,7 +868,7 @@ xlsx_axis_end (GsfXMLIn *xin, G_GNUC_UNUSED GsfXMLBlob *blob)
                        }
                }
 
-               for (ptr = state->axis.info->plots; ptr != NULL ; ptr = ptr->next) {
+               for (ptr = info->plots; ptr != NULL ; ptr = ptr->next) {
                        GogPlot *plot = ptr->data;
 #ifdef DEBUG_AXIS
                        g_printerr ("connect plot %p to %p\n", plot, axis);
diff --git a/plugins/excel/xlsx-write-drawing.c b/plugins/excel/xlsx-write-drawing.c
index e539345..e3f9475 100644
--- a/plugins/excel/xlsx-write-drawing.c
+++ b/plugins/excel/xlsx-write-drawing.c
@@ -459,9 +459,13 @@ xlsx_write_axis (XLSXWriteState *state, GsfXMLOut *xml, GogAxis *axis, GogAxisTy
        switch (pos) {
        default:
        case GOG_AXIS_AT_LOW:
-               /* FIXME: might be wrong if the axis is inverted */
-               xlsx_write_chart_cstr_unchecked (xml, "c:crosses", "min");
+       case GOG_AXIS_AT_HIGH: {
+               gboolean is_low = (pos == GOG_AXIS_AT_LOW);
+               gboolean cross_inv = gog_axis_is_inverted (crossed);
+               xlsx_write_chart_cstr_unchecked (xml, "c:crosses",
+                                                is_low ^ cross_inv ? "min" : "max");
                break;
+       }
        case GOG_AXIS_CROSS: {
                double cross = gog_axis_base_get_cross_location (GOG_AXIS_BASE (axis));
                if (cross == 0.)
@@ -470,9 +474,6 @@ xlsx_write_axis (XLSXWriteState *state, GsfXMLOut *xml, GogAxis *axis, GogAxisTy
                        xlsx_write_chart_float (xml, "c:crossesAt", 0., cross);
                break;
        }
-       case GOG_AXIS_AT_HIGH:
-               xlsx_write_chart_cstr_unchecked (xml, "c:crosses", "max");
-               break;
        }
 
        d = gog_axis_get_entry (axis, GOG_AXIS_ELEM_MAJOR_TICK, &user_defined);
diff --git a/samples/graph-tests.gnumeric b/samples/graph-tests.gnumeric
index 02e3f96..25448f2 100644
Binary files a/samples/graph-tests.gnumeric and b/samples/graph-tests.gnumeric differ


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