[gnumeric] Work around OOo's failure to correctly define its named ranges. [#625332]
- From: Andreas J. Guelzow <guelzow src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] Work around OOo's failure to correctly define its named ranges. [#625332]
- Date: Tue, 27 Jul 2010 20:02:17 +0000 (UTC)
commit 3f0eb6a747ee837a7595f94a000108d6faa8503f
Author: Andreas J Guelzow <aguelzow pyrshep ca>
Date: Tue Jul 27 14:01:44 2010 -0600
Work around OOo's failure to correctly define its named ranges. [#625332]
2010-07-26 Andreas J. Guelzow <aguelzow pyrshep ca>
* openoffice-read.c (oo_db_range_start): If this filter range
has a name define it as a named-range. Some files created
by OOo depend on it.
NEWS | 1 +
plugins/openoffice/ChangeLog | 6 ++++++
plugins/openoffice/openoffice-read.c | 25 +++++++++++++++++++++++--
3 files changed, 30 insertions(+), 2 deletions(-)
---
diff --git a/NEWS b/NEWS
index 3707965..eae4eee 100644
--- a/NEWS
+++ b/NEWS
@@ -47,6 +47,7 @@ Andreas:
* Fix undo of Clear->All and Clear->Comments. [#625151][#623803]
* Add menu items to allow clearing of filtered rows only.
* Fix editing of hyperlinks.
+ * Work around OOo's failure to correctly define its named ranges. [#625332]
Jean:
* Fix strong/weak cursor display. [#623241]
diff --git a/plugins/openoffice/ChangeLog b/plugins/openoffice/ChangeLog
index b375fc2..375541b 100644
--- a/plugins/openoffice/ChangeLog
+++ b/plugins/openoffice/ChangeLog
@@ -1,3 +1,9 @@
+2010-07-26 Andreas J. Guelzow <aguelzow pyrshep ca>
+
+ * openoffice-read.c (oo_db_range_start): If this filter range
+ has a name define it as a named-range. Some files created
+ by OOo depend on it.
+
2010-07-08 Morten Welinder <terra gnome org>
* openoffice-read.c (odf_scientific): Use go_format_details_new
diff --git a/plugins/openoffice/openoffice-read.c b/plugins/openoffice/openoffice-read.c
index 20353be..b77c376 100644
--- a/plugins/openoffice/openoffice-read.c
+++ b/plugins/openoffice/openoffice-read.c
@@ -3096,6 +3096,9 @@ oo_db_range_start (GsfXMLIn *xin, xmlChar const **attrs)
gboolean buttons = TRUE;
GnmRangeRef ref;
GnmRange r;
+ char const *name = NULL;
+ GnmExpr const *expr = NULL;
+ GnmParsePos pp;
g_return_if_fail (state->filter == NULL);
@@ -3103,12 +3106,30 @@ oo_db_range_start (GsfXMLIn *xin, xmlChar const **attrs)
if (gsf_xml_in_namecmp (xin, CXML2C (attrs[0]), OO_NS_TABLE, "target-range-address")) {
char const *ptr = oo_cellref_parse (&ref.a, CXML2C (attrs[1]), &state->pos);
if (':' == *ptr &&
- '\0' == *oo_cellref_parse (&ref.b, ptr+1, &state->pos))
+ '\0' == *oo_cellref_parse (&ref.b, ptr+1, &state->pos)) {
state->filter = gnm_filter_new (ref.a.sheet, range_init_rangeref (&r, &ref));
- else
+ expr = gnm_expr_new_constant (value_new_cellrange_r (ref.a.sheet, &r));
+ } else
oo_warning (xin, _("Invalid DB range '%s'"), attrs[1]);
} else if (oo_attr_bool (xin, attrs, OO_NS_TABLE, "display-filter-buttons", &buttons))
/* ignore this */;
+ else if (gsf_xml_in_namecmp (xin, CXML2C (attrs[0]), OO_NS_TABLE, "name"))
+ name = CXML2C (attrs[1]);
+
+ /* It appears that OOo likes to use the names it assigned to filters as named-ranges */
+ /* This really violates ODF/OpenFormula. So we make sure that there isn't already a named */
+ /* expression or range with that name. */
+ if (expr != NULL) {
+ GnmNamedExpr *nexpr = NULL;
+ if (name != NULL
+ && (NULL == (nexpr = expr_name_lookup
+ (parse_pos_init (&pp, state->pos.wb, NULL, 0, 0), name)) ||
+ nexpr->is_placeholder)) {
+ GnmExprTop const *texpr = gnm_expr_top_new (expr);
+ expr_name_add (&pp, name, texpr, NULL, TRUE, NULL);
+ } else
+ gnm_expr_free (expr);
+ }
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]