Commit 3d7f1211 authored by Morten Welinder's avatar Morten Welinder

xlsx: fix import/export of graph backplane.

parent 230c26c9
......@@ -3,6 +3,9 @@ Gnumeric 1.12.23
Jean:
* Fix xlsx import of plot area manual layout. [#748016]
Morten:
* Fix import/export of graph backplane.
--------------------------------------------------------------------------
Gnumeric 1.12.22
......
2015-04-21 Morten Welinder <terra@gnome.org>
* xlsx-read-drawing.c (xlsx_chart_ring_hole): read hole size.
2015-04-17 Jean Brefort <jean.brefort@normalesup.org>
* xlsx-read-drawing.c (xlsx_chart_layout_manual): fix plot area manual
......
......@@ -634,6 +634,9 @@ xlsx_chart_add_plot (GsfXMLIn *xin, char const *type)
/* Replace dummy object. */
xlsx_chart_pop_obj (state);
xlsx_chart_push_obj (state, bp);
/* If there is no style, we will remove the backplane. */
state->cur_style->fill.type = GO_STYLE_FILL_NONE;
}
}
}
......@@ -669,6 +672,17 @@ xlsx_chart_pie_angle (GsfXMLIn *xin, xmlChar const **attrs)
"initial-angle", (double)angle, NULL);
}
static void
xlsx_chart_ring_hole (GsfXMLIn *xin, xmlChar const **attrs)
{
XLSXReadState *state = (XLSXReadState *)xin->user_state;
unsigned size = 50;
(void)simple_uint (xin, attrs, &size);
/* Allow full range for size. Spec says 10-90. */
g_object_set (G_OBJECT (state->plot),
"center-size", CLAMP (size, 0, 100) / 100.0, NULL);
}
/* shared with pie of pie, and bar of pie */
static void xlsx_chart_pie (GsfXMLIn *xin, G_GNUC_UNUSED xmlChar const **attrs) { xlsx_chart_add_plot (xin, "GogPiePlot"); }
static void xlsx_chart_ring (GsfXMLIn *xin, G_GNUC_UNUSED xmlChar const **attrs) { xlsx_chart_add_plot (xin, "GogRingPlot"); }
......@@ -2122,7 +2136,20 @@ static void
xlsx_plot_area_end (GsfXMLIn *xin, G_GNUC_UNUSED GsfXMLBlob *blob)
{
XLSXReadState *state = (XLSXReadState *)xin->user_state;
GogObject *bp = state->cur_obj;
GOStyle const *s = state->cur_style;
gboolean delete;
delete = (GOG_IS_GRID (bp) &&
!go_style_is_fill_visible (s) &&
gog_object_is_deletable (bp));
if (delete)
gog_object_clear_parent (bp);
xlsx_chart_pop_obj (state);
if (delete)
g_object_unref (bp); /* from _clear_parent. */
}
......@@ -2217,6 +2244,7 @@ xlsx_ext_gostyle (GsfXMLIn *xin, xmlChar const **attrs)
for (; attrs != NULL && attrs[0] && attrs[1] ; attrs += 2) {
gnm_float f;
int i;
if (strcmp (attrs[0], "pattern") == 0) {
GOPatternType p = go_pattern_from_str (attrs[1]);
......@@ -2229,6 +2257,10 @@ xlsx_ext_gostyle (GsfXMLIn *xin, xmlChar const **attrs)
style->fill.pattern.fore = GO_COLOR_BLACK;
}
style->fill.pattern.pattern = p;
} else if (attr_bool (xin, attrs, "auto-pattern", &i)) {
style->fill.auto_type = i != 0;
} else if (attr_bool (xin, attrs, "auto-back", &i)) {
style->fill.auto_back = i != 0;
} else if (start_arrow && strcmp (attrs[0], "StartArrowType") == 0) {
start_arrow->typ = go_arrow_type_from_str (attrs[1]);
} else if (start_arrow && attr_float (xin, attrs, "StartArrowShapeA", &f)) {
......@@ -2695,7 +2727,7 @@ GSF_XML_IN_NODE_FULL (START, CHART_SPACE, XL_NS_CHART, "chartSpace", GSF_XML_NO_
GSF_XML_IN_NODE (DOUGHNUT, SERIES, XL_NS_CHART, "ser", GSF_XML_2ND, NULL, NULL),
GSF_XML_IN_NODE (DOUGHNUT, VARY_COLORS, XL_NS_CHART, "varyColors", GSF_XML_2ND, NULL, NULL),
GSF_XML_IN_NODE (DOUGHNUT, PIE_FIRST_SLICE, XL_NS_CHART, "firstSliceAng", GSF_XML_2ND, NULL, NULL),
GSF_XML_IN_NODE (DOUGHNUT, HOLE_SIZE, XL_NS_CHART, "holeSize", GSF_XML_NO_CONTENT, NULL, NULL),
GSF_XML_IN_NODE (DOUGHNUT, HOLE_SIZE, XL_NS_CHART, "holeSize", GSF_XML_NO_CONTENT, &xlsx_chart_ring_hole, NULL),
GSF_XML_IN_NODE (DOUGHNUT, PLOT_DLBLS, XL_NS_CHART, "dLbls", GSF_XML_2ND, NULL, NULL),
GSF_XML_IN_NODE (PLOTAREA, DATA_TABLE, XL_NS_CHART, "dTable", GSF_XML_NO_CONTENT, NULL, NULL),
......
......@@ -321,6 +321,8 @@ xlsx_write_go_style_full (GsfXMLOut *xml, GOStyle *style, const XLSXStyleContext
!style->font.auto_color);
gboolean has_font = xlsx_go_style_has_font (style);
gboolean ext_fill_pattern = FALSE;
gboolean ext_fill_auto_pattern = FALSE;
gboolean ext_fill_auto_back = FALSE;
gboolean ext_start_arrow = FALSE;
gboolean ext_end_arrow = FALSE;
gboolean ext_gradient_rev = FALSE;
......@@ -358,18 +360,16 @@ xlsx_write_go_style_full (GsfXMLOut *xml, GOStyle *style, const XLSXStyleContext
break;
case GO_STYLE_FILL_PATTERN: {
const char *pattname = NULL;
ext_fill_auto_pattern = TRUE;
switch (style->fill.pattern.pattern) {
case GO_PATTERN_SOLID:
ext_fill_pattern = TRUE;
if (!style->fill.auto_back) {
if (!style->fill.auto_back || sctx->must_fill_fill) {
if (style->fill.auto_back)
ext_fill_auto_back = TRUE;
gsf_xml_out_start_element (xml, "a:solidFill");
xlsx_write_rgbarea (xml, style->fill.pattern.back);
gsf_xml_out_end_element (xml);
} else if (sctx->must_fill_fill) {
/* We must output a color, or we'll get the foreground colour, i.e., black. */
gsf_xml_out_start_element (xml, "a:solidFill");
xlsx_write_rgbarea (xml, GO_COLOR_WHITE);
gsf_xml_out_end_element (xml);
}
break;
case GO_PATTERN_FOREGROUND_SOLID:
......@@ -557,7 +557,8 @@ xlsx_write_go_style_full (GsfXMLOut *xml, GOStyle *style, const XLSXStyleContext
}
if (sctx->state->with_extension &&
(ext_fill_pattern || ext_start_arrow || ext_end_arrow ||
(ext_fill_pattern || ext_fill_auto_pattern || ext_fill_auto_back ||
ext_start_arrow || ext_end_arrow ||
ext_gradient_rev || ext_dash_type)) {
gsf_xml_out_start_element (xml, "a:extLst");
gsf_xml_out_start_element (xml, "a:ext");
......@@ -570,7 +571,14 @@ xlsx_write_go_style_full (GsfXMLOut *xml, GOStyle *style, const XLSXStyleContext
: go_line_dash_as_str (style->line.dash_type));
}
if (ext_fill_pattern) {
gsf_xml_out_add_cstr (xml, "pattern", go_pattern_as_str (style->fill.pattern.pattern));
gsf_xml_out_add_cstr (xml, "pattern",
go_pattern_as_str (style->fill.pattern.pattern));
}
if (ext_fill_auto_pattern) {
xlsx_add_bool (xml, "auto-pattern", style->fill.auto_type);
}
if (ext_fill_auto_back) {
xlsx_add_bool (xml, "auto-back", style->fill.auto_back);
}
if (ext_start_arrow) {
GOArrow const *arrow = sctx->start_arrow;
......@@ -1208,8 +1216,14 @@ xlsx_write_one_chart (XLSXWriteState *state, GsfXMLOut *xml, GogObject const *ch
xlsx_write_plots (state, xml, chart, &ser_count);
obj = gog_object_get_child_by_name (GOG_OBJECT (chart), "Backplane");
if (obj)
xlsx_write_go_style (xml, state, go_styled_object_get_style (GO_STYLED_OBJECT (obj)));
if (obj) {
XLSXStyleContext sctx;
xlsx_style_context_init (&sctx, state);
sctx.must_fill_fill = TRUE;
xlsx_write_go_style_full
(xml, go_styled_object_get_style (GO_STYLED_OBJECT (obj)),
&sctx);
}
gsf_xml_out_end_element (xml); /* </c:plotArea> */
......
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