[goffice] Write text formats to ODF. [#636158]
- From: Andreas J. Guelzow <guelzow src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [goffice] Write text formats to ODF. [#636158]
- Date: Tue, 30 Nov 2010 21:49:56 +0000 (UTC)
commit fc2bc664d95d2ad71141a2d629574fc86f0d0402
Author: Andreas J Guelzow <aguelzow pyrshep ca>
Date: Tue Nov 30 14:50:50 2010 -0700
Write text formats to ODF. [#636158]
2010-11-30 Andreas J. Guelzow <aguelzow pyrshep ca>
* goffice/utils/go-format.c (go_format_output_text_to_odf): new
(go_format_output_to_odf): connect go_format_output_text_to_odf
ChangeLog | 5 ++
NEWS | 3 +
goffice/utils/go-format.c | 103 ++++++++++++++++++++++++++++++++++++++++++++-
3 files changed, 110 insertions(+), 1 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 51d4cd5..81155ef 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2010-11-30 Andreas J. Guelzow <aguelzow pyrshep ca>
+
+ * goffice/utils/go-format.c (go_format_output_text_to_odf): new
+ (go_format_output_to_odf): connect go_format_output_text_to_odf
+
2010-11-25 Morten Welinder <terra gnome org>
* configure.in: Post-release bump.
diff --git a/NEWS b/NEWS
index 964d49e..f3dff58 100644
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,8 @@
goffice 0.8.13:
+Andreas
+ * Write text formats to ODF. [#636158]
+
--------------------------------------------------------------------------
goffice 0.8.12:
diff --git a/goffice/utils/go-format.c b/goffice/utils/go-format.c
index 23f26e8..d1cf57b 100644
--- a/goffice/utils/go-format.c
+++ b/goffice/utils/go-format.c
@@ -6389,8 +6389,106 @@ go_format_output_number_to_odf (GsfXMLOut *xout, GOFormat const *fmt,
#undef ODF_CLOSE_STRING
#undef ODF_OPEN_STRING
-#undef ODF_WRITE_NUMBER
+#define ODF_CLOSE_STRING if (string_is_open) { \
+ gsf_xml_out_add_cstr (xout, NULL, accum->str); \
+ gsf_xml_out_end_element (xout); /* </number:text> */ \
+ string_is_open = FALSE; \
+ }
+#define ODF_OPEN_STRING if (!string_is_open) { \
+ gsf_xml_out_start_element (xout, NUMBER "text"); \
+ string_is_open = TRUE; \
+ g_string_erase (accum, 0, -1); \
+ }
+
+static void
+go_format_output_text_to_odf (GsfXMLOut *xout, GOFormat const *fmt,
+ char const *name, int cond_part)
+{
+ char const *xl = go_format_as_XL (fmt);
+ GString *accum = g_string_new (NULL);
+
+ gboolean string_is_open = FALSE;
+
+ gsf_xml_out_start_element (xout, NUMBER "text-style");
+
+ gsf_xml_out_add_cstr (xout, STYLE "name", name);
+
+ while (1) {
+ const char *token = xl;
+ GOFormatTokenType tt;
+ int t = go_format_token (&xl, &tt);
+
+ switch (t) {
+ case 0: case ';':
+ ODF_CLOSE_STRING;
+ gsf_xml_out_end_element (xout); /* </number:text-style> */
+ g_string_free (accum, TRUE);
+ return;
+
+ case TOK_COLOR: {
+ GOColor color;
+ char *str;
+ if (go_format_parse_color (token, &color, NULL, NULL, FALSE)) {
+ ODF_CLOSE_STRING;
+ gsf_xml_out_start_element (xout, STYLE "text-properties");
+ str = g_strdup_printf ("#%.2X%.2X%.2X",
+ GO_COLOR_UINT_R (color), GO_COLOR_UINT_G (color),
+ GO_COLOR_UINT_B (color));
+ gsf_xml_out_add_cstr_unchecked (xout, FOSTYLE "color", str);
+ g_free (str);
+ gsf_xml_out_end_element (xout); /*<style:text-properties>*/
+ }
+ } break;
+
+ case TOK_STRING: {
+ size_t len = strchr (token + 1, '"') - (token + 1);
+ if (len > 0) {
+ ODF_OPEN_STRING;
+ g_string_append_len (accum, token + 1, len);
+ }
+ break;
+ }
+
+ case TOK_CHAR: {
+ size_t len = g_utf8_next_char(token) - (token);
+ if (len > 0) {
+ ODF_OPEN_STRING;
+ if (*token == '-')
+ g_string_append_unichar (accum, UNICODE_MINUS);
+ else
+ g_string_append_len (accum, token, len);
+ }
+ break;
+ }
+
+ case TOK_ESCAPED_CHAR: {
+ size_t len = g_utf8_next_char(token + 1) - (token + 1);
+ if (len > 0) {
+ ODF_OPEN_STRING;
+ if (*(token+1) == '-')
+ g_string_append_unichar (accum, UNICODE_MINUS);
+ else
+ g_string_append_len (accum, token + 1, len);
+ }
+ break;
+ }
+
+ case '@':
+ ODF_CLOSE_STRING;
+ gsf_xml_out_simple_element (xout, NUMBER "text-content", NULL);
+ break;
+
+ default:
+ ODF_OPEN_STRING;
+ g_string_append_c (accum, t);
+ break;
+ }
+ }
+}
+
+#undef ODF_CLOSE_STRING
+#undef ODF_OPEN_STRING
#define ODF_CLOSE_STRING if (string_is_open) { \
gsf_xml_out_add_cstr (xout, NULL, accum->str); \
@@ -6663,6 +6761,9 @@ go_format_output_to_odf (GsfXMLOut *xout, GOFormat const *fmt,
case GO_FORMAT_FRACTION:
go_format_output_fraction_to_odf (xout, act_fmt, name, with_extension);
break;
+ case GO_FORMAT_TEXT:
+ go_format_output_text_to_odf (xout, act_fmt, name, with_extension);
+ break;
case GO_FORMAT_SCIENTIFIC:
go_format_output_scientific_number_to_odf (xout, act_fmt, name, with_extension);
break;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]