Commit 7d300c8c authored by Jody Goldberg's avatar Jody Goldberg Committed by Jody Goldberg

convert to using RangeRef and rangeref_parse and rangeref_as_string.

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

	* gnumeric-expr-entry.c : convert to using RangeRef and rangeref_parse
	  and rangeref_as_string.

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

	* src/sheet-control-gui.c (scg_colrow_select) : don't do a start and a
	  change.  Do a start or a change.  do not sheet_update for rangesel.

	* src/parser.y : some utf8 fixes for escaped characters

	* src/expr.c (do_expr_as_string) : rangeref_name -> rangeref_as_string
	* src/parse-util.c (rangeref_parse) : new.
	(parse_surrounding_ranges) : delete.
parent 40e50a02
2002-09-06 Jody Goldberg <jody@gnome.org>
* src/sheet-control-gui.c (scg_colrow_select) : don't do a start and a
change. Do a start or a change. do not sheet_update for rangesel.
* src/parser.y : some utf8 fixes for escaped characters
* src/expr.c (do_expr_as_string) : rangeref_name -> rangeref_as_string
* src/parse-util.c (rangeref_parse) : new.
(parse_surrounding_ranges) : delete.
2002-09-06 Morten Welinder <terra@diku.dk>
* src/workbook-control-gui.c (setup_progress_bar): Use
......
......@@ -10,6 +10,7 @@ Jody:
* Fix some drawing issues related to the pango conversion
* remove some deprecated functions
* Fix handling of files named .xml.gz
* Improvements for ExprEntry
Morten:
* Leak plugging.
......
2002-09-06 Jody Goldberg <jody@gnome.org>
* src/sheet-control-gui.c (scg_colrow_select) : don't do a start and a
change. Do a start or a change. do not sheet_update for rangesel.
* src/parser.y : some utf8 fixes for escaped characters
* src/expr.c (do_expr_as_string) : rangeref_name -> rangeref_as_string
* src/parse-util.c (rangeref_parse) : new.
(parse_surrounding_ranges) : delete.
2002-09-06 Morten Welinder <terra@diku.dk>
* src/workbook-control-gui.c (setup_progress_bar): Use
......
2002-09-06 Jody Goldberg <jody@gnome.org>
* src/sheet-control-gui.c (scg_colrow_select) : don't do a start and a
change. Do a start or a change. do not sheet_update for rangesel.
* src/parser.y : some utf8 fixes for escaped characters
* src/expr.c (do_expr_as_string) : rangeref_name -> rangeref_as_string
* src/parse-util.c (rangeref_parse) : new.
(parse_surrounding_ranges) : delete.
2002-09-06 Morten Welinder <terra@diku.dk>
* src/workbook-control-gui.c (setup_progress_bar): Use
......
2002-09-05 Jody Goldberg <jody@gnome.org>
* ms-formula-write.c (ms_formula_write_pre_data) : remove some obvious
silliness
2002-09-04 Jody Goldberg <jody@gnome.org>
* *.c : remove ifdef WITH_BONOBOization of graphs
......
......@@ -239,7 +239,6 @@ ms_formula_write_pre_data (BiffPut *bp, ExcelSheet *sheet,
GSF_LE_SET_GUINT16 (data + 4, 0x0);
ms_biff_put_var_write (bp, data, 6);
txt = g_strdup (fce->u.ename_v7.name);
g_strup (txt); /* scraping the barrel here */
len = biff_convert_text(&buf, txt, MS_BIFF_V7);
biff_put_text (bp, buf, len,
MS_BIFF_V7,
......
2002-09-06 Jody Goldberg <jody@gnome.org>
* xml-sax-read.c (xml_sax_finish_parse_wb_names_name) : convert to
cellref_get.
(xml_sax_finish_parse_sheet_names_name) : ditto.
2002-08-25 Jody Goldberg <jody@gnome.org>
* Release 1.1.8
......
......@@ -1456,7 +1456,7 @@ xml_sax_finish_parse_wb_names_name (XMLSaxParseState *state)
if (state->name.position) {
CellRef tmp;
char const *res;
res = cellref_a1_get (&tmp, state->name.position, &pos.eval);
res = cellref_get (&tmp, state->name.position, &pos.eval);
if (res != NULL && *res == '\0') {
pos.eval.col = tmp.col;
pos.eval.row = tmp.row;
......@@ -1501,7 +1501,7 @@ xml_sax_finish_parse_sheet_names_name (XMLSaxParseState *state)
parse_pos_init (&pos, NULL, state->sheet, 0, 0);
if (state->name.position) {
CellRef tmp;
char const *res = cellref_a1_get (&tmp, state->name.position, &pos.eval);
char const *res = cellref_get (&tmp, state->name.position, &pos.eval);
if (res != NULL && *res == '\0') {
pos.eval.col = tmp.col;
pos.eval.row = tmp.row;
......
......@@ -1252,7 +1252,7 @@ do_expr_as_string (GnmExpr const *expr, ParsePos const *pp,
if (v->type == VALUE_STRING)
return gnumeric_strescape (v->v_str.val->str);
if (v->type == VALUE_CELLRANGE)
return rangeref_name (&v->v_range.cell, pp);
return rangeref_as_string (&v->v_range.cell, pp);
res = value_get_as_string (v);
......
......@@ -66,7 +66,7 @@ gnm_canvas_key_mode_sheet (GnumericCanvas *gcanvas, GdkEventKey *event)
/* Magic : Some of these are accelerators,
* we need to catch them before entering because they appear to be printable
*/
if (!wbcg->editing && event->keyval == GDK_space &&
if (!wbcg_is_editing (wbcg) && event->keyval == GDK_space &&
(event->state & (GDK_SHIFT_MASK|GDK_CONTROL_MASK)))
return FALSE;
......@@ -256,7 +256,7 @@ gnm_canvas_key_mode_sheet (GnumericCanvas *gcanvas, GdkEventKey *event)
*/
case GDK_KP_Enter:
case GDK_Return:
if (wbcg->editing &&
if (wbcg_is_editing (wbcg) &&
(state == GDK_CONTROL_MASK ||
state == (GDK_CONTROL_MASK|GDK_SHIFT_MASK) ||
event->state == GDK_MOD1_MASK))
......@@ -273,8 +273,8 @@ gnm_canvas_key_mode_sheet (GnumericCanvas *gcanvas, GdkEventKey *event)
break;
/* Be careful to restore the editing sheet if we are editing */
if (wbcg->editing)
sheet = wbcg->editing_sheet;
if (wbcg_is_editing (wbcg))
sheet = wbcg->wb_control.editing_sheet;
if (wbcg_edit_finish (wbcg, TRUE)) {
/* Figure out the direction */
......@@ -292,7 +292,7 @@ gnm_canvas_key_mode_sheet (GnumericCanvas *gcanvas, GdkEventKey *event)
break;
case GDK_F4:
if (wbcg->editing)
if (wbcg_is_editing (wbcg))
return gtk_widget_event (GTK_WIDGET (gnm_expr_entry_get_entry (wbcg_get_entry_logical (wbcg))),
(GdkEvent *) event);
return TRUE;
......@@ -307,14 +307,14 @@ gnm_canvas_key_mode_sheet (GnumericCanvas *gcanvas, GdkEventKey *event)
case GDK_BackSpace:
/* Re-center the view on the active cell */
if (!wbcg->editing && (event->state & GDK_CONTROL_MASK) != 0) {
if (!wbcg_is_editing (wbcg) && (event->state & GDK_CONTROL_MASK) != 0) {
scg_make_cell_visible (gcanvas->simple.scg, sv->edit_pos.col,
sv->edit_pos.row, FALSE, TRUE);
break;
}
default:
if (!wbcg->editing) {
if (!wbcg_is_editing (wbcg)) {
if ((event->state & (GDK_MOD1_MASK|GDK_CONTROL_MASK)) != 0)
return FALSE;
......@@ -332,7 +332,7 @@ gnm_canvas_key_mode_sheet (GnumericCanvas *gcanvas, GdkEventKey *event)
(GdkEvent *) event);
}
if (wbcg->editing)
if (wbcg_is_editing (wbcg))
sheet_update_only_grid (sheet);
else
sheet_update (sheet);
......
......@@ -40,7 +40,7 @@
#include "format.h"
#include "mstyle.h"
#include "sheet-style.h"
#include "sheet-object-container.h"
#include "sheet-object-impl.h"
#include "dialogs.h"
#include "sheet-control-gui.h"
......@@ -63,19 +63,15 @@
#define MANAGER_OAF "IDL:GNOME/Gnumeric/Graph_v2/Manager:1.0"
struct _GnmGraph {
SheetObjectContainer parent;
#if 0
Bonobo_Unknown manager_client;
MANAGER manager;
#endif
SheetObject parent;
GPtrArray *vectors;
GPtrArray *plots;
xmlDoc *xml_doc;
};
typedef struct {
SheetObjectContainerClass parent;
SheetObjectClass parent;
} GnmGraphClass;
struct _GnmGraphVector {
......@@ -87,26 +83,8 @@ struct _GnmGraphVector {
Value *value;
GnmGraph *graph;
int id;
gboolean initialized : 1;
gboolean activated : 1;
gboolean is_header : 1;
GnmGraphVector *header;
#if 0
CORBA_Object corba_obj; /* local CORBA object */
union {
POA_GNOME_Gnumeric_Scalar_Vector scalar;
POA_GNOME_Gnumeric_String_Vector string;
PortableServer_POA any;
} servant;
/* The remote server monitoring this vector */
union {
GNOME_Gnumeric_Scalar_Vector scalar;
GNOME_Gnumeric_String_Vector string;
CORBA_Object any;
} subscriber;
#endif
};
typedef struct {
......@@ -115,10 +93,8 @@ typedef struct {
#define DEP_TO_GRAPH_VECTOR(ptr) \
(GnmGraphVector *)(((char *)ptr) - GTK_STRUCT_OFFSET(GnmGraphVector, dep))
#define SERVANT_TO_GRAPH_VECTOR(ptr) \
(GnmGraphVector *)(((char *)ptr) - GTK_STRUCT_OFFSET(GnmGraphVector, servant))
char const *const gnm_graph_vector_type_name [] =
char const * const gnm_graph_vector_type_name [] =
{
"Unknown", "scalars", "dates (unimplemented)", "strings",
};
......@@ -126,17 +102,6 @@ char const *const gnm_graph_vector_type_name [] =
/***************************************************************************/
#if 0
static void
impl_vector_selection_selected (PortableServer_Servant servant,
const GNOME_Gnumeric_SeqPair *ranges,
CORBA_Environment * ev)
{
GnmGraphVector *vector = SERVANT_TO_GRAPH_VECTOR (servant);
g_warning ("Gnumeric : VectorSelection::selected (%p) placeholder.",
(void *)vector);
}
static GNOME_Gnumeric_Scalar_Seq *
gnm_graph_vector_seq_scalar (GnmGraphVector *vector)
{
......@@ -340,7 +305,6 @@ gnm_graph_vector_get_dependent (GnmGraphVector const *vec)
/******************************************************************************/
static GObjectClass *gnm_graph_vector_parent_class = NULL;
#if 0
static POA_GNOME_Gnumeric_VectorSelection__vepv vector_selection_vepv;
static POA_GNOME_Gnumeric_Scalar_Vector__vepv scalar_vector_vepv;
......@@ -388,106 +352,11 @@ cb_check_range_for_pure_string (EvalPos const *ep, Value const *v, void *user)
return NULL;
}
#if 0
static gboolean
gnm_graph_vector_corba_init (GnmGraphVector *vector)
{
CORBA_Environment ev;
gboolean ok;
CORBA_exception_init (&ev);
switch (vector->type) {
case GNM_VECTOR_SCALAR :
case GNM_VECTOR_DATE :
vector->servant.scalar.vepv = &scalar_vector_vepv;
POA_GNOME_Gnumeric_Scalar_Vector__init (
&vector->servant.scalar, &ev);
break;
case GNM_VECTOR_STRING :
vector->servant.string.vepv = &string_vector_vepv;
POA_GNOME_Gnumeric_String_Vector__init (
&vector->servant.string, &ev);
break;
default :
g_assert_not_reached ();
};
if ((ok = ev._major == CORBA_NO_EXCEPTION)) {
PortableServer_ObjectId *oid;
PortableServer_POA poa = bonobo_poa ();
vector->initialized = TRUE;
oid = PortableServer_POA_activate_object (poa,
&vector->servant.any, &ev);
vector->activated = (ev._major == CORBA_NO_EXCEPTION);
vector->corba_obj = PortableServer_POA_servant_to_reference (poa,
&vector->servant.any, &ev);
CORBA_free (oid);
} else {
g_warning ("'%s' : while creating a vector",
bonobo_exception_get_text (&ev));
}
CORBA_exception_free (&ev);
return ok;
}
static void
gnm_graph_vector_corba_finalize (GnmGraphVector *vector)
{
CORBA_Environment ev;
CORBA_exception_init (&ev);
if (vector->subscriber.any != CORBA_OBJECT_NIL) {
CORBA_Object_release(vector->subscriber.any, &ev);
if (ev._major != CORBA_NO_EXCEPTION) {
g_warning ("'%s' : while releasing a vector",
bonobo_exception_get_text (&ev));
}
vector->subscriber.any = CORBA_OBJECT_NIL;
}
if (vector->activated) {
PortableServer_ObjectId *oid;
PortableServer_POA poa = bonobo_poa ();
oid = PortableServer_POA_servant_to_id (poa,
&vector->servant.any, &ev);
PortableServer_POA_deactivate_object (poa, oid, &ev);
vector->activated = FALSE;
CORBA_free (oid);
g_return_if_fail (ev._major == CORBA_NO_EXCEPTION);
}
if (vector->initialized) {
switch (vector->type) {
case GNM_VECTOR_SCALAR :
case GNM_VECTOR_DATE :
POA_GNOME_Gnumeric_Scalar_Vector__fini (
&vector->servant.scalar, &ev);
break;
case GNM_VECTOR_STRING :
POA_GNOME_Gnumeric_String_Vector__fini (
&vector->servant.string, &ev);
break;
default :
g_assert_not_reached ();
};
g_return_if_fail (ev._major == CORBA_NO_EXCEPTION);
}
CORBA_exception_free (&ev);
}
#endif
static void
gnm_graph_vector_finalize (GObject *obj)
{
GnmGraphVector *vector = GNUMERIC_GRAPH_VECTOR (obj);
GObjectClass *parent_class;
d(printf ("graph-vector::finalize %p\n", obj));
......@@ -497,8 +366,6 @@ gnm_graph_vector_finalize (GObject *obj)
vector->dep.expression = NULL;
}
/* gnm_graph_vector_corba_finalize (vector); */
if (vector->value != NULL) {
value_release (vector->value);
vector->value = NULL;
......@@ -511,60 +378,22 @@ gnm_graph_vector_finalize (GObject *obj)
/* vector->id = -1; leave the ID intact for debugging */
}
if (gnm_graph_vector_parent_class->finalize)
gnm_graph_vector_parent_class->finalize (obj);
parent_class = g_type_class_peek (G_TYPE_OBJECT);
if (parent_class->finalize)
parent_class->finalize (obj);
}
#if 0
static void
gnm_graph_vector_corba_class_init (void)
{
static POA_GNOME_Gnumeric_VectorSelection__epv selection_epv;
static POA_GNOME_Gnumeric_Scalar_Vector__epv scalar_epv;
static POA_GNOME_Gnumeric_String_Vector__epv string_epv;
selection_epv.selected = &impl_vector_selection_selected;
vector_selection_vepv.GNOME_Gnumeric_VectorSelection_epv =
&selection_epv;
scalar_epv.changed = &impl_scalar_vector_changed;
scalar_epv.value = &impl_scalar_vector_value;
scalar_vector_vepv.GNOME_Gnumeric_Scalar_Vector_epv =
&scalar_epv;
scalar_vector_vepv.GNOME_Gnumeric_VectorSelection_epv =
&selection_epv;
string_epv.changed = & impl_string_vector_changed;
string_epv.value = &impl_string_vector_value;
string_vector_vepv.GNOME_Gnumeric_String_Vector_epv =
&string_epv;
string_vector_vepv.GNOME_Gnumeric_VectorSelection_epv =
&selection_epv;
}
#endif
static void
gnm_graph_vector_class_init (GObjectClass *object_class)
{
gnm_graph_vector_parent_class = g_type_class_peek (gtk_object_get_type ());
object_class->finalize = &gnm_graph_vector_finalize;
/* gnm_graph_vector_corba_class_init (); */
}
static void
gnm_graph_vector_init (GObject *obj)
{
GnmGraphVector *vector = GNUMERIC_GRAPH_VECTOR (obj);
#if 0
vector->subscriber.any = CORBA_OBJECT_NIL;
vector->corba_obj = CORBA_OBJECT_NIL;
#endif
vector->graph = NULL; /* don't attach until we subscribe */
vector->activated = FALSE;
vector->initialized = FALSE;
}
GSF_CLASS (GnmGraphVector, gnm_graph_vector,
......
......@@ -140,7 +140,7 @@ item_edit_draw (GnomeCanvasItem *item, GdkDrawable *drawable,
pango_layout_set_width (layout, (int)(item->x2-item->x1)*PANGO_SCALE);
pango_layout_get_pixel_size (layout, &width, &height);
attrs = pango_attr_list_new();
attrs = pango_attr_list_new ();
pango_layout_set_attributes (layout, attrs);
text = wbcg_edit_get_display_text (item_edit->scg->wbcg);
......@@ -153,6 +153,7 @@ item_edit_draw (GnomeCanvasItem *item, GdkDrawable *drawable,
left_pos + PANGO_PIXELS (pos.x), top_pos + PANGO_PIXELS (pos.y),
left_pos + PANGO_PIXELS (pos.x), top_pos + PANGO_PIXELS (pos.y + pos.height));
g_object_unref (G_OBJECT (layout));
pango_attr_list_unref (attrs);
}
static double
......
......@@ -303,7 +303,7 @@ item_grid_draw (GnomeCanvasItem *item, GdkDrawable *drawable,
GnomeCanvas *canvas = item->canvas;
GnumericCanvas *gcanvas = GNUMERIC_CANVAS (canvas);
Sheet const *sheet = ((SheetControl *) gcanvas->simple.scg)->sheet;
Cell const * const edit_cell = gcanvas->simple.scg->wbcg->editing_cell;
Cell const * const edit_cell = gcanvas->simple.scg->wbcg->wb_control.editing_cell;
ItemGrid *ig = ITEM_GRID (item);
ColRowInfo const *ri = NULL, *next_ri = NULL;
......
......@@ -92,13 +92,13 @@ cellref_abs_row (CellRef const *ref, ParsePos const *pp)
}
/**
* rangeref_name :
* rangeref_as_string :
* @ref :
* @pp :
*
**/
char *
rangeref_name (RangeRef const *ref, ParsePos const *pp)
rangeref_as_string (RangeRef const *ref, ParsePos const *pp)
{
char buf [2*(10 /* max digits in 32 bit row */
+ 7 /* max letters in 32 bit col */
......@@ -228,7 +228,7 @@ cellref_name (CellRef const *cell_ref, ParsePos const *pp, gboolean no_sheetname
return g_strdup (buffer);
}
char const *
static char const *
cellref_a1_get (CellRef *out, char const *in, CellPos const *pos)
{
int col = 0;
......@@ -333,12 +333,9 @@ r1c1_get_item (int *num, unsigned char *rel, char const * *in)
return TRUE;
}
char const *
static char const *
cellref_r1c1_get (CellRef *out, char const *in, CellPos const *pos)
{
g_return_val_if_fail (in != NULL, NULL);
g_return_val_if_fail (out != NULL, NULL);
out->row_relative = FALSE;
out->col_relative = FALSE;
out->col = pos->col;
......@@ -378,7 +375,12 @@ cellref_r1c1_get (CellRef *out, char const *in, CellPos const *pos)
char const *
cellref_get (CellRef *out, char const *in, CellPos const *pos)
{
char const *res = cellref_a1_get (out, in, pos);
char const *res;
g_return_val_if_fail (in != NULL, NULL);
g_return_val_if_fail (out != NULL, NULL);
res = cellref_a1_get (out, in, pos);
if (res != NULL)
return res;
return cellref_r1c1_get (out, in, pos);
......@@ -654,84 +656,218 @@ parse_error_free (ParseError *pe)
}
}
/***************************************************************************/
#undef DEBUG_PARSE_SURROUNDING_RANGES
static char const *
check_quoted (char const *str, int *num_escapes)
{
if (*str == '\'' || *str == '\"') {
char const quote = *str;
*num_escapes = 0;
for (; *str && *str != quote; str = g_utf8_next_char (str))
if (*str == '\\' && str[1]) {
str = g_utf8_next_char (str+1);
(*num_escapes)++;
}
} else
*num_escapes = -1;
return str;
}
gboolean
parse_surrounding_ranges (char const *text, gint cursor, Sheet *sheet,
gboolean single_range_only, gint *from, gint *to,
RangeRef **range)
static void
unquote (char *dst, char const *src, int n)
{
int start, end, last;
gchar *test;
gboolean last_was_alnum = FALSE;
if (text == NULL)
return FALSE;
while (n-- > 0)
if (*src == '\\') {
int n = g_utf8_skip [*(guchar *)(++src)];
strncpy (dst, src, n);
dst += n;
src += n;
} else
*dst++ = *src++;
*dst = 0;
}
#ifdef DEBUG_PARSE_SURROUNDING_RANGES
g_warning ("Starting to parse [%s]", text);
#endif
last = strlen (text);
for (start = 0;
start <= cursor;
start = g_utf8_next_char (text + start) - text) {
int next_end = -1;
gboolean next_was_alnum = FALSE;
gunichar c = g_utf8_get_char (text + start);
gboolean is_alnum = g_unichar_isalnum (c);
/* A range does not start in the middle of a word. */
if (last_was_alnum && is_alnum)
continue;
last_was_alnum = is_alnum;
/* A range starts with a letter, a quote, or a dollar sign. */
if (is_alnum ? g_unichar_isdigit (c) : (c != '\'' && c != '$'))
continue;
for (end = last; end >= MAX (cursor, start + 1); end = next_end) {
GSList *ranges;
gunichar c_end;
gboolean is_alnum;
next_end = g_utf8_prev_char (text + end) - text;
c_end = g_utf8_get_char (text + next_end);
is_alnum = g_unichar_isalnum (c_end);
/* A range does not end in the middle of a word. */
if (is_alnum && next_was_alnum)
continue;
next_was_alnum = is_alnum;
/* A range ends in a letter, digit, or quote. */
if (!is_alnum && c_end != '\'')
continue;
test = g_strndup (text + start, end - start);
#ifdef DEBUG_PARSE_SURROUNDING_RANGES
g_warning ("Parsing [%s]", test);
#endif
ranges = global_range_list_parse (sheet, test);
g_free (test);
if (ranges != NULL) {
if ((ranges->next != NULL) && single_range_only) {
range_list_destroy (ranges);
continue;
}
*from = start;
*to = end;
if (range) {
*range = value_to_rangeref
((Value *) ((g_slist_last
(ranges))->data), FALSE);
}
range_list_destroy (ranges);
return TRUE;
}
static char const *
wbref_parse (char const *start, Workbook **wb)
{
/* Is this an external reference ? */
if (*start == '[') {
int num_escapes;
char const *end = check_quoted (start, &num_escapes);
char *name;
if (end == start) {
end = strchr (start, ']');
if (end == NULL)
return start;
}
if (*end != ']')
return NULL;
/* might be too big if quoted (remember leading [' */
name = g_alloca (1 + end - start - 2);
if (num_escapes < 0) {
strncpy (name, start+1, end-start-1);
name [end-start-1] = '\0';
} else
unquote (name, start+2, end-start-2);
#warning TODO
return end + 1;
}
return start;
}
static char const *
sheet_parse (char const *start, Sheet **sheet, Workbook const *wb,
gboolean allow_3d)
{
int num_escapes;
char const *end = check_quoted (start, &num_escapes);
char *name;
*sheet = NULL;
/* Quoted definitely indicates a sheet */
if (end == start)
while (*end && g_unichar_isalnum (g_utf8_get_char (end)))
end = g_utf8_next_char (end);
if (*end != '!' && (!allow_3d || *end != ':'))
return start;
/* might be too big if quoted */
name = g_alloca (1 + end - start);
if (num_escapes < 0) {
strncpy (name, start, end-start);
name [end-start-1] = '\0';
} else
unquote (name, start+1, end-start-2);
*sheet = workbook_sheet_by_name (wb, name);
return *sheet != NULL ? end : start;
}
static char const *
col_parse (char const *str, int *res, unsigned char *relative)
{
char const *ptr = str;
int col = 0;
if (!(*relative = (*ptr != '$')))
ptr++;
for (; TRUE ; ptr++)
if (('a' <= *ptr && *ptr <= 'z'))
col = col * 26 + (*ptr - 'a');
else if (('A' <= *ptr && *ptr <= 'Z'))
col = col * 26 + (*ptr - 'A');
else if (col < SHEET_MAX_COLS) {
*res = col;
return ptr;
} else
return str;
}
static char const *
row_parse (char const *str, int *res, unsigned char *relative)
{
char const *ptr = str;
int row;
if (!(*relative = (*ptr != '$')))
ptr++;
row = strtol (str, (char **)&ptr, 10);
if (0 < row && row <= SHEET_MAX_ROWS) {
*res = row - 1;
return ptr;
} else
return str;
}
/** rangeref_parse :
* @res : where to store the result
* @start : the start of the string to parse
* @pos : the location to parse relative to
*
* Returns the a pointer to the first invalid character.
* If the result != @start then @res is valid.
**/
char const *
rangeref_parse (RangeRef *res, char const *start, ParsePos const *pp)
{