[gnumeric] Fix export/import of minor axis divisors to and from ODF.



commit e237a7404f866a9e434053ccae9fcac32f3f3a9a
Author: Andreas J. Guelzow <aguelzow pyrshep ca>
Date:   Thu Oct 26 23:33:04 2017 -0600

    Fix export/import of minor axis divisors to and from ODF.
    
    2017-10-26  Andreas J. Guelzow <aguelzow pyrshep ca>
    
        * openoffice-read.c (oo_prop_list_apply_to_axis): convert interval_minor_divisor
        based on map-name
        * openoffice-write.c (odf_write_axis_style): convert minor tick info into
        interval_minor_divisor

 plugins/openoffice/ChangeLog          |    6 ++++--
 plugins/openoffice/openoffice-read.c  |   17 +++++++++++++----
 plugins/openoffice/openoffice-write.c |   17 +++++++++++------
 3 files changed, 28 insertions(+), 12 deletions(-)
---
diff --git a/plugins/openoffice/ChangeLog b/plugins/openoffice/ChangeLog
index b1284b8..cd97bde 100644
--- a/plugins/openoffice/ChangeLog
+++ b/plugins/openoffice/ChangeLog
@@ -1,7 +1,9 @@
 2017-10-26  Andreas J. Guelzow <aguelzow pyrshep ca>
 
-       * openoffice-read.c (od_style_prop_chart): correct property name and
-       handle LO trendline intercept extension
+       * openoffice-read.c (oo_prop_list_apply_to_axis): convert interval_minor_divisor
+       based on map-name
+       * openoffice-write.c (odf_write_axis_style): convert minor tick info into
+       interval_minor_divisor
 
 2017-10-16  Andreas J. Guelzow <aguelzow pyrshep ca>
 
diff --git a/plugins/openoffice/openoffice-read.c b/plugins/openoffice/openoffice-read.c
index 597cdb8..0396dfc 100644
--- a/plugins/openoffice/openoffice-read.c
+++ b/plugins/openoffice/openoffice-read.c
@@ -6945,6 +6945,7 @@ oo_prop_list_apply_to_axis (GsfXMLIn *xin, GSList *props, GObject *obj)
        double interval_minor_divisor = 0.;
        gchar const *minimum_expression = NULL;
        gchar const *maximum_expression = NULL;
+       gboolean logarithmic = FALSE;
 
 
        oo_prop_list_apply_to_axisline (xin, props, obj);
@@ -6964,6 +6965,8 @@ oo_prop_list_apply_to_axis (GsfXMLIn *xin, GSList *props, GObject *obj)
                        minimum_expression = g_value_get_string (&prop->value);
                else if (0 == strcmp ("maximum-expression", prop->name))
                        maximum_expression = g_value_get_string (&prop->value);
+               else if (0 == strcmp ("map-name", prop->name))
+                       logarithmic = (0 == strcmp (g_value_get_string (&prop->value), "Log"));
        }
 
        gog_axis_set_bounds (GOG_AXIS (obj), minimum, maximum);
@@ -6978,10 +6981,16 @@ oo_prop_list_apply_to_axis (GsfXMLIn *xin, GSList *props, GObject *obj)
                         (value_new_float(interval_major)));
                gog_dataset_set_dim (GOG_DATASET (obj), 2, data, NULL);
                if (interval_minor_divisor > 1) {
-                       data = gnm_go_data_scalar_new_expr
-                               (state->chart.src_sheet,
-                                gnm_expr_top_new_constant
-                                (value_new_float (interval_minor_divisor - 1)));
+                       if (logarithmic)
+                               data = gnm_go_data_scalar_new_expr
+                                       (state->chart.src_sheet,
+                                        gnm_expr_top_new_constant
+                                        (value_new_float (interval_minor_divisor - 1)));
+                       else
+                               data = gnm_go_data_scalar_new_expr
+                                       (state->chart.src_sheet,
+                                        gnm_expr_top_new_constant
+                                        (value_new_float (interval_major/interval_minor_divisor)));
                        gog_dataset_set_dim (GOG_DATASET (obj), 3, data, NULL);
                }
        }
diff --git a/plugins/openoffice/openoffice-write.c b/plugins/openoffice/openoffice-write.c
index cd4559f..0b67808 100644
--- a/plugins/openoffice/openoffice-write.c
+++ b/plugins/openoffice/openoffice-write.c
@@ -7230,12 +7230,13 @@ odf_write_axis_style (GnmOOExport *state, GOStyle const *style,
        double tmp;
        GOData const *interval;
        gboolean user_defined;
+       gboolean logarithmic = FALSE;
        char *map_name_str = NULL;
 
        if (gnm_object_has_readable_prop (axis, "map-name",
                                          G_TYPE_STRING, &map_name_str)) {
-               odf_add_bool (state->xml, CHART "logarithmic",
-                             0 != strcmp (map_name_str, "Linear"));
+               logarithmic = (0 != strcmp (map_name_str, "Linear"));
+               odf_add_bool (state->xml, CHART "logarithmic", logarithmic);
                g_free (map_name_str);
        }
 
@@ -7272,11 +7273,15 @@ odf_write_axis_style (GnmOOExport *state, GOStyle const *style,
                                    GNM_EXPR_GET_OPER (texpr->expr) == GNM_EXPR_OP_CONSTANT) {
                                        double val_minor = value_get_as_float
                                                (texpr->expr->constant.value);
-                                       if (val_minor > 0)
+                                       if (val_minor > 0) {
+                                               if (logarithmic)
+                                                       val_minor = gnm_floor(val_minor + 1.5);
+                                               else
+                                                       val_minor = gnm_floor(val/val_minor + 0.5);
                                                gsf_xml_out_add_float
-                                                       (state->xml,
-                                                        CHART "interval-minor-divisor",
-                                                        gnm_floor(val_minor + 1.5), 0);
+                                                       (state->xml, CHART "interval-minor-divisor",
+                                                        val_minor, 0);
+                                       }
                                }
                        }
                }


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