[gnumeric] Fix storing of error-literals in ODF. [#610175]



commit 64e10e650e06be2763d114f5446a40e45cae2ad9
Author: Andreas J. Guelzow <aguelzow pyrshep ca>
Date:   Thu Feb 18 12:18:00 2010 -0700

    Fix storing of error-literals in ODF. [#610175]
    
    2010-02-18  Andreas J. Guelzow <aguelzow pyrshep ca>
    
    	* openoffice-write.c (odf_write_cell): Sore error literals
    	  as assignment. FIxes #610175.

 NEWS                                  |    3 +++
 plugins/openoffice/ChangeLog          |    5 +++++
 plugins/openoffice/openoffice-write.c |   27 +++++++++++++++++++--------
 3 files changed, 27 insertions(+), 8 deletions(-)
---
diff --git a/NEWS b/NEWS
index f4ae964..f1cf2b7 100644
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,8 @@
 Gnumeric 1.10.1
 
+Andreas:
+	* Fix storing of error-literals in ODF. [#610175]
+
 Jean:
 	* Fix a crasher in excelplugin: don't call a NULL function. [#610012]
 
diff --git a/plugins/openoffice/ChangeLog b/plugins/openoffice/ChangeLog
index a5f5dc0..9901bf4 100644
--- a/plugins/openoffice/ChangeLog
+++ b/plugins/openoffice/ChangeLog
@@ -1,3 +1,8 @@
+2010-02-18  Andreas J. Guelzow <aguelzow pyrshep ca>
+
+	* openoffice-write.c (odf_write_cell): Sore error literals
+	  as assignment. FIxes #610175.
+
 2010-02-18  Morten Welinder  <terra gnome org>
 
 	* openoffice-read.c (openoffice_file_open): Queue everything for
diff --git a/plugins/openoffice/openoffice-write.c b/plugins/openoffice/openoffice-write.c
index 78c5989..be28371 100644
--- a/plugins/openoffice/openoffice-write.c
+++ b/plugins/openoffice/openoffice-write.c
@@ -2351,6 +2351,8 @@ odf_write_cell (GnmOOExport *state, GnmCell *cell, GnmRange const *merge_range,
 		}
 
 		switch (cell->value->type) {
+		case VALUE_EMPTY:
+			break;
 		case VALUE_BOOLEAN:
 			gsf_xml_out_add_cstr_unchecked (state->xml,
 							OFFICE "value-type", "boolean");
@@ -2365,24 +2367,33 @@ odf_write_cell (GnmOOExport *state, GnmCell *cell, GnmRange const *merge_range,
 					       (cell->value),
 					       -1);
 			break;
-
-		case VALUE_STRING:
-			gsf_xml_out_add_cstr_unchecked (state->xml,
-							OFFICE "value-type", "string");
-			break;
 		case VALUE_ERROR:
+			if (NULL == cell->base.texpr) {
+				/* see https://bugzilla.gnome.org/show_bug.cgi?id=610175 */
+				/* this is the same that Excel does, OOo does not have   */
+				/* error literals. ODF 1.2 might be introducing a new    */
+				/* value-type to address this issue                      */
+				char *eq_formula = g_strdup_printf 
+					("of:=%s", value_peek_string (cell->value));
+				gsf_xml_out_add_cstr (state->xml,
+						      TABLE "formula",
+						      eq_formula);
+				g_free (eq_formula);
+			}
 			gsf_xml_out_add_cstr_unchecked (state->xml,
 							OFFICE "value-type", "string");
 			gsf_xml_out_add_cstr (state->xml,
 					      OFFICE "string-value",
 					      value_peek_string (cell->value));
 			break;
-
-		case VALUE_ARRAY:
+		case VALUE_STRING:
+			gsf_xml_out_add_cstr_unchecked (state->xml,
+							OFFICE "value-type", "string");
+			break;
 		case VALUE_CELLRANGE:
+		case VALUE_ARRAY:
 		default:
 			break;
-
 		}
 	}
 



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