[gnumeric] Fix various data labels import issues.
- From: Jean BrÃfort <jbrefort src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] Fix various data labels import issues.
- Date: Sun, 28 Aug 2011 17:08:59 +0000 (UTC)
commit 71d5056ee572b42031a205fb353197478a1c59e2
Author: Jean Brefort <jean brefort normalesup org>
Date: Sun Aug 28 19:13:38 2011 +0200
Fix various data labels import issues.
ChangeLog | 4 +
plugins/excel/ChangeLog | 14 +++
plugins/excel/ms-chart.c | 80 ++++---------
plugins/excel/xlsx-read-drawing.c | 221 ++++++++++++++++++++++++++++++-------
src/graph.c | 3 +
5 files changed, 226 insertions(+), 96 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index f8ecf31..415f996 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2011-08-28 Jean Brefort <jean brefort normalesup org>
+
+ * src/graph.c (gnm_go_data_scalar_get_str): format the string.
+
2011-08-22 Jean Brefort <jean brefort normalesup org>
* src/sheet-object-widget.c (sheet_widget_combo_create_widget): fixed combo
diff --git a/plugins/excel/ChangeLog b/plugins/excel/ChangeLog
index 0037016..f9b8817 100644
--- a/plugins/excel/ChangeLog
+++ b/plugins/excel/ChangeLog
@@ -1,3 +1,17 @@
+2011-08-28 Jean Brefort <jean brefort normalesup org>
+
+ * ms-chart.c (end), (xl_chart_import_error_bar),
+ (ms_excel_chart_read), (store_dim), (chart_write_series): moved two helpers
+ to goffice.
+ * xlsx-read-drawing.c (xlsx_tx_pr), (xlsx_draw_text_run_props),
+ (xlsx_ser_labels_show_val), (xlsx_ser_labels_show_cat),
+ (xlsx_ser_labels_pos), (xlsx_ser_labels_start),
+ (xlsx_ser_labels_end), (xlsx_data_label_pos),
+ (xlsx_data_label_index), (xlsx_data_label_show_val),
+ (xlsx_data_label_show_cat), (xlsx_data_label_start),
+ (xlsx_chart_ser_f), (xlsx_chart_solid_fill),
+ (xlsx_draw_color_themed): fix various data labels import issues.
+
2011-08-22 Jean Brefort <jean brefort normalesup org>
* xlsx-read-drawing.c (xlsx_ser_data_show_val),
diff --git a/plugins/excel/ms-chart.c b/plugins/excel/ms-chart.c
index 2458b4a..9bf614d 100644
--- a/plugins/excel/ms-chart.c
+++ b/plugins/excel/ms-chart.c
@@ -2430,36 +2430,6 @@ BC_R(valuerange)(XLChartHandler const *handle,
/****************************************************************************/
-static int
-XL_gog_series_map_dim (GogSeries const *series, GogMSDimType ms_type)
-{
- GogSeriesDesc const *desc = &series->plot->desc.series;
- unsigned i = desc->num_dim;
-
- if (ms_type == GOG_MS_DIM_LABELS)
- return -1;
- while (i-- > 0)
- if (desc->dim[i].ms_type == ms_type)
- return i;
- return -2;
-}
-
-extern void
-XL_gog_series_set_dim (GogSeries *series, GogMSDimType ms_type, GOData *val);
-
-void
-XL_gog_series_set_dim (GogSeries *series, GogMSDimType ms_type, GOData *val)
-{
- int dim;
- g_return_if_fail (series !=NULL);
- dim = XL_gog_series_map_dim (series, ms_type);
- if (dim >= -1) {
- gog_series_set_dim (series, dim, val, NULL);
- return;
- }
- g_object_unref (val);
-}
-
static void
cb_store_singletons (gpointer indx, GOStyle *style, GogObject *series)
{
@@ -2916,21 +2886,21 @@ not_a_matrix:
series = gog_plot_new_series (GOG_PLOT (plot));
g_object_set (plot, "gap_percentage", s->dropbar_width, NULL);
if (eseries->data [GOG_MS_DIM_CATEGORIES].data != NULL) {
- XL_gog_series_set_dim (series, GOG_MS_DIM_CATEGORIES,
- eseries->data [GOG_MS_DIM_CATEGORIES].data);
+ gog_series_set_XL_dim (series, GOG_MS_DIM_CATEGORIES,
+ eseries->data [GOG_MS_DIM_CATEGORIES].data, NULL);
eseries->data [GOG_MS_DIM_CATEGORIES].data = NULL;
}
if (eseries->data [GOG_MS_DIM_VALUES].data != NULL) {
- XL_gog_series_set_dim (series, GOG_MS_DIM_END,
- eseries->data [GOG_MS_DIM_VALUES].data);
+ gog_series_set_XL_dim (series, GOG_MS_DIM_END,
+ eseries->data [GOG_MS_DIM_VALUES].data, NULL);
eseries->data [GOG_MS_DIM_VALUES].data = NULL;
} else
eseries->extra_dim = GOG_MS_DIM_END;
while (eseries = g_ptr_array_index (s->series, k++),
eseries->chart_group != s->plot_counter);
if (eseries->data [GOG_MS_DIM_VALUES].data != NULL) {
- XL_gog_series_set_dim (series, GOG_MS_DIM_START,
- eseries->data [GOG_MS_DIM_VALUES].data);
+ gog_series_set_XL_dim (series, GOG_MS_DIM_START,
+ eseries->data [GOG_MS_DIM_VALUES].data, NULL);
eseries->data [GOG_MS_DIM_VALUES].data = NULL;
} else
eseries->extra_dim = GOG_MS_DIM_START;
@@ -2953,21 +2923,21 @@ not_a_matrix:
while (eseries = g_ptr_array_index (s->series, k++),
eseries->chart_group != s->plot_counter);
if (eseries->data [GOG_MS_DIM_CATEGORIES].data != NULL) {
- XL_gog_series_set_dim (series, GOG_MS_DIM_CATEGORIES,
- eseries->data [GOG_MS_DIM_CATEGORIES].data);
+ gog_series_set_XL_dim (series, GOG_MS_DIM_CATEGORIES,
+ eseries->data [GOG_MS_DIM_CATEGORIES].data, NULL);
eseries->data [GOG_MS_DIM_CATEGORIES].data = NULL;
}
if (eseries->data [GOG_MS_DIM_VALUES].data != NULL) {
- XL_gog_series_set_dim (series, GOG_MS_DIM_HIGH,
- eseries->data [GOG_MS_DIM_VALUES].data);
+ gog_series_set_XL_dim (series, GOG_MS_DIM_HIGH,
+ eseries->data [GOG_MS_DIM_VALUES].data, NULL);
eseries->data [GOG_MS_DIM_VALUES].data = NULL;
} else
eseries->extra_dim = GOG_MS_DIM_HIGH;
while (eseries = g_ptr_array_index (s->series, k++),
eseries->chart_group != s->plot_counter);
if (eseries->data [GOG_MS_DIM_VALUES].data != NULL) {
- XL_gog_series_set_dim (series, GOG_MS_DIM_LOW,
- eseries->data [GOG_MS_DIM_VALUES].data);
+ gog_series_set_XL_dim (series, GOG_MS_DIM_LOW,
+ eseries->data [GOG_MS_DIM_VALUES].data, NULL);
eseries->data [GOG_MS_DIM_VALUES].data = NULL;
} else
eseries->extra_dim = GOG_MS_DIM_LOW;
@@ -2986,8 +2956,8 @@ not_a_matrix:
series = gog_plot_new_series (s->plot);
for (j = 0 ; j < GOG_MS_DIM_TYPES; j++ )
if (eseries->data [j].data != NULL) {
- XL_gog_series_set_dim (series, j,
- eseries->data [j].data);
+ gog_series_set_XL_dim (series, j,
+ eseries->data [j].data, NULL);
eseries->data [j].data = NULL;
}
eseries->series = series;
@@ -3445,7 +3415,7 @@ xl_chart_import_error_bar (XLChartReadState *state, XLChartSeries *series)
value_new_float (series->err_val));
error_bar->type = GOG_ERROR_BAR_TYPE_PERCENT;
data = gnm_go_data_vector_new_expr (sheet, texpr);
- XL_gog_series_set_dim (parent->series, msdim, data);
+ gog_series_set_XL_dim (parent->series, msdim, data, NULL);
break;
}
case 2: {
@@ -3455,7 +3425,7 @@ xl_chart_import_error_bar (XLChartReadState *state, XLChartSeries *series)
value_new_float (series->err_val));
error_bar->type = GOG_ERROR_BAR_TYPE_ABSOLUTE;
data = gnm_go_data_vector_new_expr (sheet, texpr);
- XL_gog_series_set_dim (parent->series, msdim, data);
+ gog_series_set_XL_dim (parent->series, msdim, data, NULL);
break;
}
case 3:
@@ -3467,8 +3437,8 @@ xl_chart_import_error_bar (XLChartReadState *state, XLChartSeries *series)
: GOG_MS_DIM_VALUES;
error_bar->type = GOG_ERROR_BAR_TYPE_ABSOLUTE;
if (series->data[orig_dim].data) {
- XL_gog_series_set_dim (parent->series, msdim,
- series->data[orig_dim].data);
+ gog_series_set_XL_dim (parent->series, msdim,
+ series->data[orig_dim].data, NULL);
series->data[orig_dim].data = NULL;
} else if (series->data[orig_dim].value) {
GnmExprTop const *texpr =
@@ -3476,7 +3446,7 @@ xl_chart_import_error_bar (XLChartReadState *state, XLChartSeries *series)
series->data[orig_dim].value);
series->data[orig_dim].value = NULL;
data = gnm_go_data_vector_new_expr (sheet, texpr);
- XL_gog_series_set_dim (parent->series, msdim, data);
+ gog_series_set_XL_dim (parent->series, msdim, data, NULL);
}
break;
default:
@@ -3784,9 +3754,9 @@ ms_excel_chart_read (BiffQuery *q, MSContainer *container,
data = gnm_go_data_vector_new_expr (sheet, texpr);
if (series->extra_dim == 0)
- XL_gog_series_set_dim (series->series, j, data);
+ gog_series_set_XL_dim (series->series, j, data, NULL);
else if (j == GOG_MS_DIM_VALUES)
- XL_gog_series_set_dim (series->series, series->extra_dim, data);
+ gog_series_set_XL_dim (series->series, series->extra_dim, data, NULL);
}
}
}
@@ -4398,7 +4368,7 @@ static void
store_dim (GogSeries const *series, GogMSDimType t,
guint8 *store_type, guint8 *store_count, guint16 default_count)
{
- int msdim = XL_gog_series_map_dim (series, t);
+ int msdim = gog_series_map_XL_dim (series, t);
GOData *dat = NULL;
guint16 count, type;
@@ -4725,7 +4695,7 @@ chart_write_series (XLChartWriteState *s, GogSeries const *series, unsigned n)
store_dim (series, GOG_MS_DIM_CATEGORIES, data+0, data+4, num_elements);
store_dim (series, GOG_MS_DIM_VALUES, data+2, data+6, num_elements);
if (s->bp->version >= MS_BIFF_V8) {
- msdim = XL_gog_series_map_dim (series, GOG_MS_DIM_BUBBLES);
+ msdim = gog_series_map_XL_dim (series, GOG_MS_DIM_BUBBLES);
store_dim (series, GOG_MS_DIM_BUBBLES, data+8, data+10,
(msdim >= 0) ? num_elements : 0);
}
@@ -4733,10 +4703,10 @@ chart_write_series (XLChartWriteState *s, GogSeries const *series, unsigned n)
chart_write_BEGIN (s);
for (i = GOG_MS_DIM_LABELS; i <= GOG_MS_DIM_BUBBLES; i++) {
- msdim = XL_gog_series_map_dim (series, i);
+ msdim = gog_series_map_XL_dim (series, i);
if (msdim >= -1)
dat = gog_dataset_get_dim (GOG_DATASET (series),
- XL_gog_series_map_dim (series, i));
+ gog_series_map_XL_dim (series, i));
else
dat = NULL;
chart_write_AI (s, dat, i, default_ref_type[i]);
diff --git a/plugins/excel/xlsx-read-drawing.c b/plugins/excel/xlsx-read-drawing.c
index 2427fe6..73d6175 100644
--- a/plugins/excel/xlsx-read-drawing.c
+++ b/plugins/excel/xlsx-read-drawing.c
@@ -74,6 +74,16 @@ xlsx_chart_text_start (GsfXMLIn *xin, G_GNUC_UNUSED xmlChar const **attrs)
}
static void
+xlsx_tx_pr (GsfXMLIn *xin, G_GNUC_UNUSED xmlChar const **attrs)
+{
+ XLSXReadState *state = (XLSXReadState *)xin->user_state;
+ if (GO_IS_STYLED_OBJECT (state->cur_obj) && state->cur_style) {
+ state->gocolor = &state->cur_style->font.color;
+ state->auto_color = NULL;
+ }
+}
+
+static void
xlsx_chart_text (GsfXMLIn *xin, G_GNUC_UNUSED GsfXMLBlob *blob)
{
XLSXReadState *state = (XLSXReadState *)xin->user_state;
@@ -145,13 +155,14 @@ static void
xlsx_draw_text_run_props (GsfXMLIn *xin, xmlChar const **attrs)
{
XLSXReadState *state = (XLSXReadState *)xin->user_state;
+ /* FIXME: this should be for a text run, not for the full object */
if (GO_IS_STYLED_OBJECT (state->cur_obj) && state->cur_style) {
PangoFontDescription *desc = pango_font_description_new ();
int size;
GOFont const *font;
/* looks like the default font is Calibri, FIXME: import that from file instead */
pango_font_description_set_family (desc, "Calibri");
- for (; *attrs; attrs += 2)
+ for (; attrs && *attrs; attrs += 2)
if (attr_int (xin, attrs, "sz", &size))
pango_font_description_set_size (desc, size * PANGO_SCALE / 100);
/* FIXME: don't set the size to the whole object, only to the run,
@@ -793,7 +804,7 @@ xlsx_chart_ser_end (GsfXMLIn *xin, G_GNUC_UNUSED GsfXMLBlob *blob)
}
static void
-xlsx_ser_data_show_val (GsfXMLIn *xin, xmlChar const **attrs)
+xlsx_ser_labels_show_val (GsfXMLIn *xin, xmlChar const **attrs)
{
XLSXReadState *state = (XLSXReadState *)xin->user_state;
gboolean has_val;
@@ -801,21 +812,26 @@ xlsx_ser_data_show_val (GsfXMLIn *xin, xmlChar const **attrs)
GogPlotDesc const *desc = gog_plot_description (state->plot);
unsigned i;
char *f, *new_f;
+ g_object_get (state->cur_obj, "format", &f, NULL);
+ /* seems that xl does not show anything else if a custom label is given */
+ if (strstr (f, "%c") != NULL) {
+ g_free (f);
+ return;
+ }
for (i = 0; i < desc->series.num_dim; i++)
if (desc->series.dim[i].ms_type == GOG_MS_DIM_VALUES)
break;
- if (i == desc->series.num_dim)
- return;
- g_object_get (state->cur_obj, "format", &f, NULL);
- new_f = (f && *f)? g_strdup_printf ("%s %%%d", f, i): g_strdup_printf ("%%%d", i);
- g_object_set (state->cur_obj, "format", new_f, NULL);
+ if (i != desc->series.num_dim) {
+ new_f = (f && *f)? g_strdup_printf ("%s %%%d", f, i): g_strdup_printf ("%%%d", i);
+ g_object_set (state->cur_obj, "format", new_f, NULL);
+ g_free (new_f);
+ }
g_free (f);
- g_free (new_f);
}
}
static void
-xlsx_ser_data_show_cat (GsfXMLIn *xin, xmlChar const **attrs)
+xlsx_ser_labels_show_cat (GsfXMLIn *xin, xmlChar const **attrs)
{
XLSXReadState *state = (XLSXReadState *)xin->user_state;
gboolean has_cat;
@@ -823,21 +839,26 @@ xlsx_ser_data_show_cat (GsfXMLIn *xin, xmlChar const **attrs)
GogPlotDesc const *desc = gog_plot_description (state->plot);
unsigned i;
char *f, *new_f;
+ g_object_get (state->cur_obj, "format", &f, NULL);
+ /* seems that xl does not show anything else if a custom label is given */
+ if (strstr (f, "%c") != NULL) {
+ g_free (f);
+ return;
+ }
for (i = 0; i < desc->series.num_dim; i++)
if (desc->series.dim[i].ms_type == GOG_MS_DIM_CATEGORIES)
break;
- if (i == desc->series.num_dim)
- return;
- g_object_get (state->cur_obj, "format", &f, NULL);
- new_f = (f && *f)? g_strdup_printf ("%s %%%d", f, i): g_strdup_printf ("%%%d", i);
- g_object_set (state->cur_obj, "format", new_f, NULL);
+ if (i != desc->series.num_dim) {
+ new_f = (f && *f)? g_strdup_printf ("%s %%%d", f, i): g_strdup_printf ("%%%d", i);
+ g_object_set (state->cur_obj, "format", new_f, NULL);
+ g_free (new_f);
+ }
g_free (f);
- g_free (new_f);
}
}
static void
-xlsx_ser_data_pos (GsfXMLIn *xin, xmlChar const **attrs)
+xlsx_ser_labels_pos (GsfXMLIn *xin, xmlChar const **attrs)
{
static EnumVal pos[] = {
{"b", GOG_SERIES_LABELS_BOTTOM},
@@ -858,18 +879,125 @@ xlsx_ser_data_pos (GsfXMLIn *xin, xmlChar const **attrs)
}
static void
-xlsx_ser_data_start (GsfXMLIn *xin, xmlChar const **attrs)
+xlsx_ser_labels_start (GsfXMLIn *xin, xmlChar const **attrs)
{
XLSXReadState *state = (XLSXReadState *)xin->user_state;
if (NULL != state->series) {
GogObject *data = gog_object_add_by_name (GOG_OBJECT (state->series), "Data labels", NULL);
- g_object_set (data, "format", "", NULL);
+ g_object_set (data, "format", "", "offset", 3, NULL);
xlsx_chart_push_obj (state, data);
}
}
-#warning shared from ms-chart.c for now, move to GOffice with the enum
-extern void XL_gog_series_set_dim (GogSeries *series, GogMSDimType ms_type, GOData *val);
+static void
+xlsx_ser_labels_end (GsfXMLIn *xin, G_GNUC_UNUSED GsfXMLBlob *blob)
+{
+ XLSXReadState *state = (XLSXReadState *)xin->user_state;
+ if (!go_style_is_auto (state->cur_style)) {
+ /* NOTE: this is a hack, but seems xl uses something like that */
+ GSList *children, *ptr;
+ children = gog_object_get_children (state->cur_obj, NULL);
+ for (ptr = children; ptr; ptr = ptr->next)
+ if (go_style_is_auto (go_styled_object_get_style (GO_STYLED_OBJECT (ptr->data))))
+ g_object_set (ptr->data, "style", state->cur_style, NULL);
+ g_slist_free (children);
+ }
+ xlsx_chart_pop_obj (state);
+}
+
+static void
+xlsx_data_label_pos (GsfXMLIn *xin, xmlChar const **attrs)
+{
+ static EnumVal pos[] = {
+ {"b", GOG_SERIES_LABELS_BOTTOM},
+ {"bestFit", GOG_SERIES_LABELS_DEFAULT_POS},
+ {"ctr", GOG_SERIES_LABELS_CENTERED},
+ {"inBase", GOG_SERIES_LABELS_NEAR_ORIGIN},
+ {"inEnd", GOG_SERIES_LABELS_INSIDE},
+ {"l", GOG_SERIES_LABELS_LEFT},
+ {"outEnd", GOG_SERIES_LABELS_OUTSIDE},
+ {"r", GOG_SERIES_LABELS_RIGHT},
+ {"t", GOG_SERIES_LABELS_TOP}
+ };
+ XLSXReadState *state = (XLSXReadState *)xin->user_state;
+ int position;
+
+ if (simple_enum (xin, attrs, pos, &position))
+ gog_data_label_set_position (GOG_DATA_LABEL (state->cur_obj), position);
+}
+
+static void
+xlsx_data_label_index (GsfXMLIn *xin, xmlChar const **attrs)
+{
+ XLSXReadState *state = (XLSXReadState *)xin->user_state;
+ int index;
+ if (simple_int (xin, attrs, &index))
+ g_object_set (state->cur_obj, "index", index, NULL);
+}
+
+static void
+xlsx_data_label_show_val (GsfXMLIn *xin, xmlChar const **attrs)
+{
+ XLSXReadState *state = (XLSXReadState *)xin->user_state;
+ gboolean has_val;
+ if (GOG_IS_DATA_LABEL (state->cur_obj) && attr_bool (xin, attrs, "val", &has_val)) {
+ GogPlotDesc const *desc = gog_plot_description (state->plot);
+ unsigned i;
+ char *f, *new_f;
+ g_object_get (state->cur_obj, "format", &f, NULL);
+ /* seems that xl does not show anything else if a custom label is given */
+ if (strstr (f, "%c") != NULL) {
+ g_free (f);
+ return;
+ }
+ for (i = 0; i < desc->series.num_dim; i++)
+ if (desc->series.dim[i].ms_type == GOG_MS_DIM_VALUES)
+ break;
+ if (i != desc->series.num_dim) {
+ new_f = (f && *f)? g_strdup_printf ("%s %%%d", f, i): g_strdup_printf ("%%%d", i);
+ g_object_set (state->cur_obj, "format", new_f, NULL);
+ g_free (new_f);
+ }
+ g_free (f);
+ }
+}
+
+static void
+xlsx_data_label_show_cat (GsfXMLIn *xin, xmlChar const **attrs)
+{
+ XLSXReadState *state = (XLSXReadState *)xin->user_state;
+ gboolean has_cat;
+ if (GOG_IS_DATA_LABEL (state->cur_obj) && attr_bool (xin, attrs, "val", &has_cat)) {
+ GogPlotDesc const *desc = gog_plot_description (state->plot);
+ unsigned i;
+ char *f, *new_f;
+ g_object_get (state->cur_obj, "format", &f, NULL);
+ /* seems that xl does not show anything else if a custom label is given */
+ if (strstr (f, "%c") != NULL) {
+ g_free (f);
+ return;
+ }
+ for (i = 0; i < desc->series.num_dim; i++)
+ if (desc->series.dim[i].ms_type == GOG_MS_DIM_CATEGORIES)
+ break;
+ if (i != desc->series.num_dim) {
+ new_f = (f && *f)? g_strdup_printf ("%s %%%d", f, i): g_strdup_printf ("%%%d", i);
+ g_object_set (state->cur_obj, "format", new_f, NULL);
+ g_free (new_f);
+ }
+ g_free (f);
+ }
+}
+
+static void
+xlsx_data_label_start (GsfXMLIn *xin, xmlChar const **attrs)
+{
+ XLSXReadState *state = (XLSXReadState *)xin->user_state;
+ GogObject *data = gog_object_add_by_name (state->cur_obj, "Point", NULL);
+ g_object_set (data, "format", "", "offset", 3, NULL);
+ xlsx_chart_push_obj (state, data);
+}
+
static void
xlsx_chart_ser_f (GsfXMLIn *xin, G_GNUC_UNUSED GsfXMLBlob *blob)
{
@@ -879,10 +1007,10 @@ xlsx_chart_ser_f (GsfXMLIn *xin, G_GNUC_UNUSED GsfXMLBlob *blob)
GnmExprTop const *texpr = xlsx_parse_expr (xin, xin->content->str,
parse_pos_init_sheet (&pp, state->sheet));
- XL_gog_series_set_dim (state->series, state->dim_type,
- (state->dim_type != GOG_MS_DIM_LABELS)
+ gog_series_set_XL_dim (state->series, state->dim_type,
+ ((state->dim_type != GOG_MS_DIM_LABELS)
? gnm_go_data_vector_new_expr (state->sheet, texpr)
- : gnm_go_data_scalar_new_expr (state->sheet, texpr));
+ : gnm_go_data_scalar_new_expr (state->sheet, texpr)), NULL);
} else if (GOG_IS_LABEL (state->cur_obj)) {
GnmParsePos pp;
GnmExprTop const *texpr = xlsx_parse_expr (xin, xin->content->str,
@@ -894,14 +1022,25 @@ xlsx_chart_ser_f (GsfXMLIn *xin, G_GNUC_UNUSED GsfXMLBlob *blob)
GnmParsePos pp;
GnmExprTop const *texpr = xlsx_parse_expr (xin, xin->content->str,
parse_pos_init_sheet (&pp, state->sheet));
- char *f, *new_f;
+ char *new_f;
gog_dataset_set_dim (GOG_DATASET (state->cur_obj), 0,
gnm_go_data_vector_new_expr (state->sheet, texpr), NULL);
- g_object_get (state->cur_obj, "format", &f, NULL);
- new_f = (f && *f)? g_strconcat (f, " %c", NULL): g_strdup ("%c");
+ /* seems that xl does not show anything else in that case, even if showVal is there */
+ new_f = g_strdup ("%c");
+ g_object_set (state->cur_obj, "format", new_f, NULL);
+ g_free (new_f);
+ } else if (GOG_IS_DATA_LABEL (state->cur_obj)) {
+ GnmParsePos pp;
+ GnmExprTop const *texpr = xlsx_parse_expr (xin, xin->content->str,
+ parse_pos_init_sheet (&pp, state->sheet));
+ char *new_f;
+
+ gog_dataset_set_dim (GOG_DATASET (state->cur_obj), 0,
+ gnm_go_data_scalar_new_expr (state->sheet, texpr), NULL);
+ /* seems that xl does not show anything else in that case, even if showVal is there */
+ new_f = g_strdup ("%c");
g_object_set (state->cur_obj, "format", new_f, NULL);
- g_free (f);
g_free (new_f);
}
}
@@ -1092,7 +1231,7 @@ xlsx_chart_solid_fill (GsfXMLIn *xin, xmlChar const **attrs)
state->color_setter = (void (*) (gpointer data, GOColor color)) go_marker_set_outline_color;
state->color_data = state->marker;
}
- } else if (NULL != state->cur_style) {
+ } else if ((NULL != state->cur_style) && (state->gocolor == NULL)) {
if (!(state->sp_type & GO_STYLE_LINE)) {
state->cur_style->fill.type = GO_STYLE_FILL_PATTERN;
state->cur_style->fill.auto_type = FALSE;
@@ -1145,7 +1284,7 @@ xlsx_draw_color_themed (GsfXMLIn *xin, xmlChar const **attrs)
state->color = GPOINTER_TO_UINT (val);
if (state->gocolor) {
if (*state->gocolor != state->color) {
- *state->gocolor =state-> color;
+ *state->gocolor = state->color;
if (state->auto_color)
*state->auto_color = FALSE;
}
@@ -1398,12 +1537,12 @@ GSF_XML_IN_NODE_FULL (START, CHART_SPACE, XL_NS_CHART, "chartSpace", GSF_XML_NO_
GSF_XML_IN_NODE (SHAPE_PR_LN, LN_ROUND, XL_NS_DRAW, "round", GSF_XML_NO_CONTENT, NULL, NULL),
GSF_XML_IN_NODE (SHAPE_PR_LN, LN_HEAD, XL_NS_DRAW, "headEnd", GSF_XML_NO_CONTENT, NULL, NULL),
GSF_XML_IN_NODE (SHAPE_PR_LN, LN_TAIL, XL_NS_DRAW, "tailEnd", GSF_XML_NO_CONTENT, NULL, NULL),
- GSF_XML_IN_NODE (SHAPE_PR, TEXT_PR, XL_NS_CHART, "txPr", GSF_XML_NO_CONTENT, NULL, NULL),
+ GSF_XML_IN_NODE (SHAPE_PR, TEXT_PR, XL_NS_CHART, "txPr", GSF_XML_NO_CONTENT, &xlsx_tx_pr, NULL),
GSF_XML_IN_NODE (TEXT_PR, TEXT_PR_BODY, XL_NS_DRAW, "bodyPr", GSF_XML_NO_CONTENT, &xlsx_body_pr, NULL),
GSF_XML_IN_NODE (TEXT_PR, TEXT_PR_STYLE, XL_NS_DRAW, "lstStyle", GSF_XML_NO_CONTENT, NULL, NULL),
GSF_XML_IN_NODE (TEXT_PR, TEXT_PR_P, XL_NS_DRAW, "p", GSF_XML_NO_CONTENT, NULL, NULL),
GSF_XML_IN_NODE (TEXT_PR_P, PR_P_PR, XL_NS_DRAW, "pPr", GSF_XML_NO_CONTENT, NULL, NULL),
- GSF_XML_IN_NODE (PR_P_PR, PR_P_PR_DEF, XL_NS_DRAW, "defRPr", GSF_XML_NO_CONTENT, NULL, NULL),
+ GSF_XML_IN_NODE (PR_P_PR, PR_P_PR_DEF, XL_NS_DRAW, "defRPr", GSF_XML_NO_CONTENT, &xlsx_draw_text_run_props, NULL),
GSF_XML_IN_NODE (PR_P_PR_DEF, PR_P_PR_DEF_CS, XL_NS_DRAW, "cs", GSF_XML_NO_CONTENT, NULL, NULL),
GSF_XML_IN_NODE (PR_P_PR_DEF, PR_P_PR_DEF_EA, XL_NS_DRAW, "ea", GSF_XML_NO_CONTENT, NULL, NULL),
GSF_XML_IN_NODE (PR_P_PR_DEF, PR_P_PR_DEF_LATIN, XL_NS_DRAW, "latin", GSF_XML_NO_CONTENT, NULL, NULL),
@@ -1477,7 +1616,7 @@ GSF_XML_IN_NODE_FULL (START, CHART_SPACE, XL_NS_CHART, "chartSpace", GSF_XML_NO_
GSF_XML_IN_NODE (TITLE, TEXT, XL_NS_CHART, "tx", GSF_XML_NO_CONTENT, &xlsx_chart_text_start, &xlsx_chart_text),
GSF_XML_IN_NODE (TEXT, TX_RICH, XL_NS_CHART, "rich", GSF_XML_NO_CONTENT, NULL, NULL),
GSF_XML_IN_NODE (TX_RICH, TX_RICH_BODY, XL_NS_CHART, "bodyP", GSF_XML_NO_CONTENT, NULL, NULL),
- GSF_XML_IN_NODE (TX_RICH, TX_RICH_BODY_PR, XL_NS_DRAW, "bodyPr", GSF_XML_NO_CONTENT, NULL, NULL),
+ GSF_XML_IN_NODE (TX_RICH, TEXT_PR_BODY, XL_NS_DRAW, "bodyPr", GSF_XML_NO_CONTENT, NULL, NULL),
GSF_XML_IN_NODE (TX_RICH, TX_RICH_STYLES, XL_NS_DRAW, "lstStyle", GSF_XML_NO_CONTENT, NULL, NULL),
GSF_XML_IN_NODE (TX_RICH, TX_RICH_P, XL_NS_DRAW, "p", GSF_XML_NO_CONTENT, &xlsx_chart_p_start, NULL),
GSF_XML_IN_NODE (TX_RICH_P, PR_P_PR, XL_NS_DRAW, "pPr", GSF_XML_NO_CONTENT, NULL, NULL), /* 2nd Def */
@@ -1600,23 +1739,23 @@ GSF_XML_IN_NODE_FULL (START, CHART_SPACE, XL_NS_CHART, "chartSpace", GSF_XML_NO_
GSF_XML_IN_NODE (SERIES, SHAPE_PR, XL_NS_CHART, "spPr", GSF_XML_NO_CONTENT, NULL, NULL), /* 2nd Def */
GSF_XML_IN_NODE (SERIES, SERIES_SMOOTH, XL_NS_CHART, "smooth", GSF_XML_NO_CONTENT, NULL, NULL),
GSF_XML_IN_NODE (SERIES, SERIES_IDX, XL_NS_CHART, "idx", GSF_XML_NO_CONTENT, NULL, NULL),
- GSF_XML_IN_NODE (SERIES, SERIES_D_LBLS, XL_NS_CHART, "dLbls", GSF_XML_NO_CONTENT, &xlsx_ser_data_start, &xlsx_chart_pop),
- GSF_XML_IN_NODE (SERIES_D_LBLS, SERIES_D_LBL_POS, XL_NS_CHART, "dLblPos", GSF_XML_NO_CONTENT, &xlsx_ser_data_pos, NULL),
- GSF_XML_IN_NODE (SERIES_D_LBLS, SERIES_D_LBL, XL_NS_CHART, "dLbl", GSF_XML_NO_CONTENT, NULL, NULL),
- GSF_XML_IN_NODE (SERIES_D_LBL, SERIES_D_LBL_POS, XL_NS_CHART, "dLblPos", GSF_XML_NO_CONTENT, NULL, NULL),
- GSF_XML_IN_NODE (SERIES_D_LBL, SERIES_D_LBL_IDX, XL_NS_CHART, "idx", GSF_XML_NO_CONTENT, NULL, NULL),
+ GSF_XML_IN_NODE (SERIES, SERIES_D_LBLS, XL_NS_CHART, "dLbls", GSF_XML_NO_CONTENT, &xlsx_ser_labels_start, &xlsx_ser_labels_end),
+ GSF_XML_IN_NODE (SERIES_D_LBLS, SERIES_D_LBLS_POS, XL_NS_CHART, "dLblPos", GSF_XML_NO_CONTENT, &xlsx_ser_labels_pos, NULL),
+ GSF_XML_IN_NODE (SERIES_D_LBLS, SERIES_D_LBL, XL_NS_CHART, "dLbl", GSF_XML_NO_CONTENT, &xlsx_data_label_start, &xlsx_chart_pop),
+ GSF_XML_IN_NODE (SERIES_D_LBL, SERIES_D_LBL_POS, XL_NS_CHART, "dLblPos", GSF_XML_NO_CONTENT, &xlsx_data_label_pos, NULL),
+ GSF_XML_IN_NODE (SERIES_D_LBL, SERIES_D_LBL_IDX, XL_NS_CHART, "idx", GSF_XML_NO_CONTENT, &xlsx_data_label_index, NULL),
GSF_XML_IN_NODE (SERIES_D_LBL, SERIES_D_LBL_LAYOUT, XL_NS_CHART, "layout", GSF_XML_NO_CONTENT, NULL, NULL),
- GSF_XML_IN_NODE (SERIES_D_LBL, SERIES_D_LBL_SHOW_VAL, XL_NS_CHART, "showVal", GSF_XML_NO_CONTENT, &xlsx_ser_data_show_val, NULL),
- GSF_XML_IN_NODE (SERIES_D_LBL, SERIES_D_LBL_SHOW_CAT, XL_NS_CHART, "showCatName", GSF_XML_NO_CONTENT, &xlsx_ser_data_show_cat, NULL),
+ GSF_XML_IN_NODE (SERIES_D_LBL, SERIES_D_LBL_SHOW_VAL, XL_NS_CHART, "showVal", GSF_XML_NO_CONTENT, &xlsx_data_label_show_val, NULL),
+ GSF_XML_IN_NODE (SERIES_D_LBL, SERIES_D_LBL_SHOW_CAT, XL_NS_CHART, "showCatName", GSF_XML_NO_CONTENT, &xlsx_data_label_show_cat, NULL),
GSF_XML_IN_NODE (SERIES_D_LBL, SHAPE_PR, XL_NS_CHART, "spPr", GSF_XML_NO_CONTENT, NULL, NULL), /* 2nd Def */
GSF_XML_IN_NODE (SERIES_D_LBL, TEXT, XL_NS_CHART, "tx", GSF_XML_NO_CONTENT, NULL, NULL),
GSF_XML_IN_NODE (SERIES_D_LBL, TEXT_PR, XL_NS_CHART, "txPr", GSF_XML_NO_CONTENT, NULL, NULL), /* 2nd Def */
GSF_XML_IN_NODE (SERIES_D_LBLS, SHAPE_PR, XL_NS_CHART, "spPr", GSF_XML_NO_CONTENT, NULL, NULL), /* 2nd Def */
GSF_XML_IN_NODE (SERIES_D_LBLS, TEXT_PR, XL_NS_CHART, "txPr", GSF_XML_NO_CONTENT, NULL, NULL), /* 2nd Def */
- GSF_XML_IN_NODE (SERIES_D_LBLS, SHOW_VAL, XL_NS_CHART, "showVal", GSF_XML_NO_CONTENT, NULL, NULL),
+ GSF_XML_IN_NODE (SERIES_D_LBLS, SHOW_VAL, XL_NS_CHART, "showVal", GSF_XML_NO_CONTENT, &xlsx_ser_labels_show_val, NULL),
GSF_XML_IN_NODE (SERIES_D_LBLS, NUM_FMT, XL_NS_CHART, "numFmt", GSF_XML_NO_CONTENT, NULL, NULL),
GSF_XML_IN_NODE (SERIES_D_LBLS, SHOW_BUBBLE, XL_NS_CHART, "showBubbleSize", GSF_XML_NO_CONTENT, NULL, NULL),
- GSF_XML_IN_NODE (SERIES_D_LBLS, SHOW_CAT_NAME, XL_NS_CHART, "showCatName", GSF_XML_NO_CONTENT, NULL, NULL),
+ GSF_XML_IN_NODE (SERIES_D_LBLS, SHOW_CAT_NAME, XL_NS_CHART, "showCatName", GSF_XML_NO_CONTENT, &xlsx_ser_labels_show_cat, NULL),
GSF_XML_IN_NODE (SERIES_D_LBLS, SHOW_LEADERS, XL_NS_CHART, "showLeaderLines", GSF_XML_NO_CONTENT, NULL, NULL),
GSF_XML_IN_NODE (SERIES_D_LBLS, SHOW_PERCENT, XL_NS_CHART, "showPercent", GSF_XML_NO_CONTENT, NULL, NULL),
diff --git a/src/graph.c b/src/graph.c
index d89a02b..1a3288b 100644
--- a/src/graph.c
+++ b/src/graph.c
@@ -382,9 +382,12 @@ gnm_go_data_scalar_get_str (GODataScalar *dat)
GnmEvalPos ep;
eval_pos_init_dep (&ep, &scalar->dep);
+ fmt = auto_style_format_suggest (scalar->dep.texpr, &ep);
scalar->val_str =
render_val (scalar_get_val (scalar), 0, 0, fmt, &ep);
}
+ if (fmt)
+ go_format_unref (fmt);
return scalar->val_str;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]