gnumeric r17229 - in trunk: . plugins/excel



Author: mortenw
Date: Fri Mar 20 14:58:48 2009
New Revision: 17229
URL: http://svn.gnome.org/viewvc/gnumeric?rev=17229&view=rev

Log:
2009-03-20  Morten Welinder  <terra gnome org>

	* ms-excel-read.c (excel_read_init): Use magic formats for 0x0e,
	0x0f, and 0x16.  Keep the nameless magic for 0x10.



Modified:
   trunk/NEWS
   trunk/plugins/excel/ChangeLog
   trunk/plugins/excel/ms-excel-read.c

Modified: trunk/NEWS
==============================================================================
--- trunk/NEWS	(original)
+++ trunk/NEWS	Fri Mar 20 14:58:48 2009
@@ -41,6 +41,8 @@
 	* Improve date entry for locales that end abbreviated month names
 	with punctuation.
 	* Fix ODS crashes.  [#575600] [#575843] [#575981]
+	* Use goffice magic formats for certain date and time formats so we
+	can persist them in .gnumeric.
 
 Sum1:
 	* Implement OOO probing.  [#574381]

Modified: trunk/plugins/excel/ms-excel-read.c
==============================================================================
--- trunk/plugins/excel/ms-excel-read.c	(original)
+++ trunk/plugins/excel/ms-excel-read.c	Fri Mar 20 14:58:48 2009
@@ -70,6 +70,7 @@
 #include <goffice/app/io-context.h>
 #include <goffice/app/go-doc.h>
 #include <goffice/utils/go-font.h>
+#include <goffice/utils/go-format.h>
 #include <goffice/utils/go-locale.h>
 #include <goffice/utils/go-units.h>
 #include <goffice/utils/go-glib-extras.h>
@@ -6796,16 +6797,29 @@
 }
 
 
+static GSList *formats;
+
 void
 excel_read_init (void)
 {
 	int i;
 	int mbd = go_locale_month_before_day ();
+	GOFormat *fmt;
+
+	fmt = go_format_new_magic (GO_FORMAT_MAGIC_SHORT_DATE);
+	formats = g_slist_prepend (formats, fmt);
+	excel_builtin_formats[0x0e] = go_format_as_XL (fmt);
+
+	fmt = go_format_new_magic (GO_FORMAT_MAGIC_MEDIUM_DATE);
+	formats = g_slist_prepend (formats, fmt);
+	excel_builtin_formats[0x0f] = go_format_as_XL (fmt);
 
-	excel_builtin_formats[0x0e] = mbd ? "m/d/yy" : "d/m/yy";
-	excel_builtin_formats[0x0f] = mbd ? "d-mmm-yy" : "mmm-d-yy";
+	/* Doesn't seem to have a name.  */
 	excel_builtin_formats[0x10] = mbd ? "d-mmm" : "mmm-d";
-	excel_builtin_formats[0x16] = mbd ? "m/d/yy h:mm" : "d/m/yy h:mm";
+
+	fmt = go_format_new_magic (GO_FORMAT_MAGIC_SHORT_DATETIME);
+	formats = g_slist_prepend (formats, fmt);
+	excel_builtin_formats[0x16] = go_format_as_XL (fmt);
 
 	excel_func_by_name = g_hash_table_new (g_str_hash, g_str_equal);
 	for (i = 0; i < excel_func_desc_size; i++) {
@@ -6823,4 +6837,8 @@
 excel_read_cleanup (void)
 {
 	g_hash_table_destroy (excel_func_by_name);
+	excel_func_by_name = NULL;
+
+	go_slist_free_custom (formats, (GFreeFunc)go_format_unref);
+	formats = NULL;
 }



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