[gnumeric] ODF import/export additional axislines.



commit 6e97de47b37b092b97b07ef56cf17c904eceb84d
Author: Andreas J. Guelzow <aguelzow pyrshep ca>
Date:   Tue Feb 10 20:37:31 2015 -0700

    ODF import/export additional axislines.
    
    2015-02-10  Andreas J. Guelzow <aguelzow pyrshep ca>
    
        * openoffice-read.c (oo_prop_list_apply_to_axisline): new
        (oo_prop_list_apply_to_axis): use oo_prop_list_apply_to_axisline
        (oo_chart_axisline): new
        (opendoc_content_dtd): connect oo_chart_axisline
        * openoffice-write.c (odf_write_axisline_style): new
        (odf_write_axis_style): use odf_write_axisline_style
        (odf_write_axislines): new
        (odf_write_axis_full): call odf_write_axislines
        (odf_fill_chart_props_hash): connect odf_write_axisline_style

 NEWS                                  |    1 +
 plugins/openoffice/ChangeLog          |   12 +++++
 plugins/openoffice/openoffice-read.c  |   73 ++++++++++++++++++++++++++++-----
 plugins/openoffice/openoffice-write.c |   60 +++++++++++++++++++++------
 4 files changed, 122 insertions(+), 24 deletions(-)
---
diff --git a/NEWS b/NEWS
index b9a10fb..e9f8653 100644
--- a/NEWS
+++ b/NEWS
@@ -10,6 +10,7 @@ Andreas:
          graphs. [#743789]
        * Fix ODF export of serieslines styles.
        * Fix ODF import/export of axes label visibility. [#743788]
+       * ODF import/export additional axislines.
 
 Morten:
        * Initial xlsx import of sheet widgets.
diff --git a/plugins/openoffice/ChangeLog b/plugins/openoffice/ChangeLog
index 3ab7cf3..7ce0572 100644
--- a/plugins/openoffice/ChangeLog
+++ b/plugins/openoffice/ChangeLog
@@ -1,3 +1,15 @@
+2015-02-10  Andreas J. Guelzow <aguelzow pyrshep ca>
+
+       * openoffice-read.c (oo_prop_list_apply_to_axisline): new
+       (oo_prop_list_apply_to_axis): use oo_prop_list_apply_to_axisline
+       (oo_chart_axisline): new
+       (opendoc_content_dtd): connect oo_chart_axisline
+       * openoffice-write.c (odf_write_axisline_style): new
+       (odf_write_axis_style): use odf_write_axisline_style
+       (odf_write_axislines): new
+       (odf_write_axis_full): call odf_write_axislines
+       (odf_fill_chart_props_hash): connect odf_write_axisline_style
+
 2015-02-08  Andreas J. Guelzow <aguelzow pyrshep ca>
 
        * openoffice-read.c (od_style_prop_chart): read chart:display-label
diff --git a/plugins/openoffice/openoffice-read.c b/plugins/openoffice/openoffice-read.c
index 5a295ea..125cf9b 100644
--- a/plugins/openoffice/openoffice-read.c
+++ b/plugins/openoffice/openoffice-read.c
@@ -6810,6 +6810,31 @@ odf_apply_expression (GsfXMLIn *xin, gint dim, GObject *obj, gchar const *expres
 }
 
 static void
+oo_prop_list_apply_to_axisline (GsfXMLIn *xin, GSList *props, GObject *obj)
+{
+       GSList *ptr;
+       OOProp *prop;
+       gchar const *pos_str_expression = NULL;
+       gchar const *pos_str_val = NULL;
+
+       oo_prop_list_apply (props, obj);
+
+       for (ptr = props; ptr; ptr = ptr->next) {
+               prop = ptr->data;
+               if (0 == strcmp ("pos-str-expr", prop->name))
+                       pos_str_expression = g_value_get_string (&prop->value);
+               else if (0 == strcmp ("pos-str-val", prop->name))
+                       pos_str_val = g_value_get_string (&prop->value);
+       }
+
+       if (pos_str_expression)
+               odf_apply_expression (xin, 4, obj, pos_str_expression);
+       else if (pos_str_val)
+               odf_apply_expression (xin, 4, obj, pos_str_val);
+
+}
+
+static void
 oo_prop_list_apply_to_axis (GsfXMLIn *xin, GSList *props, GObject *obj)
 {
        OOParseState *state = (OOParseState *)xin->user_state;
@@ -6823,10 +6848,9 @@ 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;
-       gchar const *pos_str_expression = NULL;
-       gchar const *pos_str_val = NULL;
 
-       oo_prop_list_apply (props, obj);
+
+       oo_prop_list_apply_to_axisline (xin, props, obj);
 
        for (ptr = props; ptr; ptr = ptr->next) {
                prop = ptr->data;
@@ -6843,10 +6867,6 @@ 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 ("pos-str-expr", prop->name))
-                       pos_str_expression = g_value_get_string (&prop->value);
-               else if (0 == strcmp ("pos-str-val", prop->name))
-                       pos_str_val = g_value_get_string (&prop->value);
        }
 
        gog_axis_set_bounds (GOG_AXIS (obj), minimum, maximum);
@@ -6854,10 +6874,6 @@ oo_prop_list_apply_to_axis (GsfXMLIn *xin, GSList *props, GObject *obj)
                odf_apply_expression (xin, 0, obj, minimum_expression);
        if (maximum_expression)
                odf_apply_expression (xin, 1, obj, maximum_expression);
-       if (pos_str_expression)
-               odf_apply_expression (xin, 4, obj, pos_str_expression);
-       else if (pos_str_val)
-               odf_apply_expression (xin, 4, obj, pos_str_val);
 
        if (interval_major > 0) {
                data = gnm_go_data_scalar_new_expr
@@ -9800,6 +9816,39 @@ oo_chart_wall (GsfXMLIn *xin, xmlChar const **attrs)
 }
 
 static void
+oo_chart_axisline (GsfXMLIn *xin, xmlChar const **attrs)
+{
+       OOParseState *state = (OOParseState *)xin->user_state;
+       gchar const *style_name = NULL;
+       GogObject *axisline;
+
+       for (; attrs != NULL && attrs[0] && attrs[1] ; attrs += 2)
+               if (gsf_xml_in_namecmp (xin, CXML2C (attrs[0]), OO_NS_CHART, "style-name"))
+                       style_name = CXML2C (attrs[1]);
+
+       axisline = gog_object_add_by_name (GOG_OBJECT (state->chart.axis), "AxisLine", NULL);
+
+       if (style_name != NULL && axisline != NULL) {
+               GOStyle *style = NULL;
+               g_object_get (G_OBJECT (axisline), "style", &style, NULL);
+
+               if (style != NULL) {
+                       OOChartStyle *chart_style = g_hash_table_lookup
+                               (state->chart.graph_styles, style_name);
+                       if (chart_style) {
+                               oo_prop_list_apply_to_axisline (xin, chart_style->axis_props,
+                                                               G_OBJECT (axisline));
+                               odf_apply_style_props (xin, chart_style->style_props, style, TRUE);
+                       } else
+                               oo_warning (xin, _("Chart style with name '%s' is missing."),
+                                           style_name);
+                       g_object_unref (style);
+               }
+       }
+
+}
+
+static void
 oo_chart_style_free (OOChartStyle *cstyle)
 {
        if (cstyle == NULL)
@@ -11819,6 +11868,7 @@ static GsfXMLInNode const opendoc_content_dtd [] =
                GSF_XML_IN_NODE (CHART_PLOT_AREA, CHART_WALL, OO_NS_CHART, "wall", GSF_XML_NO_CONTENT, 
&oo_chart_wall, NULL),
                GSF_XML_IN_NODE (CHART_PLOT_AREA, CHART_FLOOR, OO_NS_CHART, "floor", GSF_XML_NO_CONTENT, 
NULL, NULL),
                GSF_XML_IN_NODE (CHART_PLOT_AREA, CHART_AXIS, OO_NS_CHART, "axis", GSF_XML_NO_CONTENT, 
&oo_chart_axis, &oo_chart_axis_end),
+                 GSF_XML_IN_NODE (CHART_AXIS, CHART_AXIS_LINE, OO_GNUM_NS_EXT, "axisline", 
GSF_XML_NO_CONTENT, &oo_chart_axisline, NULL),
                  GSF_XML_IN_NODE (CHART_AXIS, CHART_GRID, OO_NS_CHART, "grid", GSF_XML_NO_CONTENT, 
&oo_chart_grid, NULL),
                  GSF_XML_IN_NODE (CHART_AXIS, CHART_AXIS_CAT,   OO_NS_CHART, "categories", 
GSF_XML_NO_CONTENT, &od_chart_axis_categories, NULL),
                  GSF_XML_IN_NODE_FULL (CHART_AXIS, CHART_AXIS_TITLE, OO_NS_CHART, "title", 
GSF_XML_NO_CONTENT, FALSE, FALSE, &oo_chart_title, &oo_chart_title_end, .v_int = 3),
@@ -12091,6 +12141,7 @@ static GsfXMLInNode const opendoc_content_preparse_dtd [] =
                GSF_XML_IN_NODE (CHART_PLOT_AREA, CHART_WALL, OO_NS_CHART, "wall", GSF_XML_NO_CONTENT, NULL, 
NULL),
                GSF_XML_IN_NODE (CHART_PLOT_AREA, CHART_FLOOR, OO_NS_CHART, "floor", GSF_XML_NO_CONTENT, 
NULL, NULL),
                GSF_XML_IN_NODE (CHART_PLOT_AREA, CHART_AXIS, OO_NS_CHART, "axis", GSF_XML_NO_CONTENT, NULL, 
NULL),
+                 GSF_XML_IN_NODE (CHART_AXIS, CHART_AXISLINE, OO_GNUM_NS_EXT, "axisline", 
GSF_XML_NO_CONTENT, NULL, NULL),
                  GSF_XML_IN_NODE (CHART_AXIS, CHART_GRID, OO_NS_CHART, "grid", GSF_XML_NO_CONTENT, NULL, 
NULL),
                  GSF_XML_IN_NODE (CHART_AXIS, CHART_AXIS_CAT,   OO_NS_CHART, "categories", 
GSF_XML_NO_CONTENT, NULL, NULL),
                  GSF_XML_IN_NODE_FULL (CHART_AXIS, CHART_AXIS_TITLE, OO_NS_CHART, "title", 
GSF_XML_NO_CONTENT, FALSE, FALSE, NULL, NULL, .v_int = 3),
diff --git a/plugins/openoffice/openoffice-write.c b/plugins/openoffice/openoffice-write.c
index 57f9b6c..a9bb0ae 100644
--- a/plugins/openoffice/openoffice-write.c
+++ b/plugins/openoffice/openoffice-write.c
@@ -6997,6 +6997,24 @@ odf_write_axis_position (GnmOOExport *state, G_GNUC_UNUSED GOStyle const *style,
 }
 
 static void
+odf_write_axisline_style (GnmOOExport *state, GOStyle const *style,
+                     GogObject const *axis)
+{
+       odf_write_axis_position (state, style, axis);
+
+       odf_write_plot_style_bool
+               (state->xml, axis, "major-tick-in", CHART "tick-marks-major-inner");
+       odf_write_plot_style_bool
+               (state->xml, axis, "major-tick-out", CHART "tick-marks-major-outer");
+       odf_write_plot_style_bool
+               (state->xml, axis, "minor-tick-in", CHART "tick-marks-minor-inner");
+       odf_write_plot_style_bool
+               (state->xml, axis, "minor-tick-out", CHART "tick-marks-minor-outer");
+       odf_write_plot_style_bool
+               (state->xml, axis, "major-tick-labeled", CHART "display-label");
+}
+
+static void
 odf_write_axis_style (GnmOOExport *state, GOStyle const *style,
                      GogObject const *axis)
 {
@@ -7005,8 +7023,6 @@ odf_write_axis_style (GnmOOExport *state, GOStyle const *style,
        gboolean user_defined;
        char *map_name_str = NULL;
 
-       odf_write_axis_position (state, style, axis);
-
        if (gnm_object_has_readable_prop (axis, "map-name",
                                          G_TYPE_STRING, &map_name_str)) {
                odf_add_bool (state->xml, CHART "logarithmic",
@@ -7059,17 +7075,6 @@ odf_write_axis_style (GnmOOExport *state, GOStyle const *style,
                        }
                }
        }
-       odf_write_plot_style_bool
-               (state->xml, axis, "major-tick-in", CHART "tick-marks-major-inner");
-       odf_write_plot_style_bool
-               (state->xml, axis, "major-tick-out", CHART "tick-marks-major-outer");
-       odf_write_plot_style_bool
-               (state->xml, axis, "minor-tick-in", CHART "tick-marks-minor-inner");
-       odf_write_plot_style_bool
-               (state->xml, axis, "minor-tick-out", CHART "tick-marks-minor-outer");
-       odf_write_plot_style_bool
-               (state->xml, axis, "major-tick-labeled", CHART "display-label");
-
        if (state->odf_version > 101)
                odf_write_plot_style_bool
                        (state->xml, axis,
@@ -7078,6 +7083,8 @@ odf_write_axis_style (GnmOOExport *state, GOStyle const *style,
                odf_write_plot_style_bool
                        (state->xml, axis,
                         "invert-axis", GNMSTYLE "reverse-direction");
+
+       odf_write_axisline_style (state, style, axis);
 }
 
 static void
@@ -7205,6 +7212,31 @@ odf_write_axis_grid (GnmOOExport *state, GogObject const *axis)
 }
 
 static void
+odf_write_axislines (GnmOOExport *state, GogObject const *axis)
+{
+       g_return_if_fail (axis != NULL);
+       
+       if (state->with_extension) {
+               GogObjectRole const *role;
+               role = gog_object_find_role_by_name (axis, "AxisLine");
+               if (role != NULL) {
+                       GSList *l, *lines = gog_object_get_children (axis, role);
+                       l = lines;
+                       while (l != NULL && l->data != NULL) {
+                               char *name = odf_get_gog_style_name_from_obj (state, GOG_OBJECT (l->data));
+                               gsf_xml_out_start_element (state->xml, GNMSTYLE "axisline");
+                               if (name != NULL)
+                                       gsf_xml_out_add_cstr (state->xml, CHART "style-name", name);
+                               gsf_xml_out_end_element (state->xml); /* </gnm:axisline> */
+                               l = l->next;
+                       }
+                       g_slist_free (lines);
+               }
+               
+       }
+}
+
+static void
 odf_write_title (GnmOOExport *state, GogObject const *title,
                 char const *id, gboolean allow_content)
 {
@@ -7806,6 +7838,7 @@ odf_write_axis_full (GnmOOExport *state,
                if (include_cats)
                        odf_write_axis_categories (state, series);
                odf_write_axis_grid (state, axis);
+               odf_write_axislines (state, axis);
                gsf_xml_out_end_element (state->xml); /* </chart:axis> */
        }
 
@@ -8511,6 +8544,7 @@ odf_fill_chart_props_hash (GnmOOExport *state)
        } props[] = {
                {"GogSeriesLines", odf_write_drop},
                {"GogAxis", odf_write_axis_style},
+               {"GogAxisLine", odf_write_axisline_style},
                {"GogLinRegCurve", odf_write_lin_reg},
                {"GogPolynomRegCurve", odf_write_polynom_reg},
                {"GogExpRegCurve", odf_write_exp_reg},


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