[goffice] GOFormat: new function go_format_locale_currency.



commit 5d4cf6969f333646080b73d74b4bb89497211995
Author: Morten Welinder <terra gnome org>
Date:   Thu May 28 11:23:04 2009 -0400

    GOFormat: new function go_format_locale_currency.
---
 ChangeLog                 |    5 +++++
 goffice/utils/go-format.c |   45 +++++++++++++++++++++++++++++++++++++++++++++
 goffice/utils/go-format.h |    2 ++
 3 files changed, 52 insertions(+), 0 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 7883361..371394d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2009-05-28  Morten Welinder  <terra gnome org>
+
+	* goffice/utils/go-format.c (go_format_locale_currency): New
+	function.
+
 2009-05-27  Morten Welinder  <terra gnome org>
 
 	* goffice/gtk/go-format-sel.c (generate_number): Simplify using
diff --git a/goffice/utils/go-format.c b/goffice/utils/go-format.c
index 18d7bba..2c84b36 100644
--- a/goffice/utils/go-format.c
+++ b/goffice/utils/go-format.c
@@ -5123,6 +5123,51 @@ go_format_generate_currency_str (GString *dst,
 }
 #endif
 
+#ifdef DEFINE_COMMON
+GOFormatCurrency const *
+go_format_locale_currency (void)
+{
+	static GOFormatCurrency currency;
+	const char *symbol;
+	gboolean precedes, has_space;
+	int i;
+
+	symbol = go_locale_get_currency (&precedes, &has_space)->str;
+
+#if 0
+	g_printerr ("go_format_locale_currency: looking for [%s] %d %d\n", symbol, precedes, has_space);
+#endif
+
+	for (i = 1; go_format_currencies[i].symbol; i++) {
+		const GOFormatCurrency *c = go_format_currencies + i;
+		size_t clen;
+
+		if (c->precedes != precedes)
+			continue;
+		if (c->has_space != has_space)
+			continue;
+
+		if (strcmp (symbol, c->symbol) == 0)
+			return c;
+
+		clen = strlen (c->symbol);
+		if (clen == 3 + strlen (symbol) &&
+		    c->symbol[0] == '[' && c->symbol[1] == '$' &&
+		    c->symbol[clen - 1] == ']' &&
+		    g_ascii_strncasecmp (c->symbol + 1, symbol, clen - 3) == 0)
+			return c;
+	}
+
+	currency.has_space = has_space;
+	currency.precedes = precedes;
+	currency.symbol = symbol;
+	currency.description = NULL;
+	return &currency;
+}
+
+#endif
+
+
 /********************* GOFormat ODF Support ***********************/
 
 #define STYLE	 "style:"
diff --git a/goffice/utils/go-format.h b/goffice/utils/go-format.h
index a0bdd14..60b3605 100644
--- a/goffice/utils/go-format.h
+++ b/goffice/utils/go-format.h
@@ -217,6 +217,8 @@ gboolean go_format_output_to_odf (GsfXMLOut *xout, GOFormat const *fmt,
 GO_VAR_DECL char const * const * const go_format_builtins [];
 GO_VAR_DECL GOFormatCurrency     const go_format_currencies [];
 
+GOFormatCurrency const *go_format_locale_currency (void);
+
 /*************************************************************************/
 
 void go_number_format_init (void);



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