[gnumeric] ssconvert: make it possible to split files into multiple .txt files.
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] ssconvert: make it possible to split files into multiple .txt files.
- Date: Tue, 29 Dec 2015 02:05:24 +0000 (UTC)
commit ca1f917a2158a4e83be73b2cb9a121b147bd9ad6
Author: Morten Welinder <terra gnome org>
Date: Mon Dec 28 21:04:39 2015 -0500
ssconvert: make it possible to split files into multiple .txt files.
cvs has long worked, but txt has a sheet selector and thus is different.
ChangeLog | 8 ++++++++
NEWS | 3 +++
src/ssconvert.c | 14 ++++++++++++++
src/stf-export.c | 9 +++++++--
4 files changed, 32 insertions(+), 2 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 0b89127..a1fcb89 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2015-12-28 Morten Welinder <terra gnome org>
+
+ * src/ssconvert.c (convert): When separating sheets, move current
+ sheet to the front. See bug #694408.
+
+ * src/stf-export.c (gnm_stf_file_saver_save): If we add current
+ sheet, remove it at the end.
+
2015-12-28 Morten Welinder <terra gnome org>
* configure.ac: Post-release bump.
diff --git a/NEWS b/NEWS
index 8c9c712..3c23620 100644
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,8 @@
Gnumeric 1.12.27
+Morten:
+ * Teach ssconvert to split sheets into separate .txt files [#694408]
+
--------------------------------------------------------------------------
Gnumeric 1.12.26
diff --git a/src/ssconvert.c b/src/ssconvert.c
index f08bc6d..399aa13 100644
--- a/src/ssconvert.c
+++ b/src/ssconvert.c
@@ -803,6 +803,7 @@ convert (char const *inarg, char const *outarg, char const *mergeargs[],
if (ssconvert_one_file_per_sheet) {
GSList *ptr, *sheets;
char *template;
+
res = 0;
template = strchr (outarg, '%')
@@ -813,8 +814,21 @@ convert (char const *inarg, char const *outarg, char const *mergeargs[],
for (ptr = sheets; ptr; ptr = ptr->next) {
Sheet *sheet = ptr->data;
char *tmpfile = resolve_template (template, sheet);
+ int oldn = sheet->index_in_wb;
+
+ /*
+ * HACK: (bug 694408).
+ *
+ * We don't have a good way of specifying the
+ * sheet. Move it to the front and select
+ * it. That will at least make cvs and txt
+ * exporters reliable find it.
+ */
+ workbook_sheet_move (sheet, -oldn);
wb_view_sheet_focus (wbv, sheet);
+
res = !wb_view_save_as (wbv, fs, tmpfile, cc);
+ workbook_sheet_move (sheet, +oldn);
g_free (tmpfile);
if (res)
break;
diff --git a/src/stf-export.c b/src/stf-export.c
index fe90800..13c1891 100644
--- a/src/stf-export.c
+++ b/src/stf-export.c
@@ -605,7 +605,7 @@ GSF_CLASS (GnmStfExport, gnm_stf_export,
* gnm_stf_get_stfe:
* @obj: #GObject with a #GnmStfExport attached as data.
*
- * If non is found, a new one is created ans attached to @obj.
+ * If none is found, a new one is created and attached to @obj.
* Returns: (transfer none): the #GnmStfExport.
**/
GnmStfExport *
@@ -665,6 +665,7 @@ gnm_stf_file_saver_save (G_GNUC_UNUSED GOFileSaver const *fs, GOIOContext *conte
Workbook *wb = wb_view_get_workbook (wbv);
GnmStfExport *stfe = gnm_stf_get_stfe (G_OBJECT (wb));
GsfOutput *dummy_sink;
+ gboolean nosheets;
/* TODO: move this GUI dependent code out of this
* filesaver into gui-file.c. After this, remove includes (see above). */
@@ -677,7 +678,8 @@ gnm_stf_file_saver_save (G_GNUC_UNUSED GOFileSaver const *fs, GOIOContext *conte
}
}
- if (!stfe->sheet_list)
+ nosheets = (stfe->sheet_list == NULL);
+ if (nosheets)
gnm_stf_export_options_sheet_list_add
(stfe, wb_view_cur_sheet (wbv));
@@ -690,6 +692,9 @@ gnm_stf_file_saver_save (G_GNUC_UNUSED GOFileSaver const *fs, GOIOContext *conte
dummy_sink = gsf_output_memory_new ();
g_object_set (G_OBJECT (stfe), "sink", dummy_sink, NULL);
g_object_unref (dummy_sink);
+
+ if (nosheets)
+ gnm_stf_export_options_sheet_list_clear (stfe);
}
static gboolean
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]