[gnumeric] xlsx: fix output of colour for rich text.
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] xlsx: fix output of colour for rich text.
- Date: Thu, 5 Jun 2014 19:25:09 +0000 (UTC)
commit 76753c5d689adf32c3969ce55d90c72e6b3d3180
Author: Morten Welinder <terra gnome org>
Date: Thu Jun 5 15:24:02 2014 -0400
xlsx: fix output of colour for rich text.
Wrong format "%2x" -> "%02x".
Also reduce use of xml:space to cases where it matters.
plugins/excel/ChangeLog | 5 +++++
plugins/excel/xlsx-write.c | 14 ++++++++++++--
2 files changed, 17 insertions(+), 2 deletions(-)
---
diff --git a/plugins/excel/ChangeLog b/plugins/excel/ChangeLog
index a3adeb3..8df4e10 100644
--- a/plugins/excel/ChangeLog
+++ b/plugins/excel/ChangeLog
@@ -1,3 +1,8 @@
+2014-06-05 Morten Welinder <terra gnome org>
+
+ * xlsx-write.c (xlsx_write_rich_text): Fix color attribute. Only
+ write xml:space attribute when text has spaces.
+
2014-06-03 Morten Welinder <terra gnome org>
* xlsx-write.c (xlsx_write_rich_text): Add two missing "break;".
diff --git a/plugins/excel/xlsx-write.c b/plugins/excel/xlsx-write.c
index 4ca0a1f..8be5edc 100644
--- a/plugins/excel/xlsx-write.c
+++ b/plugins/excel/xlsx-write.c
@@ -316,7 +316,7 @@ xlsx_write_rich_text (GsfXMLOut *xml, char const *text, PangoAttrList *attrs)
attr = pango_attr_iterator_get (iter, PANGO_ATTR_FOREGROUND);
if (attr) {
PangoColor *color = &((PangoAttrColor *) attr)->color;
- char *buf = g_strdup_printf("FF%2x%2x%2x", color->red >> 8, color->green >> 8,
color->blue >> 8);
+ char *buf = g_strdup_printf("FF%02x%02x%02x", color->red >> 8, color->green >> 8,
color->blue >> 8);
gsf_xml_out_start_element (xml, "color");
gsf_xml_out_add_cstr_unchecked (xml, "rgb", buf);
gsf_xml_out_end_element (xml); /* </color> */
@@ -372,12 +372,22 @@ xlsx_write_rich_text (GsfXMLOut *xml, char const *text, PangoAttrList *attrs)
gsf_xml_out_end_element (xml); /* </rPr> */
gsf_xml_out_start_element (xml, "t");
- gsf_xml_out_add_cstr_unchecked (xml, "xml:space", "preserve");
pango_attr_iterator_range (iter, &start, &end);
if (end > max)
end = max;
if (start < end) {
char *buf = g_strndup (text + start, end - start);
+ const char *p;
+ gboolean has_space = FALSE;
+ for (p = buf; *p; p = g_utf8_next_char (p)) {
+ if (g_unichar_isspace (g_utf8_get_char (p))) {
+ has_space = TRUE;
+ break;
+ }
+ }
+ if (has_space)
+ gsf_xml_out_add_cstr_unchecked
+ (xml, "xml:space", "preserve");
gsf_xml_out_add_cstr (xml, NULL, buf);
g_free (buf);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]