[gnumeric] Avoid series/plot conflicts for initial-angles in ODF import.



commit c037f77119c6278534f9778f046e6accaa557862
Author: Andreas J. Guelzow <aguelzow pyrshep ca>
Date:   Wed Apr 15 21:10:17 2015 -0600

    Avoid series/plot conflicts for initial-angles in ODF import.
    
    2015-04-15  Andreas J. Guelzow <aguelzow pyrshep ca>
    
        * openoffice-read.c (od_style_prop_chart): don't use the real
        property name, no need to set a default here
        (oo_prop_list_has_double): new
        (odf_create_plot): set the initial-angle for plots

 plugins/openoffice/ChangeLog         |    7 +++++
 plugins/openoffice/openoffice-read.c |   41 +++++++++++++++++++++++++--------
 2 files changed, 38 insertions(+), 10 deletions(-)
---
diff --git a/plugins/openoffice/ChangeLog b/plugins/openoffice/ChangeLog
index 9ba06e0..426d953 100644
--- a/plugins/openoffice/ChangeLog
+++ b/plugins/openoffice/ChangeLog
@@ -1,5 +1,12 @@
 2015-04-15  Andreas J. Guelzow <aguelzow pyrshep ca>
 
+       * openoffice-read.c (od_style_prop_chart): don't use the real
+       property name, no need to set a default here
+       (oo_prop_list_has_double): new
+       (odf_create_plot): set the initial-angle for plots
+
+2015-04-15  Andreas J. Guelzow <aguelzow pyrshep ca>
+
        * openoffice-write.c (odf_write_office_styles): use
        gnm_hash_table_foreach_ordered for text_colours
        (odf_write_graphs): use gnm_hash_table_foreach_ordered
diff --git a/plugins/openoffice/openoffice-read.c b/plugins/openoffice/openoffice-read.c
index 064e9f4..4e768dd 100644
--- a/plugins/openoffice/openoffice-read.c
+++ b/plugins/openoffice/openoffice-read.c
@@ -7051,7 +7051,6 @@ od_style_prop_chart (GsfXMLIn *xin, xmlChar const **attrs)
        gboolean stacked_unset = FALSE;
        gboolean overlap_set = FALSE;
        gboolean percentage_set = FALSE;
-       gboolean initial_angle_set = FALSE;
        char const *interpolation = NULL;
 
 
@@ -7177,12 +7176,11 @@ od_style_prop_chart (GsfXMLIn *xin, xmlChar const **attrs)
                        style->plot_props = g_slist_prepend (style->plot_props,
                                oo_prop_new_double ("center-size", ftmp));
                else if (oo_attr_angle (xin, attrs, OO_NS_CHART,
-                                       "angle-offset", &tmp)) {
-                       initial_angle_set = TRUE;
+                                       "angle-offset", &tmp))
                        style->plot_props = g_slist_prepend 
-                               (style->plot_props, oo_prop_new_double ("initial-angle", 
+                               (style->plot_props, oo_prop_new_double ("plot-initial-angle", 
                                                                        (double) odf_scale_initial_angle 
(tmp)));
-               } else if (oo_attr_bool (xin, attrs, OO_NS_CHART,
+               else if (oo_attr_bool (xin, attrs, OO_NS_CHART,
                                         "reverse-direction", &btmp))
                        style->axis_props = g_slist_prepend (style->axis_props,
                                oo_prop_new_bool ("invert-axis", btmp));
@@ -7555,10 +7553,6 @@ od_style_prop_chart (GsfXMLIn *xin, xmlChar const **attrs)
                                oo_prop_new_bool ("major-tick-labeled", btmp));
        }
 
-       if (!initial_angle_set)
-               style->plot_props = g_slist_prepend
-                       (style->plot_props, oo_prop_new_double ("initial-angle", odf_scale_initial_angle 
(0)));
-
        if ((stacked_set && !overlap_set) ||
            (percentage_set && !stacked_unset && !overlap_set))
                style->plot_props = g_slist_prepend (style->plot_props,
@@ -9045,6 +9039,21 @@ static gchar const
        }
 }
 
+static gboolean
+oo_prop_list_has_double (GSList *props, double *d, char const *tag)
+{
+       GSList *ptr;
+       for (ptr = props; ptr; ptr = ptr->next) {
+               OOProp *prop = ptr->data;
+               if (0 == strcmp (prop->name, tag)) { 
+                       *d = g_value_get_double (&prop->value);
+                       return TRUE;
+               }
+       }
+       return FALSE;
+}
+
+
 static GogPlot *odf_create_plot (OOParseState *state,  OOPlotType *oo_type)
 {
        GogPlot *plot;
@@ -9056,9 +9065,21 @@ static GogPlot *odf_create_plot (OOParseState *state,  OOPlotType *oo_type)
        gog_object_add_by_name (GOG_OBJECT (state->chart.chart),
                "Plot", GOG_OBJECT (plot));
 
-       if (state->chart.i_plot_styles[OO_CHART_STYLE_PLOTAREA] != NULL)
+       if (state->chart.i_plot_styles[OO_CHART_STYLE_PLOTAREA] != NULL) 
                oo_prop_list_apply (state->chart.i_plot_styles[OO_CHART_STYLE_PLOTAREA]->
                                    plot_props, G_OBJECT (plot));
+
+       if (0 == strcmp (type, "GogPiePlot") || 0 == strcmp (type, "GogRingPlot")) {
+               /* Note we cannot use the oo_prop_list_apply method since series also have a */
+               /* initial-angle property */
+               double angle = 0.;
+               if (!((state->chart.i_plot_styles[OO_CHART_STYLE_PLOTAREA] != NULL) &&
+                   oo_prop_list_has_double (state->chart.i_plot_styles[OO_CHART_STYLE_PLOTAREA]->
+                                            plot_props, &angle, "plot-initial-angle")))
+                       angle = odf_scale_initial_angle (90);
+               g_object_set (plot, "initial-angle", angle, NULL);
+       }
+
        return plot;
 }
 


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