Commit d6ecc0c2 authored by Morten Welinder's avatar Morten Welinder

Reduce use of gnm_conventions_default and gnm_expr_parse_str_simple

parent 062ec989
2009-04-29 Morten Welinder <terra@gnome.org>
* */*.c: Reduce use of gnm_conventions_default and
gnm_expr_parse_str_simple. Use conventions from sheet or passed
down from sax writer.
2009-04-29 Morten Welinder <terra@gnome.org>
* src/wbc-gtk.c (cb_wbcg_window_state_event): When entering
......
......@@ -18,6 +18,8 @@ Morten:
* Fix problem with global names shadowed by sheet names. [#306686]
* Fix relocation problem with expressions using names. [#552749]
* Fix fullscreen toolbar issues. [#574603]
* Fix various R1C1 bugs.
* Fix precision for xml saving inside graphs.
--------------------------------------------------------------------------
Gnumeric 1.9.6
......
......@@ -141,7 +141,7 @@ PKG_PROG_PKG_CONFIG(0.18)
dnl *****************************
libspreadsheet_reqs="
libgoffice-${GOFFICE_API_VER} >= 0.7.5
libgoffice-${GOFFICE_API_VER} >= 0.7.6
libgsf-1 >= 1.14.11
libxml-2.0 >= 2.4.12
"
......
......@@ -4180,7 +4180,7 @@ chart_write_AI (XLChartWriteState *s, GOData const *dim, unsigned n,
} else if ((value = gnm_expr_top_get_constant (texpr)))
ref_type = 1;
} else {
char *str = go_data_as_str (dim);
char *str = go_data_serialize (dim, (gpointer)gnm_conventions_default);
ref_type = 1;
value = value_new_string (str);
g_free (str);
......@@ -4214,7 +4214,8 @@ chart_write_AI (XLChartWriteState *s, GOData const *dim, unsigned n,
} else {
guint dat[2];
char *str = (NULL != value && VALUE_IS_STRING (value))
? value_get_as_string (value) : go_data_as_str (dim);
? value_get_as_string (value)
: go_data_serialize (dim, (gpointer)gnm_conventions_default);
ms_biff_put_commit (s->bp);
ms_biff_put_var_next (s->bp, BIFF_CHART_seriestext);
......
......@@ -92,13 +92,9 @@ do_af_suggest (GnmExpr const *expr, GnmEvalPos const *epos, GOFormat **explicit)
#if 0
{
GnmParsePos pp;
pp.eval = epos->eval;
pp.sheet = epos->sheet;
pp.wb = pp.sheet->workbook;
parse_pos_init_evalpos (&pp, epos);
g_printerr ("Suggesting format for [%s]\n",
gnm_expr_as_string (expr,
&pp,
gnm_conventions_default));
gnm_expr_as_string (expr, &pp, NULL));
}
#endif
......
......@@ -4037,7 +4037,7 @@ cmd_search_replace_do_cell (CmdSearchReplace *me, GnmEvalPos *ep,
out.accum = g_string_new ("=");
out.pp = &pp;
out.convs = gnm_conventions_default;
out.convs = pp.sheet->convs;
gnm_expr_top_as_gstring (ee, &out);
gnm_expr_top_unref (ee);
cell_res.new_text = g_string_free (out.accum, FALSE);
......
......@@ -1408,8 +1408,10 @@ gnm_cell_eval_content (GnmCell *cell)
#ifdef DEBUG_EVALUATION
{
GnmParsePos pp;
char *str = gnm_expr_top_as_string (cell->base.texpr,
parse_pos_init_cell (&pp, cell), gnm_conventions_default);
char *str = gnm_expr_top_as_string
(cell->base.texpr,
parse_pos_init_cell (&pp, cell),
NULL);
g_printerr ("{\nEvaluating %s!%s: %s;\n",
cell->base.sheet->name_quoted, cell_name (cell),
str);
......
......@@ -3157,7 +3157,7 @@ cb_expression_pool_leak (gpointer data, G_GNUC_UNUSED gpointer user)
pp.eval.row = 0;
pp.sheet = NULL;
pp.wb = NULL;
s = gnm_expr_as_string (expr, &pp, gnm_conventions_default);
s = gnm_expr_as_string (expr, &pp, NULL);
g_printerr ("Leaking expression at %p: %s.\n", (void *)expr, s);
g_free (s);
}
......
......@@ -336,7 +336,8 @@ gnm_so_filled_read_xml_dom (SheetObject *so, char const *typename,
}
static void
gnm_so_filled_write_xml_sax (SheetObject const *so, GsfXMLOut *output)
gnm_so_filled_write_xml_sax (SheetObject const *so, GsfXMLOut *output,
GnmConventions const *convs)
{
GnmSOFilled const *sof = GNM_SO_FILLED (so);
gsf_xml_out_add_int (output, "Type", sof->is_oval ? 102 : 101);
......@@ -362,7 +363,9 @@ sof_sax_style (GsfXMLIn *xin, xmlChar const **attrs)
}
static void
gnm_so_filled_prep_sax_parser (SheetObject *so, GsfXMLIn *xin, xmlChar const **attrs)
gnm_so_filled_prep_sax_parser (SheetObject *so, GsfXMLIn *xin,
xmlChar const **attrs,
GnmConventions const *convs)
{
static GsfXMLInNode const dtd[] = {
GSF_XML_IN_NODE (STYLE, STYLE, -1, "Style", GSF_XML_NO_CONTENT, &sof_sax_style, NULL),
......
......@@ -311,7 +311,8 @@ gnm_so_line_read_xml_dom (SheetObject *so, char const *typename,
}
static void
gnm_so_line_write_xml_sax (SheetObject const *so, GsfXMLOut *output)
gnm_so_line_write_xml_sax (SheetObject const *so, GsfXMLOut *output,
GnmConventions const *convs)
{
GnmSOLine const *sol = GNM_SO_LINE (so);
......@@ -339,7 +340,9 @@ sol_sax_style (GsfXMLIn *xin, xmlChar const **attrs)
}
static void
gnm_so_line_prep_sax_parser (SheetObject *so, GsfXMLIn *xin, xmlChar const **attrs)
gnm_so_line_prep_sax_parser (SheetObject *so, GsfXMLIn *xin,
xmlChar const **attrs,
GnmConventions const *convs)
{
static GsfXMLInNode const dtd[] = {
GSF_XML_IN_NODE (STYLE, STYLE, -1, "Style", GSF_XML_NO_CONTENT, &sol_sax_style, NULL),
......
......@@ -220,10 +220,11 @@ gnm_so_polygon_read_xml_dom (SheetObject *so, char const *typename,
}
static void
gnm_so_polygon_write_xml_sax (SheetObject const *so, GsfXMLOut *output)
gnm_so_polygon_write_xml_sax (SheetObject const *so, GsfXMLOut *output,
GnmConventions const *convs)
{
/* TODO */
gnm_so_polygon_parent_class->write_xml_sax (so, output);
gnm_so_polygon_parent_class->write_xml_sax (so, output, convs);
}
static void
......
......@@ -41,6 +41,37 @@
#include <gsf/gsf-impl-utils.h>
#include <string.h>
/* ------------------------------------------------------------------------- */
static inline char *
get_pending_str (const GOData *data)
{
return g_object_get_data (G_OBJECT (data), "unserialize");
}
static inline GnmConventions *
get_pending_convs (const GOData *data)
{
return g_object_get_data (G_OBJECT (data), "unserialize-convs");
}
static inline void
set_pending_str (const GOData *data, const char *str)
{
return g_object_set_data_full (G_OBJECT (data),
"unserialize", g_strdup (str),
g_free);
}
static inline void
set_pending_convs (GOData *data, const GnmConventions *convs)
{
g_object_set_data (G_OBJECT (data),
"unserialize-convs", (gpointer)convs);
}
/* ------------------------------------------------------------------------- */
static GnmDependent *gnm_go_data_get_dep (GOData const *obj);
static GOData *
......@@ -58,9 +89,8 @@ gnm_go_data_dup (GOData const *src)
dependent_set_sheet (dst_dep, src_dep->sheet);
if (dst_dep->texpr == NULL) {
char const *str = g_object_get_data (G_OBJECT (src), "from-str");
g_object_set_data_full (G_OBJECT (dst),
"from-str", g_strdup (str), g_free);
set_pending_str (dst, get_pending_str (src));
set_pending_convs (dst, get_pending_convs (src));
}
return GO_DATA (dst);
......@@ -72,8 +102,8 @@ gnm_go_data_eq (GOData const *data_a, GOData const *data_b)
GnmDependent const *a = gnm_go_data_get_dep (data_a);
GnmDependent const *b = gnm_go_data_get_dep (data_b);
if (a->texpr == NULL && b->texpr == NULL) {
char const *str_a = g_object_get_data (G_OBJECT (data_a), "from-str");
char const *str_b = g_object_get_data (G_OBJECT (data_b), "from-str");
char const *str_a = get_pending_str (data_a);
char const *str_b = get_pending_str (data_b);
return go_str_compare (str_a, str_b) == 0;
}
......@@ -96,33 +126,47 @@ gnm_go_data_preferred_fmt (GOData const *dat)
}
static char *
gnm_go_data_as_str (GOData const *dat)
gnm_go_data_serialize (GOData const *dat, gpointer user)
{
GnmParsePos pp;
GnmConventions const *convs = user;
GnmDependent const *dep = gnm_go_data_get_dep (dat);
if (dep->sheet == NULL)
return g_strdup ("No sheet for GnmGOData");
if (!convs) {
g_warning ("NULL convs in gnm_go_data_serialize");
convs = gnm_conventions_default;
}
return gnm_expr_top_as_string (dep->texpr,
parse_pos_init_dep (&pp, dep),
gnm_conventions_default);
parse_pos_init_dep (&pp, dep),
convs);
}
static gboolean
gnm_go_data_from_str (GOData *dat, char const *str)
gnm_go_data_unserialize (GOData *dat, char const *str, gpointer user)
{
GnmConventions const *convs = user;
GnmExprTop const *texpr;
GnmParsePos pp;
GnmDependent *dep = gnm_go_data_get_dep (dat);
if (!convs) {
g_warning ("NULL convs in gnm_go_data_serialize");
convs = gnm_conventions_default;
}
/* It is too early in the life cycle to know where we
* are. Wait until later when we parse the sheet */
if (dep->sheet == NULL) {
g_object_set_data_full (G_OBJECT (dat),
"from-str", g_strdup (str), g_free);
set_pending_str (dat, str);
/* Ugh. We assume that convs will stay valid. */
set_pending_convs (dat, convs);
return TRUE;
}
texpr = gnm_expr_parse_str_simple (str, parse_pos_init_dep (&pp, dep));
parse_pos_init_dep (&pp, dep);
texpr = gnm_expr_parse_str (str, &pp, GNM_EXPR_PARSE_DEFAULT,
convs, NULL);
if (texpr != NULL) {
dependent_set_expr (dep, texpr);
gnm_expr_top_unref (texpr);
......@@ -143,24 +187,27 @@ gnm_go_data_set_sheet (GOData *dat, Sheet *sheet)
dependent_unlink (dep);
dep->sheet = NULL;
}
if (sheet != NULL) {
/* no expression ?
* Do we need to parse one now that we have more context ? */
if (dep->texpr == NULL) {
char const *str = g_object_get_data (G_OBJECT (dat), "from-str");
if (str != NULL) { /* bingo */
dep->sheet = sheet; /* cheat a bit */
if (gnm_go_data_from_str (dat, str)) {
g_object_set_data (G_OBJECT (dat),
"from-str", NULL); /* free it */
go_data_emit_changed (GO_DATA (dat));
}
if (sheet == NULL)
return;
/* no expression?
* Do we need to parse one now that we have more context ? */
if (dep->texpr == NULL) {
char const *str = get_pending_str (dat);
GnmConventions *convs = get_pending_convs (dat);
if (str != NULL) { /* bingo */
dep->sheet = sheet; /* cheat a bit */
if (gnm_go_data_unserialize (dat, str, convs)) {
set_pending_str (dat, NULL);
set_pending_convs (dat, NULL);
go_data_emit_changed (GO_DATA (dat));
}
}
dep->sheet = NULL;
dependent_set_sheet (dep, sheet);
}
dep->sheet = NULL;
dependent_set_sheet (dep, sheet);
}
Sheet *
......@@ -279,8 +326,8 @@ gnm_go_data_scalar_class_init (GObjectClass *gobject_klass)
godata_klass->dup = gnm_go_data_dup;
godata_klass->eq = gnm_go_data_eq;
godata_klass->preferred_fmt = gnm_go_data_preferred_fmt;
godata_klass->as_str = gnm_go_data_as_str;
godata_klass->from_str = gnm_go_data_from_str;
godata_klass->serialize = gnm_go_data_serialize;
godata_klass->unserialize = gnm_go_data_unserialize;
scalar_klass->get_value = gnm_go_data_scalar_get_value;
scalar_klass->get_str = gnm_go_data_scalar_get_str;
}
......@@ -373,7 +420,7 @@ gnm_go_data_vector_load_len (GODataVector *dat)
#if 0
{
char *str = go_data_as_str (dat);
char *str = go_data_serialize (dat);
g_warning ("load_len '%s'", str);
g_free (str);
}
......@@ -671,8 +718,8 @@ gnm_go_data_vector_class_init (GObjectClass *gobject_klass)
godata_klass->dup = gnm_go_data_dup;
godata_klass->eq = gnm_go_data_eq;
godata_klass->preferred_fmt = gnm_go_data_preferred_fmt;
godata_klass->as_str = gnm_go_data_as_str;
godata_klass->from_str = gnm_go_data_from_str;
godata_klass->serialize = gnm_go_data_serialize;
godata_klass->unserialize = gnm_go_data_unserialize;
vector_klass->load_len = gnm_go_data_vector_load_len;
vector_klass->load_values = gnm_go_data_vector_load_values;
vector_klass->get_value = gnm_go_data_vector_get_value;
......@@ -765,7 +812,7 @@ gnm_go_data_matrix_load_size (GODataMatrix *dat)
#if 0
{
char *str = go_data_as_str (dat);
char *str = go_data_serialize (dat);
g_warning ("load_len '%s'", str);
g_free (str);
}
......@@ -1078,8 +1125,8 @@ gnm_go_data_matrix_class_init (GObjectClass *gobject_klass)
godata_klass->dup = gnm_go_data_dup;
godata_klass->eq = gnm_go_data_eq;
godata_klass->preferred_fmt = gnm_go_data_preferred_fmt;
godata_klass->as_str = gnm_go_data_as_str;
godata_klass->from_str = gnm_go_data_from_str;
godata_klass->serialize = gnm_go_data_serialize;
godata_klass->unserialize = gnm_go_data_unserialize;
matrix_klass->load_size = gnm_go_data_matrix_load_size;
matrix_klass->load_values = gnm_go_data_matrix_load_values;
matrix_klass->get_value = gnm_go_data_matrix_get_value;
......
......@@ -657,7 +657,8 @@ graph_write (GnmCellRegion *cr, gchar const *mime_type, int *size)
}
output = gsf_output_memory_new ();
omem = GSF_OUTPUT_MEMORY (output);
sheet_object_write_object (so, mime_type, output, NULL);
sheet_object_write_object (so, mime_type, output, NULL,
gnm_conventions_default);
osize = gsf_output_size (output);
*size = osize;
......
......@@ -879,7 +879,8 @@ afc_set_cell_hint (AutoFiller *af, GnmCell *cell, GnmCellPos const *pos,
gnm_expr_top_new (aexpr));
else {
res = gnm_expr_as_string (aexpr,
&rinfo.pos, gnm_conventions_default);
&rinfo.pos,
cell->base.sheet->convs);
gnm_expr_free (aexpr);
}
} else if (texpr) {
......@@ -887,14 +888,16 @@ afc_set_cell_hint (AutoFiller *af, GnmCell *cell, GnmCellPos const *pos,
gnm_cell_set_expr (cell, texpr);
else
res = gnm_expr_top_as_string (texpr,
&rinfo.pos, gnm_conventions_default);
&rinfo.pos,
cell->base.sheet->convs);
gnm_expr_top_unref (texpr);
} else {
if (doit)
gnm_cell_set_expr (cell, src_texpr);
else
res = gnm_expr_top_as_string (src_texpr,
&rinfo.pos, gnm_conventions_default);
&rinfo.pos,
cell->base.sheet->convs);
}
} else if (src) {
if (doit)
......
......@@ -3563,7 +3563,8 @@ scg_drag_send_graph (SheetControlGUI *scg,
output = gsf_output_memory_new ();
omem = GSF_OUTPUT_MEMORY (output);
sheet_object_write_object (so, mime_type, output, NULL);
sheet_object_write_object (so, mime_type, output, NULL,
gnm_conventions_default);
osize = gsf_output_size (output);
gtk_selection_data_set
......
......@@ -280,7 +280,8 @@ cell_comment_read_xml_dom (SheetObject *so, char const *typename,
}
static void
cell_comment_write_xml_sax (SheetObject const *so, GsfXMLOut *output)
cell_comment_write_xml_sax (SheetObject const *so, GsfXMLOut *output,
GnmConventions const *convs)
{
GnmComment const *cc = CELL_COMMENT (so);
if (NULL != cc->author)
......@@ -290,7 +291,9 @@ cell_comment_write_xml_sax (SheetObject const *so, GsfXMLOut *output)
}
static void
cell_comment_prep_sax_parser (SheetObject *so, GsfXMLIn *xin, xmlChar const **attrs)
cell_comment_prep_sax_parser (SheetObject *so, GsfXMLIn *xin,
xmlChar const **attrs,
GnmConventions const *convs)
{
GnmComment *cc = CELL_COMMENT (so);
......
......@@ -248,7 +248,8 @@ gnm_sog_write_image (SheetObject const *so, char const *format, double resolutio
static void
gnm_sog_write_object (SheetObject const *so, char const *format,
GsfOutput *output, GError **err)
GsfOutput *output, GError **err,
GnmConventions const *convs)
{
SheetObjectGraph *sog = SHEET_OBJECT_GRAPH (so);
GsfXMLOut *xout;
......@@ -259,7 +260,7 @@ gnm_sog_write_object (SheetObject const *so, char const *format,
graph = gog_object_dup (GOG_OBJECT (sog->graph),
NULL, gog_dataset_dup_to_simple);
xout = gsf_xml_out_new (output);
gog_object_write_xml_sax (GOG_OBJECT (graph), xout);
gog_object_write_xml_sax (GOG_OBJECT (graph), xout, (gpointer)convs);
g_object_unref (xout);
g_object_unref (graph);
}
......@@ -347,7 +348,8 @@ gnm_sog_read_xml_dom (SheetObject *so, char const *typename,
xmlNodePtr child = e_xml_get_child_by_name (tree, "GogObject");
if (child != NULL) {
GogObject *graph = gog_object_new_from_xml (NULL, child);
GogObject *graph = gog_object_new_from_xml
(NULL, child, (gpointer)gnm_conventions_default);
sheet_object_graph_set_gog (so, GOG_GRAPH (graph));
g_object_unref (graph);
}
......@@ -355,10 +357,12 @@ gnm_sog_read_xml_dom (SheetObject *so, char const *typename,
}
static void
gnm_sog_write_xml_sax (SheetObject const *so, GsfXMLOut *output)
gnm_sog_write_xml_sax (SheetObject const *so, GsfXMLOut *output,
GnmConventions const *convs)
{
SheetObjectGraph const *sog = SHEET_OBJECT_GRAPH (so);
gog_object_write_xml_sax (GOG_OBJECT (sog->graph), output);
gog_object_write_xml_sax (GOG_OBJECT (sog->graph), output,
(gpointer)convs);
}
static void
......@@ -369,17 +373,19 @@ sog_xml_finish (GogObject *graph, SheetObject *so)
}
static void
gnm_sog_prep_sax_parser (SheetObject *so, GsfXMLIn *xin, xmlChar const **attrs)
gnm_sog_prep_sax_parser (SheetObject *so, GsfXMLIn *xin, xmlChar const **attrs,
GnmConventions const *convs)
{
gog_object_sax_push_parser (xin, attrs,
(GogObjectSaxHandler) sog_xml_finish, so);
(GogObjectSaxHandler) sog_xml_finish,
(gpointer)convs, so);
}
static void
gnm_sog_copy (SheetObject *dst, SheetObject const *src)
{
SheetObjectGraph const *sog = SHEET_OBJECT_GRAPH (src);
GogGraph *graph = gog_graph_dup (sog->graph);
GogGraph *graph = gog_graph_dup (sog->graph);
sheet_object_graph_set_gog (dst, graph);
g_object_unref (graph);
}
......
......@@ -516,7 +516,8 @@ content_end (GsfXMLIn *xin, G_GNUC_UNUSED GsfXMLBlob *unknown)
}
static void
gnm_soi_prep_sax_parser (SheetObject *so, GsfXMLIn *xin, xmlChar const **attrs)
gnm_soi_prep_sax_parser (SheetObject *so, GsfXMLIn *xin,
xmlChar const **attrs, GnmConventions const *convs)
{
static GsfXMLInNode const dtd[] = {
GSF_XML_IN_NODE (CONTENT, CONTENT, -1, "Content", GSF_XML_CONTENT, &content_start, &content_end),
......@@ -538,7 +539,8 @@ gnm_soi_prep_sax_parser (SheetObject *so, GsfXMLIn *xin, xmlChar const **attrs)
}
static void
gnm_soi_write_xml_sax (SheetObject const *so, GsfXMLOut *output)
gnm_soi_write_xml_sax (SheetObject const *so, GsfXMLOut *output,
GnmConventions const *convs)
{
SheetObjectImage *soi;
......
......@@ -61,8 +61,11 @@ typedef struct {
XmlParseContext const *ctxt,
xmlNodePtr tree);
void (*prep_sax_parser) (SheetObject *so,
GsfXMLIn *xin, xmlChar const **attrs);
void (*write_xml_sax) (SheetObject const *so, GsfXMLOut *output);
GsfXMLIn *xin, xmlChar const **attrs,
GnmConventions const *convs);
void (*write_xml_sax) (SheetObject const *so,
GsfXMLOut *output,
GnmConventions const *convs);
void (*copy) (SheetObject *dst,
SheetObject const *src);
......@@ -165,7 +168,8 @@ struct _SheetObjectExportableIface {
GtkTargetList *(*get_target_list) (SheetObject const *so);
void (*write_object) (SheetObject const *so,
char const *format,
GsfOutput *output, GError **err);
GsfOutput *output, GError **err,
GnmConventions const *convs);
};
G_END_DECLS
......
......@@ -61,6 +61,7 @@
#include <string.h>
#define CXML2C(s) ((char const *)(s))
#define CC2XML(s) ((xmlChar const *)(s))
static inline gboolean
attr_eq (const xmlChar *a, const char *s)
......@@ -216,13 +217,15 @@ static GObjectClass *sheet_object_widget_class = NULL;
static GType sheet_object_widget_get_type (void);
static void
sax_write_dep (GsfXMLOut *output, GnmDependent const *dep, char const *id)
sax_write_dep (GsfXMLOut *output, GnmDependent const *dep, char const *id,
GnmConventions const *convs)
{
if (dep->texpr != NULL) {
GnmParsePos pos;
char *val = gnm_expr_top_as_string (dep->texpr,
parse_pos_init_sheet (&pos, dep->sheet),
gnm_conventions_default);
char *val = gnm_expr_top_as_string
(dep->texpr,
parse_pos_init_sheet (&pos, dep->sheet),
convs);
gsf_xml_out_add_cstr (output, id, val);
g_free (val);
}
......@@ -230,7 +233,7 @@ sax_write_dep (GsfXMLOut *output, GnmDependent const *dep, char const *id)
static gboolean
sax_read_dep (xmlChar const * const *attrs, char const *name,
GnmDependent *dep, GsfXMLIn *xin)
GnmDependent *dep, GsfXMLIn *xin, GnmConventions const *convs)
{
g_return_val_if_fail (attrs != NULL, FALSE);
g_return_val_if_fail (attrs[0] != NULL, FALSE);
......@@ -242,8 +245,11 @@ sax_read_dep (xmlChar const * const *attrs, char const *name,
dep->sheet = NULL;
if (attrs[1] != NULL && *attrs[1] != '\0') {
GnmParsePos pp;
dep->texpr = gnm_expr_parse_str_simple (CXML2C (attrs[1]),
parse_pos_init_sheet (&pp, gnm_xml_in_cur_sheet (xin)));
parse_pos_init_sheet (&pp, gnm_xml_in_cur_sheet (xin));
dep->texpr = gnm_expr_parse_str (CXML2C (attrs[1]), &pp,
GNM_EXPR_PARSE_DEFAULT,
convs, NULL);
} else
dep->texpr = NULL;
......@@ -254,14 +260,15 @@ static void
read_dep (GnmDependent *dep, char const *name,
xmlNodePtr tree, XmlParseContext const *context)
{
char *txt = (gchar *)xmlGetProp (tree, (xmlChar *)name);
xmlChar *txt = xmlGetProp (tree, CC2XML (name));
dep->sheet = NULL;
dep->texpr = NULL;
if (txt != NULL && *txt != '\0') {
GnmParsePos pos;
dep->texpr = gnm_expr_parse_str_simple (txt,
parse_pos_init_sheet (&pos, context->sheet));
parse_pos_init_sheet (&pos, context->sheet);
dep->texpr = gnm_expr_parse_str_simple (CC2XML (txt), &pos);
xmlFree (txt);
}
}
......@@ -365,14 +372,17 @@ sheet_widget_frame_copy (SheetObject *dst, SheetObject const *src)
}
static void
sheet_widget_frame_write_xml_sax (SheetObject const *so, GsfXMLOut *output)
sheet_widget_frame_write_xml_sax (SheetObject const *so, GsfXMLOut *output,
GnmConventions const *convs)
{
SheetWidgetFrame const *swf = SHEET_WIDGET_FRAME (so);
gsf_xml_out_add_cstr (output, "Label", swf->label);
}
static void
sheet_widget_frame_prep_sax_parser (SheetObject *so, GsfXMLIn *xin, xmlChar const **attrs)
sheet_widget_frame_prep_sax_parser (SheetObject *so, GsfXMLIn *xin,
xmlChar const **attrs,
GnmConventions const *convs)
{
SheetWidgetFrame *swf = SHEET_WIDGET_FRAME (so);
for (; attrs != NULL && attrs[0] && attrs[1] ; attrs += 2)
......@@ -388,7 +398,7 @@ sheet_widget_frame_read_xml_dom (SheetObject *so, char const *typename,
xmlNodePtr tree)
{
SheetWidgetFrame *swf = SHEET_WIDGET_FRAME (so);
gchar *label = (gchar *)xmlGetProp (tree, (xmlChar *)"Label");
xmlChar *label = xmlGetProp (tree, CC2XML ("Label"));
if (!label) {
g_warning ("Could not read a SheetWidgetFrame because it lacks a label property.");
......@@ -396,7 +406,7 @@ sheet_widget_frame_read_xml_dom (SheetObject *so, char const *typename,
}
g_free (swf->label);
swf->label = g_strdup (label);
swf->label = g_strdup (CC2XML (label));
xmlFree (label);
return FALSE;
......@@ -613,7 +623,8 @@ sheet_widget_button_copy (SheetObject *dst, SheetObject const *src_swb)
}
static void
sheet_widget_button_write_xml_sax (SheetObject const *so, GsfXMLOut *output)
sheet_widget_button_write_xml_sax (SheetObject const *so, GsfXMLOut *output,
GnmConventions const *convs)
{
/* FIXME: markup */
SheetWidgetButton *swb = SHEET_WIDGET_BUTTON (so);
......@@ -621,7 +632,9 @@ sheet_widget_button_write_xml_sax (SheetObject const *so, GsfXMLOut *output)
}
static void
sheet_widget_button_prep_sax_parser (SheetObject *so, GsfXMLIn *xin, xmlChar const **attrs)
sheet_widget_button_prep_sax_parser (SheetObject *so, GsfXMLIn *xin,
xmlChar const **attrs,
GnmConventions const *convs)
{
SheetWidgetButton *swb = SHEET_WIDGET_BUTTON (so);
for (; attrs != NULL && attrs[0] && attrs[1] ; attrs += 2)
......@@ -636,14 +649,14 @@ sheet_widget_button_read_xml_dom (SheetObject *so, char const *typename,
{
/* FIXME: markup */
SheetWidgetButton *swb = SHEET_WIDGET_BUTTON (so);
gchar *label = (gchar *)xmlGetProp (tree, (xmlChar *)"Label");
xmlChar *label = xmlGetProp (tree, CC2XML ("Label"));
if (!label) {
g_warning ("Could not read a SheetWidgetButton because it lacks a label property.");
return TRUE;
}
swb->label = g_strdup (label);
swb->label = g_strdup (CC2XML (label));
xmlFree (label);
return FALSE;
......@@ -1123,7 +1136,8 @@ sheet_widget_adjustment_foreach_dep (SheetObject *so,
}
static void
sheet_widget_adjustment_write_xml_sax (SheetObject const *so, GsfXMLOut *output)
sheet_widget_adjustment_write_xml_sax (SheetObject const *so, GsfXMLOut *output,
GnmConventions const *convs)
{
SheetWidgetAdjustment const *swa = SHEET_WIDGET_ADJUSTMENT (so);
gsf_xml_out_add_float (output, "Min", swa->adjustment->lower, 2);
......@@ -1131,16 +1145,19 @@ sheet_widget_adjustment_write_xml_sax (SheetObject const *so, GsfXMLOut *output)
gsf_xml_out_add_float (output, "Inc", swa->adjustment->step_increment, 2);
gsf_xml_out_add_float (output, "Page", swa->adjustment->page_increment, 2);
gsf_xml_out_add_float (output, "Value", swa->adjustment->value, 2);
sax_write_dep (output, &swa->dep, "Input");
sax_write_dep (output, &swa->dep, "Input", convs);
}
static void
sheet_widget_adjustment_prep_sax_parser (SheetObject *so, GsfXMLIn *xin, xmlChar const **attrs)
sheet_widget_adjustment_prep_sax_parser (SheetObject *so, GsfXMLIn *xin,
xmlChar const **attrs,
GnmConventions const *convs)
{
SheetWidgetAdjustment *swa = SHEET_WIDGET_ADJUSTMENT (so);
double tmp;
for (; attrs != NULL && attrs[0] && attrs[1] ; attrs += 2)
for (; attrs != NULL && attrs[0] && attrs[1] ; attrs += 2) {
double tmp;
if (gnm_xml_attr_double (attrs, "Min", &tmp))
swa->adjustment->lower = tmp;
else if (gnm_xml_attr_double (attrs, "Max", &tmp))
......@@ -1151,8 +1168,9 @@ sheet_widget_adjustment_prep_sax_parser (SheetObject *so, GsfXMLIn *xin, xmlChar
swa->adjustment->page_increment = tmp;
else if (gnm_xml_attr_double (attrs, "Value", &tmp))
swa->adjustment->value = tmp;
else if (sax_read_dep (attrs, "Input", &swa->dep, xin))
else if (sax_read_dep (attrs, "Input", &swa->dep, xin, convs))
;
}