[gnumeric] GnmSOLine: eliminate is-arrow property.



commit 2ceb576fe9dbe8e98c34ee681ad2c32c1b4f325b
Author: Morten Welinder <terra gnome org>
Date:   Wed Oct 14 13:42:46 2009 -0400

    GnmSOLine: eliminate is-arrow property.

 ChangeLog                      |    1 +
 plugins/excel/ChangeLog        |    5 +++++
 plugins/excel/ms-escher.h      |    1 +
 plugins/excel/ms-excel-read.c  |   31 +++++++++----------------------
 plugins/excel/ms-excel-write.c |   20 +++++++++++++++-----
 src/gnm-so-line.c              |   18 +-----------------
 src/wbc-gtk-actions.c          |    8 ++++++--
 src/xml-sax-read.c             |   10 ++++++++--
 8 files changed, 46 insertions(+), 48 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index eca06bc..0ad5b0b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,7 @@
 2009-10-14  Morten Welinder  <terra gnome org>
 
 	* src/gnm-so-line.c: Move GOArrow to goffice.
+	(gnm_so_line_set_property): Eliminate is-arrow property.
 
 	* configure.in (libspreadsheet_reqs): Require goffice 0.7.15 for
 	GOArrow.
diff --git a/plugins/excel/ChangeLog b/plugins/excel/ChangeLog
index 370f410..948d8e9 100644
--- a/plugins/excel/ChangeLog
+++ b/plugins/excel/ChangeLog
@@ -1,3 +1,8 @@
+2009-10-14  Morten Welinder  <terra gnome org>
+
+	* ms-excel-write.c (excel_write_line_v8): Export line start arrow
+	head too.
+
 2009-10-13  Morten Welinder  <terra gnome org>
 
 	* ms-formula-write.c (excel_write_array_formula): Set
diff --git a/plugins/excel/ms-escher.h b/plugins/excel/ms-escher.h
index dff1409..a516cc2 100644
--- a/plugins/excel/ms-escher.h
+++ b/plugins/excel/ms-escher.h
@@ -33,6 +33,7 @@ enum {
 	MSEP_NOFILLHITTEST       = 0x01bf,
 	MSEP_LINECOLOR           = 0x01c0,
 	MSEP_LINEWIDTH           = 0x01cb,
+	MSEP_LINESTARTARROWHEAD  = 0x01d0,
 	MSEP_LINEENDARROWHEAD    = 0x01d1,
 	MSEP_ARROWHEADSOK        = 0x01fb,
 	MSEP_LINE                = 0x01fc,
diff --git a/plugins/excel/ms-excel-read.c b/plugins/excel/ms-excel-read.c
index 7f4883d..212c449 100644
--- a/plugins/excel/ms-excel-read.c
+++ b/plugins/excel/ms-excel-read.c
@@ -546,9 +546,7 @@ ms_sheet_realize_obj (MSContainer *container, MSObj *obj)
 		break;
 
 	case MSOT_LINE:
-	case MSOT_ARC: {
-		gboolean is_arrow;
-
+	case MSOT_ARC:
 		style = go_style_new ();
 		style->line.color = ms_sheet_map_color
 			(esheet, obj, MS_OBJ_ATTR_OUTLINE_COLOR,
@@ -561,17 +559,13 @@ ms_sheet_realize_obj (MSContainer *container, MSObj *obj)
 		g_object_set (G_OBJECT (so), "style", style, NULL);
 		g_object_unref (style);
 
-		g_object_get (so, "is-arrow", &is_arrow, NULL);
-		if (is_arrow) {
-			handle_arrow_head (so, "start-arrow",
-					   obj->attrs,
-					   MS_OBJ_ATTR_ARROW_START);
-			handle_arrow_head (so, "end-arrow",
-					   obj->attrs,
-					   MS_OBJ_ATTR_ARROW_END);
-		}
+		handle_arrow_head (so, "start-arrow",
+				   obj->attrs,
+				   MS_OBJ_ATTR_ARROW_START);
+		handle_arrow_head (so, "end-arrow",
+				   obj->attrs,
+				   MS_OBJ_ATTR_ARROW_END);
 		break;
-	}
 
 	case MSOT_POLYGON:
 		g_object_set (G_OBJECT (so), "points",
@@ -716,16 +710,9 @@ ms_sheet_create_obj (MSContainer *container, MSObj *obj)
 
 	switch (obj->excel_type) {
 	case MSOT_LINE:
-	case MSOT_ARC: {
-		int arrow_end =
-			ms_obj_attr_get_int (obj->attrs, MS_OBJ_ATTR_ARROW_END, 0);
-		int arrow_start =
-			ms_obj_attr_get_int (obj->attrs, MS_OBJ_ATTR_ARROW_START, 0);
-		so = g_object_new (GNM_SO_LINE_TYPE,
-				   "is-arrow", arrow_end || arrow_start,
-				   NULL);
+	case MSOT_ARC:
+		so = g_object_new (GNM_SO_LINE_TYPE, NULL);
 		break;
-	}
 
 	case 0x00: /* draw the group border */
 	case MSOT_RECTANGLE:
diff --git a/plugins/excel/ms-excel-write.c b/plugins/excel/ms-excel-write.c
index d4ff97d..c6c9144 100644
--- a/plugins/excel/ms-excel-write.c
+++ b/plugins/excel/ms-excel-write.c
@@ -4545,7 +4545,6 @@ excel_write_widget_v8 (ExcelWriteSheet *esheet, SheetObject *so)
 static gsize
 excel_write_line_v8 (ExcelWriteSheet *esheet, SheetObject *so)
 {
-	gboolean is_arrow;
 	GString *escher = g_string_new (NULL);
 	GString *extra;
 	ExcelWriteState *ewb = esheet->ewb;
@@ -4559,9 +4558,11 @@ excel_write_line_v8 (ExcelWriteSheet *esheet, SheetObject *so)
 	char *name;
 	guint8 zero[4] = { 0, 0, 0, 0 };
 	GOStyle *style;
+	GOArrow *start_arrow, *end_arrow;
 
 	g_object_get (so,
-		      "is-arrow", &is_arrow,
+		      "start-arrow", &start_arrow,
+		      "end-arrow", &end_arrow,
 		      "name", &name,
 		      "style", &style,
 		      NULL);
@@ -4585,10 +4586,17 @@ excel_write_line_v8 (ExcelWriteSheet *esheet, SheetObject *so)
 		gint32 w = CLAMP (12700 * style->line.width, 0, G_MAXINT32);
 		ms_escher_opt_add_simple (escher, optmark, MSEP_LINEWIDTH, w);
 	}
-	if (is_arrow)
+	if (start_arrow->typ) {
 		ms_escher_opt_add_simple (escher, optmark,
-					  MSEP_LINEENDARROWHEAD, 1);
-	ms_escher_opt_add_bool (escher, optmark, MSEP_ARROWHEADSOK, is_arrow);
+					  MSEP_LINEENDARROWHEAD,
+					  start_arrow->typ);
+	}
+	if (end_arrow->typ) {
+		ms_escher_opt_add_simple (escher, optmark,
+					  MSEP_LINEENDARROWHEAD,
+					  end_arrow->typ);
+	}
+	ms_escher_opt_add_bool (escher, optmark, MSEP_ARROWHEADSOK, TRUE);
 	if (name)
 		ms_escher_opt_add_str_wchar (escher, optmark, extra,
 					     MSEP_NAME, name);
@@ -4617,6 +4625,8 @@ excel_write_line_v8 (ExcelWriteSheet *esheet, SheetObject *so)
 
 	g_free (name);
 	g_object_unref (style);
+	g_free (start_arrow);
+	g_free (end_arrow);
 
 	return draw_len;
 }
diff --git a/src/gnm-so-line.c b/src/gnm-so-line.c
index b9c89e7..b2a0d00 100644
--- a/src/gnm-so-line.c
+++ b/src/gnm-so-line.c
@@ -93,8 +93,7 @@ enum {
 	SOL_PROP_0,
 	SOL_PROP_STYLE,
 	SOL_PROP_START_ARROW,
-	SOL_PROP_END_ARROW,
-        SOL_PROP_IS_ARROW
+	SOL_PROP_END_ARROW
 };
 
 static GOStyle *
@@ -330,15 +329,6 @@ gnm_so_line_set_property (GObject *obj, guint param_id,
 	case SOL_PROP_END_ARROW:
 		sol->end_arrow = *((GOArrow* )g_value_peek_pointer (value));
 		break;
-	case SOL_PROP_IS_ARROW:
-		if (g_value_get_boolean (value))
-			go_arrow_init (&sol->end_arrow,
-				       GO_ARROW_TRIANGLE, GO_COLOR_BLACK,
-				       8., 10., 3.);
-		else
-			go_arrow_clear (&sol->end_arrow);
-		break;
-
 	default:
 		G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, param_id, pspec);
 		return;
@@ -360,9 +350,6 @@ gnm_so_line_get_property (GObject *obj, guint param_id,
 	case SOL_PROP_END_ARROW:
 		g_value_set_boxed (value, &sol->end_arrow);
 		break;
-	case SOL_PROP_IS_ARROW:
-		g_value_set_boolean (value, sol->end_arrow.c > 0);
-		break;
 	default :
 		G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, param_id, pspec);
 		break;
@@ -411,9 +398,6 @@ gnm_so_line_class_init (GObjectClass *gobject_class)
                  g_param_spec_boxed ("end-arrow", NULL, NULL,
 				     GO_ARROW_TYPE,
 				     GSF_PARAM_STATIC | G_PARAM_READWRITE));
-        g_object_class_install_property (gobject_class, SOL_PROP_IS_ARROW,
-                 g_param_spec_boolean ("is-arrow", NULL, NULL, FALSE,
-			GSF_PARAM_STATIC | G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
 }
 
 static void
diff --git a/src/wbc-gtk-actions.c b/src/wbc-gtk-actions.c
index cbbdcce..057ae9c 100644
--- a/src/wbc-gtk-actions.c
+++ b/src/wbc-gtk-actions.c
@@ -1237,8 +1237,12 @@ static GNM_ACTION_DEF (cmd_create_combo)
 	{ create_object (wbcg, sheet_widget_combo_get_type(), NULL); }
 static GNM_ACTION_DEF (cmd_create_line)
 	{ create_object (wbcg, GNM_SO_LINE_TYPE, NULL); }
-static GNM_ACTION_DEF (cmd_create_arrow)
-	{ create_object (wbcg, GNM_SO_LINE_TYPE, "is-arrow", TRUE, NULL); }
+static GNM_ACTION_DEF (cmd_create_arrow) {
+	GOArrow arrow;
+	go_arrow_init (&arrow, GO_ARROW_TRIANGLE, GO_COLOR_BLACK,
+		       8., 10., 3.);
+	create_object (wbcg, GNM_SO_LINE_TYPE, "end-arrow", &arrow, NULL);
+}
 static GNM_ACTION_DEF (cmd_create_rectangle)
 	{ create_object (wbcg, GNM_SO_FILLED_TYPE, NULL); }
 static GNM_ACTION_DEF (cmd_create_ellipse)
diff --git a/src/xml-sax-read.c b/src/xml-sax-read.c
index 014422d..cc7ea31 100644
--- a/src/xml-sax-read.c
+++ b/src/xml-sax-read.c
@@ -2156,9 +2156,15 @@ xml_sax_read_obj (GsfXMLIn *xin, gboolean needs_cleanup,
 	else if (!strcmp (type_name, "Ellipse"))
 		so = g_object_new (GNM_SO_FILLED_TYPE, "is-oval", TRUE, NULL);
 	else if (!strcmp (type_name, "Line"))
-		so = g_object_new (GNM_SO_LINE_TYPE, "is-arrow", TRUE, NULL);
-	else if (!strcmp (type_name, "Arrow"))
 		so = g_object_new (GNM_SO_LINE_TYPE, NULL);
+	else if (!strcmp (type_name, "Arrow")) {
+		GOArrow arrow;
+		go_arrow_init (&arrow, GO_ARROW_TRIANGLE, GO_COLOR_BLACK,
+			       8., 10., 3.);
+		so = g_object_new (GNM_SO_LINE_TYPE,
+				   "end-arrow", &arrow,
+				   NULL);
+	}
 
 	/* Class renamed between 1.0.x and 1.2.x */
 	else if (!strcmp (type_name, "GnmGraph"))



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