[goffice] GODoc: fix image id handling.
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [goffice] GODoc: fix image id handling.
- Date: Wed, 1 Sep 2010 13:51:48 +0000 (UTC)
commit c483855b72d02a7bb2550ac90bd45844478fad4c
Author: Morten Welinder <terra gnome org>
Date: Wed Sep 1 09:50:38 2010 -0400
GODoc: fix image id handling.
ChangeLog | 13 ++++++++++---
NEWS | 1 +
goffice/app/go-doc.c | 50 +++++++++++++++++++++++++++++++-------------------
3 files changed, 42 insertions(+), 22 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index a1861ae..4c4f48e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,12 +1,19 @@
+2010-09-01 Morten Welinder <terra gnome org>
+
+ * goffice/app/go-doc.c (go_doc_init_read, go_doc_init_write): Make
+ ->imagebug own the ids.
+ (go_doc_save_image, go_doc_image_fetch): Copy image ids.
+
2010-08-31 Andreas J. Guelzow <aguelzow pyrshep ca>
- * goffice/app/go-cmd-context.c (go_cmd_context_class_init): this should be a
- base init function, so change its name and arguments
+ * goffice/app/go-cmd-context.c (go_cmd_context_class_init): this
+ should be a base init function, so change its name and arguments
2010-08-31 Jean Brefort <jean brefort normalesup org>
* goffice/graph/gog-plot.c (gog_plot_update_cardinality),
- (gog_plot_foreach_elem): optionnaly delete trendlines from legend. [#628031]
+ (gog_plot_foreach_elem): optionnaly delete trendlines from
+ legend. [#628031]
* goffice/graph/gog-trend-line.c (gog_trend_line_set_property),
(gog_trend_line_get_property), (cb_show_in_legend),
(gog_trend_line_populate_editor), (gog_trend_line_class_init),
diff --git a/NEWS b/NEWS
index 865d81f..5476590 100644
--- a/NEWS
+++ b/NEWS
@@ -21,6 +21,7 @@ Morten:
* Fix graph crash. [#628259]
* Improve go_format_is_date.
* Improve handling of date axes with time-of-day.
+ * Fix FMR on image load. [Part of #628467]
--------------------------------------------------------------------------
goffice 0.8.9:
diff --git a/goffice/app/go-doc.c b/goffice/app/go-doc.c
index e849c04..95ea3cd 100644
--- a/goffice/app/go-doc.c
+++ b/goffice/app/go-doc.c
@@ -403,18 +403,23 @@ go_doc_get_images (GODoc *doc) {
void
go_doc_init_write (GODoc *doc, GsfXMLOut *output)
{
- if (doc->imagebuf != NULL)
- g_critical ("Images buffer should be NULL");
- doc->imagebuf = g_hash_table_new (g_str_hash, g_str_equal);
- g_object_set_data (G_OBJECT (gsf_xml_out_get_output (output)), "document", doc);
+ g_return_if_fail (GO_IS_DOC (doc));
+ g_return_if_fail (doc->imagebuf == NULL);
+
+ doc->imagebuf = g_hash_table_new_full (g_str_hash, g_str_equal,
+ g_free, NULL);
+ g_object_set_data (G_OBJECT (gsf_xml_out_get_output (output)),
+ "document", doc);
}
void
go_doc_init_read (GODoc *doc, GsfInput *input)
{
- if (doc->imagebuf != NULL)
- g_critical ("Images buffer should be NULL");
- doc->imagebuf = g_hash_table_new (g_str_hash, g_str_equal);
+ g_return_if_fail (GO_IS_DOC (doc));
+ g_return_if_fail (doc->imagebuf == NULL);
+
+ doc->imagebuf = g_hash_table_new_full (g_str_hash, g_str_equal,
+ g_free, NULL);
g_object_set_data (G_OBJECT (input), "document", doc);
}
@@ -444,7 +449,9 @@ go_doc_save_image (GODoc *doc, char const *id)
if (!g_hash_table_lookup (doc->imagebuf, id)) {
GOImage *image = g_hash_table_lookup (doc->images, id);
if (image)
- g_hash_table_insert (doc->imagebuf, (gpointer) id, image);
+ g_hash_table_replace (doc->imagebuf,
+ g_strdup (id),
+ image);
}
}
@@ -474,20 +481,23 @@ load_image_data (GsfXMLIn *xin, GsfXMLBlob *unknown)
go_image_load_data (image, xin);
real = go_doc_add_image (doc, go_image_get_name (image), image);
g_hash_table_remove (doc->imagebuf, (gpointer) go_image_get_name (image));
- /* We have an issue if the image already existed and this can happen on pasting
- or if one day, we implement merging two documents (import a workbook as new sheets
- in an existing workbook). At the moment, I don't see any way to tell the clients
- to reference the image stored in the document instead of the one created by
- go_doc_image_fetch, so let's just make certain they share the same id. Anyway
- this should not happen very often (may be with a company logo?) and it is not so harmful
- since the duplicationwill not survive serialization. (Jean)
- */
+ /*
+ * We have an issue if the image already existed and this can
+ * happen on pasting or if one day, we implement merging two
+ * documents (import a workbook as new sheets in an existing
+ * workbook). At the moment, I don't see any way to tell the
+ * clients to reference the image stored in the document instead
+ * of the one created by go_doc_image_fetch, so let's just make
+ * certain they share the same id. Anyway this should not happen
+ * very often (may be with a company logo?) and it is not so
+ * harmful since the duplicationwill not survive
+ * serialization. (Jean)
+ */
if (real == image)
g_object_unref (image);
else
go_image_set_name (image, go_image_get_name (real));
g_object_set_data (G_OBJECT (doc), "new image", NULL);
-
}
void
@@ -516,14 +526,16 @@ go_doc_end_read (GODoc *doc)
doc->imagebuf = NULL;
}
-GOImage*
+GOImage *
go_doc_image_fetch (GODoc *doc, char const *id)
{
GOImage *image = g_hash_table_lookup (doc->imagebuf, id);
if (!image) {
image = g_object_new (GO_TYPE_IMAGE, NULL);
go_image_set_name (image, id);
- g_hash_table_insert (doc->imagebuf, (gpointer) go_image_get_name (image), image);
+ g_hash_table_replace (doc->imagebuf,
+ g_strdup (go_image_get_name (image)),
+ image);
}
return image;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]