[goffice] fix fraction export to ODF



commit 63c3d027b2e42181dde9618713c25da80a2e544b
Author: Andreas J Guelzow <aguelzow pyrshep ca>
Date:   Tue Sep 6 01:34:17 2011 -0600

    fix fraction export to ODF
    
    2011-09-06  Andreas J. Guelzow <aguelzow pyrshep ca>
    
    	* goffice/utils/go-format.c (go_format_output_fraction_to_odf): fix
    	int_digits and don't force a 0 into the denominator

 ChangeLog                 |    5 +++++
 goffice/utils/go-format.c |   21 +++++++++++++++------
 2 files changed, 20 insertions(+), 6 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 9a9a96f..019d3c7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2011-09-06  Andreas J. Guelzow <aguelzow pyrshep ca>
+
+	* goffice/utils/go-format.c (go_format_output_fraction_to_odf): fix
+	int_digits and don't force a 0 into the denominator
+
 2011-09-05  Jean Brefort  <jean brefort normalesup org>
 
 	* goffice/canvas/goc-widget.c (goc_widget_set_widget): fixed signals target,
diff --git a/goffice/utils/go-format.c b/goffice/utils/go-format.c
index 72d0e2f..ad5b33f 100644
--- a/goffice/utils/go-format.c
+++ b/goffice/utils/go-format.c
@@ -6755,6 +6755,8 @@ go_format_output_fraction_to_odf (GsfXMLOut *xout, GOFormat const *fmt,
 			/* fall through */
 		case '#': case '?': {
 			int i = 1;
+			char const *slash;
+			char const *look;
 			if (fraction_completed) {
 				zeroes = 0;
 				break;
@@ -6767,10 +6769,19 @@ go_format_output_fraction_to_odf (GsfXMLOut *xout, GOFormat const *fmt,
 				xl++; i++;
 			}
 			if (zeroes > 0 && *(xl - 1) != '0') zeroes++;
-			if (*xl == '/')
-				min_numerator_digits = zeroes;
-			else
-				int_digits = zeroes;
+
+			slash = strchr (xl, '/');
+			if (slash) {
+				for (look = xl; look < slash; look++)
+					if (*look == '0' || *look == '?' || *look == '#')
+						break;
+				if (look < slash)
+					int_digits = zeroes;
+				else
+					min_numerator_digits = zeroes;
+				zeroes = 0;
+				break;
+			} 
 			zeroes = 0;
 			break;
 		}
@@ -6790,8 +6801,6 @@ go_format_output_fraction_to_odf (GsfXMLOut *xout, GOFormat const *fmt,
 				if (g_ascii_isdigit (*xl)) digits ++;
 				xl++; i++;
 			}
-			if (!g_ascii_isdigit (*(xl - 1)))
-				zeroes++;
 
 			gsf_xml_out_start_element (xout, NUMBER "fraction");
 			odf_add_bool (xout, NUMBER "grouping", FALSE);



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