[gnumeric] xlsx: handle superscript/subscript in rich text.
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] xlsx: handle superscript/subscript in rich text.
- Date: Tue, 3 Jun 2014 23:58:48 +0000 (UTC)
commit da7ca00c95c637e2bf8d37e226a50c567c7ab6ba
Author: Morten Welinder <terra gnome org>
Date: Tue Jun 3 19:58:09 2014 -0400
xlsx: handle superscript/subscript in rich text.
Also, don't output markup formats as cell styles.
plugins/excel/ChangeLog | 4 +++-
plugins/excel/xlsx-write.c | 18 +++++++++++++++++-
2 files changed, 20 insertions(+), 2 deletions(-)
---
diff --git a/plugins/excel/ChangeLog b/plugins/excel/ChangeLog
index a6e7f1f..bfcd20a 100644
--- a/plugins/excel/ChangeLog
+++ b/plugins/excel/ChangeLog
@@ -1,8 +1,10 @@
2014-06-03 Morten Welinder <terra gnome org>
* xlsx-write.c (xlsx_write_rich_text): Add two missing "break;".
- Write only attributes that are present.
+ Write only attributes that are present. Handle superscript/subscript.
(xlsx_write_shared_strings): Handle rich text.
+ (xlsx_write_cells): Don't actually store a markup format as a cell
+ format.
* xlsx-read.c (xlsx_run_color): Handle indexed colours.
(xlsx_run_weight): Fix handling of bold.
diff --git a/plugins/excel/xlsx-write.c b/plugins/excel/xlsx-write.c
index 21b47b5..fc9f4f7 100644
--- a/plugins/excel/xlsx-write.c
+++ b/plugins/excel/xlsx-write.c
@@ -280,6 +280,7 @@ xlsx_write_rich_text (GsfXMLOut *xml, char const *text, PangoAttrList *attrs)
iter = pango_attr_list_get_iterator (attrs);
do {
PangoAttribute *attr;
+ GOFontScript fs = GO_FONT_SCRIPT_STANDARD;
gsf_xml_out_start_element (xml, "r");
gsf_xml_out_start_element (xml, "rPr");
@@ -354,6 +355,21 @@ xlsx_write_rich_text (GsfXMLOut *xml, char const *text, PangoAttrList *attrs)
gsf_xml_out_end_element (xml); /* </u> */
}
+ attr = pango_attr_iterator_get (iter, go_pango_attr_subscript_get_attr_type ());
+ if (attr && ((PangoAttrInt *) attr)->value)
+ fs = GO_FONT_SCRIPT_SUB;
+ attr = pango_attr_iterator_get (iter, go_pango_attr_superscript_get_attr_type ());
+ if (attr && ((PangoAttrInt *) attr)->value)
+ fs = GO_FONT_SCRIPT_SUPER;
+ if (fs != GO_FONT_SCRIPT_STANDARD) {
+ const char *va = (fs == GO_FONT_SCRIPT_SUB)
+ ? "subscript"
+ : "superscript";
+ gsf_xml_out_start_element (xml, "vertAlign");
+ gsf_xml_out_add_cstr_unchecked (xml, "val", va);
+ gsf_xml_out_end_element (xml); /* </vertAlign> */
+ }
+
gsf_xml_out_end_element (xml); /* </rPr> */
gsf_xml_out_start_element (xml, "t");
gsf_xml_out_add_cstr_unchecked (xml, "xml:space", "preserve");
@@ -1539,7 +1555,7 @@ xlsx_write_cells (XLSXWriteState *state, GsfXMLOut *xml,
style = sheet_style_get (sheet, c, r);
fmt1 = gnm_style_get_format (style);
fmt2 = cell ? gnm_cell_get_format_given_style (cell, style) : fmt1;
- if (fmt1 != fmt2) {
+ if (fmt1 != fmt2 && !go_format_is_markup (fmt2)) {
style = style1 = gnm_style_dup (style);
gnm_style_set_format (style1, fmt2);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]