[gnumeric] Fix regression line export to ODF.
- From: Andreas J. Guelzow <guelzow src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] Fix regression line export to ODF.
- Date: Mon, 13 Jun 2011 03:10:11 +0000 (UTC)
commit 6d2bcb96e2bf21f8e86ae2fac800041d92785bde
Author: Andreas J Guelzow <aguelzow pyrshep ca>
Date: Sun Jun 12 21:08:47 2011 -0600
Fix regression line export to ODF.
2011-06-12 Andreas J. Guelzow <aguelzow pyrshep ca>
* openoffice-write.c (odf_write_regression_curve): new
(odf_write_standard_series): move some code to odf_write_regression_curve
and call it both for "Regression curve" and "Trend line"
NEWS | 1 +
plugins/openoffice/ChangeLog | 6 ++
plugins/openoffice/openoffice-write.c | 137 ++++++++++++++++++---------------
3 files changed, 82 insertions(+), 62 deletions(-)
---
diff --git a/NEWS b/NEWS
index 5c71c71..236a46c 100644
--- a/NEWS
+++ b/NEWS
@@ -11,6 +11,7 @@ Andreas
* Import external references from ODF. [#645580]
* Some documentation improvements.
* Read fraction formats correctly from ODF 1.2 files.
+ * Fix regression line export to ODF.
Morten:
* Fix leaks in SHEET. [#650761]
diff --git a/plugins/openoffice/ChangeLog b/plugins/openoffice/ChangeLog
index 4fadb10..0f6e738 100644
--- a/plugins/openoffice/ChangeLog
+++ b/plugins/openoffice/ChangeLog
@@ -1,5 +1,11 @@
2011-06-12 Andreas J. Guelzow <aguelzow pyrshep ca>
+ * openoffice-write.c (odf_write_regression_curve): new
+ (odf_write_standard_series): move some code to odf_write_regression_curve
+ and call it both for "Regression curve" and "Trend line"
+
+2011-06-12 Andreas J. Guelzow <aguelzow pyrshep ca>
+
* openoffice-write.c (odf_write_sheet): we need the full extent not
just the cells-extent
diff --git a/plugins/openoffice/openoffice-write.c b/plugins/openoffice/openoffice-write.c
index f70de5d..08d0b67 100644
--- a/plugins/openoffice/openoffice-write.c
+++ b/plugins/openoffice/openoffice-write.c
@@ -4999,6 +4999,71 @@ cmp_data_points (GObject *a, GObject *b)
}
static void
+odf_write_regression_curve (GnmOOExport *state, GogObjectRole const *role, GogObject const *series, GnmParsePos *pp)
+{
+ GSList *l, *regressions = gog_object_get_children
+ (series, role);
+ char *str;
+
+ for (l = regressions; l != NULL && l->data != NULL; l = l->next) {
+ GOData const *bd;
+ GogObject const *regression = l->data;
+ GogObject const *equation
+ = gog_object_get_child_by_name (regression, "Equation");
+ str = odf_get_gog_style_name_from_obj
+ (GOG_OBJECT (regression));
+ gsf_xml_out_start_element
+ (state->xml,
+ (l == regressions) ? CHART "regression-curve"
+ : GNMSTYLE "regression-curve");
+ gsf_xml_out_add_cstr (state->xml, CHART "style-name", str);
+
+ if (state->with_extension) {
+ /* Upper and lower bounds */
+ bd = gog_dataset_get_dim (GOG_DATASET (regression), 0);
+ if (bd != NULL)
+ odf_write_data_attribute
+ (state, bd, pp, GNMSTYLE "lower-bound");
+ bd = gog_dataset_get_dim (GOG_DATASET (regression), 1);
+ if (bd != NULL)
+ odf_write_data_attribute
+ (state, bd, pp, GNMSTYLE "upper-bound");
+ }
+ if (equation != NULL) {
+ GObjectClass *klass = G_OBJECT_GET_CLASS (equation);
+ char const *eq_element, *eq_automatic, *eq_display, *eq_r;
+ if (get_gsf_odf_version () > 101) {
+ eq_element = CHART "equation";
+ eq_automatic = CHART "automatic-content";
+ eq_display = CHART "display-equation";
+ eq_r = CHART "display-r-square";
+ } else {
+ eq_element = GNMSTYLE "equation";
+ eq_automatic = GNMSTYLE "automatic-content";
+ eq_display = GNMSTYLE "display-equation";
+ eq_r = GNMSTYLE "display-r-square";
+ }
+ gsf_xml_out_start_element
+ (state->xml, eq_element);
+ odf_add_bool (state->xml, eq_automatic, TRUE);
+ odf_write_plot_style_bool (state->xml, equation, klass,
+ "show-eq", eq_display);
+ odf_write_plot_style_bool (state->xml, equation, klass,
+ "show-r2", eq_r);
+ str = odf_get_gog_style_name_from_obj
+ (GOG_OBJECT (equation));
+ gsf_xml_out_add_cstr (state->xml, CHART "style-name", str);
+ odf_write_gog_position (state, equation);
+ gsf_xml_out_end_element (state->xml); /* </chart:equation> */
+ }
+
+ gsf_xml_out_end_element (state->xml); /* </chart:regression-curve> */
+ g_free (str);
+ }
+}
+
+
+static void
odf_write_standard_series (GnmOOExport *state, GSList const *series)
{
GnmParsePos pp;
@@ -5009,9 +5074,7 @@ odf_write_standard_series (GnmOOExport *state, GSList const *series)
GOData const *dat = gog_dataset_get_dim (GOG_DATASET (series->data), GOG_MS_DIM_VALUES);
if (NULL != dat && odf_write_data_element (state, dat, &pp, CHART "series",
CHART "values-cell-range-address")) {
- GogObjectRole const *role =
- gog_object_find_role_by_name
- (GOG_OBJECT (series->data), "Regression curve");
+ GogObjectRole const *role;
GSList *points;
GOData const *cat = gog_dataset_get_dim (GOG_DATASET (series->data),
GOG_MS_DIM_LABELS);
@@ -5026,65 +5089,15 @@ odf_write_standard_series (GnmOOExport *state, GSList const *series)
TABLE "cell-range-address"))
gsf_xml_out_end_element (state->xml); /* </chart:domain> */
- if (role != NULL) {
- GSList *l, *regressions = gog_object_get_children
- (GOG_OBJECT (series->data), role);
- for (l = regressions; l != NULL && l->data != NULL; l = l->next) {
- GOData const *bd;
- GogObject const *regression = l->data;
- GogObject const *equation
- = gog_object_get_child_by_name (regression, "Equation");
- str = odf_get_gog_style_name_from_obj
- (GOG_OBJECT (regression));
- gsf_xml_out_start_element
- (state->xml,
- (l == regressions) ? CHART "regression-curve"
- : GNMSTYLE "regression-curve");
- gsf_xml_out_add_cstr (state->xml, CHART "style-name", str);
-
- if (state->with_extension) {
- /* Upper and lower bounds */
- bd = gog_dataset_get_dim (GOG_DATASET (regression), 0);
- if (bd != NULL)
- odf_write_data_attribute
- (state, bd, &pp, GNMSTYLE "lower-bound");
- bd = gog_dataset_get_dim (GOG_DATASET (regression), 1);
- if (bd != NULL)
- odf_write_data_attribute
- (state, bd, &pp, GNMSTYLE "upper-bound");
- }
- if (equation != NULL) {
- GObjectClass *klass = G_OBJECT_GET_CLASS (equation);
- char const *eq_element, *eq_automatic, *eq_display, *eq_r;
- if (get_gsf_odf_version () > 101) {
- eq_element = CHART "equation";
- eq_automatic = CHART "automatic-content";
- eq_display = CHART "display-equation";
- eq_r = CHART "display-r-square";
- } else {
- eq_element = GNMSTYLE "equation";
- eq_automatic = GNMSTYLE "automatic-content";
- eq_display = GNMSTYLE "display-equation";
- eq_r = GNMSTYLE "display-r-square";
- }
- gsf_xml_out_start_element
- (state->xml, eq_element);
- odf_add_bool (state->xml, eq_automatic, TRUE);
- odf_write_plot_style_bool (state->xml, equation, klass,
- "show-eq", eq_display);
- odf_write_plot_style_bool (state->xml, equation, klass,
- "show-r2", eq_r);
- str = odf_get_gog_style_name_from_obj
- (GOG_OBJECT (equation));
- gsf_xml_out_add_cstr (state->xml, CHART "style-name", str);
- odf_write_gog_position (state, equation);
- gsf_xml_out_end_element (state->xml); /* </chart:equation> */
- }
-
- gsf_xml_out_end_element (state->xml); /* </chart:regression-curve> */
- g_free (str);
- }
- }
+ role = gog_object_find_role_by_name
+ (GOG_OBJECT (series->data), "Regression curve");
+ if (role != NULL)
+ odf_write_regression_curve (state, role, GOG_OBJECT (series->data), &pp);
+
+ role = gog_object_find_role_by_name
+ (GOG_OBJECT (series->data), "Trend line");
+ if (role != NULL)
+ odf_write_regression_curve (state, role, GOG_OBJECT (series->data), &pp);
/* Write data points if any */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]