[gnumeric] xlsx: fix export of non-shared strings.
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] xlsx: fix export of non-shared strings.
- Date: Mon, 8 Sep 2014 13:07:36 +0000 (UTC)
commit 919064a64c2db5ead692f2404530e609c13909b2
Author: Morten Welinder <terra gnome org>
Date: Mon Sep 8 09:09:22 2014 -0400
xlsx: fix export of non-shared strings.
NEWS | 1 +
plugins/excel/ChangeLog | 8 ++++++++
plugins/excel/xlsx-write.c | 33 +++++++++++++++++++++++++--------
3 files changed, 34 insertions(+), 8 deletions(-)
---
diff --git a/NEWS b/NEWS
index 7d14697..e528a5b 100644
--- a/NEWS
+++ b/NEWS
@@ -7,6 +7,7 @@ Andreas:
Morten:
* Fix xls export problem. [#733771]
* Update WEEKDAY function.
+ * Fix xlsx export problem for strings. [#736202]
--------------------------------------------------------------------------
Gnumeric 1.12.17
diff --git a/plugins/excel/ChangeLog b/plugins/excel/ChangeLog
index 1249610..b0362b2 100644
--- a/plugins/excel/ChangeLog
+++ b/plugins/excel/ChangeLog
@@ -1,3 +1,11 @@
+2014-09-08 Morten Welinder <terra gnome org>
+
+ * xlsx-write.c (xlsx_write_cells): Write string values that are
+ not formula results and not shared using the proper "inlineStr"
+ type. Neither Excel nor LO really cares, but someone else does,
+ see bug 736202. As a side effect, this will improve the rich-text
+ situation.
+
2014-07-27 Morten Welinder <terra gnome org>
* ms-excel-write.c (excel_write_DIMENSION): Fix off-by-one, see
diff --git a/plugins/excel/xlsx-write.c b/plugins/excel/xlsx-write.c
index 22e10aa..bbfc221 100644
--- a/plugins/excel/xlsx-write.c
+++ b/plugins/excel/xlsx-write.c
@@ -1473,9 +1473,7 @@ xlsx_write_cells (XLSXWriteState *state, GsfXMLOut *xml,
GnmRange const *extent, GnmStyle **col_styles)
{
int r, c;
- char const *type;
char *content;
- int str_id = -1;
GnmParsePos pp;
GnmExprTop const *texpr;
GnmExprArrayCorner const *array;
@@ -1579,6 +1577,10 @@ xlsx_write_cells (XLSXWriteState *state, GsfXMLOut *xml,
gnm_style_unref (style1);
if (cell) {
+ char const *type;
+ gboolean inlineStr = FALSE;
+ int str_id = -1;
+
xlsx_write_init_row (&needs_row, xml, r, cheesy_span);
gsf_xml_out_start_element (xml, "c");
gsf_xml_out_add_cstr_unchecked (xml, "r",
@@ -1606,8 +1608,12 @@ xlsx_write_cells (XLSXWriteState *state, GsfXMLOut *xml,
if (go_string_get_ref_count (val->v_str.val) > 1) {
str_id = xlsx_shared_string (state, val);
type = "s";
- } else
+ } else if (gnm_cell_has_expr (cell))
type = "str";
+ else {
+ type = "inlineStr";
+ inlineStr = TRUE;
+ }
break;
case VALUE_CELLRANGE:
case VALUE_ARRAY:
@@ -1639,14 +1645,25 @@ xlsx_write_cells (XLSXWriteState *state, GsfXMLOut *xml,
gsf_xml_out_end_element (xml); /* </f> */
}
}
- if (NULL != type) {
+
+ if (inlineStr) {
+ PangoAttrList *attrs = VALUE_FMT (val)
+ ? (PangoAttrList *)go_format_get_markup (VALUE_FMT (val))
+ : NULL;
+
+ gsf_xml_out_start_element (xml, "is");
+ xlsx_write_rich_text (xml,
+ value_peek_string (val),
+ attrs,
+ FALSE);
+ gsf_xml_out_end_element (xml); /* </is> */
+ } else if (type) {
gsf_xml_out_start_element (xml, "v");
- if (str_id >= 0) {
+ if (str_id >= 0)
gsf_xml_out_add_int (xml, NULL, str_id);
- str_id = -1;
- } else if (VALUE_IS_BOOLEAN (val)) {
+ else if (VALUE_IS_BOOLEAN (val))
xlsx_add_bool (xml, NULL, value_get_as_int (val));
- } else {
+ else {
GString *str = g_string_new (NULL);
value_get_as_gstring (cell->value, str, state->convs);
gsf_xml_out_add_cstr (xml, NULL, str->str);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]