[gnumeric] hlinks: fix inter-sheet local name references.
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] hlinks: fix inter-sheet local name references.
- Date: Mon, 13 Mar 2017 13:03:49 +0000 (UTC)
commit 6591849e2a786681cc29b3d7be0a1aeeb01c0cc4
Author: Morten Welinder <terra gnome org>
Date: Mon Mar 13 09:03:15 2017 -0400
hlinks: fix inter-sheet local name references.
ChangeLog | 5 +++++
samples/hlink-tests.gnumeric | Bin 2518 -> 2643 bytes
src/hlink.c | 25 +++++++++++++------------
3 files changed, 18 insertions(+), 12 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index a52f748..199e11e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2017-03-13 Morten Welinder <terra gnome org>
+
+ * src/hlink.c (gnm_hlink_cur_wb_set_target): Improve parsing of
+ inter-sheet local name references.
+
2017-03-10 Morten Welinder <terra gnome org>
* src/hlink.c (gnm_hlink_get_name_target)
diff --git a/samples/hlink-tests.gnumeric b/samples/hlink-tests.gnumeric
index 5bcef2a..d3e03af 100644
Binary files a/samples/hlink-tests.gnumeric and b/samples/hlink-tests.gnumeric differ
diff --git a/src/hlink.c b/src/hlink.c
index f8aa85f..55134c9 100644
--- a/src/hlink.c
+++ b/src/hlink.c
@@ -288,20 +288,21 @@ gnm_hlink_cur_wb_set_target (GnmHLink *lnk, const char *target)
if (target && lnk->sheet) {
GnmParsePos pp;
- GnmNamedExpr *nexpr;
+ GnmExprParseFlags flags = GNM_EXPR_PARSE_UNKNOWN_NAMES_ARE_INVALID;
+ GnmConventions const *convs = lnk->sheet->convs;
- // Try as name
parse_pos_init_sheet (&pp, lnk->sheet);
- nexpr = expr_name_lookup (&pp, target);
- if (nexpr != NULL)
- texpr = gnm_expr_top_new
- (gnm_expr_new_name (nexpr, NULL, NULL));
-
- if (!texpr) {
- // Try as cell range
- GnmValue *v = value_new_cellrange_str (lnk->sheet, target);
- if (v)
- texpr = gnm_expr_top_new_constant (v);
+ texpr = gnm_expr_parse_str (target, &pp, flags, convs, NULL);
+
+ if (texpr == NULL || gnm_expr_top_is_err (texpr, GNM_ERROR_REF)) {
+ // Nothing, error
+ } else if (GNM_EXPR_GET_OPER (texpr->expr) == GNM_EXPR_OP_NAME) {
+ // Nothing, we're good
+ } else {
+ // Allow only ranges and normalize
+ GnmValue *v = gnm_expr_top_get_range (texpr);
+ gnm_expr_top_unref (texpr);
+ texpr = v ? gnm_expr_top_new_constant (v) : NULL;
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]