[gnumeric] Set ODF files to save by default as ODF files. [#629962]



commit 0e225edad281fb11e7885b0308c7cd9899b963df
Author: Andreas J Guelzow <aguelzow pyrshep ca>
Date:   Sat Sep 18 02:42:34 2010 -0600

    Set ODF files to save by default as ODF files. [#629962]
    
    2010-09-18  Andreas J. Guelzow <aguelzow pyrshep ca>
    
    	* openoffice-read.c (odf_created_by_gnumeric): new
    	(openoffice_file_open): set saveinfo

 NEWS                                 |    1 +
 plugins/openoffice/ChangeLog         |    5 +++++
 plugins/openoffice/openoffice-read.c |   23 +++++++++++++++++++++--
 3 files changed, 27 insertions(+), 2 deletions(-)
---
diff --git a/NEWS b/NEWS
index a8124b5..ec89c36 100644
--- a/NEWS
+++ b/NEWS
@@ -8,6 +8,7 @@ Andreas:
 	* Fix reformatting of cells on expression entry. [#629303]
 	* Allow multiple selection in manage sheet dialog.
 	* Permit ctrl-click specification of sort columns.
+	* Set ODF files to save by default as ODF files. [#629962]
 
 Jean:
 	* Export/import tick label rotation angle. [#629675]
diff --git a/plugins/openoffice/ChangeLog b/plugins/openoffice/ChangeLog
index b6112dd..91be555 100644
--- a/plugins/openoffice/ChangeLog
+++ b/plugins/openoffice/ChangeLog
@@ -1,3 +1,8 @@
+2010-09-18  Andreas J. Guelzow <aguelzow pyrshep ca>
+
+	* openoffice-read.c (odf_created_by_gnumeric): new
+	(openoffice_file_open): set saveinfo
+
 2010-09-15  Andreas J. Guelzow <aguelzow pyrshep ca>
 
 	* openoffice-read.c (od_style_prop_chart): add 
diff --git a/plugins/openoffice/openoffice-read.c b/plugins/openoffice/openoffice-read.c
index 9d3ccca..1f1e30a 100644
--- a/plugins/openoffice/openoffice-read.c
+++ b/plugins/openoffice/openoffice-read.c
@@ -6860,8 +6860,17 @@ dump_settings_hash (char const *key, GValue *val, char const *prefix)
 		g_hash_table_foreach (hash, (GHFunc)dump_settings_hash, pre);
 		g_free (pre);
 	}
+}
 
-	
+static gboolean
+odf_created_by_gnumeric (OOParseState *state)
+{
+	GsfDocMetaData *meta_data = go_doc_get_meta_data (GO_DOC (state->pos.wb));
+	GsfDocProp *prop = gsf_doc_meta_data_lookup  (meta_data,
+						      "meta:generator");
+	char const *str = g_value_get_string (gsf_doc_prop_get_val (prop));
+	gboolean res = g_str_has_prefix (str, "gnumeric");
+	return res;
 }
 
 static gboolean
@@ -8395,6 +8404,7 @@ openoffice_file_open (GOFileOpener const *fo, GOIOContext *io_context,
 		gsf_ooo_ns);
 	if (gsf_xml_in_doc_parse (doc, contents, &state)) {
 		GsfInput *settings;
+		char const *filesaver;
 
 		/* get the sheet in the right order (in case something was
 		 * created out of order implictly) */
@@ -8445,8 +8455,17 @@ openoffice_file_open (GOFileOpener const *fo, GOIOContext *io_context,
 		if (state.debug)
 			g_hash_table_foreach (state.settings.settings, 
 					      (GHFunc)dump_settings_hash, (char *)"");
-		if (!odf_has_gnm_foreign (&state))
+		if (!odf_has_gnm_foreign (&state)) {
 			odf_apply_ooo_config (&state);
+			filesaver = odf_created_by_gnumeric (&state) ? 
+				"Gnumeric_OpenCalc:openoffice"
+				: "Gnumeric_OpenCalc:odf";
+		} else
+			filesaver = "Gnumeric_OpenCalc:odf";
+		
+		workbook_set_saveinfo (state.pos.wb, GO_FILE_FL_AUTO,
+				       go_file_saver_for_id 
+				       (filesaver));
 
 		g_hash_table_destroy (state.settings.settings);
 		state.settings.settings = NULL;



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