[gnumeric] cleanups.



commit e483f8ec7f24910a7a9c86491f0c6db9d47ef41b
Author: Morten Welinder <terra gnome org>
Date:   Fri Mar 23 20:56:35 2012 -0400

    cleanups.

 ChangeLog                 |    3 +++
 src/sheet-object-image.c  |   16 ++++++++++------
 src/sheet-object-widget.c |    8 +++++---
 3 files changed, 18 insertions(+), 9 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index cf1b746..de2f78b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2012-03-23  Morten Welinder  <terra gnome org>
 
+	* src/sheet-object-image.c (content_end): Simplify.  Decode image
+	also if we don't have a name.
+
 	* src/sheet-object-widget.c
 	(sheet_widget_adjustment_prep_sax_parser): Set the right thing
 	when we see a "Page" attribute.  Fixes #672716 item 2.
diff --git a/src/sheet-object-image.c b/src/sheet-object-image.c
index 94ac0dd..d67bd5e 100644
--- a/src/sheet-object-image.c
+++ b/src/sheet-object-image.c
@@ -381,12 +381,15 @@ content_end (GsfXMLIn *xin, G_GNUC_UNUSED GsfXMLBlob *unknown)
 {
 	SheetObject *so = gnm_xml_in_cur_obj (xin);
 	SheetObjectImage *soi = SHEET_OBJECT_IMAGE (so);
-
-	if (soi->name == NULL) {
-		soi->bytes.len  = gsf_base64_decode_simple (
-			xin->content->str, xin->content->len);
-		soi->bytes.data = g_memdup (xin->content->str, soi->bytes.len);
-		soi->image = go_image_new_from_data (soi->type, xin->content->str, soi->bytes.len, NULL, NULL);
+	GString *data = xin->content;
+
+	if (data->len >= 4) {
+		size_t len = gsf_base64_decode_simple (data->str, data->len);
+		soi->bytes.len = len;
+		soi->bytes.data = g_memdup (data->str, len);
+		soi->image = go_image_new_from_data (soi->type,
+						     soi->bytes.data,
+						     len, NULL, NULL);
 	}
 }
 
@@ -544,6 +547,7 @@ gnm_soi_assign_to_sheet (SheetObject *so, Sheet *sheet)
 		GODoc *doc = GO_DOC (sheet->workbook);
 		GType type = go_image_type_for_format (soi->type);
 		soi->image = g_object_ref (go_doc_image_fetch (doc, soi->name, type));
+	} else {
 	}
 	return FALSE;
 }
diff --git a/src/sheet-object-widget.c b/src/sheet-object-widget.c
index 16567ff..cc169ad 100644
--- a/src/sheet-object-widget.c
+++ b/src/sheet-object-widget.c
@@ -3044,7 +3044,7 @@ list_content_eval (GnmDependent *dep)
 				       GNM_EXPR_EVAL_PERMIT_EMPTY);
 	}
 	model = gtk_list_store_new (1, G_TYPE_STRING);
-	if ((dep != NULL) && (v != NULL)) {
+	if (v) {
 		value_area_foreach (v, &ep, CELL_ITER_ALL,
 				    (GnmValueIterFunc) cb_collect, model);
 		value_release (v);
@@ -3093,8 +3093,10 @@ sheet_widget_list_base_finalize (GObject *obj)
 	SheetWidgetListBase *swl = SHEET_WIDGET_LIST_BASE (obj);
 	dependent_set_expr (&swl->content_dep, NULL);
 	dependent_set_expr (&swl->output_dep, NULL);
-	if (swl->model != NULL)
-		g_object_unref (G_OBJECT (swl->model)), swl->model = NULL;
+	if (swl->model != NULL) {
+		g_object_unref (swl->model);
+		swl->model = NULL;
+	}
 	sheet_object_widget_class->finalize (obj);
 }
 



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