[gnumeric] GOArrow: move to goffice.



commit 6366e1fa2e8d5e52fa26deecd262f6ecc03bad11
Author: Morten Welinder <terra gnome org>
Date:   Wed Oct 14 10:50:41 2009 -0400

    GOArrow: move to goffice.

 ChangeLog                     |    7 +++
 configure.in                  |    2 +-
 plugins/excel/ms-excel-read.c |   95 ++++++++++++++++++++++++++++++-----------
 src/gnm-so-line.c             |   32 ++++---------
 4 files changed, 88 insertions(+), 48 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index cf3af44..eca06bc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2009-10-14  Morten Welinder  <terra gnome org>
+
+	* src/gnm-so-line.c: Move GOArrow to goffice.
+
+	* configure.in (libspreadsheet_reqs): Require goffice 0.7.15 for
+	GOArrow.
+
 2009-10-13  Morten Welinder  <terra gnome org>
 
 	* src/libgnumeric.c (gnm_shutdown): Call gnm_xml_sax_read_shutdown
diff --git a/configure.in b/configure.in
index c6c1b6e..a543ef3 100644
--- a/configure.in
+++ b/configure.in
@@ -143,7 +143,7 @@ PKG_PROG_PKG_CONFIG(0.18)
 
 dnl *****************************
 libspreadsheet_reqs="
-	libgoffice-${GOFFICE_API_VER}	>= 0.7.14
+	libgoffice-${GOFFICE_API_VER}	>= 0.7.15
 	libgsf-1		>= 1.14.15
 	libxml-2.0		>= 2.4.12
 "
diff --git a/plugins/excel/ms-excel-read.c b/plugins/excel/ms-excel-read.c
index 6208e8c..4bf1ee2 100644
--- a/plugins/excel/ms-excel-read.c
+++ b/plugins/excel/ms-excel-read.c
@@ -439,7 +439,34 @@ ms_sheet_obj_anchor_to_pos (Sheet const * sheet, MsBiffVersion const ver,
 	return FALSE;
 }
 
-unsigned xl_pattern_to_line_type (guint16 pattern)
+static void
+handle_arrow_head (SheetObject *so, const char *prop_name,
+		   MSObjAttrBag *attrs, MSObjAttrID typid)
+{
+	GOArrow arrow;
+	gpointer parrow;
+	GOColor col = GO_COLOR_BLACK;
+
+	int typ = ms_obj_attr_get_int (attrs, typid, 0);
+
+	g_object_get (so, prop_name, &parrow, NULL);
+	arrow = *((GOArrow*)parrow);
+
+	switch (typ) {
+	case 0:
+		go_arrow_init (&arrow, GO_ARROW_NONE, col, 0, 0, 0);
+		break;
+	default:
+	case 1:
+		go_arrow_init (&arrow, GO_ARROW_TRIANGLE, col, 8., 10., 3.);
+		break;
+	}
+
+	g_object_set (so, prop_name, &arrow, NULL);
+}
+
+unsigned
+xl_pattern_to_line_type (guint16 pattern)
 {
 	static GOLineDashType const dash_map []= {
 		GO_LINE_SOLID,
@@ -522,8 +549,10 @@ ms_sheet_realize_obj (MSContainer *container, MSObj *obj)
 	case 0x00:
 		break;
 
-	case MSOT_LINE: /* Line */
-	case MSOT_ARC: /* Arc */
+	case MSOT_LINE:
+	case MSOT_ARC: {
+		gboolean is_arrow;
+
 		style = go_style_new ();
 		style->line.color = ms_sheet_map_color
 			(esheet, obj, MS_OBJ_ATTR_OUTLINE_COLOR,
@@ -535,7 +564,18 @@ ms_sheet_realize_obj (MSContainer *container, MSObj *obj)
 			: 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);
+
+		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);
+		}
 		break;
+	}
 
 	case MSOT_POLYGON:
 		g_object_set (G_OBJECT (so), "points",
@@ -649,8 +689,8 @@ ms_sheet_realize_obj (MSContainer *container, MSObj *obj)
 			ms_obj_attr_get_int (obj->attrs, MS_OBJ_ATTR_SCROLLBAR_PAGE, 10));
 		break;
 
-	case MSOT_LIST: /* List */
-	case MSOT_COMBO: /* Combo  */
+	case MSOT_LIST:
+	case MSOT_COMBO:
 		sheet_widget_list_base_set_links (obj->gnum_obj,
 			ms_obj_attr_get_expr (obj->attrs, MS_OBJ_ATTR_LINKED_TO_CELL, NULL, FALSE),
 			ms_obj_attr_get_expr (obj->attrs, MS_OBJ_ATTR_INPUT_FROM, NULL, FALSE));
@@ -679,55 +719,60 @@ ms_sheet_create_obj (MSContainer *container, MSObj *obj)
 	g_return_val_if_fail (container != NULL, NULL);
 
 	switch (obj->excel_type) {
-	case 0x01: /* Line */
-	case 0x04: /* Arc */
+	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", 0 != ms_obj_attr_get_int (obj->attrs, MS_OBJ_ATTR_ARROW_END, 0),
-			NULL);
+				   "is-arrow", arrow_end || arrow_start,
+				   NULL);
 		break;
+	}
 
 	case 0x00: /* draw the group border */
-	case 0x02: /* Box */
-	case 0x03: /* Oval */
-	case 0x06: /* TextBox */
-	case 0x0E: /* Label */
+	case MSOT_RECTANGLE:
+	case MSOT_OVAL:
+	case MSOT_TEXTBOX:
+	case MSOT_LABEL:
 		so = g_object_new (GNM_SO_FILLED_TYPE,
 			"is-oval", obj->excel_type == 3,
 			NULL);
 		break;
 
-	case 0x05: /* Chart */
+	case MSOT_CHART:
 		so = sheet_object_graph_new (NULL);
 		break;
 
 	/* Button */
-	case 0x07:
+	case MSOT_BUTTON:
 		so = g_object_new (sheet_widget_button_get_type (), NULL);
 		break;
-	case 0x08:
+	case MSOT_PICTURE:
 		so = g_object_new (SHEET_OBJECT_IMAGE_TYPE, NULL); /* Picture */
 		break;
-	case 0x09:
+	case MSOT_POLYGON:
 		so = g_object_new (GNM_SO_POLYGON_TYPE, NULL);
 		break;
-	case 0x0B:
+	case MSOT_CHECKBOX:
 		so = g_object_new (sheet_widget_checkbox_get_type (), NULL);
 		break;
-	case 0x0C:
+	case MSOT_OPTION:
 		so = g_object_new (sheet_widget_radio_button_get_type (), NULL);
 		break;
-	case 0x10:
+	case MSOT_SPINNER:
 		so = g_object_new (sheet_widget_spinbutton_get_type (), NULL);
 		break;
-	case 0x11:
+	case MSOT_SCROLLBAR:
 		so = g_object_new (sheet_widget_scrollbar_get_type (), NULL);
 		break;
-	case 0x12:
+	case MSOT_LIST:
 		so = g_object_new (sheet_widget_list_get_type (), NULL);
 		break;
 
 	/* ignore combos associateed with filters */
-	case 0x14: {
+	case MSOT_COMBO: {
 		ExcelReadSheet *esheet = (ExcelReadSheet *)container;
 
 		if (!obj->combo_in_autofilter)
@@ -739,12 +784,12 @@ ms_sheet_create_obj (MSContainer *container, MSObj *obj)
 	}
 	break;
 
-	case 0x19:
+	case MSOT_COMMENT:
 		so = g_object_new (cell_comment_get_type (), NULL);
 		break;
 
 	/* Gnumeric specific addition to handle toggle button controls */
-	case 0x70:
+	case MSOT_TOGGLE:
 		so = g_object_new (sheet_widget_toggle_button_get_type (), NULL);
 		break;
 
diff --git a/src/gnm-so-line.c b/src/gnm-so-line.c
index 62b5ab0..a55aa00 100644
--- a/src/gnm-so-line.c
+++ b/src/gnm-so-line.c
@@ -43,27 +43,11 @@ attr_eq (const xmlChar *a, const char *s)
 #define GNM_SO_LINE_CLASS(k)	(G_TYPE_CHECK_CLASS_CAST ((k),   GNM_SO_LINE_TYPE, GnmSOLineClass))
 
 /*****************************************************************************/
-typedef struct {
-	GOColor	color;
-	double  a, b, c;
-} GOArrow;
-
-static void
-go_arrow_init (GOArrow *res, double a, double b, double c)
-{
-	res->color = GO_COLOR_BLACK;
-	res->a = a;
-	res->b = b;
-	res->c = c;
-}
 
 static void
 go_arrow_copy (GOArrow *dst, GOArrow const *src)
 {
-	dst->color = src->color;
-	dst->a = src->a;
-	dst->b = src->b;
-	dst->c = src->c;
+	*dst = *src;
 }
 
 /*****************************************************************************/
@@ -317,7 +301,9 @@ gnm_so_line_prep_sax_parser (SheetObject *so, GsfXMLIn *xin,
 
 	/* 2 == arrow */
 	if (type == 2 && arrow_a >= 0. && arrow_b >= 0. && arrow_c >= 0.)
-		go_arrow_init (&sol->end_arrow, arrow_a, arrow_b, arrow_c);
+		go_arrow_init (&sol->end_arrow,
+			       GO_ARROW_TRIANGLE, GO_COLOR_BLACK,
+			       arrow_a, arrow_b, arrow_c);
 }
 
 static void
@@ -353,9 +339,13 @@ gnm_so_line_set_property (GObject *obj, guint param_id,
 		break;
 	case SOL_PROP_IS_ARROW:
 		if (g_value_get_boolean (value))
-			go_arrow_init (&sol->end_arrow, 8., 10., 3.);
+			go_arrow_init (&sol->end_arrow,
+				       GO_ARROW_TRIANGLE, GO_COLOR_BLACK,
+				       8., 10., 3.);
 		else
-			go_arrow_init (&sol->end_arrow, 0., 0., 0.);
+			go_arrow_init (&sol->end_arrow,
+				       GO_ARROW_NONE, GO_COLOR_BLACK,
+				       0., 0., 0.);
 		break;
 
 	default:
@@ -438,8 +428,6 @@ gnm_so_line_init (GObject *obj)
 {
 	GnmSOLine *sol  = GNM_SO_LINE (obj);
 	sol->style = sol_default_style ();
-	go_arrow_init (&sol->start_arrow, 0., 0., 0.);
-	go_arrow_init (&sol->end_arrow,   0., 0., 0.);
 
 	SHEET_OBJECT (obj)->anchor.base.direction = GOD_ANCHOR_DIR_NONE_MASK;
 }



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