Commit c7f8e1c0 authored by Miguel de Icaza's avatar Miguel de Icaza Committed by Arturo Espinosa

New function. Used in an initial pass over the XML file to load all of the



1999-04-06  Miguel de Icaza  <miguel@nuclecu.unam.mx>

	* src/xml-io.c (createXmlSheet): New function.  Used in an initial
	pass over the XML file to load all of the Sheets defined there.
	(readXmlWorkbook): Now this does two passes at loading the sheet:
	the first pass creates the sheets, the second pass actually loads
	the contents.
parent 5bcab256
1999-04-06 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/xml-io.c (createXmlSheet): New function. Used in an initial
pass over the XML file to load all of the Sheets defined there.
(readXmlWorkbook): Now this does two passes at loading the sheet:
the first pass creates the sheets, the second pass actually loads
the contents.
1999-04-06 Michael Meeks <michael@imaginator.com>
* src/func.c (tokenised_help_new): Improved algorithem.
......
1999-04-06 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/xml-io.c (createXmlSheet): New function. Used in an initial
pass over the XML file to load all of the Sheets defined there.
(readXmlWorkbook): Now this does two passes at loading the sheet:
the first pass creates the sheets, the second pass actually loads
the contents.
1999-04-06 Michael Meeks <michael@imaginator.com>
* src/func.c (tokenised_help_new): Improved algorithem.
......
1999-04-06 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/xml-io.c (createXmlSheet): New function. Used in an initial
pass over the XML file to load all of the Sheets defined there.
(readXmlWorkbook): Now this does two passes at loading the sheet:
the first pass creates the sheets, the second pass actually loads
the contents.
1999-04-06 Michael Meeks <michael@imaginator.com>
* src/func.c (tokenised_help_new): Improved algorithem.
......
1999-04-06 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/xml-io.c (createXmlSheet): New function. Used in an initial
pass over the XML file to load all of the Sheets defined there.
(readXmlWorkbook): Now this does two passes at loading the sheet:
the first pass creates the sheets, the second pass actually loads
the contents.
1999-04-06 Michael Meeks <michael@imaginator.com>
* src/func.c (tokenised_help_new): Improved algorithem.
......
......@@ -105,3 +105,7 @@ GNOME Spread Sheet task list
Integrate 'advance' into read_copy, and write, and rename to lseek
Snarf wine OLE API.
* Sheets
When adding a sheet or renaming a sheet, should we reparse everything?
......@@ -1389,25 +1389,27 @@ readXmlSheet (parseXmlContextPtr ctxt, xmlNodePtr tree)
/* xmlNodePtr styles; */
xmlNodePtr cells;
xmlNodePtr objects;
Sheet *ret;
Sheet *ret = NULL;
const char *val;
if (strcmp (tree->name, "Sheet")){
fprintf (stderr,
"readXmlSheet: invalid element type %s, 'Sheet' expected`\n",
"readXmlSheet: invalid element type %s, 'Sheet' expected\n",
tree->name);
}
child = tree->childs;
/*
* Get the name to create the sheet
* Get the name of the sheet. If it does exist, use the existing
* name, otherwise create a sheet (ie, for the case of only reading
* a new sheet).
*/
val = xmlGetValue (tree, "Name");
if (val != NULL){
ret = sheet_new (ctxt->wb, (char *) val);
} else {
fprintf (stderr, "readXmlSheet: Sheet has no name\n");
ret = sheet_new (ctxt->wb, _ ("NoName"));
}
ret = workbook_sheet_lookup (ctxt->wb, (const char *) val);
if (ret == NULL)
ret = sheet_new (ctxt->wb, (const char *) val);
}
if (ret == NULL)
return NULL;
......@@ -1522,6 +1524,29 @@ writeXmlWorkbook (parseXmlContextPtr ctxt, Workbook *wb)
return cur;
}
static void
createXmlSheet (parseXmlContextPtr ctxt, xmlNodePtr tree)
{
const char *val;
xmlNodePtr child;
if (strcmp (tree->name, "Sheet")){
fprintf (stderr,
"createXmlSheet: invalid element type %s, 'Sheet' expected\n",
tree->name);
return;
}
child = tree->childs;
val = xmlGetValue (tree, "Name");
if (val != NULL){
Sheet *sheet;
sheet = sheet_new (ctxt->wb, (char *) val);
workbook_attach_sheet (ctxt->wb, sheet);
}
return;
}
/*
* Create a Workbook equivalent to the XML subtree of doc.
*/
......@@ -1530,7 +1555,7 @@ readXmlWorkbook (parseXmlContextPtr ctxt, xmlNodePtr tree)
{
Workbook *ret;
Sheet *sheet;
xmlNodePtr child;
xmlNodePtr child, c;
if (strcmp (tree->name, "Workbook")){
fprintf (stderr,
......@@ -1556,12 +1581,25 @@ readXmlWorkbook (parseXmlContextPtr ctxt, xmlNodePtr tree)
child = xmlSearchChild (tree, "Sheets");
if (child == NULL)
return ret;
child = child->childs;
while (child != NULL){
sheet = readXmlSheet (ctxt, child);
if (sheet != NULL)
workbook_attach_sheet (ret, sheet);
child = child->next;
/*
* Pass 1: Create all the sheets, to make sure
* all of the references to forward sheets are properly
* handled
*/
c = child->childs;
while (c != NULL){
createXmlSheet (ctxt, c);
c = c->next;
}
/*
* Pass 2: read the contents
*/
c = child->childs;
while (c != NULL){
sheet = readXmlSheet (ctxt, c);
c = c->next;
}
return ret;
......
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