[gnumeric] Work around a spec violation in LO generated files with custom-shapes.



commit 7af0cd7466afebd9ed9bf41d001cf26c97a67ba6
Author: Andreas J Guelzow <aguelzow pyrshep ca>
Date:   Tue Aug 28 21:41:00 2012 -0600

    Work around a spec violation in LO generated files with custom-shapes.
    
    2012-08-28  Andreas J. Guelzow <aguelzow pyrshep ca>
    
    	* openoffice-read.c (odf_get_cs_formula_value): assume, contrary
    	to spec, that function reference names consist of alphanumerics
    	only since LO forgets to terminate the names with space or tab!

 plugins/openoffice/ChangeLog         |    6 ++++++
 plugins/openoffice/openoffice-read.c |   23 +++++++++++++++++++++--
 2 files changed, 27 insertions(+), 2 deletions(-)
---
diff --git a/plugins/openoffice/ChangeLog b/plugins/openoffice/ChangeLog
index bc7de00..c9c4573 100644
--- a/plugins/openoffice/ChangeLog
+++ b/plugins/openoffice/ChangeLog
@@ -1,3 +1,9 @@
+2012-08-28  Andreas J. Guelzow <aguelzow pyrshep ca>
+
+	* openoffice-read.c (odf_get_cs_formula_value): assume, contrary
+	to spec, that function reference names consist of alphanumerics
+	only since LO forgets to terminate the names with space or tab!
+
 2012-08-27  Andreas J. Guelzow <aguelzow pyrshep ca>
 
 	* openoffice-read.c (opendoc_content_dtd): support custom-shapes
diff --git a/plugins/openoffice/openoffice-read.c b/plugins/openoffice/openoffice-read.c
index cbe279c..34e1266 100644
--- a/plugins/openoffice/openoffice-read.c
+++ b/plugins/openoffice/openoffice-read.c
@@ -9178,8 +9178,27 @@ odf_get_cs_formula_value (GsfXMLIn *xin, char const *key, GHashTable *vals, gint
 			break;
 		case '?':
 			here = formula + 1;
-			while (*here != ' ' && *here != '\t')
+			/* ODF 1.2 is quite clear that:
+			   --------------------------
+			   function_reference::= "?" name
+			   name::= [^#x20#x9]+
+			   --------------------------
+			   so we should graball non-space, non-tab characters 
+			   as a function_reference name.
+			   
+			   The problem is that LO creates files in which these
+			   function reference are not terminated by space or tab!
+
+			   So if we want to read them correctly we should only use
+			   alphanumerics...
+			*/
+
+			/* while (*here != ' ' && *here != '\t') */
+			/* 	here++; */
+
+			while (g_ascii_isalnum (*here))
 				here++;
+
 			name = g_strndup (formula, here - formula);
 			formula = here;
 			fval = odf_get_cs_formula_value (xin, name, vals, level - 1);
@@ -9257,7 +9276,7 @@ odf_get_cs_formula_value (GsfXMLIn *xin, char const *key, GHashTable *vals, gint
 			break;
 		case 'w':
 			if (g_str_has_prefix (formula, "width")) {
-				formula += 6;
+				formula += 5;
 				g_string_append_printf (gstr, "%.12" GNM_FORMAT_g, viewbox_width);
 			} else {
 				g_string_append_c (gstr, *formula);



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