[goffice] We need to output some format to ODF when asked.



commit bf86e4c37f992eb1442af066796d17d2c617d028
Author: Andreas J. Guelzow <aguelzow pyrshep ca>
Date:   Wed Jun 17 21:46:02 2009 -0600

    We need to output some format to ODF when asked.
    
    2009-06-17  Andreas J. Guelzow  <aguelzow pyrshep ca>
    
    	* utils/go-format.c (go_format_output_general_to_odf): we need to
    	  output something
    	(go_format_output_to_odf): if we don't know what knind of format
    	  it is, make a guess

 ChangeLog                 |    7 ++++++
 goffice/utils/go-format.c |   52 +++++++++++++++++++++++++++++++++++++++++---
 2 files changed, 55 insertions(+), 4 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 1bf5995..bb106fa 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2009-06-17  Andreas J. Guelzow  <aguelzow pyrshep ca>
+
+	* utils/go-format.c (go_format_output_general_to_odf): we need to 
+	  output something
+	(go_format_output_to_odf): if we don't know what knind of format 
+	  it is, make a guess
+	
 2009-06-14  Morten Welinder  <terra gnome org>
 
 	* goffice/app/go-doc.c (go_doc_set_uri): Allow setting a NULL uri.
diff --git a/goffice/utils/go-format.c b/goffice/utils/go-format.c
index 9f4262c..2e7eceb 100644
--- a/goffice/utils/go-format.c
+++ b/goffice/utils/go-format.c
@@ -6070,12 +6070,12 @@ go_format_output_scientific_number_to_odf (GsfXMLOut *xout, GOFormat const *fmt,
 }
 
 static void
-go_format_output_number_to_odf (GsfXMLOut *xout, GOFormat const *fmt,
+go_format_output_number_to_odf (GsfXMLOut *xout, G_GNUC_UNUSED GOFormat const *fmt,
 				char const *name, 
 				GOFormatDetails const *details, 
 				GOFormatCondition const *condition,
 				int cond_part, 
-				gboolean with_extension)
+				G_GNUC_UNUSED gboolean with_extension)
 {
 	gboolean parentheses = (cond_part == 1) && details->negative_paren;
 	gboolean no_neg = (condition != NULL) && condition->true_inhibits_minus;
@@ -6107,7 +6107,27 @@ go_format_output_number_to_odf (GsfXMLOut *xout, GOFormat const *fmt,
 }
 
 static void
-go_format_output_currency_to_odf (GsfXMLOut *xout, GOFormat const *fmt,
+go_format_output_general_to_odf (GsfXMLOut *xout, G_GNUC_UNUSED GOFormat const *fmt,
+				char const *name, 
+				G_GNUC_UNUSED GOFormatDetails const *details, 
+				G_GNUC_UNUSED GOFormatCondition const *condition,
+				int cond_part, 
+				G_GNUC_UNUSED gboolean with_extension)
+{
+	gsf_xml_out_start_element (xout, NUMBER "number-style");
+	gsf_xml_out_add_cstr (xout, STYLE "name", name);
+	if (cond_part == 1)
+		gsf_xml_out_simple_element(xout, NUMBER "text", "\xe2\x88\x92");
+	gsf_xml_out_start_element (xout, NUMBER "number");
+	gsf_xml_out_add_int (xout, NUMBER "decimal-places", 2);
+	if (cond_part == 1)
+		gsf_xml_out_add_int (xout, NUMBER "display-factor",  -1);
+	gsf_xml_out_end_element (xout); /* </number:number> */
+	gsf_xml_out_end_element (xout); /* </number:number-style> */
+}
+
+static void
+go_format_output_currency_to_odf (GsfXMLOut *xout, G_GNUC_UNUSED GOFormat const *fmt,
 				  char const *name, 
 				  GOFormatDetails const *details, 
 				  GOFormatCondition const *condition,
@@ -6183,6 +6203,8 @@ go_format_output_to_odf (GsfXMLOut *xout, GOFormat const *fmt,
 
 	switch (details.family) {
 	case GO_FORMAT_GENERAL:
+		go_format_output_general_to_odf (xout, act_fmt, name, &details, 
+						condition, cond_part, with_extension);
 		result = FALSE;
 		break;
 	case GO_FORMAT_DATE:
@@ -6208,10 +6230,32 @@ go_format_output_to_odf (GsfXMLOut *xout, GOFormat const *fmt,
 		go_format_output_number_to_odf (xout, act_fmt, name, &details, 
 						condition, cond_part, with_extension);
 		break;
-	default:
+	default: {
+		/* We need to output something and we don't need any details for this */
+		int date = 0, digit = 0;
+		char const *str = go_format_as_XL (fmt);
+		while (*str != '\0') {
+			switch (*str) {
+			case 'd': case 'm': case 'y': case 'h': case 's':
+				date++;
+				break;
+			case '#': case '.': case '0': case 'e':
+				digit++;
+				break;
+			default:
+				break;
+			}
+			str++;
+		}
+		if (digit < date)
+			go_format_output_date_to_odf (xout, act_fmt, name, &details, with_extension);
+		else
+			go_format_output_general_to_odf (xout, act_fmt, name, &details, 
+						condition, cond_part, with_extension);
 		result = FALSE;
 		break;
 	}
+	}
 
 	g_object_set (G_OBJECT (xout), "pretty-print", pp, NULL);
 



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