[goffice] Improve ODF output of elapsed time



commit 790eff5bc172d8b000611783d53820e85a7e52c6
Author: Andreas J. Guelzow <aguelzow pyrshep ca>
Date:   Tue Jun 23 13:02:31 2009 -0600

    Improve ODF output of elapsed time
    
    2009-06-23  Andreas J. Guelzow  <aguelzow pyrshep ca>
    
    	* utils/go-format.c (go_format_output_date_to_odf): be as explicit
    	  as possible with respect to elapsed time and avoid it when we
    	  are outputting a date-style.

 ChangeLog                 |    6 ++++++
 goffice/utils/go-format.c |   18 ++++++++++++++----
 2 files changed, 20 insertions(+), 4 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 09fd994..4457864 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2009-06-23  Andreas J. Guelzow  <aguelzow pyrshep ca>
 
+	* utils/go-format.c (go_format_output_date_to_odf): be as explicit 
+	  as possible with respect to elapsed time and avoid it when we
+	  are outputting a date-style.
+	
+2009-06-23  Andreas J. Guelzow  <aguelzow pyrshep ca>
+
 	* utils/go-format.c (go_format_output_date_to_odf): also consider 
 	  elapsed seconds
 
diff --git a/goffice/utils/go-format.c b/goffice/utils/go-format.c
index 0a6a52e..7e4ddca 100644
--- a/goffice/utils/go-format.c
+++ b/goffice/utils/go-format.c
@@ -5693,6 +5693,8 @@ go_format_output_date_to_odf (GsfXMLOut *xout, GOFormat const *fmt,
 			gsf_xml_out_start_element (xout, NUMBER "hours");
 			gsf_xml_out_add_cstr (xout, NUMBER "style", 
 					      (n == 1) ? "short" : "long");
+			if (with_extension)
+				gsf_xml_out_add_cstr (xout, GNMSTYLE "truncate-on-overflow", "true");
 			gsf_xml_out_end_element (xout); /* </number:hours> */
 			m_is_minutes = TRUE;
 			break;
@@ -5714,6 +5716,8 @@ go_format_output_date_to_odf (GsfXMLOut *xout, GOFormat const *fmt,
 				gsf_xml_out_start_element (xout, NUMBER "minutes");
 				gsf_xml_out_add_cstr (xout, NUMBER "style", 
 						      (n == 1) ? "short" : "long");
+				if (with_extension)
+					gsf_xml_out_add_cstr (xout, GNMSTYLE "truncate-on-overflow", "true");
 				gsf_xml_out_end_element (xout); /* </number:minutes> */
 			} else {
 				if (seen_month || time_only) break;
@@ -5767,6 +5771,8 @@ go_format_output_date_to_odf (GsfXMLOut *xout, GOFormat const *fmt,
 			gsf_xml_out_add_cstr (xout, NUMBER "style", 
 					      (n == 1) ? "short" : "long");
 			gsf_xml_out_add_int (xout, NUMBER "decimal-places", d);
+			if (with_extension)
+				gsf_xml_out_add_cstr (xout, GNMSTYLE "truncate-on-overflow", "true");
 			gsf_xml_out_end_element (xout); /* </number:seconds> */
 			break;
 		}
@@ -5785,11 +5791,11 @@ go_format_output_date_to_odf (GsfXMLOut *xout, GOFormat const *fmt,
 			seen_hour = TRUE;
 			seen_elapsed  = TRUE;
 			ODF_CLOSE_STRING;
-			if ((!text_written) && !element_written)
+			if ((!text_written) && !element_written && time_only)
 				gsf_xml_out_add_cstr (xout, NUMBER "truncate-on-overflow", "false");
 			gsf_xml_out_start_element (xout, NUMBER "hours");
 			gsf_xml_out_add_cstr (xout, NUMBER "style", "short");
-			/* ODF can mark elapsed hours in the time-style only */
+			/* ODF can mark elapsed time in the time-style only and then not clearly */
 			if (with_extension)
 				gsf_xml_out_add_cstr (xout, GNMSTYLE "truncate-on-overflow", "false");
 			gsf_xml_out_end_element (xout); /* </number:hours> */
@@ -5804,12 +5810,14 @@ go_format_output_date_to_odf (GsfXMLOut *xout, GOFormat const *fmt,
 			m_is_minutes = FALSE;
 			seconds_trigger_minutes = FALSE;
 			ODF_CLOSE_STRING;
-			element_written = TRUE;
+			if ((!text_written) && !element_written && time_only)
+				gsf_xml_out_add_cstr (xout, NUMBER "truncate-on-overflow", "false");
 			gsf_xml_out_start_element (xout, NUMBER "minutes");
 			gsf_xml_out_add_cstr (xout, NUMBER "style", "long");
 			if (with_extension)
 				gsf_xml_out_add_cstr (xout, GNMSTYLE "truncate-on-overflow", "false");
 			gsf_xml_out_end_element (xout); /* </number:minutes> */
+			element_written = TRUE;
 
 		case TOK_ELAPSED_S:
 			if (seen_elapsed || seen_ampm || seen_second) break;
@@ -5821,12 +5829,14 @@ go_format_output_date_to_odf (GsfXMLOut *xout, GOFormat const *fmt,
 				seconds_trigger_minutes = FALSE;
 			}
 			ODF_CLOSE_STRING;
-			element_written = TRUE;
+			if ((!text_written) && !element_written && time_only)
+				gsf_xml_out_add_cstr (xout, NUMBER "truncate-on-overflow", "false");
 			gsf_xml_out_start_element (xout, NUMBER "seconds");
 			gsf_xml_out_add_cstr (xout, NUMBER "style", "short");
 			if (with_extension)
 				gsf_xml_out_add_cstr (xout, GNMSTYLE "truncate-on-overflow", "false");
 			gsf_xml_out_end_element (xout); /* </number:seconds> */
+			element_written = TRUE;
 			break;
 
 		case TOK_STRING: {



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