[gnumeric] handle permanent expressions in xlsx export
- From: Andreas J. Guelzow <guelzow src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] handle permanent expressions in xlsx export
- Date: Thu, 21 Jul 2011 09:14:27 +0000 (UTC)
commit 9a040aa1ce91f21fd5f15bd8224f6fdbdb67fcfe
Author: Andreas J Guelzow <aguelzow pyrshep ca>
Date: Thu Jul 21 03:13:52 2011 -0600
handle permanent expressions in xlsx export
2011-07-21 Andreas J. Guelzow <aguelzow pyrshep ca>
* xlsx-read.c (xlsx_wb_name_end): check for "_xlnm." prefix
* xlsx-write.c (xlsx_write_named_expression): also write permanent
expressions
plugins/excel/ChangeLog | 6 ++++++
plugins/excel/xlsx-read.c | 15 ++++++++++++---
plugins/excel/xlsx-write.c | 16 +++++++++++++---
3 files changed, 31 insertions(+), 6 deletions(-)
---
diff --git a/plugins/excel/ChangeLog b/plugins/excel/ChangeLog
index ed4d75f..a68e020 100644
--- a/plugins/excel/ChangeLog
+++ b/plugins/excel/ChangeLog
@@ -1,5 +1,11 @@
2011-07-21 Andreas J. Guelzow <aguelzow pyrshep ca>
+ * xlsx-read.c (xlsx_wb_name_end): check for "_xlnm." prefix
+ * xlsx-write.c (xlsx_write_named_expression): also write permanent
+ expressions
+
+2011-07-21 Andreas J. Guelzow <aguelzow pyrshep ca>
+
* xlsx-write.c (xlsx_write_named_expression): new
(xlsx_write_definedNames): new
(xlsx_write_workbook): call xlsx_write_definedNames
diff --git a/plugins/excel/xlsx-read.c b/plugins/excel/xlsx-read.c
index affabf2..d150152 100644
--- a/plugins/excel/xlsx-read.c
+++ b/plugins/excel/xlsx-read.c
@@ -2862,9 +2862,18 @@ xlsx_wb_name_end (GsfXMLIn *xin, G_GNUC_UNUSED GsfXMLBlob *blob)
g_return_if_fail (state->defined_name != NULL);
parse_pos_init (&pp, state->wb, sheet, 0, 0);
- nexpr = expr_name_add (&pp, state->defined_name,
- gnm_expr_top_new_constant (value_new_empty ()),
- &error_msg, TRUE, NULL);
+
+ if (g_str_has_prefix (state->defined_name, "_xlnm.")) {
+ gboolean editable = (0 == strcmp (state->defined_name + 6, "Sheet_Title"));
+ nexpr = expr_name_add (&pp, state->defined_name + 6,
+ gnm_expr_top_new_constant (value_new_empty ()),
+ &error_msg, TRUE, NULL);
+ nexpr->is_permanent = TRUE;
+ nexpr->is_editable = editable;
+ } else
+ nexpr = expr_name_add (&pp, state->defined_name,
+ gnm_expr_top_new_constant (value_new_empty ()),
+ &error_msg, TRUE, NULL);
if (nexpr) {
state->delayed_names =
diff --git a/plugins/excel/xlsx-write.c b/plugins/excel/xlsx-write.c
index 88bec48..d38fb75 100644
--- a/plugins/excel/xlsx-write.c
+++ b/plugins/excel/xlsx-write.c
@@ -2050,12 +2050,22 @@ xlsx_write_named_expression (gpointer key, GnmNamedExpr *nexpr, XLSXClosure *clo
char *formula;
g_return_if_fail (nexpr != NULL);
- if (!expr_name_is_active (nexpr) || nexpr->is_permanent)
+ if (!expr_name_is_active (nexpr))
return;
gsf_xml_out_start_element (closure->xml, "definedName");
- gsf_xml_out_add_cstr (closure->xml, "name", expr_name_name (nexpr));
-
+
+ if (nexpr->is_permanent) {
+ char const *expr_name = expr_name_name (nexpr);
+ if (0 == strcmp (expr_name, "Print_Area"))
+ gsf_xml_out_add_cstr (closure->xml, "name", "_xlnm.Print_Area");
+ else if (0 == strcmp (expr_name, "Sheet_Title"))
+ gsf_xml_out_add_cstr (closure->xml, "name", "_xlnm.Sheet_Title");
+ else
+ gsf_xml_out_add_cstr (closure->xml, "name", expr_name);
+ } else {
+ gsf_xml_out_add_cstr (closure->xml, "name", expr_name_name (nexpr));
+ }
if (nexpr->pos.sheet != NULL)
gsf_xml_out_add_int (closure->xml, "localSheetId",
nexpr->pos.sheet->index_in_wb);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]