[gnumeric] ods: fix import/export of ods series markers.



commit bc5129c3e1427ad2584948fa57f5034ece6995d5
Author: Morten Welinder <terra gnome org>
Date:   Sat May 10 18:05:49 2014 -0400

    ods: fix import/export of ods series markers.
    
    We were dropping the size of the marker for automatic shape.

 NEWS                                  |    1 +
 plugins/openoffice/ChangeLog          |   10 +++++
 plugins/openoffice/openoffice-read.c  |   29 +++++++++------
 plugins/openoffice/openoffice-write.c |   65 +++++++++++++++++++--------------
 4 files changed, 65 insertions(+), 40 deletions(-)
---
diff --git a/NEWS b/NEWS
index 1ce49b8..6cd7508 100644
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,7 @@ Gnumeric 1.12.16
 Morten:
        * Start moving off GtkUIManager.
        * Clean out old #ifdef.
+       * Fix ods series marker import/export.
 
 --------------------------------------------------------------------------
 Gnumeric 1.12.15
diff --git a/plugins/openoffice/ChangeLog b/plugins/openoffice/ChangeLog
index 639ea05..aa54581 100644
--- a/plugins/openoffice/ChangeLog
+++ b/plugins/openoffice/ChangeLog
@@ -1,3 +1,13 @@
+2014-05-10  Morten Welinder  <terra gnome org>
+
+       * openoffice-write.c (odf_write_gog_style_chart): Write marker
+       size also for automatic shape.  Resolve confusion about whether
+       plot type has markers by default.  Only write marker information
+       for styles that have such information.
+
+       * openoffice-read.c (odf_apply_style_props): Even automatic
+       symbols can have a size attached.
+
 2014-05-09  Morten Welinder  <terra gnome org>
 
        * openoffice-read.c (od_style_prop_chart): Read text colour.
diff --git a/plugins/openoffice/openoffice-read.c b/plugins/openoffice/openoffice-read.c
index fd9d8d8..d23bb59 100644
--- a/plugins/openoffice/openoffice-read.c
+++ b/plugins/openoffice/openoffice-read.c
@@ -1082,33 +1082,38 @@ odf_apply_style_props (GsfXMLIn *xin, GSList *props, GOStyle *style)
 
        switch (symbol_type) {
        case OO_SYMBOL_TYPE_AUTO:
+               m = go_marker_new ();
                style->marker.auto_shape = TRUE;
                break;
        case OO_SYMBOL_TYPE_NONE:
                style->marker.auto_shape = FALSE;
                m = go_marker_new ();
                go_marker_set_shape (m, GO_MARKER_NONE);
-               go_style_set_marker (style, m);
                break;
        case OO_SYMBOL_TYPE_NAMED:
                style->marker.auto_shape = FALSE;
                m = go_marker_new ();
                go_marker_set_shape (m, symbol_name);
-               if (symbol_height >= 0. || symbol_width >= 0.) {
-                       int size;
-                       if (symbol_height >= 0. && symbol_width >= 0.)
-                               size = (symbol_height+symbol_width+1.)/2;
-                       else if (symbol_height >= 0.)
-                               size = symbol_height + 0.5;
-                       else
-                               size = symbol_width+ 0.5;
-                       go_marker_set_size (m, size);
-               }
-               go_style_set_marker (style, m);
                break;
        default:
+               m = NULL;
                break;
        }
+       if (m) {
+               if (symbol_height >= 0. || symbol_width >= 0.) {
+                       double size;
+                       /* If we have only one dimension, use that for the other */
+                       if (symbol_width < 0) symbol_width = symbol_height;
+                       if (symbol_height < 0) symbol_height = symbol_width;
+
+                       size = (symbol_height + symbol_width + 1) / 2;
+                       size = MIN (size, G_MAXINT);
+
+                       go_marker_set_size (m, (int)size);
+               }
+
+               go_style_set_marker (style, m);
+       }
 }
 
 /* returns pts */
diff --git a/plugins/openoffice/openoffice-write.c b/plugins/openoffice/openoffice-write.c
index 1709cd6..fd7c498 100644
--- a/plugins/openoffice/openoffice-write.c
+++ b/plugins/openoffice/openoffice-write.c
@@ -7293,9 +7293,7 @@ static void
 odf_write_gog_style_chart (GnmOOExport *state, GOStyle const *style, GogObject const *obj)
 {
        gchar const *type = G_OBJECT_TYPE_NAME (G_OBJECT (obj));
-       GObjectClass *klass = G_OBJECT_GET_CLASS (G_OBJECT (obj));
        void (*func) (GnmOOExport *state, GOStyle const *style, GogObject const *obj);
-       GParamSpec *spec;
 
        if (GOG_IS_PLOT (obj))
                odf_write_plot_style (state, obj);
@@ -7309,44 +7307,55 @@ odf_write_gog_style_chart (GnmOOExport *state, GOStyle const *style, GogObject c
        if (func != NULL)
                func (state, style, obj);
 
-       if (style != NULL) {
-               if (go_style_is_line_visible (style)) {
-                       odf_add_bool (state->xml, CHART "lines", TRUE);
-               } else {
-                       odf_add_bool (state->xml, CHART "lines", FALSE);
-               }
+       if (!style)
+               return;
+
+       if (style->interesting_fields & (GO_STYLE_LINE | GO_STYLE_OUTLINE)) {
+               odf_add_bool (state->xml,
+                             CHART "lines",
+                             go_style_is_line_visible (style));
+       }
+
+       if (style->interesting_fields & GO_STYLE_MARKER) {
+               GOMarker const *marker = go_style_get_marker (style);
+               const char *symbol_type = NULL;
 
                if (style->marker.auto_shape) {
-                       if (NULL != (spec = g_object_class_find_property (klass, "type"))
-                           && spec->value_type == G_TYPE_BOOLEAN
-                           && (G_PARAM_READABLE & spec->flags)) {
-                               gboolean has_marker = TRUE;
-                               g_object_get (G_OBJECT (obj), "default-style-has-markers",
+                       GogPlot *plot = GOG_IS_SERIES (obj)
+                               ? gog_series_get_plot (GOG_SERIES (obj))
+                               : NULL;
+                       GObjectClass *plot_klass = plot ? G_OBJECT_GET_CLASS (G_OBJECT (plot)) : NULL;
+                       GParamSpec *spec = plot_klass
+                               ? g_object_class_find_property (plot_klass, "default-style-has-markers")
+                               : NULL;
+                       gboolean has_marker;
+                       if (spec &&
+                           spec->value_type == G_TYPE_BOOLEAN &&
+                           (G_PARAM_READABLE & spec->flags)) {
+                               g_object_get (G_OBJECT (plot), "default-style-has-markers",
                                              &has_marker, NULL);
                                if (has_marker)
-                                       gsf_xml_out_add_cstr (state->xml, CHART "symbol-type",
-                                                     "automatic");
-                               else
-                                       gsf_xml_out_add_cstr (state->xml, CHART "symbol-type",
-                                                             "none");
+                                       symbol_type = "automatic";
                        }
                } else {
-                       GOMarker const *marker = go_style_get_marker ((GOStyle *)style);
                        GOMarkerShape m = go_marker_get_shape (marker);
 
-                       if (m == GO_MARKER_NONE)
-                               gsf_xml_out_add_cstr (state->xml, CHART "symbol-type",
-                                                     "none");
-                       else {
-                               int size = go_marker_get_size (marker);
-                               gsf_xml_out_add_cstr (state->xml, CHART "symbol-type",
-                                                     "named-symbol");
+                       if (m != GO_MARKER_NONE) {
+                               symbol_type = "named-symbol";
+
                                gsf_xml_out_add_cstr
                                        (state->xml, CHART "symbol-name", odf_get_marker (m));
-                               odf_add_pt (state->xml, CHART "symbol-width", size);
-                               odf_add_pt (state->xml, CHART "symbol-height", size);
                        }
                }
+
+               if (symbol_type) {
+                       int size = go_marker_get_size (marker);
+                       odf_add_pt (state->xml, CHART "symbol-width", size);
+                       odf_add_pt (state->xml, CHART "symbol-height", size);
+               } else
+                       symbol_type = "none";
+
+               gsf_xml_out_add_cstr (state->xml, CHART "symbol-type", symbol_type);
        }
 }
 


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