[gnumeric] Fix import/export of Pie charts from/to ODF to interoperate with LO.
- From: Andreas J. Guelzow <guelzow src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] Fix import/export of Pie charts from/to ODF to interoperate with LO.
- Date: Wed, 15 Apr 2015 14:09:50 +0000 (UTC)
commit 577cb00abaa0dda965d7be7e17c2a978619f32fb
Author: Andreas J. Guelzow <aguelzow pyrshep ca>
Date: Wed Apr 15 08:06:03 2015 -0600
Fix import/export of Pie charts from/to ODF to interoperate with LO.
2015-04-15 Andreas J. Guelzow <aguelzow pyrshep ca>
* openoffice-read.c (odf_scale_initial_angle): new
(od_style_prop_chart): use odf_scale_initial_angle
(oo_chart_axis): do not add axes to ring and pie plots
* openoffice-write.c (odf_scale_initial_angle): new
(odf_write_plot_style): use odf_scale_initial_angle
(odf_write_pie_axis): new (former odf_write_generic_axis)
(odf_write_plot): connect odf_write_pie_axis
plugins/openoffice/ChangeLog | 10 +++++++
plugins/openoffice/openoffice-read.c | 28 ++++++++++++++++++---
plugins/openoffice/openoffice-write.c | 43 ++++++++++++++++++++++++++------
3 files changed, 69 insertions(+), 12 deletions(-)
---
diff --git a/plugins/openoffice/ChangeLog b/plugins/openoffice/ChangeLog
index 74e7a8d..21cb640 100644
--- a/plugins/openoffice/ChangeLog
+++ b/plugins/openoffice/ChangeLog
@@ -1,3 +1,13 @@
+2015-04-15 Andreas J. Guelzow <aguelzow pyrshep ca>
+
+ * openoffice-read.c (odf_scale_initial_angle): new
+ (od_style_prop_chart): use odf_scale_initial_angle
+ (oo_chart_axis): do not add axes to ring and pie plots
+ * openoffice-write.c (odf_scale_initial_angle): new
+ (odf_write_plot_style): use odf_scale_initial_angle
+ (odf_write_pie_axis): new (former odf_write_generic_axis)
+ (odf_write_plot): connect odf_write_pie_axis
+
2015-04-14 Andreas J. Guelzow <aguelzow pyrshep ca>
* openoffice-read.c (od_style_prop_chart): read
diff --git a/plugins/openoffice/openoffice-read.c b/plugins/openoffice/openoffice-read.c
index 36afe8b..064e9f4 100644
--- a/plugins/openoffice/openoffice-read.c
+++ b/plugins/openoffice/openoffice-read.c
@@ -6981,6 +6981,16 @@ oo_style_has_plot_property (OOChartStyle **style, char const *prop, gboolean def
return has_prop;
}
+static int
+odf_scale_initial_angle (int angle)
+{
+ angle = 90 - angle;
+ while (angle < 0)
+ angle += 360;
+
+ return (angle % 360);
+}
+
static void
od_style_prop_chart (GsfXMLIn *xin, xmlChar const **attrs)
{
@@ -7041,6 +7051,7 @@ 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;
@@ -7166,10 +7177,12 @@ 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))
- style->plot_props = g_slist_prepend (style->plot_props,
- oo_prop_new_double ("initial-angle", (double) tmp));
- else if (oo_attr_bool (xin, attrs, OO_NS_CHART,
+ "angle-offset", &tmp)) {
+ initial_angle_set = TRUE;
+ style->plot_props = g_slist_prepend
+ (style->plot_props, oo_prop_new_double ("initial-angle",
+ (double) odf_scale_initial_angle
(tmp)));
+ } 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));
@@ -7542,6 +7555,10 @@ 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,
@@ -8681,6 +8698,9 @@ oo_chart_axis (GsfXMLIn *xin, xmlChar const **attrs)
else
axes_types = types;
break;
+ case OO_PLOT_CIRCLE:
+ case OO_PLOT_RING:
+ return;
default:
axes_types = types;
break;
diff --git a/plugins/openoffice/openoffice-write.c b/plugins/openoffice/openoffice-write.c
index 13239a3..998d815 100644
--- a/plugins/openoffice/openoffice-write.c
+++ b/plugins/openoffice/openoffice-write.c
@@ -6905,12 +6905,24 @@ odf_write_interpolation_attribute (GnmOOExport *state,
g_free (interpolation);
}
+static int
+odf_scale_initial_angle (gnm_float angle)
+{
+ angle = 90 - angle;
+ while (angle < 0)
+ angle += 360.;
+ angle = gnm_fake_round (angle);
+
+ return (((int) angle) % 360);
+}
+
static void
odf_write_plot_style (GnmOOExport *state, GogObject const *plot)
{
gchar const *plot_type = G_OBJECT_TYPE_NAME (plot);
gchar *type_str = NULL;
double default_separation = 0.;
+ double d;
odf_add_bool (state->xml, CHART "auto-size", TRUE);
@@ -6960,9 +6972,8 @@ odf_write_plot_style (GnmOOExport *state, GogObject const *plot)
"center-size",
CHART "hole-size");
- odf_write_plot_style_double (state->xml, plot,
- "initial-angle",
- CHART "angle-offset");
+ if (gnm_object_has_readable_prop (plot, "initial-angle", G_TYPE_DOUBLE, &d))
+ gsf_xml_out_add_int (state->xml, CHART "angle-offset", odf_scale_initial_angle (d));
if (gnm_object_has_readable_prop (plot, "interpolation",
G_TYPE_NONE, NULL))
@@ -7887,6 +7898,22 @@ odf_write_axis_no_cats (GnmOOExport *state,
}
static void
+odf_write_pie_axis (GnmOOExport *state,
+ G_GNUC_UNUSED GogObject const *chart,
+ G_GNUC_UNUSED char const *axis_role,
+ char const *dimension,
+ G_GNUC_UNUSED odf_chart_type_t gtype,
+ GSList const *series)
+{
+ gsf_xml_out_start_element (state->xml, CHART "axis");
+ gsf_xml_out_add_cstr (state->xml, CHART "dimension", dimension);
+ gsf_xml_out_add_cstr (state->xml, CHART "style-name", "pie-axis");
+ odf_write_axis_categories (state, series);
+ gsf_xml_out_end_element (state->xml); /* </chart:axis> */
+}
+
+
+static void
odf_write_plot (GnmOOExport *state, SheetObject *so, GogObject const *graph,
GogObject const *chart, GogObject const *plot, GSList *other_plots)
{
@@ -7962,9 +7989,9 @@ odf_write_plot (GnmOOExport *state, SheetObject *so, GogObject const *graph,
odf_write_min_max_series,
odf_write_axis, odf_write_axis, odf_write_axis},
{ "GogPiePlot", CHART "circle", ODF_CIRCLE,
- 5., NULL, NULL, NULL,
+ 5., NULL, "Y-Axis", NULL,
odf_write_standard_series,
- NULL, NULL, NULL},
+ NULL, odf_write_pie_axis, NULL},
{ "GogRadarPlot", CHART "radar", ODF_RADAR,
10., "Circular-Axis", "Radial-Axis", NULL,
odf_write_standard_series,
@@ -7974,9 +8001,9 @@ odf_write_plot (GnmOOExport *state, SheetObject *so, GogObject const *graph,
odf_write_standard_series,
odf_write_axis, odf_write_axis, odf_write_axis},
{ "GogRingPlot", CHART "ring", ODF_RING,
- 10., NULL, NULL, NULL,
+ 10., NULL, "Y-Axis", NULL,
odf_write_standard_series,
- NULL, NULL, NULL},
+ NULL, odf_write_pie_axis, NULL},
{ "GogXYPlot", CHART "scatter", ODF_SCATTER,
20., "X-Axis", "Y-Axis", NULL,
odf_write_standard_series,
@@ -8044,7 +8071,7 @@ odf_write_plot (GnmOOExport *state, SheetObject *so, GogObject const *graph,
gsf_xml_out_start_element (state->xml, OFFICE "automatic-styles");
odf_write_character_styles (state);
- odf_write_generic_axis_style (state, "generic-axis");
+ odf_write_generic_axis_style (state, "pie-axis");
odf_start_style (state->xml, "plotstyle", "chart");
gsf_xml_out_start_element (state->xml, STYLE "chart-properties");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]