[gnumeric] xls: fix reading of sheet object colours.
- From: Morten Welinder <mortenw src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gnumeric] xls: fix reading of sheet object colours.
- Date: Tue, 6 Oct 2009 13:37:41 +0000 (UTC)
commit b86617493828aae01c13ce8cc55b841e33dcefb7
Author: Morten Welinder <terra gnome org>
Date: Tue Oct 6 09:37:26 2009 -0400
xls: fix reading of sheet object colours.
ChangeLog | 6 ++++
NEWS | 1 +
plugins/excel/ChangeLog | 6 ++++
plugins/excel/ms-excel-read.c | 65 ++++++++++++++++++++++++++---------------
samples/excel/objs.xls | Bin 221696 -> 221696 bytes
src/gnm-so-filled.c | 11 ++++---
src/gnm-so-line.c | 8 +++--
src/gnm-so-polygon.c | 14 ++++----
8 files changed, 72 insertions(+), 39 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 3555d3e..de6ee62 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+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
diff --git a/NEWS b/NEWS
index d6222ab..c464436 100644
--- a/NEWS
+++ b/NEWS
@@ -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
diff --git a/plugins/excel/ChangeLog b/plugins/excel/ChangeLog
index e9b908f..4288ba5 100644
--- a/plugins/excel/ChangeLog
+++ b/plugins/excel/ChangeLog
@@ -1,3 +1,9 @@
+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
diff --git a/plugins/excel/ms-excel-read.c b/plugins/excel/ms-excel-read.c
index 031d058..b624d1d 100644
--- a/plugins/excel/ms-excel-read.c
+++ b/plugins/excel/ms-excel-read.c
@@ -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:
diff --git a/samples/excel/objs.xls b/samples/excel/objs.xls
index e2f7507..fec5966 100644
Binary files a/samples/excel/objs.xls and b/samples/excel/objs.xls differ
diff --git a/src/gnm-so-filled.c b/src/gnm-so-filled.c
index 158b2dd..459d31f 100644
--- a/src/gnm-so-filled.c
+++ b/src/gnm-so-filled.c
@@ -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;
diff --git a/src/gnm-so-line.c b/src/gnm-so-line.c
index f5ec7e5..62b5ab0 100644
--- a/src/gnm-so-line.c
+++ b/src/gnm-so-line.c
@@ -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;
diff --git a/src/gnm-so-polygon.c b/src/gnm-so-polygon.c
index 5f7f10f..cfc96bf 100644
--- a/src/gnm-so-polygon.c
+++ b/src/gnm-so-polygon.c
@@ -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)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]