[gnumeric] ssconvert: also merge document-level images for --merge-to.
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] ssconvert: also merge document-level images for --merge-to.
- Date: Thu, 11 Jun 2020 22:00:27 +0000 (UTC)
commit d336d2828b82f906d5885f3ee7b59020c035dde1
Author: Morten Welinder <terra gnome org>
Date: Thu Jun 11 17:59:47 2020 -0400
ssconvert: also merge document-level images for --merge-to.
NEWS | 1 +
src/ssconvert.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++++--------
2 files changed, 52 insertions(+), 8 deletions(-)
---
diff --git a/NEWS b/NEWS
index 56d0eb3ff..98958069f 100644
--- a/NEWS
+++ b/NEWS
@@ -16,6 +16,7 @@ Morten:
* Fix partial-line issue with sample_datasource.
* Fix load of in-place graph data with extra ()s. [#492]
* Fix Ctrl-; cursor position. [#494]
+ * Fix ssconvert --merge-to problem. [#496]
--------------------------------------------------------------------------
Gnumeric 1.12.47
diff --git a/src/ssconvert.c b/src/ssconvert.c
index 3505fe510..68502f1a3 100644
--- a/src/ssconvert.c
+++ b/src/ssconvert.c
@@ -512,17 +512,13 @@ cb_collect_names (G_GNUC_UNUSED gconstpointer key,
*plist = g_slist_prepend (*plist, expr_name_ref (nexpr));
}
-/* Append the sheets of workbook wb2 to workbook wb. Resize sheets
- if necessary. Fix workbook links in sheet if necessary.
- Merge names in workbook scope (conflicts result in an error). */
static gboolean
-merge_single (Workbook *wb, Workbook *wb2,
- int cmax, int rmax,
- GOCmdContext *cc)
+merge_single_names (Workbook *wb, Workbook *wb2, GOCmdContext *cc)
{
/* Move names with workbook scope in wb2 over to wb */
- GSList *names = g_slist_sort (gnm_named_expr_collection_list (wb2->names),
- (GCompareFunc)expr_name_cmp_by_name);
+ GSList *names = g_slist_sort
+ (gnm_named_expr_collection_list (wb2->names),
+ (GCompareFunc)expr_name_cmp_by_name);
GSList *p;
for (p = names; p; p = p->next) {
@@ -556,6 +552,52 @@ merge_single (Workbook *wb, Workbook *wb2,
}
g_slist_free (names);
+ return FALSE;
+}
+
+static gboolean
+merge_single_images (Workbook *wb, Workbook *wb2, GOCmdContext *cc)
+{
+ GHashTable *images = go_doc_get_images (GO_DOC (wb2));
+ GHashTableIter hiter;
+ gpointer key, value;
+
+ if (!images)
+ return FALSE;
+
+ g_hash_table_iter_init (&hiter, images);
+ while (g_hash_table_iter_next (&hiter, &key, &value)) {
+ const char *name = key;
+ GOImage *image = go_doc_get_image (GO_DOC (wb), name);
+
+ if (image) {
+ g_printerr (_("Unhandled image name clash: %s\n"),
+ name);
+ return TRUE;
+ }
+
+ image = value;
+ go_doc_add_image (GO_DOC (wb), name, image);
+ }
+
+ return FALSE;
+}
+
+
+/* Append the sheets of workbook wb2 to workbook wb. Resize sheets
+ if necessary. Fix workbook links in sheet if necessary.
+ Merge names in workbook scope (conflicts result in an error). */
+static gboolean
+merge_single (Workbook *wb, Workbook *wb2,
+ int cmax, int rmax,
+ GOCmdContext *cc)
+{
+ if (merge_single_names (wb, wb2, cc))
+ return TRUE;
+
+ if (merge_single_images (wb, wb2, cc))
+ return TRUE;
+
while (workbook_sheet_count (wb2) > 0) {
/* Remove sheet from incoming workbook */
Sheet *sheet = workbook_sheet_by_index (wb2, 0);
@@ -596,6 +638,7 @@ merge_single (Workbook *wb, Workbook *wb2,
/* Insert and revive the sheet */
workbook_sheet_attach_at_pos (wb, sheet, loc);
dependents_revive_sheet (sheet);
+
g_object_unref (sheet);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]