[gnumeric] Fix conditional number format import from ODF. [#672489]



commit 6434a05012a15cfffcd2457cdfe320b6df88d3c4
Author: Andreas J Guelzow <aguelzow pyrshep ca>
Date:   Wed Mar 21 01:11:10 2012 -0600

    Fix conditional number format import from ODF. [#672489]
    
    2012-03-21  Andreas J. Guelzow <aguelzow pyrshep ca>
    
    	* openoffice-read.c (odf_number_style_end): skip the condition
    	for the second part if we skipped it for the first and it is the
    	default

 NEWS                                 |    1 +
 plugins/openoffice/ChangeLog         |    6 ++++++
 plugins/openoffice/openoffice-read.c |   15 +++++++++++----
 3 files changed, 18 insertions(+), 4 deletions(-)
---
diff --git a/NEWS b/NEWS
index 6b89bc9..cb38337 100644
--- a/NEWS
+++ b/NEWS
@@ -10,6 +10,7 @@ Andreas:
 	* Import/Export style information attached to grids from/to ODF. 
 	Part of [#671461]
 	* Improve annotation import from ODF.
+	* Fix conditional number format import from ODF. [#672489]
 
 Jean:
 	* Fixed crash with sheet object. [#671617]
diff --git a/plugins/openoffice/ChangeLog b/plugins/openoffice/ChangeLog
index 6147da2..7fc18f0 100644
--- a/plugins/openoffice/ChangeLog
+++ b/plugins/openoffice/ChangeLog
@@ -1,3 +1,9 @@
+2012-03-21  Andreas J. Guelzow <aguelzow pyrshep ca>
+
+	* openoffice-read.c (odf_number_style_end): skip the condition
+	for the second part if we skipped it for the first and it is the
+	default
+
 2012-03-20  Morten Welinder  <terra gnome org>
 
 	* openoffice-read.c (openoffice_file_open): Don't refer to
diff --git a/plugins/openoffice/openoffice-read.c b/plugins/openoffice/openoffice-read.c
index 5e29103..25c586e 100644
--- a/plugins/openoffice/openoffice-read.c
+++ b/plugins/openoffice/openoffice-read.c
@@ -4494,6 +4494,7 @@ odf_number_style_end (GsfXMLIn *xin, G_GNUC_UNUSED GsfXMLBlob *blob)
 		GSList *lc, *lf;
 		char *accum;
 		int parts = 0;
+		gboolean default_condition = FALSE;
 
 		accum = g_string_free (state->cur_format.accum, FALSE);
 		if (strlen (accum) == 0) {
@@ -4513,6 +4514,8 @@ odf_number_style_end (GsfXMLIn *xin, G_GNUC_UNUSED GsfXMLBlob *blob)
 					g_string_append_printf
 						(state->cur_format.accum,
 						 (*(cond+1) == '=') ? "[>=%s]" : "[>%s]", val);
+				else
+					default_condition = TRUE;
 				fmt = g_hash_table_lookup (state->formats, lf->data);
 				if (fmt != NULL)
 					g_string_append (state->cur_format.accum, go_format_as_XL (fmt));
@@ -4598,12 +4601,16 @@ odf_number_style_end (GsfXMLIn *xin, G_GNUC_UNUSED GsfXMLBlob *blob)
 			if (cond != NULL && *cond == '<' && *(cond + 1) != '>') {
 				GOFormat const *fmt;
 				char *val = cond + strcspn (cond, "0123456789.");
+				float val_d = strtod (val, NULL);
 				if (parts > 0)
 					g_string_append_c (state->cur_format.accum, ';');
-				if ((*(cond+1) != '=') || (strtod (val, NULL) != 0.))
-					g_string_append_printf
-						(state->cur_format.accum,
-						 (*(cond+1) == '=') ? "[<=%s]" : "[<%s]", val);
+				if ((*(cond+1) != '=') || (val_d != 0.)) {
+					if (!(parts == 1 && default_condition && (*(cond+1) != '=')) &&
+					    val_d == 0.)
+						g_string_append_printf
+							(state->cur_format.accum,
+							 (*(cond+1) == '=') ? "[<=%s]" : "[<%s]", val);
+				}
 				fmt = g_hash_table_lookup (state->formats, lf->data);
 				if (fmt != NULL)
 					g_string_append (state->cur_format.accum,



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