[gnumeric] fix ODF export of string literals in expressions



commit 89a9744d68d1a6d157a6b419ab2444ae3a3aa78e
Author: Andreas J Guelzow <aguelzow pyrshep ca>
Date:   Tue May 10 10:16:36 2011 -0600

    fix ODF export of string literals in expressions
    
    2011-05-09  Andreas J. Guelzow <aguelzow pyrshep ca>
    
    	* openoffice-write.c (odf_string_handler): new
    	(odf_expr_conventions_new): connect odf_string_handler

 plugins/openoffice/ChangeLog          |    5 +++++
 plugins/openoffice/openoffice-write.c |   17 +++++++++++++++++
 2 files changed, 22 insertions(+), 0 deletions(-)
---
diff --git a/plugins/openoffice/ChangeLog b/plugins/openoffice/ChangeLog
index a94ae11..c6bcf4f 100644
--- a/plugins/openoffice/ChangeLog
+++ b/plugins/openoffice/ChangeLog
@@ -1,5 +1,10 @@
 2011-05-09  Andreas J. Guelzow <aguelzow pyrshep ca>
 
+	* openoffice-write.c (odf_string_handler): new
+	(odf_expr_conventions_new): connect odf_string_handler
+
+2011-05-09  Andreas J. Guelzow <aguelzow pyrshep ca>
+
 	* openoffice-write.c (odf_write_manifest): write manifest
 	version for ODF 1.2 or newer
 
diff --git a/plugins/openoffice/openoffice-write.c b/plugins/openoffice/openoffice-write.c
index 2139e9a..a5e4fb3 100644
--- a/plugins/openoffice/openoffice-write.c
+++ b/plugins/openoffice/openoffice-write.c
@@ -2397,6 +2397,22 @@ odf_expr_func_handler (GnmConventionsOut *out, GnmExprFunction const *func)
 	return;
 }
 
+static void
+odf_string_handler (GnmConventionsOut *out, GOString const *str)
+{
+	gchar const *string = str->str;
+	g_string_append_c (out->accum, '"');
+	/* This loop should be UTF-8 safe.  */
+	for (; *string; string++) {
+		switch (*string) {
+		case '"':
+			g_string_append_c (out->accum, '"');
+		default:
+			g_string_append_c (out->accum, *string);
+		}
+	}
+	g_string_append_c (out->accum, '"');
+}
 
 
 static GnmConventions *
@@ -2411,6 +2427,7 @@ odf_expr_conventions_new (void)
 	conv->array_row_sep		= '|';
 	conv->intersection_char         = '!';
 	conv->decimal_sep_dot		= TRUE;
+	conv->output.string		= odf_string_handler;
 	conv->output.cell_ref		= odf_cellref_as_string;
 	conv->output.range_ref		= odf_rangeref_as_string;
 	conv->output.func               = odf_expr_func_handler;



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