[gnumeric] Improve configurable text export of numbers. [#126444]



commit fc60dffc5dbee6b0027c225198d30f66e3400720
Author: Andreas J Guelzow <aguelzow pyrshep ca>
Date:   Wed Jun 30 10:40:11 2010 -0600

    Improve configurable text export of numbers. [#126444]
    
    2010-06-30  Andreas J. Guelzow <aguelzow pyrshep ca>
    
    	* src/stf-export.c (try_auto_float): new
    	(stf_export_cell): call try_auto_float

 ChangeLog        |    5 +++++
 NEWS             |    1 +
 src/stf-export.c |   24 ++++++++++++++++++++++++
 3 files changed, 30 insertions(+), 0 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index ee4f2e6..c15770c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2010-06-30  Andreas J. Guelzow <aguelzow pyrshep ca>
 
+	* src/stf-export.c (try_auto_float): new
+	(stf_export_cell): call try_auto_float
+	
+2010-06-30  Andreas J. Guelzow <aguelzow pyrshep ca>
+
 	* schemas/gnumeric-dialogs.schemas.in: new preferences for
 	  search and replace dialog
 	* src/gnumeric-gconf.c: add the items generated from the above 
diff --git a/NEWS b/NEWS
index 3ac994c..31f5228 100644
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,7 @@ Gnumeric 1.10.8
 Andreas:
 	* Add new Excel and Openformula units ("pica" and "picapt") to CONVERT.
 	* Save default search settings. [#105615]
+	* Improve configurable text export of numbers. [#126444]
 
 --------------------------------------------------------------------------
 Gnumeric 1.10.7
diff --git a/src/stf-export.c b/src/stf-export.c
index 31849ed..c9dfc49 100644
--- a/src/stf-export.c
+++ b/src/stf-export.c
@@ -137,6 +137,28 @@ gnm_stf_export_options_sheet_list_get (const GnmStfExport *stfe)
 
 /* ------------------------------------------------------------------------- */
 
+
+static char *
+try_auto_float (GnmValue *value, const GOFormat *format,
+	       GODateConventions const *date_conv)
+{
+	gboolean is_date;
+	int is_time;
+
+	if (value->type != VALUE_FLOAT)
+		return NULL;
+
+	format = gnm_format_specialize (format, value);
+	is_date = go_format_is_date (format) > 0;
+	is_time = go_format_is_time (format);
+
+	if (is_date || is_time > 0)
+		return NULL;
+
+	return format_value (go_format_general (), value, NULL, -1, date_conv);
+}
+
+
 static char *
 try_auto_date (GnmValue *value, const GOFormat *format,
 	       GODateConventions const *date_conv)
@@ -221,6 +243,8 @@ stf_export_cell (GnmStfExport *stfe, GnmCell *cell)
 				GOFormat const *format = gnm_cell_get_format (cell);
 				text = tmp = try_auto_date (cell->value, format, date_conv);
 				if (!text)
+					text = tmp = try_auto_float (cell->value, format, date_conv);
+				if (!text)
 					text = value_peek_string (cell->value);
 			}
 			break;



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