Commit b8661749 authored by Morten Welinder's avatar Morten Welinder

xls: fix reading of sheet object colours.

parent 46be1389
2009-10-06 Morten Welinder <terra@gnome.org>
* src/gnm-so-filled.c (gnm_so_line_set_property,
gnm_so_filled_set_property, gnm_so_polygon_set_property): Copy
style since we change it.
2009-10-05 Morten Welinder <terra@gnome.org>
* src/gnm-so-line.c (gnm_so_line_class_init): Make is-arrow
......
......@@ -30,6 +30,7 @@ Morten:
* Start cleaning up xls sheet object writing.
* Plug xls export leaks.
* Implement export of lines and arrows to xls. [Part of #597035]
* Fix xls reading of sheet object colours.
--------------------------------------------------------------------------
Gnumeric 1.9.13
......
2009-10-06 Morten Welinder <terra@gnome.org>
* ms-excel-read.c (ms_sheet_realize_obj): Restore colour reading.
(ms_sheet_map_color): Add new "pauto" argument. All callers
changed.
2009-10-05 Morten Welinder <terra@gnome.org>
* ms-excel-write.c (excel_write_textbox_v8): Export
......
......@@ -334,13 +334,16 @@ ms_sheet_get_fmt (MSContainer const *container, unsigned indx)
}
static GOColor
ms_sheet_map_color (ExcelReadSheet const *esheet, MSObj const *obj, MSObjAttrID id, GOColor default_val)
ms_sheet_map_color (ExcelReadSheet const *esheet, MSObj const *obj, MSObjAttrID id,
GOColor default_val, gboolean *pauto)
{
gushort r, g, b;
MSObjAttr *attr = ms_obj_attr_bag_lookup (obj->attrs, id);
if (attr == NULL)
if (attr == NULL) {
if (pauto) *pauto = TRUE;
return default_val;
}
if ((~0x7ffffff) & attr->v.v_uint) {
GnmColor *c = excel_palette_get (esheet->container.importer,
......@@ -356,6 +359,8 @@ ms_sheet_map_color (ExcelReadSheet const *esheet, MSObj const *obj, MSObjAttrID
b = (attr->v.v_uint >> 16) & 0xff;
}
if (pauto) *pauto = FALSE;
return GO_COLOR_FROM_RGBA (r,g,b,0xff);
}
......@@ -520,12 +525,14 @@ ms_sheet_realize_obj (MSContainer *container, MSObj *obj)
case 0x01: /* Line */
case 0x04: /* Arc */
style = go_style_new ();
style->line.color = ms_sheet_map_color (esheet, obj,
MS_OBJ_ATTR_OUTLINE_COLOR, GO_COLOR_BLACK);
style->line.color = ms_sheet_map_color
(esheet, obj, MS_OBJ_ATTR_OUTLINE_COLOR,
GO_COLOR_BLACK, &style->line.auto_color);
style->line.width = ms_obj_attr_get_uint (obj->attrs,
MS_OBJ_ATTR_OUTLINE_WIDTH, 0) / 256.;
style->line.dash_type = ms_obj_attr_bag_lookup (obj->attrs, MS_OBJ_ATTR_OUTLINE_HIDE)
? GO_LINE_NONE : xl_pattern_to_line_type (ms_obj_attr_get_int (obj->attrs, MS_OBJ_ATTR_OUTLINE_STYLE, 1));
? GO_LINE_NONE
: xl_pattern_to_line_type (ms_obj_attr_get_int (obj->attrs, MS_OBJ_ATTR_OUTLINE_STYLE, 1));
g_object_set (G_OBJECT (so), "style", style, NULL);
g_object_unref (style);
break;
......@@ -541,16 +548,19 @@ ms_sheet_realize_obj (MSContainer *container, MSObj *obj)
case 0x06: /* TextBox */
case 0x0E: /* Label */
style = go_style_new ();
style->line.color = ms_sheet_map_color (esheet, obj,
MS_OBJ_ATTR_OUTLINE_COLOR, GO_COLOR_BLACK);
style->line.color = ms_sheet_map_color
(esheet, obj, MS_OBJ_ATTR_OUTLINE_COLOR,
GO_COLOR_BLACK, &style->line.auto_color);
style->line.width = ms_obj_attr_get_uint (obj->attrs,
MS_OBJ_ATTR_OUTLINE_WIDTH, 0) / 256.;
style->line.dash_type = ms_obj_attr_bag_lookup (obj->attrs, MS_OBJ_ATTR_OUTLINE_HIDE)
? GO_LINE_NONE : xl_pattern_to_line_type (ms_obj_attr_get_int (obj->attrs, MS_OBJ_ATTR_OUTLINE_STYLE, 1));
style->fill.pattern.back = ms_sheet_map_color (esheet, obj,
MS_OBJ_ATTR_FILL_COLOR, GO_COLOR_WHITE);
style->fill.pattern.fore = ms_sheet_map_color (esheet, obj,
MS_OBJ_ATTR_FILL_BACKGROUND, GO_COLOR_BLACK);
style->fill.pattern.back = ms_sheet_map_color
(esheet, obj, MS_OBJ_ATTR_FILL_COLOR,
GO_COLOR_WHITE, &style->fill.auto_back);
style->fill.pattern.fore = ms_sheet_map_color
(esheet, obj, MS_OBJ_ATTR_FILL_BACKGROUND,
GO_COLOR_BLACK, &style->fill.auto_fore);
style->fill.type = ms_obj_attr_bag_lookup (obj->attrs, MS_OBJ_ATTR_UNFILLED)
? GO_STYLE_FILL_NONE : GO_STYLE_FILL_PATTERN;
......@@ -660,7 +670,6 @@ static SheetObject *
ms_sheet_create_obj (MSContainer *container, MSObj *obj)
{
SheetObject *so = NULL;
gpointer label;
if (obj == NULL)
return NULL;
......@@ -683,8 +692,6 @@ ms_sheet_create_obj (MSContainer *container, MSObj *obj)
so = g_object_new (GNM_SO_FILLED_TYPE,
"is-oval", obj->excel_type == 3,
NULL);
if (ms_obj_attr_get_ptr (obj->attrs, MS_OBJ_ATTR_TEXT, &label, FALSE))
g_object_set (G_OBJECT (so), "text", label, NULL);
break;
case 0x05: /* Chart */
......@@ -692,21 +699,29 @@ ms_sheet_create_obj (MSContainer *container, MSObj *obj)
break;
/* Button */
case 0x07: so = g_object_new (sheet_widget_button_get_type (), NULL);
case 0x07:
so = g_object_new (sheet_widget_button_get_type (), NULL);
break;
case 0x08: so = g_object_new (SHEET_OBJECT_IMAGE_TYPE, NULL); /* Picture */
case 0x08:
so = g_object_new (SHEET_OBJECT_IMAGE_TYPE, NULL); /* Picture */
break;
case 0x09: so = g_object_new (GNM_SO_POLYGON_TYPE, NULL);
case 0x09:
so = g_object_new (GNM_SO_POLYGON_TYPE, NULL);
break;
case 0x0B: so = g_object_new (sheet_widget_checkbox_get_type (), NULL);
case 0x0B:
so = g_object_new (sheet_widget_checkbox_get_type (), NULL);
break;
case 0x0C: so = g_object_new (sheet_widget_radio_button_get_type (), NULL);
case 0x0C:
so = g_object_new (sheet_widget_radio_button_get_type (), NULL);
break;
case 0x10: so = g_object_new (sheet_widget_spinbutton_get_type (), NULL);
case 0x10:
so = g_object_new (sheet_widget_spinbutton_get_type (), NULL);
break;
case 0x11: so = g_object_new (sheet_widget_scrollbar_get_type (), NULL);
case 0x11:
so = g_object_new (sheet_widget_scrollbar_get_type (), NULL);
break;
case 0x12: so = g_object_new (sheet_widget_list_get_type (), NULL);
case 0x12:
so = g_object_new (sheet_widget_list_get_type (), NULL);
break;
/* ignore combos associateed with filters */
......@@ -722,11 +737,13 @@ ms_sheet_create_obj (MSContainer *container, MSObj *obj)
}
break;
case 0x19: so = g_object_new (cell_comment_get_type (), NULL);
case 0x19:
so = g_object_new (cell_comment_get_type (), NULL);
break;
/* Gnumeric specific addition to handle toggle button controls */
case 0x70: so = g_object_new (sheet_widget_toggle_button_get_type (), NULL);
case 0x70:
so = g_object_new (sheet_widget_toggle_button_get_type (), NULL);
break;
default:
......
No preview for this file type
......@@ -413,12 +413,13 @@ gnm_so_filled_set_property (GObject *obj, guint param_id,
char const * str;
switch (param_id) {
case SOF_PROP_STYLE:
style = sof->style;
sof->style = g_object_ref (g_value_get_object (value));
sof->style->interesting_fields = GO_STYLE_OUTLINE | GO_STYLE_FILL;
g_object_unref (style);
case SOF_PROP_STYLE: {
GOStyle *style = go_style_dup (g_value_get_object (value));
style->interesting_fields = GO_STYLE_OUTLINE | GO_STYLE_FILL;
g_object_unref (sof->style);
sof->style = style;
break;
}
case SOF_PROP_IS_OVAL:
sof->is_oval = g_value_get_boolean (value);
break;
......
......@@ -338,11 +338,13 @@ gnm_so_line_set_property (GObject *obj, guint param_id,
{
GnmSOLine *sol = GNM_SO_LINE (obj);
switch (param_id) {
case SOL_PROP_STYLE:
case SOL_PROP_STYLE: {
GOStyle *style = go_style_dup (g_value_get_object (value));
style->interesting_fields = GO_STYLE_LINE;
g_object_unref (sol->style);
sol->style = g_object_ref (g_value_get_object (value));
sol->style->interesting_fields = GO_STYLE_LINE;
sol->style = style;
break;
}
case SOL_PROP_START_ARROW:
go_arrow_copy (&sol->start_arrow, g_value_get_pointer (value));
break;
......
......@@ -212,19 +212,19 @@ gnm_so_polygon_copy (SheetObject *dst, SheetObject const *src)
static void
gnm_so_polygon_set_property (GObject *obj, guint param_id,
GValue const *value, GParamSpec *pspec)
GValue const *value, GParamSpec *pspec)
{
GnmSOPolygon *sop = GNM_SO_POLYGON (obj);
GArray *points;
GOStyle *style;
switch (param_id) {
case SOP_PROP_STYLE:
style = sop->style;
sop->style = g_object_ref (g_value_get_object (value));
sop->style->interesting_fields = GO_STYLE_OUTLINE | GO_STYLE_FILL;
g_object_unref (style);
case SOP_PROP_STYLE: {
GOStyle *style = go_style_dup (g_value_get_object (value));
style->interesting_fields = GO_STYLE_OUTLINE | GO_STYLE_FILL;
g_object_unref (sop->style);
sop->style = style;
break;
}
case SOP_PROP_POINTS:
points = g_value_get_pointer (value);
if (!points)
......
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