Commit 8cd55d50 authored by Jody Goldberg's avatar Jody Goldberg Committed by Jody Goldberg

call gnm_expr_entry_set_parsepos to be sure we're using the right notional


2005-06-09  Jody Goldberg <jody@gnome.org>

	* src/item-edit.c (ie_scan_for_range) : call
	  gnm_expr_entry_set_parsepos to be sure we're using the right
	  notional position.  This only really matters for R1C1 refs.

	* src/rendered-value.c (rendered_value_render) : use the Sheet::convs
	  to display expressions.
	(cell_get_entered_text) : ditto.

	* src/parse-util.c (rangeref_as_string) : r1c1 support.
	(cellref_as_string) : ditto.

	* src/item-bar.c (item_bar_draw) : for r1c1 use numbers for col
	  headers.
	(item_bar_calc_size) : ditto.

	* src/sheet.c : Add use-r1c1 property
	(re_render_formulas) : split from
	(sheet_set_display_formulas) : here.
	(sheet_set_use_r1c1) : for use here.

	* src/wbcg-actions.c (toggle_actions) : Add r1c1 toggle
	* src/GNOME_Gnumeric-gtk.xml : use it
parent 9a275ddd
2005-06-09 Jody Goldberg <jody@gnome.org>
* src/item-edit.c (ie_scan_for_range) : call
gnm_expr_entry_set_parsepos to be sure we're using the right
notional position. This only really matters for R1C1 refs.
* src/rendered-value.c (rendered_value_render) : use the Sheet::convs
to display expressions.
(cell_get_entered_text) : ditto.
* src/parse-util.c (rangeref_as_string) : r1c1 support.
(cellref_as_string) : ditto.
* src/item-bar.c (item_bar_draw) : for r1c1 use numbers for col
headers.
(item_bar_calc_size) : ditto.
* src/sheet.c : Add use-r1c1 property
(re_render_formulas) : split from
(sheet_set_display_formulas) : here.
(sheet_set_use_r1c1) : for use here.
* src/wbcg-actions.c (toggle_actions) : Add r1c1 toggle
* src/GNOME_Gnumeric-gtk.xml : use it
2005-06-09 Morten Welinder <terra@gnome.org>
* src/workbook.c (workbook_sheet_delete): Merge
......
......@@ -34,7 +34,7 @@ Jody:
* Improve handling of some odd XL operators.
* Remove warning when nudging during object creation. [#164779]
* Delete while editing should not clear the cell. [#165172]
* Add R1C1 parser.
* R1C1 support.
Jon Kåre:
* Don't output the xml declaration for xhtml. [#303827]
......
2005-06-09 Jody Goldberg <jody@gnome.org>
* src/item-edit.c (ie_scan_for_range) : call
gnm_expr_entry_set_parsepos to be sure we're using the right
notional position. This only really matters for R1C1 refs.
* src/rendered-value.c (rendered_value_render) : use the Sheet::convs
to display expressions.
(cell_get_entered_text) : ditto.
* src/parse-util.c (rangeref_as_string) : r1c1 support.
(cellref_as_string) : ditto.
* src/item-bar.c (item_bar_draw) : for r1c1 use numbers for col
headers.
(item_bar_calc_size) : ditto.
* src/sheet.c : Add use-r1c1 property
(re_render_formulas) : split from
(sheet_set_display_formulas) : here.
(sheet_set_use_r1c1) : for use here.
* src/wbcg-actions.c (toggle_actions) : Add r1c1 toggle
* src/GNOME_Gnumeric-gtk.xml : use it
2005-06-09 Morten Welinder <terra@gnome.org>
* src/workbook.c (workbook_sheet_delete): Merge
......
......@@ -4347,15 +4347,15 @@ excel_read_WINDOW2 (BiffQuery *q, ExcelReadSheet *esheet, WorkbookView *wb_view)
static void
excel_read_CF (BiffQuery *q, ExcelReadSheet *esheet)
{
guint8 const type = GSF_LE_GET_GUINT8 (q->data + 0);
guint8 const op = GSF_LE_GET_GUINT8 (q->data + 1);
guint8 const type = GSF_LE_GET_GUINT8 (q->data + 0);
guint8 const op = GSF_LE_GET_GUINT8 (q->data + 1);
guint16 const expr1_len = GSF_LE_GET_GUINT16 (q->data + 2);
guint16 const expr2_len = GSF_LE_GET_GUINT16 (q->data + 4);
guint8 const fmt_type = GSF_LE_GET_GUINT8 (q->data + 9);
guint32 const fmt_type = GSF_LE_GET_GUINT32 (q->data + 6);
unsigned offset;
GnmExpr const *expr1 = NULL, *expr2 = NULL;
d (1, fprintf (stderr,"cond type = %d, op type = %d\n", (int)type, (int)op););
d (1, fprintf (stderr,"cond type = %d, op type = %d, flags = 0x%x\n", (int)type, (int)op, fmt_type););
#if 0
switch (type) {
case 1 :
......@@ -4427,7 +4427,7 @@ excel_read_CF (BiffQuery *q, ExcelReadSheet *esheet)
offset = 6 /* CF record header */ + 6; /* format header */
if (fmt_type & 0x04) { /* font */
if (fmt_type & 0x04000000) { /* font */
d (1, {
puts ("Font");
gsf_mem_dump (q->data+offset, 118);
......@@ -4436,7 +4436,7 @@ excel_read_CF (BiffQuery *q, ExcelReadSheet *esheet)
offset += 118;
}
if (fmt_type & 0x10) { /* borders */
if (fmt_type & 0x10000000) { /* borders */
d (1, {
puts ("Border");
gsf_mem_dump (q->data+offset, 8);
......@@ -4445,15 +4445,14 @@ excel_read_CF (BiffQuery *q, ExcelReadSheet *esheet)
offset += 8;
}
if (fmt_type & 0x20) { /* pattern */
/* TODO : use the head flags to conditionally set things
* FIXME : test this
*/
if (fmt_type & 0x20000000) { /* pattern */
guint16 tmp = GSF_LE_GET_GUINT16 (q->data + offset);
int pat_foregnd_col = (tmp & 0x007f);
int pat_backgnd_col = (tmp & 0x1f80) >> 7;
int fill_pattern_idx;
gsf_mem_dump (q->data+offset, 4);
tmp = GSF_LE_GET_GUINT16 (q->data + offset + 2);
fill_pattern_idx =
excel_map_pattern_index_from_excel ((tmp >> 10) & 0x3f);
......@@ -4465,7 +4464,7 @@ excel_read_CF (BiffQuery *q, ExcelReadSheet *esheet)
pat_foregnd_col = swap;
}
d (1, fprintf (stderr,"fore = %d, back = %d, pattern = %d.\n",
d (-1, fprintf (stderr,"fore = %d, back = %d, pattern = %d.\n",
pat_foregnd_col,
pat_backgnd_col,
fill_pattern_idx););
......@@ -5295,7 +5294,7 @@ static void
excel_read_REFMODE (BiffQuery *q, ExcelReadSheet *esheet)
{
guint16 mode = GSF_LE_GET_GUINT16 (q->data);
esheet->sheet->r1c1_addresses = (mode == 0);
g_object_set (esheet->sheet, "use-r1c1", mode == 0, NULL);
}
static gboolean
......
......@@ -112,6 +112,7 @@ item_bar_calc_size (ItemBar *ib)
int size = pango_font_description_get_size (src_desc);
PangoLayout *layout;
PangoRectangle ink_rect, logical_rect;
gboolean const char_label = ib->is_col_header && !sheet->r1c1_addresses;
ib_fonts_unref (ib);
......@@ -125,7 +126,7 @@ item_bar_calc_size (ItemBar *ib)
* (Note that we avoid J/Q/Y which may go below the line.)
*/
pango_layout_set_text (layout,
ib->is_col_header ? "AHW" : "0123456789",
char_label ? "AHW" : "0123456789",
-1);
ib->normal_font = pango_context_load_font (context, desc);
pango_layout_set_font_description (layout, desc);
......@@ -144,7 +145,7 @@ item_bar_calc_size (ItemBar *ib)
ib->bold_font_ascent = PANGO_PIXELS (ink_rect.height + ink_rect.y);
/* 5 pixels left and right plus the width of the widest string I can think of */
if (ib->is_col_header)
if (char_label)
pango_layout_set_text (layout, "WWWWWWWWWW", strlen (col_name (SHEET_MAX_COLS - 1)));
else
pango_layout_set_text (layout, "8888888888", strlen (row_name (SHEET_MAX_ROWS - 1)));
......@@ -338,6 +339,7 @@ item_bar_draw (FooCanvasItem *item, GdkDrawable *drawable, GdkEventExpose *expos
int const len = (inc > 4) ? 4 : inc;
int end = expose->area.x;
int total, col = gcanvas->first.col;
gboolean const char_label = !sheet->r1c1_addresses;
/* shadow type selection must be keep in sync with code in ib_draw_cell */
rect.y = ib->indent;
......@@ -393,9 +395,13 @@ item_bar_draw (FooCanvasItem *item, GdkDrawable *drawable, GdkEventExpose *expos
rect.width = pixels;
ib_draw_cell (ib, drawable, ib->text_gc,
has_object ? COL_ROW_NO_SELECTION
: sv_selection_col_type (sv, col),
col_name (col), &rect);
has_object
? COL_ROW_NO_SELECTION
: sv_selection_col_type (sv, col),
char_label
? col_name (col)
: row_name (col),
&rect);
if (len > 0) {
if (!draw_right) {
......
......@@ -97,9 +97,12 @@ ie_scan_for_range (ItemEdit *ie)
GnmRange range;
Sheet *sheet = sc_sheet (SHEET_CONTROL (ie->scg));
Sheet *parse_sheet;
GnmParsePos pp;
GnmExprEntry *gee = GNM_EXPR_ENTRY (
gtk_widget_get_parent (GTK_WIDGET (ie->entry)));
gnm_expr_entry_set_parsepos (gee,
parse_pos_init_editpos (&pp, sc_view (SHEET_CONTROL (ie->scg))));
if (!ie->feedback_disabled) {
gnm_expr_expr_find_range (gee);
if (gnm_expr_entry_get_rangesel (gee, &range, &parse_sheet) &&
......
......@@ -223,6 +223,18 @@ cellref_abs_row (GnmCellRef const *ref, GnmParsePos const *pp)
return row;
}
static void
r1c1_add_index (GString *target, char type, int num, unsigned char relative)
{
if (relative) {
if (num != 0)
g_string_append_printf (target, "%c[%d]", type, num);
else
g_string_append_c (target, type);
} else
g_string_append_printf (target, "%c%d", type, num + 1);
}
/**
* cellref_as_string :
* @ref :
......@@ -239,7 +251,7 @@ cellref_as_string (GString *target, GnmExprConventions const *conv,
GnmParsePos const *pp, gboolean no_sheetname)
{
int col, row;
Sheet *sheet = cell_ref->sheet;
Sheet const *sheet = cell_ref->sheet;
/* If it is a non-local reference, add the path to the external sheet */
if (sheet != NULL && !no_sheetname) {
......@@ -257,31 +269,36 @@ cellref_as_string (GString *target, GnmExprConventions const *conv,
g_string_append (target, conv->output_sheet_name_sep);
}
if (cell_ref->col_relative)
col = pp->eval.col + cell_ref->col;
else {
g_string_append_c (target, '$');
col = cell_ref->col;
}
if (conv->r1c1_addresses) { /* R1C1 handler */
r1c1_add_index (target, 'R', cell_ref->row, cell_ref->row_relative);
r1c1_add_index (target, 'C', cell_ref->col, cell_ref->col_relative);
} else {
if (cell_ref->col_relative)
col = pp->eval.col + cell_ref->col;
else {
g_string_append_c (target, '$');
col = cell_ref->col;
}
/* ICK! XL compatibility kludge */
col %= SHEET_MAX_COLS;
if (col < 0)
col += SHEET_MAX_COLS;
col_name_internal (target, col);
if (cell_ref->row_relative)
row = pp->eval.row + cell_ref->row;
else {
g_string_append_c (target, '$');
row = cell_ref->row;
}
/* ICK! XL compatibility kludge */
col %= SHEET_MAX_COLS;
if (col < 0)
col += SHEET_MAX_COLS;
col_name_internal (target, col);
/* ICK! XL compatibility kludge */
row %= SHEET_MAX_ROWS;
if (row < 0)
row += SHEET_MAX_ROWS;
row_name_internal (target, row);
if (cell_ref->row_relative)
row = pp->eval.row + cell_ref->row;
else {
g_string_append_c (target, '$');
row = cell_ref->row;
}
/* ICK! XL compatibility kludge */
row %= SHEET_MAX_ROWS;
if (row < 0)
row += SHEET_MAX_ROWS;
row_name_internal (target, row);
}
}
/**
......@@ -320,42 +337,72 @@ rangeref_as_string (GString *target, GnmExprConventions const *conv,
g_string_append (target, conv->output_sheet_name_sep);
}
/* be sure to use else if so that a1:iv65535 does not vanish */
if (r.start.col == 0 && r.end.col == SHEET_MAX_COLS-1) {
if (!ref->a.row_relative)
g_string_append_c (target, '$');
row_name_internal (target, r.start.row);
g_string_append_c (target, ':');
if (!ref->b.row_relative)
g_string_append_c (target, '$');
row_name_internal (target, r.end.row);
} else if (r.start.row == 0 && r.end.row == SHEET_MAX_ROWS-1) {
if (!ref->a.col_relative)
g_string_append_c (target, '$');
col_name_internal (target, r.start.col);
g_string_append_c (target, ':');
if (!ref->b.col_relative)
g_string_append_c (target, '$');
col_name_internal (target, r.end.col);
if (conv->r1c1_addresses) { /* R1C1 handler */
/* be sure to use else if so that a1:iv65535 does not vanish */
if (r.start.col == 0 && r.end.col == SHEET_MAX_COLS-1) {
r1c1_add_index (target, 'R', ref->a.row, ref->a.row_relative);
if (ref->a.row != ref->b.row ||
ref->a.row_relative != ref->b.row_relative) {
g_string_append_c (target, ':');
r1c1_add_index (target, 'R', ref->b.row, ref->b.row_relative);
}
} else if (r.start.row == 0 && r.end.row == SHEET_MAX_ROWS-1) {
r1c1_add_index (target, 'C', ref->a.col, ref->a.col_relative);
if (ref->a.col != ref->b.col ||
ref->a.col_relative != ref->b.col_relative) {
g_string_append_c (target, ':');
r1c1_add_index (target, 'C', ref->b.col, ref->b.col_relative);
}
} else {
r1c1_add_index (target, 'R', ref->a.row, ref->a.row_relative);
r1c1_add_index (target, 'C', ref->a.col, ref->a.col_relative);
if (r.start.col != r.end.col ||
ref->a.col_relative != ref->b.col_relative ||
r.start.row != r.end.row ||
ref->a.row_relative != ref->b.row_relative) {
g_string_append_c (target, ':');
r1c1_add_index (target, 'R', ref->b.row, ref->b.row_relative);
r1c1_add_index (target, 'C', ref->b.col, ref->b.col_relative);
}
}
} else {
if (!ref->a.col_relative)
g_string_append_c (target, '$');
col_name_internal (target, r.start.col);
if (!ref->a.row_relative)
g_string_append_c (target, '$');
row_name_internal (target, r.start.row);
if (r.start.col != r.end.col ||
ref->a.col_relative != ref->b.col_relative ||
r.start.row != r.end.row ||
ref->a.row_relative != ref->b.row_relative) {
/* be sure to use else if so that a1:iv65535 does not vanish */
if (r.start.col == 0 && r.end.col == SHEET_MAX_COLS-1) {
if (!ref->a.row_relative)
g_string_append_c (target, '$');
row_name_internal (target, r.start.row);
g_string_append_c (target, ':');
if (!ref->b.row_relative)
g_string_append_c (target, '$');
row_name_internal (target, r.end.row);
} else if (r.start.row == 0 && r.end.row == SHEET_MAX_ROWS-1) {
if (!ref->a.col_relative)
g_string_append_c (target, '$');
col_name_internal (target, r.start.col);
g_string_append_c (target, ':');
if (!ref->b.col_relative)
g_string_append_c (target, '$');
col_name_internal (target, r.end.col);
if (!ref->b.row_relative)
} else {
if (!ref->a.col_relative)
g_string_append_c (target, '$');
row_name_internal (target, r.end.row);
col_name_internal (target, r.start.col);
if (!ref->a.row_relative)
g_string_append_c (target, '$');
row_name_internal (target, r.start.row);
if (r.start.col != r.end.col ||
ref->a.col_relative != ref->b.col_relative ||
r.start.row != r.end.row ||
ref->a.row_relative != ref->b.row_relative) {
g_string_append_c (target, ':');
if (!ref->b.col_relative)
g_string_append_c (target, '$');
col_name_internal (target, r.end.col);
if (!ref->b.row_relative)
g_string_append_c (target, '$');
row_name_internal (target, r.end.row);
}
}
}
}
......
......@@ -110,7 +110,7 @@ rendered_value_render (GString *str,
g_string_append_c (str, '=');
gnm_expr_as_gstring (str, cell->base.expression,
parse_pos_init_cell (&pp, cell),
gnm_expr_conventions_default);
sheet->convs);
*go_color = 0;
} else if (sheet && sheet->hide_zero && cell_is_zero (cell)) {
*go_color = 0;
......@@ -588,7 +588,7 @@ cell_get_entered_text (GnmCell const *cell)
gnm_expr_as_gstring (res, cell->base.expression,
parse_pos_init_cell (&pp, cell),
gnm_expr_conventions_default);
cell->base.sheet->convs);
return g_string_free (res, FALSE);
}
......
......@@ -1280,6 +1280,7 @@ sheet_control_gui_new (SheetView *sv, WorkbookControlGUI *wbcg)
"signal::notify::display-grid", cb_scg_redraw, scg,
"signal::notify::display-column-header", cb_scg_prefs, scg,
"signal::notify::display-row-header", cb_scg_prefs, scg,
"signal::notify::use-r1c1", cb_scg_redraw, scg,
"signal::notify::display-outlines", cb_scg_redraw_resize, scg,
"signal::notify::display-outlines-below", cb_scg_redraw_resize, scg,
"signal::notify::display-outlines-right", cb_scg_redraw_resize, scg,
......
......@@ -94,6 +94,7 @@ enum {
PROP_DISPLAY_OUTLINES,
PROP_DISPLAY_OUTLINES_BELOW,
PROP_DISPLAY_OUTLINES_RIGHT,
PROP_USE_R1C1,
PROP_TAB_FOREGROUND,
PROP_TAB_BACKGROUND,
PROP_ZOOM_FACTOR
......@@ -127,16 +128,11 @@ sheet_set_visibility (Sheet *sheet, GnmSheetVisibility visibility)
sheet_set_dirty (sheet, TRUE);
}
static void
sheet_set_display_formulas (Sheet *sheet, gboolean display)
static void
re_render_formulas (Sheet const *sheet)
{
GnmCell *cell;
display = !!display;
if (sheet->display_formulas == display)
return;
sheet->display_formulas = display;
SHEET_FOREACH_DEPENDENT (sheet, dep, {
if (dependent_is_cell (dep)) {
cell = DEP_TO_CELL (dep);
......@@ -152,6 +148,32 @@ sheet_set_display_formulas (Sheet *sheet, gboolean display)
});
}
static void
sheet_set_display_formulas (Sheet *sheet, gboolean display)
{
display = !!display;
if (sheet->display_formulas == display)
return;
sheet->display_formulas = display;
re_render_formulas (sheet);
}
static void
sheet_set_use_r1c1 (Sheet *sheet, gboolean use_r1c1)
{
use_r1c1 = !!use_r1c1;
if (sheet->r1c1_addresses == use_r1c1)
return;
sheet->r1c1_addresses = use_r1c1;
sheet->convs = sheet->r1c1_addresses
? gnm_expr_conventions_r1c1
: gnm_expr_conventions_default;
if (sheet->display_formulas)
re_render_formulas (sheet);
SHEET_FOREACH_VIEW (sheet, sv,
sv->edit_pos_changed.content = TRUE;);
}
static GnmValue *
cb_rerender_zeroes (Sheet *sheet, int col, int row, GnmCell *cell,
gpointer ignored)
......@@ -323,6 +345,9 @@ gnm_sheet_set_property (GObject *object, guint property_id,
case PROP_DISPLAY_OUTLINES_RIGHT:
sheet->outline_symbols_right = !!g_value_get_boolean (value);
break;
case PROP_USE_R1C1:
sheet_set_use_r1c1 (sheet, g_value_get_boolean (value));
break;
case PROP_TAB_FOREGROUND: {
GnmColor *color = g_value_dup_boxed (value);
style_color_unref (sheet->tab_text_color);
......@@ -387,6 +412,9 @@ gnm_sheet_get_property (GObject *object, guint property_id,
case PROP_DISPLAY_OUTLINES_RIGHT:
g_value_set_boolean (value, sheet->outline_symbols_right);
break;
case PROP_USE_R1C1:
g_value_set_boolean (value, sheet->r1c1_addresses);
break;
case PROP_TAB_FOREGROUND:
g_value_set_boxed (value, sheet->tab_text_color);
break;
......@@ -472,6 +500,7 @@ gnm_sheet_init (Sheet *sheet)
sheet->priv->enable_showhide_detail = TRUE;
sheet->names = NULL;
sheet->convs = gnm_expr_conventions_default;
sheet_style_init (sheet);
......@@ -600,6 +629,15 @@ gnm_sheet_class_init (GObjectClass *gobject_class)
TRUE,
GSF_PARAM_STATIC |
G_PARAM_READWRITE));
g_object_class_install_property
(gobject_class,
PROP_USE_R1C1,
g_param_spec_boolean ("use-r1c1",
_("Use R1C1 notation rather than A1"),
_("Display cell addresses using R1C1 notion rather than the more common A1."),
TRUE,
GSF_PARAM_STATIC |
G_PARAM_READWRITE));
g_object_class_install_property
(gobject_class,
PROP_TAB_FOREGROUND,
......
......@@ -92,6 +92,7 @@ struct _Sheet {
GnmColor *tab_color;
GnmColor *tab_text_color;
GnmSheetType sheet_type;
GnmExprConventions const *convs;
/* This needs to move elsewhere and get shared. */
PangoContext *context;
......
......@@ -2020,6 +2020,7 @@ static GNM_ACTION_DEF (cb_sheet_pref_ ## flag ) \
if (!wbcg->updating_ui) { \
Sheet *sheet = wbcg_cur_sheet (wbcg); \
go_object_toggle (sheet, property); \
sheet_update (sheet); \
} \
}
......@@ -2031,6 +2032,7 @@ TOGGLE_HANDLER (hide_row_header, "display-row-header")
TOGGLE_HANDLER (display_outlines, "display-outlines")
TOGGLE_HANDLER (outline_symbols_below, "display-outlines-below")
TOGGLE_HANDLER (outline_symbols_right, "display-outlines-right")
TOGGLE_HANDLER (use_r1c1, "use-r1c1")
static const GtkToggleActionEntry toggle_actions[] = {
{ "SheetDisplayOutlines", NULL, N_("Display _Outlines"),
......@@ -2057,6 +2059,9 @@ static const GtkToggleActionEntry toggle_actions[] = {
{ "SheetHideRowHeader", NULL, N_("Hide _Row Headers"),
NULL, N_("Toggle whether or not to display row headers"),
G_CALLBACK (cb_sheet_pref_hide_row_header) },
{ "SheetUseR1C1", NULL, N_("Use R1C1 N_otation "),
NULL, N_("Display addresses as R1C1 or A1"),
G_CALLBACK (cb_sheet_pref_use_r1c1) },
{ "AlignLeft", GTK_STOCK_JUSTIFY_LEFT,
N_("_Left Align"), NULL,
......
......@@ -51,6 +51,7 @@ struct _GnmExprEntry {
GtkWidget *icon;
SheetControlGUI *scg; /* the source of the edit */
Sheet *sheet; /* from scg */
GnmParsePos pp; /* from scg->sv */
WorkbookControlGUI *wbcg; /* from scg */
Rangesel rangesel;
......@@ -555,12 +556,10 @@ static char *
gee_rangesel_make_text (GnmExprEntry const *gee)
{
GnmRangeRef ref;
GnmParsePos pp;
GString *target = g_string_new (NULL);
gee_prepare_range (gee, &ref);
rangeref_as_string (target, gnm_expr_conventions_default,
&ref, parse_pos_init_sheet (&pp, gee->sheet));
rangeref_as_string (target, gee->sheet->convs, &ref, &gee->pp);
return g_string_free (target, FALSE);
}
......@@ -617,7 +616,6 @@ gnm_expr_expr_find_range (GnmExprEntry *gee)
char const *text, *cursor, *tmp, *ptr;
GnmRangeRef range;
Rangesel *rs;
GnmParsePos pp;
int len;
g_return_if_fail (gee != NULL);
......@@ -642,13 +640,12 @@ gnm_expr_expr_find_range (GnmExprEntry *gee)
cursor = text + gtk_editable_get_position (GTK_EDITABLE (gee->entry));
parse_pos_init_sheet (&pp, gee->sheet);
ptr = gnm_expr_char_start_p (text);
if (ptr == NULL)
ptr = text;
while (ptr != NULL && *ptr && ptr <= cursor) {
tmp = rangeref_parse (&range, ptr, &pp, gnm_expr_conventions_default);
tmp = rangeref_parse (&range, ptr, &gee->pp, gee->sheet->convs);
if (tmp != ptr) {
if (tmp >= cursor) {
rs->is_valid = TRUE;
......@@ -948,6 +945,7 @@ gnm_expr_entry_set_scg (GnmExprEntry *gee, SheetControlGUI *scg)
g_object_weak_ref (G_OBJECT (gee->scg),
(GWeakNotify) cb_scg_destroy, gee);
gee->sheet = sc_sheet (SHEET_CONTROL (scg));
parse_pos_init_sheet (&gee->pp, gee->sheet);
gee->wbcg = scg_get_wbcg (gee->scg);
} else
gee->sheet = NULL;
......@@ -956,6 +954,12 @@ gnm_expr_entry_set_scg (GnmExprEntry *gee, SheetControlGUI *scg)
#endif
}
void
gnm_expr_entry_set_parsepos (GnmExprEntry *gee, GnmParsePos const *pp)
{
gee->pp = *pp;
}
/**
* gnm_expr_entry_load_from_text :
* @gee :
......@@ -983,13 +987,14 @@ gnm_expr_entry_load_from_text (GnmExprEntry *gee, char const *txt)
void
gnm_expr_entry_load_from_dep (GnmExprEntry *gee, GnmDependent const *dep)
{
GnmParsePos pp;
g_return_if_fail (IS_GNM_EXPR_ENTRY (gee));
g_return_if_fail (dep != NULL);
/* We have nowhere to store the text while frozen. */
g_return_if_fail (gee->freeze_count == 0);
if (dep->expression != NULL) {
GnmParsePos pp;
char *text = gnm_expr_as_string (dep->expression,
parse_pos_init_dep (&pp, dep), gnm_expr_conventions_default);
......@@ -1100,7 +1105,7 @@ gnm_expr_entry_load_from_range (GnmExprEntry *gee,
* The resulting range is normalized.
**/
gboolean
gnm_expr_entry_get_rangesel (GnmExprEntry *gee,
gnm_expr_entry_get_rangesel (GnmExprEntry const *gee,
GnmRange *r, Sheet **sheet)
{
GnmRangeRef ref;
......@@ -1110,24 +1115,9 @@ gnm_expr_entry_get_rangesel (GnmExprEntry *gee,
gee_prepare_range (gee, &ref);
if (r != NULL) {
/* normalize but don't bother with rel vs absolute conversions
* we always work relative to A1 internally so there is no
* difference
*/
if (ref.a.col < ref.b.col) {
r->start.col = ref.a.col;
r->end.col = ref.b.col;
} else {
r->start.col = ref.b.col;
r->end.col = ref.a.col;
}
if (ref.a.row < ref.b.row) {
r->start.row = ref.a.row;
r->end.row = ref.b.row;
} else {
r->start.row = ref.b.row;
r->end.row = ref.a.row;
}
cellref_get_abs_pos (&ref.a, &gee->pp.eval, &r->start);
cellref_get_abs_pos (&ref.b, &gee->pp.eval, &r->end);
range_normalize (r);
}
/* TODO : does not handle 3d, neither does this interface
......
......@@ -35,8 +35,10 @@ void gnm_expr_entry_set_flags (GnmExprEntry *e,
GnmExprEntryFlags mask);
void gnm_expr_entry_set_scg (GnmExprEntry *e,
SheetControlGUI *scg);
void gnm_expr_entry_set_parsepos (GnmExprEntry *e,
GnmParsePos const *pp);
GtkEntry *gnm_expr_entry_get_entry (GnmExprEntry *e);
gboolean gnm_expr_entry_get_rangesel (GnmExprEntry *e,
gboolean gnm_expr_entry_get_rangesel (GnmExprEntry const *e,
GnmRange *r, Sheet **sheet);
void gnm_expr_expr_find_range (GnmExprEntry *e);
void gnm_expr_entry_rangesel_stop (GnmExprEntry *e,
......
......@@ -828,6 +828,8 @@ wbcg_update_menu_feedback (WorkbookControlGUI *wbcg, Sheet const *sheet)
"SheetOutlineBelow", sheet->outline_symbols_below);
wbcg_set_toggle_action_state (wbcg,
"SheetOutlineRight", sheet->outline_symbols_right);
wbcg_set_toggle_action_state (wbcg,
"SheetUseR1C1", sheet->r1c1_addresses);
wbcg_ui_update_end (wbcg);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment