Commit ad6b6064 authored by Jody Goldberg's avatar Jody Goldberg

Tweak the xml routines to support content as well as attributes

parent 5526045b
2001-08-28 Jody Goldberg <jgoldberg@home.com>
* src/xml-io.c (xml_sheet_read) : no need to load the max col/row.
That is really only useful for external parsers. We handle it
internally.
2001-08-28 Morten Welinder <terra@diku.dk>
* src/workbook.h (struct _Workbook): point to first dependent
......@@ -31,21 +37,21 @@
* idl/gnumeric-graphs.idl (importSpecification) : new routine.
* src/xml-io.c : clean up.
s/xml_get_value_int/xml_prop_get_int/
s/xml_set_value_int/xml_prop_set_int/
s/xml_get_value_double/xml_prop_get_double/
s/xml_set_value_double/xml_prop_set_double/
s/xml_set_value_points/xml_prop_set_points/
s/xml_set_value_cstr/xml_prop_set_cstr/
s/xml_set_prop_cellpos/xml_prop_set_cellpos/
s/xml_get_prop_cellpos/xml_prop_get_cellpos/
s/xml_read_range/xml_prop_get_range/
s/xml_get_print_hf/xml_prop_get_print_hf/
s/xml_set_print_hf/xml_prop_set_print_hf/
s/xml_set_color_value/xml_prop_set_color/
s/xml_get_color_value/xml_prop_get_color/
s/xml_set_value_color/xml_prop_set_gdkcolor/
s/xml_get_value_color/xml_prop_get_gdkcolor/
s/xml_get_value_int/xml_node_get_int/
s/xml_set_value_int/xml_node_set_int/
s/xml_get_value_double/xml_node_get_double/
s/xml_set_value_double/xml_node_set_double/
s/xml_set_value_points/xml_node_set_points/
s/xml_set_value_cstr/xml_node_set_cstr/
s/xml_set_prop_cellpos/xml_node_set_cellpos/
s/xml_get_prop_cellpos/xml_node_get_cellpos/
s/xml_read_range/xml_node_get_range/
s/xml_get_print_hf/xml_node_get_print_hf/
s/xml_set_print_hf/xml_node_set_print_hf/
s/xml_set_color_value/xml_node_set_color/
s/xml_get_color_value/xml_node_get_color/
s/xml_set_value_color/xml_node_set_gdkcolor/
s/xml_get_value_color/xml_node_get_gdkcolor/
Remove the pointless searching of children for content.
We never relied on those semantics, nor do we want them.
......@@ -53,7 +59,7 @@
(xml_sheet_create) : Use xmlGetProp directly.
(xml_sheet_read) : ditto.
(xml_read_solver) : ditto.
(xml_write_solver) : use xml_prop_set_cstr.
(xml_write_solver) : use xml_node_set_cstr.
(xml_write_print_info) : Use xmlNewChild.
(xml_value_get) : delete and use xmlGetProp directly.
......
2001-08-28 Jody Goldberg <jgoldberg@home.com>
* src/xml-io.c (xml_sheet_read) : no need to load the max col/row.
That is really only useful for external parsers. We handle it
internally.
2001-08-28 Morten Welinder <terra@diku.dk>
* src/workbook.h (struct _Workbook): point to first dependent
......@@ -31,21 +37,21 @@
* idl/gnumeric-graphs.idl (importSpecification) : new routine.
* src/xml-io.c : clean up.
s/xml_get_value_int/xml_prop_get_int/
s/xml_set_value_int/xml_prop_set_int/
s/xml_get_value_double/xml_prop_get_double/
s/xml_set_value_double/xml_prop_set_double/
s/xml_set_value_points/xml_prop_set_points/
s/xml_set_value_cstr/xml_prop_set_cstr/
s/xml_set_prop_cellpos/xml_prop_set_cellpos/
s/xml_get_prop_cellpos/xml_prop_get_cellpos/
s/xml_read_range/xml_prop_get_range/
s/xml_get_print_hf/xml_prop_get_print_hf/
s/xml_set_print_hf/xml_prop_set_print_hf/
s/xml_set_color_value/xml_prop_set_color/
s/xml_get_color_value/xml_prop_get_color/
s/xml_set_value_color/xml_prop_set_gdkcolor/
s/xml_get_value_color/xml_prop_get_gdkcolor/
s/xml_get_value_int/xml_node_get_int/
s/xml_set_value_int/xml_node_set_int/
s/xml_get_value_double/xml_node_get_double/
s/xml_set_value_double/xml_node_set_double/
s/xml_set_value_points/xml_node_set_points/
s/xml_set_value_cstr/xml_node_set_cstr/
s/xml_set_prop_cellpos/xml_node_set_cellpos/
s/xml_get_prop_cellpos/xml_node_get_cellpos/
s/xml_read_range/xml_node_get_range/
s/xml_get_print_hf/xml_node_get_print_hf/
s/xml_set_print_hf/xml_node_set_print_hf/
s/xml_set_color_value/xml_node_set_color/
s/xml_get_color_value/xml_node_get_color/
s/xml_set_value_color/xml_node_set_gdkcolor/
s/xml_get_value_color/xml_node_get_gdkcolor/
Remove the pointless searching of children for content.
We never relied on those semantics, nor do we want them.
......@@ -53,7 +59,7 @@
(xml_sheet_create) : Use xmlGetProp directly.
(xml_sheet_read) : ditto.
(xml_read_solver) : ditto.
(xml_write_solver) : use xml_prop_set_cstr.
(xml_write_solver) : use xml_node_set_cstr.
(xml_write_print_info) : Use xmlNewChild.
(xml_value_get) : delete and use xmlGetProp directly.
......
2001-08-28 Jody Goldberg <jgoldberg@home.com>
* src/xml-io.c (xml_sheet_read) : no need to load the max col/row.
That is really only useful for external parsers. We handle it
internally.
2001-08-28 Morten Welinder <terra@diku.dk>
* src/workbook.h (struct _Workbook): point to first dependent
......@@ -31,21 +37,21 @@
* idl/gnumeric-graphs.idl (importSpecification) : new routine.
* src/xml-io.c : clean up.
s/xml_get_value_int/xml_prop_get_int/
s/xml_set_value_int/xml_prop_set_int/
s/xml_get_value_double/xml_prop_get_double/
s/xml_set_value_double/xml_prop_set_double/
s/xml_set_value_points/xml_prop_set_points/
s/xml_set_value_cstr/xml_prop_set_cstr/
s/xml_set_prop_cellpos/xml_prop_set_cellpos/
s/xml_get_prop_cellpos/xml_prop_get_cellpos/
s/xml_read_range/xml_prop_get_range/
s/xml_get_print_hf/xml_prop_get_print_hf/
s/xml_set_print_hf/xml_prop_set_print_hf/
s/xml_set_color_value/xml_prop_set_color/
s/xml_get_color_value/xml_prop_get_color/
s/xml_set_value_color/xml_prop_set_gdkcolor/
s/xml_get_value_color/xml_prop_get_gdkcolor/
s/xml_get_value_int/xml_node_get_int/
s/xml_set_value_int/xml_node_set_int/
s/xml_get_value_double/xml_node_get_double/
s/xml_set_value_double/xml_node_set_double/
s/xml_set_value_points/xml_node_set_points/
s/xml_set_value_cstr/xml_node_set_cstr/
s/xml_set_prop_cellpos/xml_node_set_cellpos/
s/xml_get_prop_cellpos/xml_node_get_cellpos/
s/xml_read_range/xml_node_get_range/
s/xml_get_print_hf/xml_node_get_print_hf/
s/xml_set_print_hf/xml_node_set_print_hf/
s/xml_set_color_value/xml_node_set_color/
s/xml_get_color_value/xml_node_get_color/
s/xml_set_value_color/xml_node_set_gdkcolor/
s/xml_get_value_color/xml_node_get_gdkcolor/
Remove the pointless searching of children for content.
We never relied on those semantics, nor do we want them.
......@@ -53,7 +59,7 @@
(xml_sheet_create) : Use xmlGetProp directly.
(xml_sheet_read) : ditto.
(xml_read_solver) : ditto.
(xml_write_solver) : use xml_prop_set_cstr.
(xml_write_solver) : use xml_node_set_cstr.
(xml_write_print_info) : Use xmlNewChild.
(xml_value_get) : delete and use xmlGetProp directly.
......
2001-08-28 Jody Goldberg <jgoldberg@home.com>
* src/xml-io.c (xml_sheet_read) : no need to load the max col/row.
That is really only useful for external parsers. We handle it
internally.
2001-08-28 Morten Welinder <terra@diku.dk>
* src/workbook.h (struct _Workbook): point to first dependent
......@@ -31,21 +37,21 @@
* idl/gnumeric-graphs.idl (importSpecification) : new routine.
* src/xml-io.c : clean up.
s/xml_get_value_int/xml_prop_get_int/
s/xml_set_value_int/xml_prop_set_int/
s/xml_get_value_double/xml_prop_get_double/
s/xml_set_value_double/xml_prop_set_double/
s/xml_set_value_points/xml_prop_set_points/
s/xml_set_value_cstr/xml_prop_set_cstr/
s/xml_set_prop_cellpos/xml_prop_set_cellpos/
s/xml_get_prop_cellpos/xml_prop_get_cellpos/
s/xml_read_range/xml_prop_get_range/
s/xml_get_print_hf/xml_prop_get_print_hf/
s/xml_set_print_hf/xml_prop_set_print_hf/
s/xml_set_color_value/xml_prop_set_color/
s/xml_get_color_value/xml_prop_get_color/
s/xml_set_value_color/xml_prop_set_gdkcolor/
s/xml_get_value_color/xml_prop_get_gdkcolor/
s/xml_get_value_int/xml_node_get_int/
s/xml_set_value_int/xml_node_set_int/
s/xml_get_value_double/xml_node_get_double/
s/xml_set_value_double/xml_node_set_double/
s/xml_set_value_points/xml_node_set_points/
s/xml_set_value_cstr/xml_node_set_cstr/
s/xml_set_prop_cellpos/xml_node_set_cellpos/
s/xml_get_prop_cellpos/xml_node_get_cellpos/
s/xml_read_range/xml_node_get_range/
s/xml_get_print_hf/xml_node_get_print_hf/
s/xml_set_print_hf/xml_node_set_print_hf/
s/xml_set_color_value/xml_node_set_color/
s/xml_get_color_value/xml_node_get_color/
s/xml_set_value_color/xml_node_set_gdkcolor/
s/xml_get_value_color/xml_node_get_gdkcolor/
Remove the pointless searching of children for content.
We never relied on those semantics, nor do we want them.
......@@ -53,7 +59,7 @@
(xml_sheet_create) : Use xmlGetProp directly.
(xml_sheet_read) : ditto.
(xml_read_solver) : ditto.
(xml_write_solver) : use xml_prop_set_cstr.
(xml_write_solver) : use xml_node_set_cstr.
(xml_write_print_info) : Use xmlNewChild.
(xml_value_get) : delete and use xmlGetProp directly.
......
......@@ -44,7 +44,7 @@ gint ms_excel_formula_debug = 0;
/* Enables debugging mesgs while reading excel colors & patterns */
gint ms_excel_color_debug = 0;
/* Enables debugging mesgs while reading excel charts */
gint ms_excel_chart_debug = 0;
gint ms_excel_chart_debug = 10;
/* Enables debugging mesgs while writing excel workbooks */
gint ms_excel_write_debug = 0;
/* Enables debugging mesgs while reading excel objects */
......
......@@ -38,12 +38,16 @@ typedef enum {
MS_VECTOR_PURPOSE_MAX = 4
} MS_VECTOR_PURPOSE;
char const *const ms_vector_purpose_type_name [] =
{
"labels", "values", "categories", "bubbles",
};
typedef struct _ExcelChartSeries
{
struct {
GnmGraphVectorType type;
int count;
GnmGraphVector *g_vector;
int count, remote_ID;
} vector [MS_VECTOR_PURPOSE_MAX];
int chart_group;
......@@ -101,7 +105,7 @@ excel_chart_series_new (void)
series->chart_group = -1;
for (i = MS_VECTOR_PURPOSE_MAX; i-- > 0 ; ) {
series->vector [i].g_vector = NULL;
series->vector [i].remote_ID = -1;
series->vector [i].type = GNM_VECTOR_AUTO; /* may be reset later */
}
......@@ -244,7 +248,7 @@ BC_R(ai)(ExcelChartHandler const *handle,
g_return_val_if_fail (purpose < MS_VECTOR_PURPOSE_MAX, TRUE);
switch (purpose) {
case MS_VECTOR_PURPOSE_LABELS : puts ("Linking title or text"); break;
case MS_VECTOR_PURPOSE_LABELS : puts ("Linking labels"); break;
case MS_VECTOR_PURPOSE_VALUES : puts ("Linking values"); break;
case MS_VECTOR_PURPOSE_CATEGORIES : puts ("Linking categories"); break;
case MS_VECTOR_PURPOSE_BUBBLES : puts ("Linking bubbles"); break;
......@@ -271,7 +275,7 @@ BC_R(ai)(ExcelChartHandler const *handle,
g_return_val_if_fail (s->currentSeries != NULL, TRUE);
#ifdef ENABLE_BONOBO
s->currentSeries->vector [purpose].g_vector =
s->currentSeries->vector [purpose].remote_ID =
gnm_graph_add_vector (s->graph, expr,
s->currentSeries->vector [purpose].type,
sheet);
......@@ -2123,7 +2127,7 @@ ms_excel_chart (BiffQuery *q, MSContainer *container, MsBiffVersion ver, GtkObje
int const num_handler = sizeof(chart_biff_handler) /
sizeof(ExcelChartHandler *);
int i;
int i, j;
xmlNodePtr tmp;
gboolean done = FALSE;
ExcelChartReadState state;
......@@ -2282,9 +2286,15 @@ ms_excel_chart (BiffQuery *q, MSContainer *container, MsBiffVersion ver, GtkObje
state.xml_ns, "Data", NULL);
for (i = state.series->len; i-- > 0 ; ) {
ExcelChartSeries *series = g_ptr_array_index (state.series, i);
xmlNodePtr s = xmlNewDocNode (state.xml_doc, state.xml_ns, "Series", NULL);
xml_prop_set_int (s, "ChartGroup", series->chart_group);
xmlAddChild (tmp, s);
xmlNodePtr s = xmlNewChild (tmp, state.xml_ns, "Series", NULL);
xml_node_set_int (s, "ChartGroup", series->chart_group);
for (j = MS_VECTOR_PURPOSE_MAX; j-- > 0 ; )
if (series->vector [j].remote_ID >= 0) {
xmlNodePtr v = xmlNewChild (s, state.xml_ns,
ms_vector_purpose_type_name [j], NULL);
xml_node_set_int (v, "ID", series->vector [j].remote_ID);
}
}
#ifdef ENABLE_BONOBO
......
......@@ -637,8 +637,10 @@ gnm_graph_subscribe_vector (GnmGraph *graph, GnmGraphVector *vector)
* @expr : the expression to evaluate for this vector.
* @type : optional, pass GNM_VECTOR_AUTO, and we will make a guess.
* @sheet : this a dependentContainer when I create it.
*
* Returns the ID of the vector
*/
GnmGraphVector *
int
gnm_graph_add_vector (GnmGraph *graph, ExprTree *expr,
GnmGraphVectorType type, Sheet *sheet)
{
......@@ -646,7 +648,7 @@ gnm_graph_add_vector (GnmGraph *graph, ExprTree *expr,
EvalPos ep;
int i;
g_return_val_if_fail (IS_GNUMERIC_GRAPH (graph), FALSE);
g_return_val_if_fail (IS_GNUMERIC_GRAPH (graph), -1);
/* If this graph already has this vector don't duplicate it.
* This is useful when importing a set of series with a common dimension.
......@@ -664,7 +666,7 @@ gnm_graph_add_vector (GnmGraph *graph, ExprTree *expr,
printf ("vector::ref (%d) @ 0x%p = %s\n", vector->type, vector, expr_str);
g_free (expr_str);
#endif
return vector;
return vector->id;
}
}
......@@ -712,7 +714,7 @@ gnm_graph_add_vector (GnmGraph *graph, ExprTree *expr,
}
#endif
return vector;
return vector->id;
}
static char *
......
......@@ -24,7 +24,7 @@ void gnm_graph_clear_vectors (GnmGraph *graph);
void gnm_graph_arrange_vectors (GnmGraph *graph);
void gnm_graph_import_specification (GnmGraph *graph,
xmlDocPtr spec);
GnmGraphVector *gnm_graph_add_vector (GnmGraph *graph,
int gnm_graph_add_vector (GnmGraph *graph,
ExprTree *expr,
GnmGraphVectorType type,
Sheet *sheet);
......
......@@ -203,8 +203,8 @@ cell_comment_write_xml (SheetObject const *so,
XmlParseContext const *ctxt, xmlNodePtr tree)
{
CellComment const *cc = CELL_COMMENT (so);
xml_prop_set_cstr (tree, "Author", cc->author);
xml_prop_set_cstr (tree, "Text", cc->text);
xml_node_set_cstr (tree, "Author", cc->author);
xml_node_set_cstr (tree, "Text", cc->text);
return FALSE;
}
......
......@@ -177,18 +177,18 @@ sheet_object_graphic_read_xml (SheetObject *so,
g_return_val_if_fail (IS_SHEET_OBJECT_GRAPHIC (so), TRUE);
sog = SHEET_OBJECT_GRAPHIC (so);
color = xml_prop_get_gdkcolor (tree, "FillColor");
color = xml_node_get_gdkcolor (tree, "FillColor");
sheet_object_graphic_fill_color_set (sog, color);
if (xml_prop_get_int (tree, "Type", &tmp))
if (xml_node_get_int (tree, "Type", &tmp))
sog->type = tmp;
xml_prop_get_double (tree, "Width", &width);
xml_node_get_double (tree, "Width", &width);
sheet_object_graphic_width_set (sog, width);
if (xml_prop_get_double (tree, "ArrowShapeA", &a) &&
xml_prop_get_double (tree, "ArrowShapeB", &b) &&
xml_prop_get_double (tree, "ArrowShapeC", &c))
if (xml_node_get_double (tree, "ArrowShapeA", &a) &&
xml_node_get_double (tree, "ArrowShapeB", &b) &&
xml_node_get_double (tree, "ArrowShapeC", &c))
sheet_object_graphic_abc_set (sog, a, b, c);
return FALSE;
......@@ -203,14 +203,14 @@ sheet_object_graphic_write_xml (SheetObject const *so,
g_return_val_if_fail (IS_SHEET_OBJECT_GRAPHIC (so), TRUE);
sog = SHEET_OBJECT_GRAPHIC (so);
xml_prop_set_gdkcolor (tree, "FillColor", sog->fill_color);
xml_prop_set_int (tree, "Type", sog->type);
xml_prop_set_double (tree, "Width", sog->width, -1);
xml_node_set_gdkcolor (tree, "FillColor", sog->fill_color);
xml_node_set_int (tree, "Type", sog->type);
xml_node_set_double (tree, "Width", sog->width, -1);
if (sog->type == SHEET_OBJECT_ARROW) {
xml_prop_set_double (tree, "ArrowShapeA", sog->a, -1);
xml_prop_set_double (tree, "ArrowShapeB", sog->b, -1);
xml_prop_set_double (tree, "ArrowShapeC", sog->c, -1);
xml_node_set_double (tree, "ArrowShapeA", sog->a, -1);
xml_node_set_double (tree, "ArrowShapeB", sog->b, -1);
xml_node_set_double (tree, "ArrowShapeC", sog->c, -1);
}
return FALSE;
......@@ -706,7 +706,7 @@ sheet_object_filled_read_xml (SheetObject *so,
g_return_val_if_fail (IS_SHEET_OBJECT_FILLED (so), TRUE);
sof = SHEET_OBJECT_FILLED (so);
color = xml_prop_get_gdkcolor (tree, "OutlineColor");
color = xml_node_get_gdkcolor (tree, "OutlineColor");
sheet_object_filled_outline_color_set (sof, color);
return sheet_object_graphic_read_xml (so, ctxt, tree);
......@@ -721,7 +721,7 @@ sheet_object_filled_write_xml (SheetObject const *so,
g_return_val_if_fail (IS_SHEET_OBJECT_FILLED (so), TRUE);
sof = SHEET_OBJECT_FILLED (so);
xml_prop_set_gdkcolor (tree, "OutlineColor", sof->outline_color);
xml_node_set_gdkcolor (tree, "OutlineColor", sof->outline_color);
return sheet_object_graphic_write_xml (so, ctxt, tree);
}
......
......@@ -252,7 +252,7 @@ sheet_widget_label_write_xml (SheetObject const *so,
{
SheetWidgetLabel *swl = SHEET_WIDGET_LABEL (so);
xml_prop_set_cstr (tree, "Label", swl->label);
xml_node_set_cstr (tree, "Label", swl->label);
return FALSE;
}
......@@ -350,7 +350,7 @@ sheet_widget_frame_write_xml (SheetObject const *so,
{
SheetWidgetFrame *swf = SHEET_WIDGET_FRAME (so);
xml_prop_set_cstr (tree, "Label", swf->label);
xml_node_set_cstr (tree, "Label", swf->label);
return FALSE;
}
......@@ -447,7 +447,7 @@ sheet_widget_button_write_xml (SheetObject const *so,
{
SheetWidgetButton *swb = SHEET_WIDGET_BUTTON (so);
xml_prop_set_cstr (tree, "Label", swb->label);
xml_node_set_cstr (tree, "Label", swb->label);
return FALSE;
}
......@@ -908,9 +908,9 @@ sheet_widget_checkbox_write_xml (SheetObject const *so,
pp = parse_pos_init (&pos, NULL, so->sheet, 0, 0);
val = expr_tree_as_string (swc->dep.expression, pp);
xml_prop_set_cstr (tree, "Label", swc->label);
xml_prop_set_int (tree, "Value", swc->value);
xml_prop_set_cstr (tree, "Input", val);
xml_node_set_cstr (tree, "Label", swc->label);
xml_node_set_int (tree, "Value", swc->value);
xml_node_set_cstr (tree, "Input", val);
return FALSE;
}
......@@ -955,7 +955,7 @@ sheet_widget_checkbox_read_xml (SheetObject *so,
swc->dep.sheet = context->sheet;
swc->dep.flags = checkbox_get_dep_type ();
xml_prop_get_int (tree, "Value", &swc->value);
xml_node_get_int (tree, "Value", &swc->value);
return FALSE;
}
......
......@@ -469,7 +469,7 @@ sheet_object_read_xml (XmlParseContext const *ctxt, xmlNodePtr tree)
xmlFree (tmp);
}
if (xml_prop_get_int (tree, "Direction", &tmp_int))
if (xml_node_get_int (tree, "Direction", &tmp_int))
so->anchor.direction = tmp_int;
else
so->anchor.direction = SO_DIR_UNKNOWN;
......@@ -503,16 +503,16 @@ sheet_object_write_xml (SheetObject const *so, XmlParseContext const *ctxt)
return NULL;
}
xml_prop_set_cstr (tree, "ObjectBound", range_name (&so->anchor.cell_bound));
xml_node_set_cstr (tree, "ObjectBound", range_name (&so->anchor.cell_bound));
snprintf (buffer, sizeof (buffer), "%.*g %.*g %.*g %.*g",
DBL_DIG, so->anchor.offset [0], DBL_DIG, so->anchor.offset [1],
DBL_DIG, so->anchor.offset [2], DBL_DIG, so->anchor.offset [3]);
xml_prop_set_cstr (tree, "ObjectOffset", buffer);
xml_node_set_cstr (tree, "ObjectOffset", buffer);
snprintf (buffer, sizeof (buffer), "%d %d %d %d",
so->anchor.type [0], so->anchor.type [1],
so->anchor.type [2], so->anchor.type [3]);
xml_prop_set_cstr (tree, "ObjectAnchorType", buffer);
xml_prop_set_int (tree, "Direction", so->anchor.direction);
xml_node_set_cstr (tree, "ObjectAnchorType", buffer);
xml_node_set_int (tree, "Direction", so->anchor.direction);
return tree;
}
......
......@@ -53,15 +53,15 @@ xml_write_format_col_row_info (XmlParseContext *ctxt, FormatColRowInfo info, xml
* Write placement
*/
child = xmlNewDocNode (ctxt->doc, ctxt->ns, "Placement", NULL);
xml_prop_set_int (child, "offset", info.offset);
xml_prop_set_int (child, "offset_gravity", info.offset_gravity);
xml_node_set_int (child, "offset", info.offset);
xml_node_set_int (child, "offset_gravity", info.offset_gravity);
xmlAddChild (node, child);
/*
* Write dimensions
*/
child = xmlNewDocNode (ctxt->doc, ctxt->ns, "Dimensions", NULL);
xml_prop_set_int (child, "size", info.size);
xml_node_set_int (child, "size", info.size);
xmlAddChild (node, child);
}
......@@ -96,10 +96,10 @@ xml_write_format_template_member (XmlParseContext *ctxt, TemplateMember *member)
* Write frequency information
*/
child = xmlNewDocNode (ctxt->doc, ctxt->ns, "Frequency", NULL);
xml_prop_set_int (child, "direction", format_template_member_get_direction (member));
xml_prop_set_int (child, "repeat", format_template_member_get_repeat (member));
xml_prop_set_int (child, "skip", format_template_member_get_skip (member));
xml_prop_set_int (child, "edge", format_template_member_get_edge (member));
xml_node_set_int (child, "direction", format_template_member_get_direction (member));
xml_node_set_int (child, "repeat", format_template_member_get_repeat (member));
xml_node_set_int (child, "skip", format_template_member_get_skip (member));
xml_node_set_int (child, "edge", format_template_member_get_edge (member));
xmlAddChild (cur, child);
/*
......@@ -141,9 +141,9 @@ xml_write_format_template_members (XmlParseContext *ctxt, FormatTemplate *ft)
name_c = format_template_get_name (ft);
description_c = format_template_get_description (ft);
xml_prop_set_cstr (child, "author", author_c);
xml_prop_set_cstr (child, "name", name_c);
xml_prop_set_cstr (child, "description", description_c);
xml_node_set_cstr (child, "author", author_c);
xml_node_set_cstr (child, "name", name_c);
xml_node_set_cstr (child, "description", description_c);
g_free (author_c);
g_free (name_c);
......@@ -229,8 +229,8 @@ xml_read_format_col_row_info (XmlParseContext *ctxt, FormatTemplate *ft, xmlNode
*/
child = e_xml_get_child_by_name (tree, "Placement");
if (child) {
xml_prop_get_int (child, "offset", &info.offset);
xml_prop_get_int (child, "offset_gravity", &info.offset_gravity);
xml_node_get_int (child, "offset", &info.offset);
xml_node_get_int (child, "offset_gravity", &info.offset_gravity);
} else {
fprintf (stderr, ERR_READ_FT_MEMBER, "Placement");
}
......@@ -240,7 +240,7 @@ xml_read_format_col_row_info (XmlParseContext *ctxt, FormatTemplate *ft, xmlNode
*/
child = e_xml_get_child_by_name (tree, "Dimensions");
if (child){
xml_prop_get_int (child, "size", &info.size);
xml_node_get_int (child, "size", &info.size);
} else {
fprintf (stderr, ERR_READ_FT_MEMBER, "Dimensions");
}
......@@ -289,10 +289,10 @@ xml_read_format_template_member (XmlParseContext *ctxt, FormatTemplate *ft, xmlN
child = e_xml_get_child_by_name (tree, "Frequency");
if (child){
xml_prop_get_int (child, "direction", (int *) &direction);
xml_prop_get_int (child, "repeat", &repeat);
xml_prop_get_int (child, "skip", &skip);
xml_prop_get_int (child, "edge", &edge);
xml_node_get_int (child, "direction", (int *) &direction);
xml_node_get_int (child, "repeat", &repeat);
xml_node_get_int (child, "skip", &skip);
xml_node_get_int (child, "edge", &edge);
} else {
fprintf (stderr, ERR_READ_FT_MEMBER, "Frequency");
return FALSE;
......@@ -352,9 +352,9 @@ xml_read_format_template_members (XmlParseContext *ctxt, FormatTemplate *ft, xml
if (child){
xmlChar *author, *name, *description;
author = xml_prop_get_cstr (child, "author");
name = xml_prop_get_cstr (child, "name");
description = xml_prop_get_cstr (child, "description");
author = xml_node_get_cstr (child, "author");
name = xml_node_get_cstr (child, "name");
description = xml_node_get_cstr (child, "description");
format_template_set_author (ft, author);
format_template_set_name (ft, name);
......
......@@ -195,66 +195,44 @@ xml_arg_get (GtkArg *arg)
return NULL;
}
static gboolean
xml_prop_get_cellpos (xmlNodePtr node, char const *name, CellPos *val)
{
char *str;
int dummy;
gboolean res;
str = (char *) xmlGetProp (node, name);
if (val == NULL)
return FALSE;
res = parse_cell_name (str, &val->col, &val->row, TRUE, &dummy);
xmlFree (str);
return res;
}
static void
xml_prop_set_cellpos (xmlNodePtr node, char const *name, CellPos const *val)
{
xmlSetProp (node, name, cell_pos_name (val));
}
/* Get an xmlChar * value for a node carried as an attibute
* result must be xmlFree
*/
xmlChar *
xml_prop_get_cstr (xmlNodePtr node, const char *name)
xml_node_get_cstr (xmlNodePtr node, const char *name)
{
return xmlGetProp (node, name);
return name ? xmlGetProp (node, name) : xmlNodeGetContent (node);
}
/* Set a string value for a node carried as an attibute */
void
xml_prop_set_cstr (xmlNodePtr node, const char *name, const char *val)
xml_node_set_cstr (xmlNodePtr node, const char *name, const char *val)
{
if (name)
xmlSetProp (node, name, val);
else
xmlNodeSetContent (node, val);
}
/* Get an integer value for a node carried as an attibute */
gboolean
xml_prop_get_int (xmlNodePtr node, const char *name, int *val)
xml_node_get_int (xmlNodePtr node, const char *name, int *val)
{
char *ret;
int i;
xmlChar *buf;
int res;