Commit 7fb0512f authored by Morten Welinder's avatar Morten Welinder

xlsx: fix import and export of trend line "affine flag".

parent cf501a76
......@@ -15,6 +15,7 @@ Morten:
* xlsx import improvements for contour graphs.
* xlsx export improvements for contour graphs.
* Fix xlsx export of trend line equation.
* Fix xlsx import and export of trend line affine flag.
* Avoid critical on exporting unnamed xlsx trend line.
--------------------------------------------------------------------------
......
2017-10-26 Morten Welinder <terra@gnome.org>
* xlsx-read-drawing.c (xlsx_ser_trendline_intercept): Read
intercept.
* xlsx-write-drawing.c (xlsx_write_axis): Make axis tag for
contour charts match what XL wants. Even if it isn't obvious why.
(xlsx_write_one_chart): Save a view3D for contour charts.
(xlsx_write_one_plot): Fix writing trendline equation. Don't
write a trendline name if there isn't one.
write a trendline name if there isn't one. Write intercept=0 when
not linear.
2017-10-24 Morten Welinder <terra@gnome.org>
......
......@@ -1408,6 +1408,19 @@ xlsx_get_trend_eq (XLSXReadState *state)
}
static void
xlsx_ser_trendline_intercept (GsfXMLIn *xin, G_GNUC_UNUSED xmlChar const **attrs)
{
XLSXReadState *state = (XLSXReadState *)xin->user_state;
gnm_float intercept = 1;
(void)simple_float (xin, attrs, &intercept);
// We don't have _writeable_ yet.
if (gnm_object_has_readable_prop (state->cur_obj, "affine", G_TYPE_BOOLEAN, NULL)) {
g_object_set (state->cur_obj, "affine", intercept != 0, NULL);
}
}
static void
xlsx_ser_trendline_disprsqr (GsfXMLIn *xin, G_GNUC_UNUSED xmlChar const **attrs)
{
......@@ -2671,6 +2684,7 @@ GSF_XML_IN_NODE_FULL (START, CHART_SPACE, XL_NS_CHART, "chartSpace", GSF_XML_NO_
GSF_XML_IN_NODE (SERIES_TRENDLINE, SERIES_TRENDLINE_NAME, XL_NS_CHART, "name", GSF_XML_CONTENT, NULL, &xlsx_ser_trendline_name),
GSF_XML_IN_NODE (SERIES_TRENDLINE, SHAPE_PR, XL_NS_CHART, "spPr", GSF_XML_2ND, NULL, NULL),
GSF_XML_IN_NODE (SERIES_TRENDLINE, SERIES_TRENDLINE_TYPE, XL_NS_CHART, "trendlineType", GSF_XML_NO_CONTENT, &xlsx_ser_trendline_type, NULL),
GSF_XML_IN_NODE (SERIES_TRENDLINE, SERIES_TRENDLINE_INTERCEPT, XL_NS_CHART, "intercept", GSF_XML_NO_CONTENT, &xlsx_ser_trendline_intercept, NULL),
GSF_XML_IN_NODE (SERIES_TRENDLINE, SERIES_TRENDLINE_RSQR, XL_NS_CHART, "dispRSqr", GSF_XML_NO_CONTENT, &xlsx_ser_trendline_disprsqr, NULL),
GSF_XML_IN_NODE (SERIES_TRENDLINE, SERIES_TRENDLINE_EQ, XL_NS_CHART, "dispEq", GSF_XML_NO_CONTENT, &xlsx_ser_trendline_dispeq, NULL),
GSF_XML_IN_NODE (SERIES_TRENDLINE, SERIES_TRENDLINE_LABEL, XL_NS_CHART, "trendlineLbl", GSF_XML_NO_CONTENT, NULL, NULL),
......
......@@ -1090,15 +1090,18 @@ xlsx_write_one_plot (XLSXWriteState *state, GsfXMLOut *xml,
GogObject *eq;
GOData *dat;
char *name;
double intercept = gnm_nan;
if (!GOG_IS_TREND_LINE (trend))
continue;
if (strcmp (trend_type_name, "GogExpRegCurve") == 0)
trend_type = "exp";
else if (strcmp (trend_type_name, "GogLinRegCurve") == 0)
else if (strcmp (trend_type_name, "GogLinRegCurve") == 0) {
trend_type = "linear";
else if (strcmp (trend_type_name, "GogLogRegCurve") == 0)
if (!gnm_object_get_bool (trend, "affine"))
intercept = 0;
} else if (strcmp (trend_type_name, "GogLogRegCurve") == 0)
trend_type = "log";
else if (strcmp (trend_type_name, "GogMovingAvg") == 0)
trend_type = "movingAvg";
......@@ -1121,6 +1124,9 @@ xlsx_write_one_plot (XLSXWriteState *state, GsfXMLOut *xml,
xlsx_write_go_style (xml, state, go_styled_object_get_style (GO_STYLED_OBJECT (trend)));
xlsx_write_chart_cstr_unchecked (xml, "c:trendlineType", trend_type);
if (!gnm_isnan (intercept))
xlsx_write_chart_float (xml, "c:intercept", intercept);
eq = gog_object_get_child_by_name (trend, "Equation");
if (eq) {
gboolean has_r2, has_eq;
......
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