[gnumeric] Implement --one-file-per-sheet in ssconvert [#604549]



commit f47afbc3ac1eb6e90ed5fb472a15d32b9bee5caf
Author: Andreas J. Guelzow <aguelzow pyrshep ca>
Date:   Tue Dec 15 01:06:46 2009 -0700

    Implement --one-file-per-sheet in ssconvert [#604549]
    
    2009-12-15  Andreas J. Guelzow <aguelzow pyrshep ca>
    	for Gabriel Kerneis
    	* src/ssconvert.c (convert): handle one sheet per file

 ChangeLog       |    4 ++++
 NEWS            |    3 +++
 src/ssconvert.c |   18 ++++++++++++++++--
 3 files changed, 23 insertions(+), 2 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index bb45173..27deeea 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,8 @@
 2009-12-15  Andreas J. Guelzow <aguelzow pyrshep ca>
+	for Gabriel Kerneis
+	* src/ssconvert.c (convert): handle one sheet per file
+
+2009-12-15  Andreas J. Guelzow <aguelzow pyrshep ca>
 
 	* component/Gnumeric-embed.xml.in: add 2 medians sign test
 	* src/HILDON_Gnumeric-gtk.xml.in: add 2 medians sign test
diff --git a/NEWS b/NEWS
index b3e00b3..8cfd4ce 100644
--- a/NEWS
+++ b/NEWS
@@ -8,6 +8,9 @@ Andreas:
 	* Add RANK.AVG (rank function returning average rank for ties)
 	* Added Sign Test to statistical analysis tools
 
+Gabriel Kerneis:
+	* Implement --one-file-per-sheet in ssconvert [#604549]
+
 Jean:
 	* Fixed problem with row headers. [#603862]
 	* Fixed pane origin when zoomed. [#604373]
diff --git a/src/ssconvert.c b/src/ssconvert.c
index bcc91a8..8225dfe 100644
--- a/src/ssconvert.c
+++ b/src/ssconvert.c
@@ -601,14 +601,28 @@ convert (char const *inarg, char const *outarg, char const *mergeargs[],
 			else if (workbook_sheet_count (wb) > 1 &&
 				 go_file_saver_get_save_scope (fs) != GO_FILE_SAVE_WORKBOOK) {
 				if (ssconvert_one_file_per_sheet) {
-					g_warning ("TODO: one sheet per file is not implemented");
+					GSList *ptr;
+					GString *s;
+					char *tmpfile;
+					int idx = 0;
+					res = 0;
+					
+					for (ptr = workbook_sheets(wb); ptr && !res; ptr = ptr->next, idx++) {
+						wb_view_sheet_focus(wbv, (Sheet *)ptr->data);
+						s = g_string_new (outfile);
+						g_string_append_printf(s, ".%d", idx);
+						tmpfile = g_string_free (s, FALSE);
+						res = !wb_view_save_as (wbv, fs, tmpfile, cc);
+						g_free(tmpfile);
+					}
+					goto printing_done;
 				} else
 					g_printerr (_("Selected exporter (%s) does not support saving multiple sheets in one file.\n"
 						      "Only the current sheet will be saved.\n"),
 						    go_file_saver_get_id (fs));
 			}
 			res = !wb_view_save_as (wbv, fs, outfile, cc);
-
+		printing_done:
 			g_object_unref (wb);
 		}
 		g_object_unref (io_context);



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