Commit d92c0fca authored by Andreas J. Guelzow 's avatar Andreas J. Guelzow

ODF: import/export interpolation

2010-08-18  Andreas J. Guelzow <aguelzow@pyrshep.ca>

	* samples/chart-tests.gnumeric: test plot types separately from our
	  ability to combine them.

2010-08-18  Andreas J. Guelzow <aguelzow@pyrshep.ca>

	* openoffice-read.c (oo_prop_list_to_series): also set properties
	(oo_prop_list_has): new
	(oo_prop_list_has_three_dimensional): replace with oo_prop_list_has
	(oo_prop_list_has_multi_series): replace with oo_prop_list_has
	(od_style_prop_chart): handle interpolation attribute
	* openoffice-write.c (odf_write_interpolation_attribute): new
	(odf_write_scatter_chart_style): use odf_write_interpolation_attribute
	(odf_write_scatter_series_style): ditto
parent 10d4b253
2010-08-18 Andreas J. Guelzow <aguelzow@pyrshep.ca>
* samples/chart-tests.gnumeric: test plot types separately from our
ability to combine them.
2010-08-16 Morten Welinder <terra@gnome.org>
* configure.in: Post-release bump.
......
2010-08-18 Andreas J. Guelzow <aguelzow@pyrshep.ca>
* openoffice-read.c (oo_prop_list_to_series): also set properties
(oo_prop_list_has): new
(oo_prop_list_has_three_dimensional): replace with oo_prop_list_has
(oo_prop_list_has_multi_series): replace with oo_prop_list_has
(od_style_prop_chart): handle interpolation attribute
* openoffice-write.c (odf_write_interpolation_attribute): new
(odf_write_scatter_chart_style): use odf_write_interpolation_attribute
(odf_write_scatter_series_style): ditto
2010-08-18 Andreas J. Guelzow <aguelzow@pyrshep.ca>
* openoffice-write.c (odf_write_line_chart_style): check the plot
......
......@@ -3013,6 +3013,24 @@ oo_prop_list_free (GSList *props)
g_slist_free (props);
}
static void
oo_prop_list_apply (GSList *props, GObject *obj)
{
GSList *ptr;
OOProp *prop;
GObjectClass *klass;
if (NULL == obj)
return;
klass = G_OBJECT_GET_CLASS (obj);
for (ptr = props; ptr; ptr = ptr->next) {
prop = ptr->data;
if (NULL != g_object_class_find_property (klass, prop->name))
g_object_set_property (obj, prop->name, &prop->value);
}
}
static void
oo_prop_list_to_series (GSList *props, GObject *obj)
{
......@@ -3021,6 +3039,10 @@ oo_prop_list_to_series (GSList *props, GObject *obj)
int symbol_type = -1, symbol_name = GO_MARKER_DIAMOND;
GOMarker *m;
oo_prop_list_apply (props, obj);
/* There are properties that apply to subitems: */
g_object_get (obj, "style", &style, NULL);
if (style != NULL)
......@@ -3065,30 +3087,13 @@ oo_prop_list_to_series (GSList *props, GObject *obj)
}
static void
oo_prop_list_apply (GSList *props, GObject *obj)
{
GSList *ptr;
OOProp *prop;
GObjectClass *klass;
if (NULL == obj)
return;
klass = G_OBJECT_GET_CLASS (obj);
for (ptr = props; ptr; ptr = ptr->next) {
prop = ptr->data;
if (NULL != g_object_class_find_property (klass, prop->name))
g_object_set_property (obj, prop->name, &prop->value);
}
}
static void
oo_prop_list_has_three_dimensional (GSList *props, gboolean *threed)
oo_prop_list_has (GSList *props, gboolean *threed, char const *tag)
{
GSList *ptr;
for (ptr = props; ptr; ptr = ptr->next) {
OOProp *prop = ptr->data;
if (0 == strcmp (prop->name, "three-dimensional") && g_value_get_boolean (&prop->value))
if (0 == strcmp (prop->name, tag) &&
g_value_get_boolean (&prop->value))
*threed = TRUE;
}
}
......@@ -3100,23 +3105,13 @@ oo_style_have_three_dimensional (GSList *styles)
gboolean is_three_dimensional = FALSE;
for (l = styles; l != NULL; l = l->next) {
OOChartStyle *style = l->data;
oo_prop_list_has_three_dimensional (style->other_props,
&is_three_dimensional);
oo_prop_list_has (style->other_props,
&is_three_dimensional,
"three-dimensional");
}
return is_three_dimensional;
}
static void
oo_prop_list_has_multi_series (GSList *props, gboolean *threed)
{
GSList *ptr;
for (ptr = props; ptr; ptr = ptr->next) {
OOProp *prop = ptr->data;
if (0 == strcmp (prop->name, "multi-series") && g_value_get_boolean (&prop->value))
*threed = TRUE;
}
}
static gboolean
oo_style_have_multi_series (GSList *styles)
{
......@@ -3124,8 +3119,9 @@ oo_style_have_multi_series (GSList *styles)
gboolean is_multi_series = FALSE;
for (l = styles; l != NULL; l = l->next) {
OOChartStyle *style = l->data;
oo_prop_list_has_multi_series (style->other_props,
&is_multi_series);
oo_prop_list_has (style->other_props,
&is_multi_series,
"multi-series");
}
return is_multi_series;
}
......@@ -3225,17 +3221,44 @@ od_style_prop_chart (GsfXMLIn *xin, xmlChar const **attrs)
(style->series_props,
oo_prop_new_int ("symbol-type", tmp));
} else if (oo_attr_enum (xin, attrs, OO_NS_CHART, "symbol-name",
named_symbols, &tmp)) {
named_symbols, &tmp)) {
style->series_props = g_slist_prepend
(style->series_props,
oo_prop_new_int ("symbol-name", tmp));
} else if (gsf_xml_in_namecmp (xin, CXML2C (attrs[0]), OO_NS_DRAW, "stroke")) {
} else if (gsf_xml_in_namecmp (xin, CXML2C (attrs[0]),
OO_NS_CHART, "interpolation")) {
char const *interpolation = NULL;
if (attr_eq (attrs[1], "none"))
interpolation = "linear";
else if (attr_eq (attrs[1], "b-spline"))
interpolation = "spline";
else if (attr_eq (attrs[1], "cubic-spline"))
interpolation = "cspline";
else if (g_str_has_prefix (CXML2C(attrs[1]), "gnm:"))
interpolation = CXML2C(attrs[1]) + 4;
else oo_warning
(xin, _("Unknown interpolation type "
"encountered: %s"), CXML2C(attrs[1]));
if (interpolation != NULL) {
style->series_props = g_slist_prepend
(style->series_props,
oo_prop_new_string
("interpolation", interpolation));
style->plot_props = g_slist_prepend
(style->plot_props,
oo_prop_new_string
("interpolation", interpolation));
}
} else if (gsf_xml_in_namecmp (xin, CXML2C (attrs[0]),
OO_NS_DRAW, "stroke")) {
draw_stroke = !attr_eq (attrs[1], "none");
draw_stroke_set = TRUE;
style->series_props = g_slist_prepend
(style->series_props,
oo_prop_new_string ("stroke",
attrs[1]));
CXML2C(attrs[1])));
} else if (oo_attr_bool (xin, attrs, OO_NS_CHART, "lines", &btmp)) {
style->series_props = g_slist_prepend
(style->series_props,
......
......@@ -3645,6 +3645,38 @@ odf_write_line_chart_style (GnmOOExport *state, G_GNUC_UNUSED GogObject const *c
has_marker ? "automatic" : "none");
}
static void
odf_write_interpolation_attribute (GnmOOExport *state, GogObject const *series)
{
gchar *interpolation = NULL;
g_object_get (G_OBJECT (series), "interpolation",
&interpolation, NULL);
if (interpolation != NULL) {
if (0 == strcmp (interpolation, "linear"))
gsf_xml_out_add_cstr
(state->xml, CHART "interpolation", "none");
else if (0 == strcmp (interpolation, "spline"))
gsf_xml_out_add_cstr
(state->xml, CHART "interpolation", "b-spline");
else if (0 == strcmp (interpolation, "cspline"))
gsf_xml_out_add_cstr
(state->xml, CHART "interpolation",
"cubic-spline");
else {
char *tag = g_strdup_printf ("gnm:%s", interpolation);
gsf_xml_out_add_cstr
(state->xml, CHART "interpolation", tag);
g_free (tag);
}
}
g_free (interpolation);
}
static void
odf_write_scatter_chart_style (GnmOOExport *state, G_GNUC_UNUSED GogObject const *chart, GogObject const *plot)
{
......@@ -3655,6 +3687,8 @@ odf_write_scatter_chart_style (GnmOOExport *state, G_GNUC_UNUSED GogObject const
gsf_xml_out_add_cstr (state->xml, CHART "symbol-type",
has_marker ? "automatic" : "none");
odf_write_interpolation_attribute (state, plot);
gsf_xml_out_add_cstr (state->xml, DRAW "stroke", "none");
odf_add_bool (state->xml, CHART "lines", FALSE);
}
......@@ -3718,6 +3752,8 @@ odf_write_scatter_series_style (GnmOOExport *state, GogObject const *plot, GogOb
{
GOStyle *style = NULL;
odf_write_interpolation_attribute (state, series);
g_object_get (G_OBJECT (series), "style", &style, NULL);
if (go_style_is_line_visible (style)) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment