[gnumeric] xls: fix import of line styles.



commit 88ffcb569e969da5c841d59b39ee9bbea77a1918
Author: Morten Welinder <terra gnome org>
Date:   Wed Oct 14 20:33:21 2009 -0400

    xls: fix import of line styles.

 NEWS                          |    1 +
 plugins/excel/ChangeLog       |    7 +++++++
 plugins/excel/ms-escher.c     |    1 -
 plugins/excel/ms-excel-read.c |   22 +++++++++++++++++-----
 4 files changed, 25 insertions(+), 6 deletions(-)
---
diff --git a/NEWS b/NEWS
index 76caa8c..f7d681a 100644
--- a/NEWS
+++ b/NEWS
@@ -15,6 +15,7 @@ Morten:
 	* Add xls export of list widgets.  [Part of #597035]
 	* Add xls export of combo widgets.  [Part of #597035]
 	* Add xls export of button widgets.  [Part of #597035]
+	* Fix xls import of line styles.
 
 --------------------------------------------------------------------------
 Gnumeric 1.9.14
diff --git a/plugins/excel/ChangeLog b/plugins/excel/ChangeLog
index 948d8e9..10e5aeb 100644
--- a/plugins/excel/ChangeLog
+++ b/plugins/excel/ChangeLog
@@ -1,5 +1,12 @@
 2009-10-14  Morten Welinder  <terra gnome org>
 
+	* ms-escher.c (ms_escher_read_OPT): Don't arbitrarily add 1 to
+	MS_OBJ_ATTR_OUTLINE_STYLE's value.
+
+	* ms-excel-read.c (ms_sheet_realize_obj): Read dash style
+	correctly.
+	(xl_pattern_to_line_type): Fix mapping.
+
 	* ms-excel-write.c (excel_write_line_v8): Export line start arrow
 	head too.
 
diff --git a/plugins/excel/ms-escher.c b/plugins/excel/ms-escher.c
index 7c823d9..b8c698d 100644
--- a/plugins/excel/ms-escher.c
+++ b/plugins/excel/ms-escher.c
@@ -1620,7 +1620,6 @@ ms_escher_read_OPT (MSEscherState *state, MSEscherHeader *h)
 		/* Solid : Can be overridden by: */
 		case 462 : id = MS_OBJ_ATTR_OUTLINE_STYLE;
 			   name = "DashedLineStyle lineDashing";
-			   val++;
 			   break;
 		/* NULL : As Win32 ExtCreatePen */
 		case 463 : name = "IMsoArray lineDashStyle"; break;
diff --git a/plugins/excel/ms-excel-read.c b/plugins/excel/ms-excel-read.c
index 212c449..ff51bdf 100644
--- a/plugins/excel/ms-excel-read.c
+++ b/plugins/excel/ms-excel-read.c
@@ -470,8 +470,14 @@ xl_pattern_to_line_type (guint16 pattern)
 		GO_LINE_DOT,
 		GO_LINE_DASH_DOT,
 		GO_LINE_DASH_DOT_DOT,
-		GO_LINE_NONE
+		GO_LINE_DOT, /* ? */
+		GO_LINE_DASH,
+		GO_LINE_DASH, /* Long dash */
+		GO_LINE_DASH_DOT,
+		GO_LINE_DASH_DOT, /* Long dash dot */
+		GO_LINE_DASH_DOT_DOT  /* Long dash dot dot */
 	};
+
 	return (pattern >= G_N_ELEMENTS (dash_map))? GO_LINE_SOLID: dash_map[pattern];
 }
 
@@ -553,9 +559,12 @@ ms_sheet_realize_obj (MSContainer *container, MSObj *obj)
 			 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)
+		style->line.auto_dash =
+			(ms_obj_attr_bag_lookup (obj->attrs, MS_OBJ_ATTR_OUTLINE_HIDE) != NULL);
+		style->line.dash_type = style->line.auto_dash
 			? GO_LINE_NONE
-			: xl_pattern_to_line_type (ms_obj_attr_get_int (obj->attrs, MS_OBJ_ATTR_OUTLINE_STYLE, 1));
+			: xl_pattern_to_line_type (ms_obj_attr_get_int (obj->attrs, MS_OBJ_ATTR_OUTLINE_STYLE, 0));
+
 		g_object_set (G_OBJECT (so), "style", style, NULL);
 		g_object_unref (style);
 
@@ -583,8 +592,11 @@ ms_sheet_realize_obj (MSContainer *container, MSObj *obj)
 			 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->line.auto_dash =
+			(ms_obj_attr_bag_lookup (obj->attrs, MS_OBJ_ATTR_OUTLINE_HIDE) != NULL);
+		style->line.dash_type = style->line.auto_dash
+			? GO_LINE_NONE
+			: xl_pattern_to_line_type (ms_obj_attr_get_int (obj->attrs, MS_OBJ_ATTR_OUTLINE_STYLE, 0));
 		style->fill.pattern.back = ms_sheet_map_color
 			(esheet, obj, MS_OBJ_ATTR_FILL_COLOR,
 			 GO_COLOR_WHITE, &style->fill.auto_back);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]