Commit a7e6356e authored by Jean Bréfort's avatar Jean Bréfort Committed by Jean Bréfort

fixed import x error bars.

2005-08-02  Jean Brefort  <jean.brefort@normalesup.org>

	* ms-chart.c: (ms_excel_chart_read): fixed import x error bars.
parent 9926d35d
2005-08-02 Jean Brefort <jean.brefort@normalesup.org>
* ms-chart.c: (ms_excel_chart_read): fixed import x error bars.
2005-07-29 Jody Goldberg <jody@gnome.org>
* ms-chart.c (BC_R(objectlink)) : store the style for labels
......
......@@ -47,7 +47,6 @@
#include <goffice/graph/gog-label.h>
#include <goffice/data/go-data-simple.h>
#include <goffice/utils/go-color.h>
#include <goffice/utils/go-font.h>
#include <goffice/utils/go-pattern.h>
#include <goffice/utils/go-marker.h>
......@@ -137,7 +136,7 @@ struct _XLChartHandler {
XLChartReader const read_fn;
};
#define BC(n) xl_chart_ ## n
#define BC(n) biff_chart_ ## n
#define BC_R(n) BC(read_ ## n)
static inline MsBiffVersion
......@@ -181,11 +180,10 @@ BC_R(get_style) (XLChartReadState *s)
}
static int
BC_R(top_state) (XLChartReadState *s, unsigned n)
BC_R(top_state) (XLChartReadState *s)
{
g_return_val_if_fail (s != NULL, 0);
g_return_val_if_fail (s->stack->len >= n+1, 0);
return g_array_index (s->stack, int, s->stack->len-1-n);
return g_array_index (s->stack, int, s->stack->len-1);
}
static GOColor
......@@ -279,10 +277,10 @@ BC_R(ai)(XLChartHandler const *handle,
guint16 const flags = GSF_LE_GET_GUINT16 (q->data + 2);
guint16 const length = GSF_LE_GET_GUINT16 (q->data + 6);
int top_state = BC_R(top_state) (s, 0);
int popped_state = BC_R(top_state) (s);
/* ignore these for now */
if (top_state == BIFF_CHART_text)
if (popped_state == BIFF_CHART_text)
return FALSE;
/* Rest are 0 */
......@@ -907,17 +905,10 @@ static gboolean
BC_R(fontx)(XLChartHandler const *handle,
XLChartReadState *s, BiffQuery *q)
{
if (s->style != NULL) {
/* Child of TEXT, index into FONT table */
ExcelFont const *font = excel_font_get (s->container.importer,
GSF_LE_GET_GUINT16 (q->data));
GOFont const *gfont = excel_font_get_gofont (font);
go_font_ref (gfont);
gog_style_set_font (s->style, gfont);
d (-2, fprintf (stderr, "apply font;"););
} else {
d (-2, fprintf (stderr, "ignore font;"););
}
#if 0
/* Child of TEXT, index into FONT table */
guint16 const font = GSF_LE_GET_GUINT16 (q->data);
#endif
return FALSE;
}
......@@ -953,7 +944,7 @@ ms_chart_map_color (XLChartReadState const *s, guint32 raw, guint32 alpha)
{
GOColor res;
if ((~0x7ffffff) & raw) {
GnmColor *c = excel_palette_get (s->container.importer,
GnmColor *c= excel_palette_get (s->container.importer,
(0x7ffffff & raw));
res = GDK_TO_UINT (c->gdk_color);
style_color_unref (c);
......@@ -1210,7 +1201,7 @@ BC_R(lineformat)(XLChartHandler const *handle,
guint16 const flags = GSF_LE_GET_GUINT16 (q->data+8);
BC_R(get_style) (s);
switch (GSF_LE_GET_GINT16 (q->data+6)) {
switch (GSF_LE_GET_GUINT16 (q->data+6)) {
default :
case -1 : s->style->line.width = 0; /* hairline */
break;
......@@ -1228,7 +1219,7 @@ BC_R(lineformat)(XLChartHandler const *handle,
d (0, fprintf (stderr, "flags == %hd.\n", flags););
d (0, fprintf (stderr, "Lines are %f pts wide.\n", s->style->line.width););
d (0, fprintf (stderr, "Lines have a %s pattern.\n",
ms_line_pattern [s->style->line.pattern]););
ms_line_pattern [s->style->line.pattern ]););
if (s->style->line.pattern <= G_N_ELEMENTS (dash_map))
s->style->line.dash_type = dash_map [s->style->line.pattern];
......@@ -1359,8 +1350,6 @@ BC_R(objectlink)(XLChartHandler const *handle,
default :
fprintf (stderr, "ERROR : TEXT is linked to undocumented object\n");
};});
if (NULL != label && NULL != s->style)
gog_styled_object_set_style (GOG_STYLED_OBJECT (label), s->style);
return FALSE;
}
......@@ -1469,13 +1458,6 @@ static gboolean
BC_R(pos)(XLChartHandler const *handle,
XLChartReadState *s, BiffQuery *q)
{
switch (BC_R(top_state) (s, 0)) {
case BIFF_CHART_text :
fprintf (stderr, "text pos;");
break;
default :
;
}
return FALSE;
}
......@@ -1737,7 +1719,7 @@ BC_R(seriestext)(XLChartHandler const *handle,
gnm_go_data_scalar_new_expr (sheet, expr);
else
value_release (value);
} else if (BC_R(top_state) (s, 0) == BIFF_CHART_text) {
} else if (BC_R(top_state) (s) == BIFF_CHART_text) {
if (s->text != NULL) {
g_warning ("multiple seriestext associated with 1 text record ?");
g_free (str);
......@@ -1785,7 +1767,7 @@ typedef enum {
MS_CHART_BLANK_ZERO = 1,
MS_CHART_BLANK_INTERPOLATE = 2,
MS_CHART_BLANK_MAX = 3
} MSChartBlank;
} MS_CHART_BLANK;
static char const *const ms_chart_blank[] = {
"Skip blanks", "Blanks are zero", "Interpolate blanks"
};
......@@ -1801,7 +1783,7 @@ BC_R(shtprops)(XLChartHandler const *handle,
gboolean const dont_size_with_window = (flags&0x04) ? TRUE : FALSE;
gboolean const has_pos_record = (flags&0x08) ? TRUE : FALSE;
gboolean ignore_pos_record = FALSE;
MSChartBlank blanks;
MS_CHART_BLANK blanks;
g_return_val_if_fail (tmp < MS_CHART_BLANK_MAX, TRUE);
blanks = tmp;
......@@ -1942,7 +1924,7 @@ BC_R(tick)(XLChartHandler const *handle,
*/
if (flags&0x02)
fputs ("Auto text background mode\n", stderr);
fputs ("Auto text background mode", stderr);
else
fprintf (stderr, "background mode = %d\n", (unsigned)GSF_LE_GET_GUINT8 (q->data+3));
......@@ -2090,7 +2072,7 @@ BC_R(end)(XLChartHandler const *handle,
g_return_val_if_fail (s->stack != NULL, TRUE);
g_return_val_if_fail (s->stack->len > 0, TRUE);
popped_state = BC_R(top_state) (s, 0);
popped_state = BC_R(top_state) (s);
s->stack = g_array_remove_index_fast (s->stack, s->stack->len-1);
switch (popped_state) {
......@@ -2102,7 +2084,7 @@ BC_R(end)(XLChartHandler const *handle,
case BIFF_CHART_frame :
if (s->style != NULL) {
int top_state = BC_R(top_state) (s, 0);
int top_state = BC_R(top_state) (s);
GogObject *obj = NULL;
if (top_state == BIFF_CHART_legend)
obj = s->legend;
......@@ -2522,6 +2504,7 @@ not_a_matrix:
break;
case BIFF_CHART_text :
#warning Do something with the style
if (s->text != NULL) {
g_free (s->text);
s->text = NULL;
......@@ -2931,6 +2914,7 @@ ms_excel_chart_read (BiffQuery *q, MSContainer *container,
}
}
} else {
int orig_dim;
prop_name = NULL;
parent = g_ptr_array_index (state.series, series->err_parent);
state.plot = parent->series->plot;
......@@ -2979,17 +2963,17 @@ ms_excel_chart_read (BiffQuery *q, MSContainer *container,
/* not supported */
break;
case 4:
orig_dim = (series->err_type < 3)? GOG_MS_DIM_CATEGORIES: GOG_MS_DIM_VALUES;
error_bar->type = GOG_ERROR_BAR_TYPE_ABSOLUTE;
if (series->data[GOG_MS_DIM_VALUES].data) {
if (series->data[orig_dim].data) {
XL_gog_series_set_dim (parent->series, msdim,
series->data[GOG_MS_DIM_VALUES].data);
series->data[GOG_MS_DIM_VALUES].data = NULL;
} else if (series->data [GOG_MS_DIM_VALUES].value) {
series->data[orig_dim].data);
series->data[orig_dim].data = NULL;
} else if (series->data [orig_dim].value) {
expr = gnm_expr_new_constant ((GnmValue *)
series->data[GOG_MS_DIM_VALUES].value);
series->data[orig_dim].value);
data = gnm_go_data_vector_new_expr (sheet, expr);
XL_gog_series_set_dim (series->series,
GOG_MS_DIM_VALUES, data);
XL_gog_series_set_dim (parent->series, msdim, data);
}
break;
default:
......@@ -4187,6 +4171,9 @@ ms_excel_chart_write (ExcelWriteState *ewb, SheetObject *so)
XLAxisSet *axis_set = NULL;
GogPlot *cur_plot;
GError *error;
#if 0
GogLabel *label;
#endif
state.bp = ewb->bp;
state.ewb = ewb;
......@@ -4607,6 +4594,19 @@ ms_excel_chart_write (ExcelWriteState *ewb, SheetObject *so)
chart_write_axis_sets (&state, sets);
#if 0
/* write chart title if any */
label = GOG_LABEL (gog_object_get_children (GOG_OBJECT (state.chart),
gog_object_find_role_by_name (GOG_OBJECT (state.chart), "Title"))->data);
if (label != NULL) {
GOData *text = gog_dataset_get_dim (GOG_DATASET (label), 0);
if (text != NULL) {
chart_write_text (&state, text,
gog_styled_object_get_style (GOG_STYLED_OBJECT (label)));
}
}
#endif
for (i = 0; i < 3; i++) {
chart_write_siindex (&state, i + 1);
g_ptr_array_foreach (state.values[i], (GFunc) g_free, NULL);
......
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