[gnumeric] Ensure the table range is unlocked before allowing the data table to be configured.
- From: Andreas J. Guelzow <guelzow src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] Ensure the table range is unlocked before allowing the data table to be configured.
- Date: Mon, 28 Jun 2010 03:54:12 +0000 (UTC)
commit e4704011da8826fa9b5ad7d88563445b69132acd
Author: Andreas J Guelzow <aguelzow pyrshep ca>
Date: Sun Jun 27 21:53:52 2010 -0600
Ensure the table range is unlocked before allowing the data table to be configured.
2010-06-27 Andreas J. Guelzow <aguelzow pyrshep ca>
* src/commands.h (cmd_area_set_text): change arguments
* src/commands.c (cmd_area_set_text): this will not be
called for array functions any longer
(cmd_create_data_table): rewrite using cmd_generic
* src/ranges.c (undo_cell_pos_name): correct comment
* src/test-pango.c (cb_exercise_pango): adjust the cmd_area_set_text
call
* src/wbc-gtk-edit.c (wbcg_edit_finish): ditto
2010-06-27 Andreas J. Guelzow <aguelzow pyrshep ca>
* dialog-data-table.c (dialog_data_table): check whether the
table range is locked.
ChangeLog | 11 ++++
NEWS | 2 +
src/commands.c | 104 ++++++++++++++++++++++-----------------
src/commands.h | 2 +-
src/dialogs/ChangeLog | 5 ++
src/dialogs/dialog-data-table.c | 5 ++
src/ranges.c | 2 +-
src/test-pango.c | 2 +-
src/wbc-gtk-edit.c | 4 +-
9 files changed, 86 insertions(+), 51 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index b055fa7..91c57ec 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
2010-06-27 Andreas J. Guelzow <aguelzow pyrshep ca>
+ * src/commands.h (cmd_area_set_text): change arguments
+ * src/commands.c (cmd_area_set_text): this will not be
+ called for array functions any longer
+ (cmd_create_data_table): rewrite using cmd_generic
+ * src/ranges.c (undo_cell_pos_name): correct comment
+ * src/test-pango.c (cb_exercise_pango): adjust the cmd_area_set_text
+ call
+ * src/wbc-gtk-edit.c (wbcg_edit_finish): ditto
+
+2010-06-27 Andreas J. Guelzow <aguelzow pyrshep ca>
+
* src/cell.h (gnm_cell_set_array_formula_undo): new
* src/cell.c (gnm_cell_set_array_formula_undo): new
(gnm_cell_set_array_formula_cb): new
diff --git a/NEWS b/NEWS
index 73af7bf..52c383a 100644
--- a/NEWS
+++ b/NEWS
@@ -5,6 +5,8 @@ Andreas:
* Avoid superfluous redo items under validation failure. [#622509]
* Fix validation for array and range entry. [#622511]
* Autofit column widths in stf import. [#427382]
+ * Ensure the table range is unlocked before allowing the data
+ table to be configured.
Jean:
* Fixed autofilter (and other) combo positions. [#621817]
diff --git a/src/commands.c b/src/commands.c
index a2251c7..2c2bf4f 100644
--- a/src/commands.c
+++ b/src/commands.c
@@ -955,7 +955,6 @@ typedef struct {
GnmParsePos pp;
char *text;
- gboolean as_array;
GSList *old_contents;
GSList *selection;
} CmdAreaSetText;
@@ -965,8 +964,7 @@ cmd_area_set_text_repeat (GnmCommand const *cmd, WorkbookControl *wbc)
{
CmdAreaSetText const *orig = (CmdAreaSetText const *) cmd;
SheetView *sv = wb_control_cur_sheet_view (wbc);
- cmd_area_set_text (wbc, sv,
- orig->text, orig->as_array);
+ cmd_area_set_text (wbc, sv, orig->text, NULL);
}
MAKE_GNM_COMMAND (CmdAreaSetText, cmd_area_set_text, cmd_area_set_text_repeat)
@@ -1010,26 +1008,13 @@ cmd_area_set_text_redo (GnmCommand *cmd, WorkbookControl *wbc)
g_return_val_if_fail (me != NULL, TRUE);
- /* Check for array subdivision */
- if (sheet_ranges_split_region (me->cmd.sheet, me->selection,
- GO_CMD_CONTEXT (wbc), _("Set Text")))
- return TRUE;
-
- /* Check for locked cells */
- if (cmd_selection_is_locked_effective (me->cmd.sheet, me->selection,
- wbc, _("Set Text")))
- return TRUE;
-
expr_txt = gnm_expr_char_start_p (me->text);
if (expr_txt != NULL)
texpr = gnm_expr_parse_str
(expr_txt, &me->pp, GNM_EXPR_PARSE_DEFAULT,
sheet_get_conventions (me->cmd.sheet), NULL);
- if (me->as_array) {
- if (texpr == NULL)
- return TRUE;
- } else if (texpr != NULL) {
+ if (texpr != NULL) {
GnmEvalPos ep;
GOFormat *sf = auto_style_format_suggest (texpr,
eval_pos_init_pos (&ep, me->cmd.sheet, &me->pp.eval));
@@ -1098,9 +1083,19 @@ cmd_area_set_text_finalize (GObject *cmd)
gnm_command_finalize (cmd);
}
+/*
+ * cmd_area_set_text
+ *
+ * the caller is expected to have ensured:
+ *
+ * 1) that no array is being split
+ * 2) that the range is not locked.
+ *
+ */
+
gboolean
cmd_area_set_text (WorkbookControl *wbc, SheetView *sv,
- char const *new_text, gboolean as_array)
+ char const *new_text, PangoAttrList *markup)
{
#warning add markup
CmdAreaSetText *me;
@@ -1112,21 +1107,7 @@ cmd_area_set_text (WorkbookControl *wbc, SheetView *sv,
me->selection = selection_get_ranges (sv, FALSE /* No intersection */);
me->old_contents = NULL;
- /* Only enter an array formula if
- * 1) the text is a formula
- * 2) It's entered as an array formula
- * 3) There is only one 1 selection
- */
- me->as_array = (as_array && gnm_expr_char_start_p (me->text) != NULL &&
- me->selection != NULL && me->selection->next == NULL);
- if (me->as_array) {
- /* parse the array expr relative to the top left */
- GnmRange const *r = me->selection->data;
- parse_pos_init (&me->pp, NULL, sv_sheet (sv),
- MIN (r->start.col, r->end.col),
- MIN (r->start.row, r->end.row));
- } else
- parse_pos_init_editpos (&me->pp, sv);
+ parse_pos_init_editpos (&me->pp, sv);
text = gnm_cmd_trunc_descriptor (g_string_new (new_text), NULL);
@@ -1169,7 +1150,7 @@ cmd_area_set_array_expr (WorkbookControl *wbc, SheetView *sv,
g_return_val_if_fail (selection->next == NULL , TRUE);
name = undo_range_list_name (sheet, selection);
- text = g_strdup_printf (_("Inserting array expression in \"%s\""), name);
+ text = g_strdup_printf (_("Inserting array expression in %s"), name);
g_free (name);
undo = clipboard_copy_range_undo (sheet, selection->data);
@@ -1183,25 +1164,56 @@ cmd_area_set_array_expr (WorkbookControl *wbc, SheetView *sv,
return result;
}
+/*
+ * cmd_create_data_table
+ *
+ * the caller is expected to have ensured:
+ *
+ * 1) that no array is being split
+ * 2) that the range is not locked.
+ *
+ */
gboolean
cmd_create_data_table (WorkbookControl *wbc, Sheet *sheet, GnmRange const *r,
char const *col_input, char const *row_input)
{
- CmdAreaSetText *me = g_object_new (CMD_AREA_SET_TEXT_TYPE, NULL);
+ GOUndo *undo = NULL;
+ GOUndo *redo = NULL;
+ gboolean result;
+ char *name;
+ char *text;
+ GnmSheetRange *sr;
+ GnmParsePos pp;
+ GnmExprTop const *texpr;
+
+ name = undo_range_name (sheet, r);
+ text = g_strdup_printf (_("Creating a Data Table in %s"), name);
+ g_free (name);
- parse_pos_init (&me->pp, NULL, sheet, r->start.col, r->start.row);
- me->text = g_strdup_printf ("=TABLE(%s,%s)", row_input, col_input);
- me->selection = g_slist_prepend (NULL, gnm_range_dup (r));
- me->old_contents = NULL;
- me->as_array = TRUE;
- me->cmd.sheet = sheet;
- me->cmd.size = 1;
- me->cmd.cmd_descriptor =
- g_strdup_printf (_("Creating a Data Table in %s"),
- range_as_string (r));
+ undo = clipboard_copy_range_undo (sheet, r);
- return gnm_command_push_undo (wbc, G_OBJECT (me));
+ sr = gnm_sheet_range_new (sheet, r);
+ parse_pos_init (&pp, NULL, sheet, r->start.col, r->start.row);
+ name = g_strdup_printf ("TABLE(%s,%s)", row_input, col_input);
+ texpr = gnm_expr_parse_str
+ (name, &pp, GNM_EXPR_PARSE_DEFAULT,
+ sheet_get_conventions (sheet), NULL);
+ g_free (name);
+
+ if (texpr == NULL) {
+ g_object_unref (G_OBJECT (undo));
+ g_free (text);
+ return TRUE;
+ }
+
+ redo = gnm_cell_set_array_formula_undo (sr, texpr);
+ gnm_expr_top_unref (texpr);
+
+ result = cmd_generic (wbc, text, undo, redo);
+ g_free (text);
+ return result;
}
+
/******************************************************************/
#define CMD_INS_DEL_COLROW_TYPE (cmd_ins_del_colrow_get_type ())
diff --git a/src/commands.h b/src/commands.h
index 80d15b6..205209f 100644
--- a/src/commands.h
+++ b/src/commands.h
@@ -36,7 +36,7 @@ gboolean cmd_set_text (WorkbookControl *wbc, Sheet *sheet,
PangoAttrList *markup);
gboolean cmd_area_set_text (WorkbookControl *wbc, SheetView *sv,
- char const *text, gboolean as_array);
+ char const *text, PangoAttrList *markup);
gboolean cmd_area_set_array_expr (WorkbookControl *wbc, SheetView *sv,
GnmExprTop const *new_texpr);
diff --git a/src/dialogs/ChangeLog b/src/dialogs/ChangeLog
index e8db1b0..0c30fbb 100644
--- a/src/dialogs/ChangeLog
+++ b/src/dialogs/ChangeLog
@@ -1,3 +1,8 @@
+2010-06-27 Andreas J. Guelzow <aguelzow pyrshep ca>
+
+ * dialog-data-table.c (dialog_data_table): check whether the
+ table range is locked.
+
2010-06-24 Andreas J. Guelzow <aguelzow pyrshep ca>
* dialog-stf.h (FormatInfo_t): add new field
diff --git a/src/dialogs/dialog-data-table.c b/src/dialogs/dialog-data-table.c
index 773e031..51fe16a 100644
--- a/src/dialogs/dialog-data-table.c
+++ b/src/dialogs/dialog-data-table.c
@@ -159,6 +159,11 @@ dialog_data_table (WBCGtk *wbcg)
if (sheet_range_splits_region (sheet, &input_range, NULL,
GO_CMD_CONTEXT (wbcg), _("Data Table")))
return;
+ if (cmd_cell_range_is_locked_effective
+ (sheet, &input_range, WORKBOOK_CONTROL (wbcg),
+ _("Data Table")))
+ return;
+
state = g_new0 (GnmDialogDataTable, 1);
state->wbcg = wbcg;
diff --git a/src/ranges.c b/src/ranges.c
index b9e4749..03102bb 100644
--- a/src/ranges.c
+++ b/src/ranges.c
@@ -910,7 +910,7 @@ undo_cell_pos_name (Sheet const *sheet, GnmCellPos const *pos)
}
/**
- * char const *undo_range_name
+ * char *undo_range_name
* @sheet:
* @r:
*
diff --git a/src/test-pango.c b/src/test-pango.c
index 599453f..9fd4f61 100644
--- a/src/test-pango.c
+++ b/src/test-pango.c
@@ -43,7 +43,7 @@ cb_exercise_pango (gpointer data)
if (state == 0) {
sv_selection_reset (sv);
sv_selection_add_full(sv, 0, 0, 0, 0, 40, STEP_SIZE*TEST_STEPS);
- cmd_area_set_text (wbc, sv, "=rand()", FALSE);
+ cmd_area_set_text (wbc, sv, "=rand()", NULL);
} else if (state < TEST_STEPS) {
SHEET_VIEW_FOREACH_CONTROL(wb_control_cur_sheet_view (wbc),
sc, sc_set_top_left (sc, 0, state*STEP_SIZE););
diff --git a/src/wbc-gtk-edit.c b/src/wbc-gtk-edit.c
index 32609a0..7843ae3 100644
--- a/src/wbc-gtk-edit.c
+++ b/src/wbc-gtk-edit.c
@@ -196,7 +196,7 @@ wbcg_edit_finish (WBCGtk *wbcg, WBCEditResult result,
GnmRange r;
r.end = r.start = pp.eval;
- if (cmd_selection_is_locked_effective (sheet, selection, wbc,
+ if (cmd_cell_range_is_locked_effective (sheet, &r, wbc,
_("Set Text"))) {
range_fragment_free (selection);
*showed_dialog = TRUE;
@@ -404,7 +404,7 @@ wbcg_edit_finish (WBCGtk *wbcg, WBCEditResult result,
cmd_set_text (wbc, sheet, &sv->edit_pos, txt, res_markup);
if (res_markup) pango_attr_list_unref (res_markup);
} else
- cmd_area_set_text (wbc, sv, txt, FALSE);
+ cmd_area_set_text (wbc, sv, txt, NULL);
}
}
if (texpr != NULL)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]