[gnumeric] Fixed loading xlsx files with empty chart titles.
- From: Jean BrÃfort <jbrefort src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] Fixed loading xlsx files with empty chart titles.
- Date: Sun, 3 Jul 2011 14:59:48 +0000 (UTC)
commit 25b8eba9ee67ae35433d1d7eeffbaf1398554a08
Author: Jean Brefort <jean brefort normalesup org>
Date: Sun Jul 3 17:03:22 2011 +0200
Fixed loading xlsx files with empty chart titles.
plugins/excel/ChangeLog | 5 +++++
plugins/excel/xlsx-read-drawing.c | 27 ++++++++++++++++++++++++---
2 files changed, 29 insertions(+), 3 deletions(-)
---
diff --git a/plugins/excel/ChangeLog b/plugins/excel/ChangeLog
index 48982e2..43f4d22 100644
--- a/plugins/excel/ChangeLog
+++ b/plugins/excel/ChangeLog
@@ -1,3 +1,8 @@
+2011-07-03 Jean Brefort <jean brefort normalesup org>
+
+ * xlsx-read-drawing.c (xlsx_chart_text_start), (xlsx_chart_text),
+ (xlsx_read_chart): fixed loading xlsx files with empty chart titles.
+
2011-07-01 Andreas J. Guelzow <aguelzow pyrshep ca>
* xlsx-write-docprops.c (xlsx_map_prop_name_to_output_fun):
diff --git a/plugins/excel/xlsx-read-drawing.c b/plugins/excel/xlsx-read-drawing.c
index 077978e..af4b4f3 100644
--- a/plugins/excel/xlsx-read-drawing.c
+++ b/plugins/excel/xlsx-read-drawing.c
@@ -66,7 +66,7 @@ static void
xlsx_chart_text_start (GsfXMLIn *xin, G_GNUC_UNUSED xmlChar const **attrs)
{
XLSXReadState *state = (XLSXReadState *)xin->user_state;
- if (IS_SHEET_OBJECT_GRAPH (state->so) && NULL == state->series) { /* Hmm, why? */
+ if (!GOG_IS_LABEL (state->cur_obj) && IS_SHEET_OBJECT_GRAPH (state->so) && NULL == state->series) { /* Hmm, why? */
GogObject *label = gog_object_add_by_name (state->cur_obj,
(state->cur_obj == (GogObject *)state->chart) ? "Title" : "Label", NULL);
xlsx_chart_push_obj (state, label);
@@ -81,7 +81,7 @@ xlsx_chart_text (GsfXMLIn *xin, G_GNUC_UNUSED GsfXMLBlob *blob)
if (IS_GNM_SO_FILLED (state->so))
g_object_set (G_OBJECT (state->so), "text", state->chart_tx, NULL);
else if (NULL == state->series) {
- if (state->cur_obj) {
+ if (GOG_IS_LABEL (state->cur_obj)) {
if (state->chart_tx) {
GnmValue *value = value_new_string_nocopy (state->chart_tx);
GnmExprTop const *texpr = gnm_expr_top_new_constant (value);
@@ -1360,7 +1360,7 @@ GSF_XML_IN_NODE_FULL (START, CHART_SPACE, XL_NS_CHART, "chartSpace", GSF_XML_NO_
GSF_XML_IN_NODE (CAT_AXIS, CAT_AXIS_LBLALGN, XL_NS_CHART, "lblAlgn", GSF_XML_NO_CONTENT, NULL, NULL),
GSF_XML_IN_NODE (CAT_AXIS, CAT_AXIS_LBLOFFSET, XL_NS_CHART, "lblOffset", GSF_XML_NO_CONTENT, NULL, NULL),
GSF_XML_IN_NODE (CAT_AXIS, TEXT_PR, XL_NS_CHART, "txPr", GSF_XML_NO_CONTENT, NULL, NULL), /* 2nd Def */
- GSF_XML_IN_NODE (CAT_AXIS, TITLE, XL_NS_CHART, "title", GSF_XML_NO_CONTENT, NULL, NULL), /* ID is used */
+ GSF_XML_IN_NODE (CAT_AXIS, TITLE, XL_NS_CHART, "title", GSF_XML_NO_CONTENT, &xlsx_chart_text_start, xlsx_chart_text), /* ID is used */
GSF_XML_IN_NODE (TITLE, LAYOUT, XL_NS_CHART, "layout", GSF_XML_NO_CONTENT, NULL, NULL),
GSF_XML_IN_NODE (LAYOUT, LAST_LAYOUT, XL_NS_CHART, "lastLayout", GSF_XML_NO_CONTENT, NULL, NULL),
GSF_XML_IN_NODE (LAST_LAYOUT, LAYOUT_X, XL_NS_CHART, "x", GSF_XML_NO_CONTENT, NULL, NULL),
@@ -1758,6 +1758,27 @@ xlsx_read_chart (GsfXMLIn *xin, xmlChar const **attrs)
g_slist_free (state->style_stack);
state->style_stack = NULL;
}
+ if (state->chart) {
+ GogObject *title = gog_object_get_child_by_name (GOG_OBJECT (state->chart), "Title");
+ if (title) {
+ /* test if the title s empty */
+ GOData *dat = gog_dataset_get_dim (GOG_DATASET (title), 0);
+ GError *err = NULL;
+ char *str = dat != NULL? go_data_get_scalar_string (dat): NULL;
+ /* if no title, use the first series label */
+ if (!str || !*str) {
+ GogPlot *plot = GOG_PLOT (gog_chart_get_plots (state->chart)->data);
+ GogDataset *ds = plot? GOG_DATASET (gog_plot_get_series (plot)->data): NULL;
+ if (ds)
+ dat = gog_dataset_get_dim (ds, -1);
+ if (dat)
+ gog_dataset_set_dim (GOG_DATASET (title), 0, GO_DATA (g_object_ref (dat)), &err);
+ if (err)
+ g_error_free (err);
+ }
+ g_free (str);
+ }
+ }
state->chart_pos[0] = go_nan;
state->gocolor = NULL;
state->color_setter = NULL;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]