[gnumeric] ODF import/export trendline names. [#743448]
- From: Andreas J. Guelzow <guelzow src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] ODF import/export trendline names. [#743448]
- Date: Sun, 25 Jan 2015 20:00:36 +0000 (UTC)
commit a5b2e931eeb6f4ab534d0ba36c8036be9daaf721
Author: Andreas J. Guelzow <aguelzow pyrshep ca>
Date: Sun Jan 25 12:58:43 2015 -0700
ODF import/export trendline names. [#743448]
2015-01-24 Andreas J. Guelzow <aguelzow pyrshep ca>
* openoffice-read.c (od_style_prop_chart): store regression name expression
from gnm: name space
(od_series_regression): apply style name expression specified by style
* openoffice-write.c (odf_write_regression_curve): do not save trendline name here
(odf_write_reg_name): new
(odf_write_*_reg): call odf_write_reg_name
NEWS | 2 +-
plugins/openoffice/ChangeLog | 9 +++++++++
plugins/openoffice/openoffice-read.c | 28 ++++++++++++++++++++++++----
plugins/openoffice/openoffice-write.c | 27 ++++++++++++++++++++++-----
4 files changed, 56 insertions(+), 10 deletions(-)
---
diff --git a/NEWS b/NEWS
index 5114ed4..04fd459 100644
--- a/NEWS
+++ b/NEWS
@@ -1,7 +1,7 @@
Gnumeric 1.12.20
Andreas:
- * ODF import/export: handle some trendline names. [#743448]
+ * ODF import/export trendline names. [#743448]
Morten:
* xlsx chart import: fix font family name.
diff --git a/plugins/openoffice/ChangeLog b/plugins/openoffice/ChangeLog
index 9a6fb36..56a8b88 100644
--- a/plugins/openoffice/ChangeLog
+++ b/plugins/openoffice/ChangeLog
@@ -1,5 +1,14 @@
2015-01-24 Andreas J. Guelzow <aguelzow pyrshep ca>
+ * openoffice-read.c (od_style_prop_chart): store regression name expression
+ from gnm: name space
+ (od_series_regression): apply style name expression specified by style
+ * openoffice-write.c (odf_write_regression_curve): do not save trendline name here
+ (odf_write_reg_name): new
+ (odf_write_*_reg): call odf_write_reg_name
+
+2015-01-24 Andreas J. Guelzow <aguelzow pyrshep ca>
+
* openoffice-read.c (od_series_regression): read trend line name
* openoffice-write.c (odf_write_regression_curve): save trendline name
diff --git a/plugins/openoffice/openoffice-read.c b/plugins/openoffice/openoffice-read.c
index 4259598..9eed508 100644
--- a/plugins/openoffice/openoffice-read.c
+++ b/plugins/openoffice/openoffice-read.c
@@ -7217,6 +7217,12 @@ od_style_prop_chart (GsfXMLIn *xin, xmlChar const **attrs)
&btmp))
style->other_props = g_slist_prepend (style->other_props,
oo_prop_new_bool ("regression-affine", btmp));
+ else if (gsf_xml_in_namecmp (xin, CXML2C (attrs[0]), OO_GNUM_NS_EXT,
+ "regression-name"))
+ style->other_props = g_slist_prepend
+ (style->other_props,
+ oo_prop_new_string ("regression-name-expression",
+ CXML2C(attrs[1])));
else if (oo_attr_bool (xin, attrs, OO_GNUM_NS_EXT,
"is-position-manual",
&btmp))
@@ -9156,7 +9162,6 @@ od_series_regression (GsfXMLIn *xin, xmlChar const **attrs)
char const *style_name = NULL;
gchar const *lower_bd = NULL;
gchar const *upper_bd = NULL;
- gchar const *name = NULL;
state->chart.regression = NULL;
@@ -9167,8 +9172,6 @@ od_series_regression (GsfXMLIn *xin, xmlChar const **attrs)
lower_bd = CXML2C (attrs[1]);
else if (gsf_xml_in_namecmp (xin, CXML2C (attrs[0]), OO_GNUM_NS_EXT, "upper-bound"))
upper_bd = CXML2C (attrs[1]);
- else if (gsf_xml_in_namecmp (xin, CXML2C (attrs[0]), OO_GNUM_NS_EXT, "name"))
- name = CXML2C (attrs[1]);
if (style_name != NULL) {
OOChartStyle *chart_style = g_hash_table_lookup
@@ -9179,6 +9182,7 @@ od_series_regression (GsfXMLIn *xin, xmlChar const **attrs)
GOStyle *style = NULL;
GogObject *regression;
gchar const *type_name = "GogLinRegCurve";
+ gchar const *regression_name = NULL;
for (l = chart_style->other_props; l != NULL; l = l->next) {
OOProp *prop = l->data;
if (0 == strcmp ("regression-type", prop->name)) {
@@ -9203,6 +9207,8 @@ od_series_regression (GsfXMLIn *xin, xmlChar const **attrs)
else if (0 == strcmp
(reg_type, "gnm:moving-average"))
type_name = "GogMovingAvg";
+ } else if (0 == strcmp ("regression-name-expression", prop->name)) {
+ regression_name = g_value_get_string (&prop->value);
}
}
@@ -9218,7 +9224,21 @@ od_series_regression (GsfXMLIn *xin, xmlChar const **attrs)
g_object_unref (style);
}
- odf_store_data (state, name, regression, -1);
+ if (regression_name != NULL) {
+ GnmParsePos pp;
+ GOData *data;
+ GnmExprTop const *expr;
+ parse_pos_init (&pp, state->pos.wb, state->pos.sheet, 0, 0);
+ expr = oo_expr_parse_str
+ (xin, regression_name, &pp,
+ GNM_EXPR_PARSE_FORCE_EXPLICIT_SHEET_REFERENCES,
+ FORMULA_OPENFORMULA);
+ if (expr != NULL) {
+ data = gnm_go_data_scalar_new_expr (state->pos.sheet, expr);
+ gog_dataset_set_dim (GOG_DATASET (regression), -1, data, NULL);
+ }
+ }
+
odf_store_data (state, lower_bd, regression, 0);
odf_store_data (state, upper_bd, regression, 1);
}
diff --git a/plugins/openoffice/openoffice-write.c b/plugins/openoffice/openoffice-write.c
index 5c7a67b..a23ed43 100644
--- a/plugins/openoffice/openoffice-write.c
+++ b/plugins/openoffice/openoffice-write.c
@@ -6311,11 +6311,6 @@ odf_write_regression_curve (GnmOOExport *state, GogObjectRole const *role, GogOb
gsf_xml_out_add_cstr (state->xml, CHART "style-name", str);
if (is_reg_curve && state->with_extension) {
- /* name */
- bd = gog_dataset_get_dim (GOG_DATASET (regression), -1);
- if (bd != NULL)
- odf_write_data_attribute
- (state, bd, pp, GNMSTYLE "name");
/* Upper and lower bounds */
bd = gog_dataset_get_dim (GOG_DATASET (regression), 0);
if (bd != NULL)
@@ -8100,6 +8095,20 @@ odf_write_drop (GnmOOExport *state, G_GNUC_UNUSED GOStyle const *style,
}
static void
+odf_write_reg_name (GnmOOExport *state, GogObject const *obj)
+{
+ if (state->with_extension) {
+ GnmParsePos pp;
+ GOData const *bd;
+ parse_pos_init (&pp, WORKBOOK (state->wb), NULL, 0,0 );
+ bd = gog_dataset_get_dim (GOG_DATASET (obj), -1);
+ if (bd != NULL)
+ odf_write_data_attribute
+ (state, bd, &pp, GNMSTYLE "regression-name");
+ }
+}
+
+static void
odf_write_lin_reg (GnmOOExport *state, G_GNUC_UNUSED GOStyle const *style,
GogObject const *obj)
{
@@ -8110,6 +8119,7 @@ odf_write_lin_reg (GnmOOExport *state, G_GNUC_UNUSED GOStyle const *style,
odf_write_plot_style_uint (state->xml, obj,
"dims", GNMSTYLE "regression-polynomial-dims");
}
+ odf_write_reg_name (state, obj);
}
static void
@@ -8124,6 +8134,7 @@ odf_write_polynom_reg (GnmOOExport *state, G_GNUC_UNUSED GOStyle const *style,
odf_write_plot_style_bool (state->xml, obj,
"affine", GNMSTYLE "regression-affine");
}
+ odf_write_reg_name (state, obj);
}
static void
@@ -8131,6 +8142,7 @@ odf_write_exp_reg (GnmOOExport *state, G_GNUC_UNUSED GOStyle const *style,
G_GNUC_UNUSED GogObject const *obj)
{
gsf_xml_out_add_cstr (state->xml, CHART "regression-type", "exponential");
+ odf_write_reg_name (state, obj);
}
static void
@@ -8138,6 +8150,7 @@ odf_write_power_reg (GnmOOExport *state, G_GNUC_UNUSED GOStyle const *style,
G_GNUC_UNUSED GogObject const *obj)
{
gsf_xml_out_add_cstr (state->xml, CHART "regression-type", "power");
+ odf_write_reg_name (state, obj);
}
static void
@@ -8145,6 +8158,7 @@ odf_write_log_reg (GnmOOExport *state, G_GNUC_UNUSED GOStyle const *style,
G_GNUC_UNUSED GogObject const *obj)
{
gsf_xml_out_add_cstr (state->xml, CHART "regression-type", "logarithmic");
+ odf_write_reg_name (state, obj);
}
static void
@@ -8154,6 +8168,7 @@ odf_write_log_fit_reg (GnmOOExport *state, G_GNUC_UNUSED GOStyle const *style,
if (state->with_extension)
gsf_xml_out_add_cstr (state->xml, CHART "regression-type",
GNMSTYLE "log-fit");
+ odf_write_reg_name (state, obj);
}
static void
@@ -8163,6 +8178,7 @@ odf_write_movig_avg_reg (GnmOOExport *state, G_GNUC_UNUSED GOStyle const *style,
if (state->with_extension)
gsf_xml_out_add_cstr (state->xml, CHART "regression-type",
GNMSTYLE "moving-average");
+ odf_write_reg_name (state, obj);
}
static void
@@ -8172,6 +8188,7 @@ odf_write_exp_smooth_reg (GnmOOExport *state, G_GNUC_UNUSED GOStyle const *style
if (state->with_extension)
gsf_xml_out_add_cstr (state->xml, CHART "regression-type",
GNMSTYLE "exponential-smoothed");
+ odf_write_reg_name (state, obj);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]