gnumeric r16288 - in branches/gnumeric-1-8: plugins/excel src



Author: jody
Date: Thu Jan 24 14:44:03 2008
New Revision: 16288
URL: http://svn.gnome.org/viewvc/gnumeric?rev=16288&view=rev

Log:
backport patch for 506017


Modified:
   branches/gnumeric-1-8/plugins/excel/ms-excel-read.c
   branches/gnumeric-1-8/src/xml-io.c
   branches/gnumeric-1-8/src/xml-sax-read.c

Modified: branches/gnumeric-1-8/plugins/excel/ms-excel-read.c
==============================================================================
--- branches/gnumeric-1-8/plugins/excel/ms-excel-read.c	(original)
+++ branches/gnumeric-1-8/plugins/excel/ms-excel-read.c	Thu Jan 24 14:44:03 2008
@@ -447,24 +447,32 @@
 	g_return_val_if_fail (container != NULL, TRUE);
 	esheet = (ExcelReadSheet *)container;
 
-	attr = ms_obj_attr_bag_lookup (obj->attrs, MS_OBJ_ATTR_ANCHOR);
-	if (attr == NULL) {
-		fprintf (stderr,"MISSING anchor for obj %p with id %d of type %s\n", (void *)obj, obj->id, obj->excel_type_name);
-		return TRUE;
-	}
-
-	if (ms_sheet_obj_anchor_to_pos (esheet->sheet, container->importer->ver,
-					attr->v.v_ptr, &range, offsets))
-		return TRUE;
-
-	flip_h = ms_obj_attr_bag_lookup (obj->attrs, MS_OBJ_ATTR_FLIP_H);
-	flip_v = ms_obj_attr_bag_lookup (obj->attrs, MS_OBJ_ATTR_FLIP_V);
-	direction =
-		((flip_h == NULL) ? GOD_ANCHOR_DIR_RIGHT : 0) |
-		((flip_v == NULL) ? GOD_ANCHOR_DIR_DOWN : 0);
+	/* our comment object is too weak.  This anchor is for the text box,
+	 * we need to store the indicator */
+	if (obj->excel_type == 0x19 &&
+	    obj->comment_pos.col >= 0 && obj->comment_pos.row >= 0) {
+		cell_comment_set_pos (CELL_COMMENT (obj->gnum_obj),
+			&obj->comment_pos);
+	} else {
+		attr = ms_obj_attr_bag_lookup (obj->attrs, MS_OBJ_ATTR_ANCHOR);
+		if (attr == NULL) {
+			fprintf (stderr,"MISSING anchor for obj %p with id %d of type %s\n", (void *)obj, obj->id, obj->excel_type_name);
+			return TRUE;
+		}
+
+		if (ms_sheet_obj_anchor_to_pos (esheet->sheet, container->importer->ver,
+						attr->v.v_ptr, &range, offsets))
+			return TRUE;
+
+		flip_h = ms_obj_attr_bag_lookup (obj->attrs, MS_OBJ_ATTR_FLIP_H);
+		flip_v = ms_obj_attr_bag_lookup (obj->attrs, MS_OBJ_ATTR_FLIP_V);
+		direction =
+			((flip_h == NULL) ? GOD_ANCHOR_DIR_RIGHT : 0) |
+			((flip_v == NULL) ? GOD_ANCHOR_DIR_DOWN : 0);
 
-	sheet_object_anchor_init (&anchor, &range, offsets, direction);
-	sheet_object_set_anchor (so, &anchor);
+		sheet_object_anchor_init (&anchor, &range, offsets, direction);
+		sheet_object_set_anchor (so, &anchor);
+	}
 	sheet_object_set_sheet (so, esheet->sheet);
 
 	if (ms_obj_attr_get_ptr (obj->attrs, MS_OBJ_ATTR_TEXT, &label, FALSE))
@@ -605,12 +613,7 @@
 			ms_obj_attr_get_expr (obj->attrs, MS_OBJ_ATTR_INPUT_FROM, NULL, FALSE));
 		break;
 
-	case 0x19:
-		/* our comment object is too weak.  This anchor is for the text box,
-		 * we need to store the indicator */
-		if (obj->comment_pos.col >= 0 && obj->comment_pos.row >= 0)
-			cell_comment_set_pos (CELL_COMMENT (obj->gnum_obj),
-				&obj->comment_pos);
+	case 0x19: /* cell comment text box */
 		break;
 
 	default:

Modified: branches/gnumeric-1-8/src/xml-io.c
==============================================================================
--- branches/gnumeric-1-8/src/xml-io.c	(original)
+++ branches/gnumeric-1-8/src/xml-io.c	Thu Jan 24 14:44:03 2008
@@ -1709,8 +1709,14 @@
 	tmp = (char *) xmlGetProp (tree, (xmlChar *)"ObjectBound");
 	if (tmp != NULL) {
 		GnmRange r;
-		if (range_parse (&r, tmp))
+		if (range_parse (&r, tmp)) {
+			/* Patch problems introduced in some 1.7.x versions that stored
+			 * comments in merged cells with the full rectangle of the merged cell
+			 * rather than just the top left corner */
+			if (G_OBJECT_TYPE (so) == CELL_COMMENT_TYPE)
+				r.end = r.start;
 			so->anchor.cell_bound = r;
+		}
 		xmlFree (tmp);
 	}
 
@@ -1722,8 +1728,8 @@
 		xmlFree (tmp);
 	}
 
-	/* DEPRECATED : There was once an 'AnchorType' but it is now ignored */
 #if 0
+	/* Deprecated in 1.7.7 */
 	tmp = (char *) xmlGetProp (tree, (xmlChar *)"ObjectAnchorType");
 	if (tmp != NULL) {
 		int i[4], count;

Modified: branches/gnumeric-1-8/src/xml-sax-read.c
==============================================================================
--- branches/gnumeric-1-8/src/xml-sax-read.c	(original)
+++ branches/gnumeric-1-8/src/xml-sax-read.c	Thu Jan 24 14:44:03 2008
@@ -2058,6 +2058,13 @@
 			unknown_attr (xin, attrs+i);
 #endif
 	}
+
+	/* Patch problems introduced in some 1.7.x versions that stored
+	 * comments in merged cells with the full rectangle of the merged cell
+	 * rather than just the top left corner */
+	if (G_OBJECT_TYPE (so) == CELL_COMMENT_TYPE)
+		anchor_r.end = anchor_r.start;
+
 	sheet_object_anchor_init (&anchor, &anchor_r, anchor_offset, anchor_dir);
 	sheet_object_set_anchor (so, &anchor);
 



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