gnumeric r17300 - in trunk: . plugins/excel src
- From: mortenw svn gnome org
- To: svn-commits-list gnome org
- Subject: gnumeric r17300 - in trunk: . plugins/excel src
- Date: Sat, 4 Apr 2009 19:11:19 +0000 (UTC)
Author: mortenw
Date: Sat Apr 4 19:11:19 2009
New Revision: 17300
URL: http://svn.gnome.org/viewvc/gnumeric?rev=17300&view=rev
Log:
Muck even more with parsing.
Modified:
trunk/ChangeLog
trunk/plugins/excel/xlsx-read.c
trunk/src/expr-name.c
trunk/src/parse-util.c
trunk/src/parse-util.h
trunk/src/print-info.c
trunk/src/ranges.c
trunk/src/ranges.h
trunk/src/xml-io.c
trunk/src/xml-sax-read.c
Modified: trunk/plugins/excel/xlsx-read.c
==============================================================================
--- trunk/plugins/excel/xlsx-read.c (original)
+++ trunk/plugins/excel/xlsx-read.c Sat Apr 4 19:11:19 2009
@@ -468,6 +468,7 @@
char const *target,
GnmCellPos *res)
{
+ XLSXReadState *state = (XLSXReadState *)xin->user_state;
char const *end;
GnmCellPos tmp;
@@ -478,7 +479,7 @@
if (strcmp (attrs[0], target))
return FALSE;
- end = cellpos_parse (attrs[1], &tmp, TRUE);
+ end = cellpos_parse (attrs[1], state->sheet, &tmp, TRUE);
if (NULL == end || *end != '\0')
return xlsx_warning (xin,
_("Invalid cell position '%s' for attribute %s"),
@@ -492,6 +493,8 @@
char const *target,
GnmRange *res)
{
+ XLSXReadState *state = (XLSXReadState *)xin->user_state;
+
g_return_val_if_fail (attrs != NULL, FALSE);
g_return_val_if_fail (attrs[0] != NULL, FALSE);
g_return_val_if_fail (attrs[1] != NULL, FALSE);
@@ -499,7 +502,7 @@
if (strcmp (attrs[0], target))
return FALSE;
- if (!range_parse (res, attrs[1]))
+ if (!range_parse (res, attrs[1], state->sheet))
xlsx_warning (xin, _("Invalid range '%s' for attribute %s"),
attrs[1], target);
return TRUE;
@@ -834,12 +837,13 @@
static GSList *
xlsx_parse_sqref (GsfXMLIn *xin, xmlChar const *refs)
{
+ XLSXReadState *state = (XLSXReadState *)xin->user_state;
GnmRange r;
xmlChar const *tmp;
GSList *res = NULL;
while (NULL != refs && *refs) {
- if (NULL == (tmp = cellpos_parse (refs, &r.start, FALSE))) {
+ if (NULL == (tmp = cellpos_parse (refs, state->sheet, &r.start, FALSE))) {
xlsx_warning (xin, "unable to parse reference list '%s'", refs);
return res;
}
@@ -848,7 +852,7 @@
if (*refs == '\0' || *refs == ' ')
r.end = r.start;
else if (*refs != ':' ||
- NULL == (tmp = cellpos_parse (refs + 1, &r.end, FALSE))) {
+ NULL == (tmp = cellpos_parse (refs + 1, state->sheet, &r.end, FALSE))) {
xlsx_warning (xin, "unable to parse reference list '%s'", refs);
return res;
}
@@ -3549,13 +3553,13 @@
return;
for (i = 0 ; NULL != refs && *refs ; i++) {
- if (NULL == (refs = cellpos_parse (refs, &r.start, FALSE)))
+ if (NULL == (refs = cellpos_parse (refs, state->sheet, &r.start, FALSE)))
return;
if (*refs == '\0' || *refs == ' ')
r.end = r.start;
else if (*refs != ':' ||
- NULL == (refs = cellpos_parse (refs + 1, &r.end, FALSE)))
+ NULL == (refs = cellpos_parse (refs + 1, state->sheet, &r.end, FALSE)))
return;
if (i == 0)
Modified: trunk/src/expr-name.c
==============================================================================
--- trunk/src/expr-name.c (original)
+++ trunk/src/expr-name.c Sat Apr 4 19:11:19 2009
@@ -52,7 +52,8 @@
return FALSE;
/* What about R1C1? */
- if (cellpos_parse (name, &cp, TRUE))
+#warning "We cannot use NULL here"
+ if (cellpos_parse (name, NULL, &cp, TRUE))
return FALSE;
/* Hmm... Now what? */
Modified: trunk/src/parse-util.c
==============================================================================
--- trunk/src/parse-util.c (original)
+++ trunk/src/parse-util.c Sat Apr 4 19:11:19 2009
@@ -605,17 +605,18 @@
* Return value: a pointer to the character following the cellref.
**/
char const *
-cellref_parse (GnmCellRef *out, char const *in, GnmCellPos const *pos)
+cellref_parse (GnmCellRef *out, Sheet const *sheet,
+ char const *in, GnmCellPos const *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, FIXME_SHEET, in, pos);
+ res = cellref_a1_get (out, sheet, in, pos);
if (res != NULL)
return res;
- return cellref_r1c1_get (out, FIXME_SHEET, in, pos);
+ return cellref_r1c1_get (out, sheet, in, pos);
}
/****************************************************************************/
@@ -686,16 +687,17 @@
* (In the strict case, that would be a pointer to the \0 or NULL.)
*/
char const *
-cellpos_parse (char const *cell_str, GnmCellPos *res, gboolean strict)
+cellpos_parse (char const *cell_str, Sheet const *sheet,
+ GnmCellPos *res, gboolean strict)
{
unsigned char dummy_relative;
- cell_str = col_parse (cell_str, FIXME_SHEET,
+ cell_str = col_parse (cell_str, sheet,
&res->col, &dummy_relative);
if (!cell_str)
return NULL;
- cell_str = row_parse (cell_str, FIXME_SHEET,
+ cell_str = row_parse (cell_str, sheet,
&res->row, &dummy_relative);
if (!cell_str)
return NULL;
@@ -1100,7 +1102,7 @@
&res->a.row, &res->a.row_relative);
if (!tmp1 || *tmp1++ != ':') /* row only requires : even for singleton */
return start;
- tmp2 = row_parse (tmp1, FIXME_SHEET,
+ tmp2 = row_parse (tmp1, res->a.sheet,
&res->b.row, &res->b.row_relative);
if (!tmp2)
return start;
@@ -1464,6 +1466,7 @@
static void
test_cellpos_stuff (void)
{
+ /* Warning: out of date */
GnmCellPos cp;
char const *end, *str;
Modified: trunk/src/parse-util.h
==============================================================================
--- trunk/src/parse-util.h (original)
+++ trunk/src/parse-util.h Sat Apr 4 19:11:19 2009
@@ -18,13 +18,13 @@
int *res, unsigned char *relative);
char const *cellpos_as_string (GnmCellPos const *pos);
-char const *cellpos_parse (char const *cell_str, GnmCellPos *res,
- gboolean strict);
+char const *cellpos_parse (char const *cell_str, Sheet const *sheet,
+ GnmCellPos *res, gboolean strict);
void cellref_as_string (GnmConventionsOut *out,
GnmCellRef const *cell_ref,
gboolean no_sheetname);
-char const *cellref_parse (GnmCellRef *out, char const *in,
- GnmCellPos const *pos);
+char const *cellref_parse (GnmCellRef *out, Sheet const *sheet,
+ char const *in, GnmCellPos const *pos);
void rangeref_as_string (GnmConventionsOut *out,
GnmRangeRef const *ref);
Modified: trunk/src/print-info.c
==============================================================================
--- trunk/src/print-info.c (original)
+++ trunk/src/print-info.c Sat Apr 4 19:11:19 2009
@@ -150,7 +150,8 @@
static gboolean
load_range (char const *str, GnmRange *r)
{
- return ((str != NULL) && range_parse (r, str));
+#warning "We cannot use NULL here"
+ return str && range_parse (r, str, NULL);
}
static void
Modified: trunk/src/ranges.c
==============================================================================
--- trunk/src/ranges.c (original)
+++ trunk/src/ranges.c Sat Apr 4 19:11:19 2009
@@ -128,9 +128,9 @@
* Returns TRUE on success.
**/
gboolean
-range_parse (GnmRange *r, char const *text)
+range_parse (GnmRange *r, char const *text, Sheet const *sheet)
{
- text = cellpos_parse (text, &r->start, FALSE);
+ text = cellpos_parse (text, sheet, &r->start, FALSE);
if (!text)
return FALSE;
@@ -142,7 +142,7 @@
if (*text != ':')
return FALSE;
- text = cellpos_parse (text + 1, &r->end, TRUE);
+ text = cellpos_parse (text + 1, sheet, &r->end, TRUE);
return text != NULL;
}
Modified: trunk/src/ranges.h
==============================================================================
--- trunk/src/ranges.h (original)
+++ trunk/src/ranges.h Sat Apr 4 19:11:19 2009
@@ -70,7 +70,8 @@
int cols, int rows);
GnmRange *range_init (GnmRange *r, int start_col, int start_row,
int end_col, int end_row);
-gboolean range_parse (GnmRange *r, char const *text);
+gboolean range_parse (GnmRange *r, char const *text,
+ Sheet const *sheet);
void range_list_destroy (GSList *ranges);
Modified: trunk/src/xml-io.c
==============================================================================
--- trunk/src/xml-io.c (original)
+++ trunk/src/xml-io.c Sat Apr 4 19:11:19 2009
@@ -227,7 +227,8 @@
}
static gboolean
-xml_node_get_cellpos (xmlNodePtr node, char const *name, GnmCellPos *val)
+xml_node_get_cellpos (xmlNodePtr node, char const *name,
+ GnmCellPos *val, Sheet const *sheet)
{
xmlChar *buf;
gboolean res;
@@ -235,7 +236,7 @@
buf = xml_node_get_cstr (node, name);
if (val == NULL)
return FALSE;
- res = cellpos_parse (CXML2C (buf), val, TRUE) != NULL;
+ res = cellpos_parse (CXML2C (buf), sheet, val, TRUE) != NULL;
xmlFree (buf);
return res;
}
@@ -374,7 +375,7 @@
xmlChar *pos_txt = xml_node_get_cstr (position, NULL);
if (pos_txt != NULL) {
GnmCellRef tmp;
- char const *res = cellref_parse (&tmp, CXML2C (pos_txt), &pp.eval);
+ char const *res = cellref_parse (&tmp, sheet, CXML2C (pos_txt), &pp.eval);
if (res != NULL && *res == '\0') {
pp.eval.col = tmp.col;
pp.eval.row = tmp.row;
@@ -561,7 +562,7 @@
if (s) {
GnmRange r;
- if (range_parse (&r, CXML2C (s))) {
+ if (range_parse (&r, CXML2C (s), ctxt->sheet)) {
range->range = r;
range->use = TRUE;
}
@@ -1340,7 +1341,8 @@
static void
xml_read_sheet_layout (XmlParseContext *ctxt, xmlNodePtr tree)
{
- SheetView *sv = sheet_get_view (ctxt->sheet, ctxt->wb_view);
+ Sheet *sheet = ctxt->sheet;
+ SheetView *sv = sheet_get_view (sheet, ctxt->wb_view);
xmlNodePtr child;
GnmCellPos tmp, frozen_tl, unfrozen_tl;
@@ -1349,13 +1351,13 @@
return;
/* The top left cell in pane[0] */
- if (xml_node_get_cellpos (tree, "TopLeft", &tmp))
+ if (xml_node_get_cellpos (tree, "TopLeft", &tmp, sheet))
sv_set_initial_top_left (sv, tmp.col, tmp.row);
child = e_xml_get_child_by_name (tree, CC2XML ("FreezePanes"));
if (child != NULL &&
- xml_node_get_cellpos (child, "FrozenTopLeft", &frozen_tl) &&
- xml_node_get_cellpos (child, "UnfrozenTopLeft", &unfrozen_tl))
+ xml_node_get_cellpos (child, "FrozenTopLeft", &frozen_tl, sheet) &&
+ xml_node_get_cellpos (child, "UnfrozenTopLeft", &unfrozen_tl, sheet))
sv_freeze_panes (sv, &frozen_tl, &unfrozen_tl);
}
@@ -1478,7 +1480,7 @@
area = xml_node_get_cstr (filter_node, "Area");
if (area == NULL)
continue;
- if (range_parse (&r, CXML2C (area))) {
+ if (range_parse (&r, CXML2C (area), ctxt->sheet)) {
filter = gnm_filter_new (ctxt->sheet, &r);
for (field = filter_node->xmlChildrenNode; field != NULL; field = field->next)
if (!xmlIsBlankNode (field))
@@ -1710,7 +1712,7 @@
tmp = (char *) xmlGetProp (tree, (xmlChar *)"ObjectBound");
if (tmp != NULL) {
GnmRange r;
- if (range_parse (&r, tmp)) {
+ if (range_parse (&r, tmp, ctxt->sheet)) {
/* Patch problems introduced in some 1.7.x versions that stored
* comments in merged cells with the full rectangle of the merged cell
* rather than just the top left corner */
@@ -1769,7 +1771,7 @@
xmlChar *content = xml_node_get_cstr (region, NULL);
GnmRange r;
if (content != NULL) {
- if (range_parse (&r, CXML2C (content)))
+ if (range_parse (&r, CXML2C (content), ctxt->sheet))
gnm_sheet_merge_add (ctxt->sheet, &r, FALSE, NULL);
xmlFree (content);
}
@@ -2201,7 +2203,7 @@
if (!xmlIsBlankNode (l)) {
GnmRange r;
xmlChar *content = (char *)xmlNodeGetContent (l);
- if (range_parse (&r, CXML2C (content)))
+ if (range_parse (&r, CXML2C (content), ctxt->sheet))
cr->merged = g_slist_prepend (cr->merged,
range_dup (&r));
xmlFree (content);
Modified: trunk/src/xml-sax-read.c
==============================================================================
--- trunk/src/xml-sax-read.c (original)
+++ trunk/src/xml-sax-read.c Sat Apr 4 19:11:19 2009
@@ -211,7 +211,7 @@
static gboolean
-xml_sax_attr_cellpos (xmlChar const * const *attrs, char const *name, GnmCellPos *val)
+xml_sax_attr_cellpos (xmlChar const * const *attrs, char const *name, GnmCellPos *val, Sheet const *sheet)
{
g_return_val_if_fail (attrs != NULL, FALSE);
g_return_val_if_fail (attrs[0] != NULL, FALSE);
@@ -220,7 +220,7 @@
if (strcmp (CXML2C (attrs[0]), name))
return FALSE;
- if (cellpos_parse (CXML2C (attrs[1]), val, TRUE) == NULL) {
+ if (cellpos_parse (CXML2C (attrs[1]), sheet, val, TRUE) == NULL) {
g_warning ("Invalid attribute '%s', expected cellpos, received '%s'",
name, attrs[1]);
return FALSE;
@@ -1017,8 +1017,10 @@
for (; attrs != NULL && attrs[0] && attrs[1] ; attrs += 2)
if (!strcmp (CXML2C (attrs[0]), "value"))
- pi->repeat_top.use = range_parse
- (&pi->repeat_top.range, CXML2C (attrs[1]));
+ pi->repeat_top.use =
+ range_parse (&pi->repeat_top.range,
+ CXML2C (attrs[1]),
+ state->sheet);
}
static void
@@ -1034,8 +1036,10 @@
for (; attrs != NULL && attrs[0] && attrs[1] ; attrs += 2)
if (!strcmp (CXML2C (attrs[0]), "value"))
- pi->repeat_left.use = range_parse
- (&pi->repeat_left.range, CXML2C (attrs[1]));
+ pi->repeat_left.use =
+ range_parse (&pi->repeat_left.range,
+ CXML2C (attrs[1]),
+ state->sheet);
}
static void
@@ -1151,7 +1155,7 @@
GnmCellPos tmp;
for (; attrs != NULL && attrs[0] && attrs[1] ; attrs += 2)
- if (xml_sax_attr_cellpos (attrs, "TopLeft", &tmp))
+ if (xml_sax_attr_cellpos (attrs, "TopLeft", &tmp, state->sheet))
sv_set_initial_top_left (
sheet_get_view (state->sheet, state->wb_view),
tmp.col, tmp.row);
@@ -1168,9 +1172,9 @@
int flags = 0;
for (; attrs != NULL && attrs[0] && attrs[1] ; attrs += 2)
- if (xml_sax_attr_cellpos (attrs, "FrozenTopLeft", &frozen_tl))
+ if (xml_sax_attr_cellpos (attrs, "FrozenTopLeft", &frozen_tl, state->sheet))
flags |= 1;
- else if (xml_sax_attr_cellpos (attrs, "UnfrozenTopLeft", &unfrozen_tl))
+ else if (xml_sax_attr_cellpos (attrs, "UnfrozenTopLeft", &unfrozen_tl, state->sheet))
flags |= 2;
else
unknown_attr (xin, attrs);
@@ -1957,7 +1961,7 @@
GnmRange r;
g_return_if_fail (xin->content->len > 0);
- if (range_parse (&r, xin->content->str))
+ if (range_parse (&r, xin->content->str, state->sheet))
gnm_sheet_merge_add (state->sheet, &r, FALSE,
GO_CMD_CONTEXT (state->context));
}
@@ -2053,7 +2057,8 @@
g_return_if_fail (state->filter == NULL);
for (i = 0; attrs != NULL && attrs[i] && attrs[i + 1] ; i += 2)
- if (attr_eq (attrs[i], "Area") && range_parse (&r, CXML2C (attrs[i + 1])))
+ if (attr_eq (attrs[i], "Area") &&
+ range_parse (&r, CXML2C (attrs[i + 1]), state->sheet))
state->filter = gnm_filter_new (state->sheet, &r);
if (NULL == state->filter)
gnm_io_warning (state->context, _("Invalid filter, missing Area"));
@@ -2135,7 +2140,7 @@
for (i = 0; attrs != NULL && attrs[i] && attrs[i + 1] ; i += 2) {
if (attr_eq (attrs[i], "ObjectBound"))
- range_parse (&anchor_r, CXML2C (attrs[i + 1]));
+ range_parse (&anchor_r, CXML2C (attrs[i + 1]), state->sheet);
else if (attr_eq (attrs[i], "ObjectOffset") &&
4 == sscanf (CXML2C (attrs[i + 1]), "%g %g %g %g",
f_tmp + 0, f_tmp + 1, f_tmp + 2, f_tmp + 3))
@@ -2216,7 +2221,8 @@
parse_pos_init (pos, state->wb, state->sheet, 0, 0);
if (state->name.position) {
GnmCellRef tmp;
- char const *res = cellref_parse (&tmp, state->name.position, &pos->eval);
+ char const *res = cellref_parse (&tmp, state->sheet,
+ state->name.position, &pos->eval);
if (res != NULL && *res == '\0') {
pos->eval.col = tmp.col;
pos->eval.row = tmp.row;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]