[gnumeric] handle elapsed times



commit 983d5a2607d074767312c3dfb4a4064e154b0cf0
Author: Andreas J. Guelzow <aguelzow pyrshep ca>
Date:   Sun May 31 23:53:34 2009 -0600

    handle elapsed times
    
    2009-06-01 Andreas J. Guelzow <aguelzow pyrshep ca>
    
    	* openoffice-write.c (oo_date_hours): handle elapsed time
    	(oo_date_minutes): ditto
    	(oo_date_seconds): ditto
---
 plugins/openoffice/ChangeLog         |    6 +++++
 plugins/openoffice/openoffice-read.c |   40 +++++++++++++++++++++++++++++++--
 2 files changed, 43 insertions(+), 3 deletions(-)

diff --git a/plugins/openoffice/ChangeLog b/plugins/openoffice/ChangeLog
index 9ae63e2..3f64e6b 100644
--- a/plugins/openoffice/ChangeLog
+++ b/plugins/openoffice/ChangeLog
@@ -1,5 +1,11 @@
 2009-06-01 Andreas J. Guelzow <aguelzow pyrshep ca>
 
+	* openoffice-write.c (oo_date_hours): handle elapsed time
+	(oo_date_minutes): ditto
+	(oo_date_seconds): ditto
+	
+2009-06-01 Andreas J. Guelzow <aguelzow pyrshep ca>
+
 	* openoffice-write.c (odf_print_spreadsheet_content_prelude):
 	  give the correct null-date
 	* openoffice-read.c (oo_date_text_end): we need to use 
diff --git a/plugins/openoffice/openoffice-read.c b/plugins/openoffice/openoffice-read.c
index 3cd9d29..bb39cf5 100644
--- a/plugins/openoffice/openoffice-read.c
+++ b/plugins/openoffice/openoffice-read.c
@@ -1504,6 +1504,7 @@ oo_date_hours (GsfXMLIn *xin, xmlChar const **attrs)
 {
 	OOParseState *state = (OOParseState *)xin->user_state;
 	gboolean is_short = TRUE;
+	gboolean is_elapsed = FALSE;
 
 	if (state->accum_fmt == NULL)
 		return;
@@ -1511,13 +1512,21 @@ oo_date_hours (GsfXMLIn *xin, xmlChar const **attrs)
 	for (; attrs != NULL && attrs[0] && attrs[1] ; attrs += 2)
 		if (gsf_xml_in_namecmp (xin, CXML2C (attrs[0]), OO_NS_NUMBER, "style"))
 			is_short = attr_eq (attrs[1], "short");
-	g_string_append (state->accum_fmt, is_short ? "h" : "hh");
+		else if (gsf_xml_in_namecmp (xin, CXML2C (attrs[0]), OO_GNUM_NS_EXT, 
+					     "elapsed"))
+			is_elapsed = attr_eq (attrs[1], "true");
+
+	if (is_elapsed)
+		g_string_append (state->accum_fmt, is_short ? "[h]" : "[hh]");
+	else
+		g_string_append (state->accum_fmt, is_short ? "h" : "hh");
 }
 static void
 oo_date_minutes (GsfXMLIn *xin, xmlChar const **attrs)
 {
 	OOParseState *state = (OOParseState *)xin->user_state;
 	gboolean is_short = TRUE;
+	gboolean is_elapsed = FALSE;
 
 	if (state->accum_fmt == NULL)
 		return;
@@ -1525,13 +1534,22 @@ oo_date_minutes (GsfXMLIn *xin, xmlChar const **attrs)
 	for (; attrs != NULL && attrs[0] && attrs[1] ; attrs += 2)
 		if (gsf_xml_in_namecmp (xin, CXML2C (attrs[0]), OO_NS_NUMBER, "style"))
 			is_short = attr_eq (attrs[1], "short");
-	g_string_append (state->accum_fmt, is_short ? "m" : "mm");
+		else if (gsf_xml_in_namecmp (xin, CXML2C (attrs[0]), OO_GNUM_NS_EXT, 
+					     "elapsed"))
+			is_elapsed = attr_eq (attrs[1], "true");
+			
+	if (is_elapsed)
+		g_string_append (state->accum_fmt, is_short ? "[m]" : "[mm]");
+	else
+		g_string_append (state->accum_fmt, is_short ? "m" : "mm");
 }
 static void
 oo_date_seconds (GsfXMLIn *xin, xmlChar const **attrs)
 {
 	OOParseState *state = (OOParseState *)xin->user_state;
 	gboolean is_short = TRUE;
+	int digits = 0;
+	gboolean is_elapsed = FALSE;
 
 	if (state->accum_fmt == NULL)
 		return;
@@ -1539,8 +1557,25 @@ oo_date_seconds (GsfXMLIn *xin, xmlChar const **attrs)
 	for (; attrs != NULL && attrs[0] && attrs[1] ; attrs += 2)
 		if (gsf_xml_in_namecmp (xin, CXML2C (attrs[0]), OO_NS_NUMBER, "style"))
 			is_short = attr_eq (attrs[1], "short");
+		else if (gsf_xml_in_namecmp (xin, CXML2C (attrs[0]), OO_NS_NUMBER, 
+					     "decimal-places"))
+			digits = atoi (attrs[1]);
+		else if (gsf_xml_in_namecmp (xin, CXML2C (attrs[0]), OO_GNUM_NS_EXT, 
+					     "elapsed"))
+			is_elapsed = attr_eq (attrs[1], "true");
+			
+	if (is_elapsed)
+		g_string_append_c (state->accum_fmt, '[');
 	g_string_append (state->accum_fmt, is_short ? "s" : "ss");
+	if (digits > 0) {
+		g_string_append_c (state->accum_fmt, '.');
+		while (digits-- > 0)
+			g_string_append_c (state->accum_fmt, '0');
+	}
+	if (is_elapsed)
+		g_string_append_c (state->accum_fmt, ']');
 }
+
 static void
 oo_date_am_pm (GsfXMLIn *xin, xmlChar const **attrs)
 {
@@ -1608,7 +1643,6 @@ oo_date_style_end (GsfXMLIn *xin, G_GNUC_UNUSED GsfXMLBlob *blob)
 		
 		g_hash_table_insert (state->formats, state->fmt_name,
 				     go_format_new_from_XL (state->accum_fmt->str));
-		g_print ("oo_date_style_end %s\n", state->accum_fmt->str);
 		g_string_free (state->accum_fmt, TRUE);
 	}
 	state->accum_fmt = NULL;



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