[gnumeric] Reduce use of gnm_conventions_default and gnm_expr_parse_str_simple
- From: Morten Welinder <mortenw src gnome org>
- To: svn-commits-list gnome org
- Subject: [gnumeric] Reduce use of gnm_conventions_default and gnm_expr_parse_str_simple
- Date: Wed, 29 Apr 2009 16:28:58 -0400 (EDT)
commit d6ecc0c23255b6847c1d6d8184a90c2f3df0af44
Author: Morten Welinder <terra gnome org>
Date: Wed Apr 29 16:28:27 2009 -0400
Reduce use of gnm_conventions_default and gnm_expr_parse_str_simple
---
ChangeLog | 6 ++
NEWS | 2 +
configure.in | 2 +-
plugins/excel/ms-chart.c | 5 +-
src/auto-format.c | 8 +--
src/commands.c | 2 +-
src/dependent.c | 6 +-
src/expr.c | 2 +-
src/gnm-so-filled.c | 7 ++-
src/gnm-so-line.c | 7 ++-
src/gnm-so-polygon.c | 5 +-
src/graph.c | 117 +++++++++++++++++++++++++++------------
src/gui-clipboard.c | 3 +-
src/sheet-autofill.c | 9 ++-
src/sheet-control-gui.c | 3 +-
src/sheet-object-cell-comment.c | 7 ++-
src/sheet-object-graph.c | 22 +++++---
src/sheet-object-image.c | 6 +-
src/sheet-object-impl.h | 10 ++-
src/sheet-object-widget.c | 96 ++++++++++++++++++++------------
src/sheet-object.c | 7 +-
src/sheet-object.h | 3 +-
src/sheet.c | 5 +-
src/style-conditions.c | 2 +-
src/validation.c | 4 +-
src/wbc-gtk.c | 10 ++-
src/xml-sax-read.c | 2 +-
src/xml-sax-write.c | 2 +-
28 files changed, 235 insertions(+), 125 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 0e4c317..c8a68c1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
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
fullscreen mode, disable the actions in ->hide_for_fullscreen.
When exiting, restore the old state.
diff --git a/NEWS b/NEWS
index 5a778ca..de7bdbf 100644
--- a/NEWS
+++ b/NEWS
@@ -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
diff --git a/configure.in b/configure.in
index bd839cd..7c6190f 100644
--- a/configure.in
+++ b/configure.in
@@ -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
"
diff --git a/plugins/excel/ms-chart.c b/plugins/excel/ms-chart.c
index 27d04c2..dd82524 100644
--- a/plugins/excel/ms-chart.c
+++ b/plugins/excel/ms-chart.c
@@ -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);
diff --git a/src/auto-format.c b/src/auto-format.c
index 12127d2..5ccbd6f 100644
--- a/src/auto-format.c
+++ b/src/auto-format.c
@@ -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
diff --git a/src/commands.c b/src/commands.c
index b00e08e..39c3671 100644
--- a/src/commands.c
+++ b/src/commands.c
@@ -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);
diff --git a/src/dependent.c b/src/dependent.c
index 43282a2..7ee967b 100644
--- a/src/dependent.c
+++ b/src/dependent.c
@@ -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);
diff --git a/src/expr.c b/src/expr.c
index 45cb675..62ead57 100644
--- a/src/expr.c
+++ b/src/expr.c
@@ -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);
}
diff --git a/src/gnm-so-filled.c b/src/gnm-so-filled.c
index d325f56..f307d32 100644
--- a/src/gnm-so-filled.c
+++ b/src/gnm-so-filled.c
@@ -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),
diff --git a/src/gnm-so-line.c b/src/gnm-so-line.c
index 3e7d53b..948d503 100644
--- a/src/gnm-so-line.c
+++ b/src/gnm-so-line.c
@@ -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),
diff --git a/src/gnm-so-polygon.c b/src/gnm-so-polygon.c
index 98445e9..3d73f21 100644
--- a/src/gnm-so-polygon.c
+++ b/src/gnm-so-polygon.c
@@ -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
diff --git a/src/graph.c b/src/graph.c
index 21fbf84..29c0043 100644
--- a/src/graph.c
+++ b/src/graph.c
@@ -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;
diff --git a/src/gui-clipboard.c b/src/gui-clipboard.c
index de14faa..c8c78ee 100644
--- a/src/gui-clipboard.c
+++ b/src/gui-clipboard.c
@@ -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;
diff --git a/src/sheet-autofill.c b/src/sheet-autofill.c
index 1b702f1..8623fb2 100644
--- a/src/sheet-autofill.c
+++ b/src/sheet-autofill.c
@@ -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)
diff --git a/src/sheet-control-gui.c b/src/sheet-control-gui.c
index 6b46caf..503f3cd 100644
--- a/src/sheet-control-gui.c
+++ b/src/sheet-control-gui.c
@@ -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
diff --git a/src/sheet-object-cell-comment.c b/src/sheet-object-cell-comment.c
index 76c1b7e..ddee507 100644
--- a/src/sheet-object-cell-comment.c
+++ b/src/sheet-object-cell-comment.c
@@ -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);
diff --git a/src/sheet-object-graph.c b/src/sheet-object-graph.c
index f07d18b..ff90c6a 100644
--- a/src/sheet-object-graph.c
+++ b/src/sheet-object-graph.c
@@ -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);
}
diff --git a/src/sheet-object-image.c b/src/sheet-object-image.c
index 2d9541b..6aae73b 100644
--- a/src/sheet-object-image.c
+++ b/src/sheet-object-image.c
@@ -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;
diff --git a/src/sheet-object-impl.h b/src/sheet-object-impl.h
index c98e473..c87812c 100644
--- a/src/sheet-object-impl.h
+++ b/src/sheet-object-impl.h
@@ -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
diff --git a/src/sheet-object-widget.c b/src/sheet-object-widget.c
index 8917ecc..b8493a6 100644
--- a/src/sheet-object-widget.c
+++ b/src/sheet-object-widget.c
@@ -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))
;
+ }
swa->dep.flags = adjustment_get_dep_type ();
gtk_adjustment_changed (swa->adjustment);
@@ -1744,17 +1762,20 @@ sheet_widget_checkbox_foreach_dep (SheetObject *so,
}
static void
-sheet_widget_checkbox_write_xml_sax (SheetObject const *so, GsfXMLOut *output)
+sheet_widget_checkbox_write_xml_sax (SheetObject const *so, GsfXMLOut *output,
+ GnmConventions const *convs)
{
SheetWidgetCheckbox const *swc = SHEET_WIDGET_CHECKBOX (so);
gsf_xml_out_add_cstr (output, "Label", swc->label);
gsf_xml_out_add_int (output, "Value", swc->value);
- sax_write_dep (output, &swc->dep, "Input");
+ sax_write_dep (output, &swc->dep, "Input", convs);
}
static void
-sheet_widget_checkbox_prep_sax_parser (SheetObject *so, GsfXMLIn *xin, xmlChar const **attrs)
+sheet_widget_checkbox_prep_sax_parser (SheetObject *so, GsfXMLIn *xin,
+ xmlChar const **attrs,
+ GnmConventions const *convs)
{
SheetWidgetCheckbox *swc = SHEET_WIDGET_CHECKBOX (so);
@@ -1764,7 +1785,7 @@ sheet_widget_checkbox_prep_sax_parser (SheetObject *so, GsfXMLIn *xin, xmlChar c
swc->label = g_strdup (CXML2C (attrs[1]));
} else if (gnm_xml_attr_int (attrs, "Value", &swc->value))
; /* ??? */
- else if (sax_read_dep (attrs, "Input", &swc->dep, xin))
+ else if (sax_read_dep (attrs, "Input", &swc->dep, xin, convs))
; /* ??? */
}
@@ -1774,14 +1795,14 @@ sheet_widget_checkbox_read_xml_dom (SheetObject *so, char const *typename,
xmlNodePtr tree)
{
SheetWidgetCheckbox *swc = SHEET_WIDGET_CHECKBOX (so);
- gchar *label = (gchar *)xmlGetProp (tree, (xmlChar *)"Label");
+ xmlChar *label = xmlGetProp (tree, CC2XML ("Label"));
if (!label) {
g_warning ("Could not read a CheckBoxWidget object because it lacks a label property");
return TRUE;
}
- swc->label = g_strdup (label);
+ swc->label = g_strdup (CC2XML (label));
xmlFree (label);
read_dep (&swc->dep, "Input", tree, context);
@@ -2275,21 +2296,24 @@ sheet_widget_list_base_foreach_dep (SheetObject *so,
}
static void
-sheet_widget_list_base_write_xml_sax (SheetObject const *so, GsfXMLOut *output)
+sheet_widget_list_base_write_xml_sax (SheetObject const *so, GsfXMLOut *output,
+ GnmConventions const *convs)
{
SheetWidgetListBase const *swl = SHEET_WIDGET_LIST_BASE (so);
- sax_write_dep (output, &swl->content_dep, "Content");
- sax_write_dep (output, &swl->output_dep, "Output");
+ sax_write_dep (output, &swl->content_dep, "Content", convs);
+ sax_write_dep (output, &swl->output_dep, "Output", convs);
}
static void
-sheet_widget_list_base_prep_sax_parser (SheetObject *so, GsfXMLIn *xin, xmlChar const **attrs)
+sheet_widget_list_base_prep_sax_parser (SheetObject *so, GsfXMLIn *xin,
+ xmlChar const **attrs,
+ GnmConventions const *convs)
{
SheetWidgetListBase *swl = SHEET_WIDGET_LIST_BASE (so);
for (; attrs != NULL && attrs[0] && attrs[1] ; attrs += 2)
- if (sax_read_dep (attrs, "Content", &swl->content_dep, xin)) ;
- else if (sax_read_dep (attrs, "Output", &swl->output_dep, xin)) ;
+ if (sax_read_dep (attrs, "Content", &swl->content_dep, xin, convs)) ;
+ else if (sax_read_dep (attrs, "Output", &swl->output_dep, xin, convs)) ;
}
static gboolean
diff --git a/src/sheet-object.c b/src/sheet-object.c
index c8dbc44..9286a93 100644
--- a/src/sheet-object.c
+++ b/src/sheet-object.c
@@ -1194,15 +1194,16 @@ sheet_object_exportable_get_target_list (SheetObject const *so)
void
sheet_object_write_object (SheetObject const *so, char const *format,
- GsfOutput *output, GError **err)
+ GsfOutput *output, GError **err,
+ GnmConventions const *convs)
{
GnmLocale *locale;
g_return_if_fail (IS_SHEET_OBJECT_EXPORTABLE (so));
locale = gnm_push_C_locale ();
- SHEET_OBJECT_EXPORTABLE_CLASS (so)->write_object (so, format,
- output, err);
+ SHEET_OBJECT_EXPORTABLE_CLASS (so)->
+ write_object (so, format, output, err, convs);
gnm_pop_C_locale (locale);
}
diff --git a/src/sheet-object.h b/src/sheet-object.h
index b5138a7..c1551f2 100644
--- a/src/sheet-object.h
+++ b/src/sheet-object.h
@@ -127,7 +127,8 @@ void sheet_object_write_image (SheetObject const *so,
GtkTargetList *sheet_object_exportable_get_target_list (SheetObject const *so);
void sheet_object_write_object (SheetObject const *so,
char const *format,
- GsfOutput *output, GError **err);
+ GsfOutput *output, GError **err,
+ GnmConventions const *convs);
/* cairo rendering */
void sheet_object_draw_cairo (SheetObject const *so, cairo_t *cr, gboolean rtl);
diff --git a/src/sheet.c b/src/sheet.c
index d299c33..cde7725 100644
--- a/src/sheet.c
+++ b/src/sheet.c
@@ -267,8 +267,9 @@ sheet_set_name (Sheet *sheet, char const *new_name)
g_free (sheet->name_unquoted_collate_key);
g_free (sheet->name_case_insensitive);
sheet->name_unquoted = new_name_unquoted;
- sheet->name_quoted = g_string_free (gnm_expr_conv_quote (
- gnm_conventions_default, new_name_unquoted), FALSE);
+ sheet->name_quoted = g_string_free
+ (gnm_expr_conv_quote (sheet->convs, new_name_unquoted),
+ FALSE);
sheet->name_unquoted_collate_key =
g_utf8_collate_key (new_name_unquoted, -1);
sheet->name_case_insensitive =
diff --git a/src/style-conditions.c b/src/style-conditions.c
index d72d87d..0c64f7d 100644
--- a/src/style-conditions.c
+++ b/src/style-conditions.c
@@ -219,7 +219,7 @@ gnm_style_conditions_eval (GnmStyleConditions const *sc, GnmEvalPos const *ep)
use_this = value_get_as_bool (val, NULL);
#if 0
char *str = gnm_expr_as_string (cond->expr[0],
- &pp, gnm_conventions_default);
+ &pp, NULL);
g_print ("'%s' = %s\n", str, use_this ? "true" : "false");
g_free (str);
#endif
diff --git a/src/validation.c b/src/validation.c
index 98e778d..a0037a7 100644
--- a/src/validation.c
+++ b/src/validation.c
@@ -431,7 +431,7 @@ validation_eval (WorkbookControl *wbc, GnmStyle const *mstyle,
char *expr_str = gnm_expr_top_as_string
(v->texpr[0],
parse_pos_init_evalpos (&pp, &ep),
- gnm_conventions_default);
+ ep.sheet->convs);
char *msg = g_strdup_printf (_("%s does not contain the new value."), expr_str);
g_free (expr_str);
BARF (msg);
@@ -465,7 +465,7 @@ validation_eval (WorkbookControl *wbc, GnmStyle const *mstyle,
char *expr_str = gnm_expr_top_as_string
(v->texpr[0],
parse_pos_init_evalpos (&pp, &ep),
- gnm_conventions_default);
+ ep.sheet->convs);
char *msg = g_strdup_printf (_("%s is not true."), expr_str);
g_free (expr_str);
BARF (msg);
diff --git a/src/wbc-gtk.c b/src/wbc-gtk.c
index 60f7f50..a171712 100644
--- a/src/wbc-gtk.c
+++ b/src/wbc-gtk.c
@@ -4410,9 +4410,8 @@ cb_graph_dim_editor_update (GnmExprEntry *gee,
if (!GTK_WIDGET_SENSITIVE (gee) || editor->dataset == NULL)
return;
- g_object_get (G_OBJECT (gee), "scg", &scg, NULL);
+ scg = gnm_expr_entry_get_scg (gee);
sheet = scg_sheet (scg);
- g_object_unref (G_OBJECT (scg));
/* If we are setting something */
if (!gnm_expr_entry_is_blank (editor->entry)) {
@@ -4479,7 +4478,9 @@ cb_dataset_changed (GogDataset *dataset,
val = gog_dataset_get_dim (dataset, editor->dim_i);
if (val != NULL) {
- char *txt = go_data_as_str (val);
+ SheetControlGUI *scg = gnm_expr_entry_get_scg (editor->entry);
+ Sheet const *sheet = scg_sheet (scg);
+ char *txt = go_data_serialize (val, (gpointer)sheet->convs);
gnm_expr_entry_load_from_text (editor->entry, txt);
g_free (txt);
}
@@ -4526,7 +4527,8 @@ wbcg_data_allocator_editor (GogDataAllocator *dalloc,
val = gog_dataset_get_dim (dataset, dim_i);
if (val != NULL) {
- char *txt = go_data_as_str (val);
+ Sheet const *sheet = wbcg_cur_sheet (wbcg);
+ char *txt = go_data_serialize (val, (gpointer)sheet->convs);
gnm_expr_entry_load_from_text (editor->entry, txt);
g_free (txt);
}
diff --git a/src/xml-sax-read.c b/src/xml-sax-read.c
index 346ca31..e5f90e7 100644
--- a/src/xml-sax-read.c
+++ b/src/xml-sax-read.c
@@ -2159,7 +2159,7 @@ xml_sax_read_obj (GsfXMLIn *xin, gboolean needs_cleanup,
sheet_object_set_anchor (so, &anchor);
if (NULL != klass->prep_sax_parser)
- (klass->prep_sax_parser) (so, xin, attrs);
+ (klass->prep_sax_parser) (so, xin, attrs, state->convs);
if (needs_cleanup) {
/* Put in something to get gnm_xml_finish_obj called */
static GsfXMLInNode const dtd[] = {
diff --git a/src/xml-sax-write.c b/src/xml-sax-write.c
index 912df98..879a14d 100644
--- a/src/xml-sax-write.c
+++ b/src/xml-sax-write.c
@@ -1098,7 +1098,7 @@ xml_write_objects (GnmOutputXML *state, GSList *objects)
gsf_xml_out_add_int (state->output, "Direction",
so->anchor.base.direction);
- (*klass->write_xml_sax) (so, state->output);
+ (*klass->write_xml_sax) (so, state->output, state->convs);
gsf_xml_out_end_element (state->output); /* </gnm:{typename}> */
g_free (tmp);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]