Commit c1c76eb2 authored by Morten Welinder's avatar Morten Welinder

Sheet: add new sheet_date_conv convenience function.

This is not a hint that date conventions are per-sheet.  They are per
workbook and will stay that way.
parent 225332e2
......@@ -3413,7 +3413,7 @@
* src/ssdiff.c (diff): Use C locale.
(ignore_cell): Ignore arrays, except for the corner.
(output_cell): New function taking proper care of value types,
convensions, etc.
conventions, etc.
(xml_cell_changed): Use output_cell.
(compare_corresponding_cells): Don't use entered_text here either,
although it's harmless.
......
......@@ -5341,7 +5341,7 @@
dependent_managed_set_expr): New functions.
* src/value.c (value_new_cellrange_parsepos_str): Use the right
convensions. Add flags argument for finer control. All callers
conventions. Add flags argument for finer control. All callers
changed.
2009-10-31 Andreas J. Guelzow <aguelzow@pyrshep.ca>
......
......@@ -40,7 +40,7 @@
GNM_PLUGIN_MODULE_HEADER;
#define DATE_CONV(ep) workbook_date_conv ((ep)->sheet->workbook)
#define DATE_CONV(ep) sheet_date_conv ((ep)->sheet)
static void
eastersunday_calc_for_year (int year, GDate *date)
......
......@@ -45,7 +45,7 @@
GNM_PLUGIN_MODULE_HEADER;
#define DAY_SECONDS (3600*24)
#define DATE_CONV(ep) workbook_date_conv ((ep)->sheet->workbook)
#define DATE_CONV(ep) sheet_date_conv ((ep)->sheet)
static GnmValue *
make_date (GnmValue *res)
......
......@@ -93,7 +93,7 @@ val_to_base (GnmFuncEvalInfo *ei,
if (flags & V2B_STRINGS_GENERAL) {
vstring = format_match_number
(value_peek_string (value), NULL,
workbook_date_conv (ei->pos->sheet->workbook));
sheet_date_conv (ei->pos->sheet));
if (!vstring || !VALUE_IS_FLOAT (vstring)) {
value_release (vstring);
return value_new_error_VALUE (ei->pos);
......
......@@ -337,7 +337,7 @@ func_coup (GnmFuncEvalInfo *ei, GnmValue const * const *argv,
conv.freq = value_get_freq (argv[2]);
conv.basis = value_get_basis (argv[3], GO_BASIS_MSRB_30_360);
conv.eom = argv[4] ? value_get_as_checked_bool (argv[4]) : TRUE;
conv.date_conv = workbook_date_conv (ei->pos->sheet->workbook);
conv.date_conv = sheet_date_conv (ei->pos->sheet);
if (!datetime_value_to_g (&settlement, argv[0], conv.date_conv) ||
!datetime_value_to_g (&maturity, argv[1], conv.date_conv))
......@@ -401,7 +401,7 @@ gnumeric_accrint (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
gboolean calc_method;
GODateConventions const *date_conv =
workbook_date_conv (ei->pos->sheet->workbook);
sheet_date_conv (ei->pos->sheet);
if (!datetime_value_to_g (&issue, argv[0], date_conv) ||
!datetime_value_to_g (&first_interest, argv[1], date_conv) ||
......@@ -466,7 +466,7 @@ gnumeric_accrintm (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
gnm_float rate, a, d, par;
int basis;
GODateConventions const *date_conv =
workbook_date_conv (ei->pos->sheet->workbook);
sheet_date_conv (ei->pos->sheet);
rate = value_get_as_float (argv[2]);
par = argv[3] ? value_get_as_float (argv[3]) : 1000;
......@@ -504,7 +504,7 @@ gnumeric_intrate (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
gnm_float investment, redemption, a, d;
int basis;
GODateConventions const *date_conv =
workbook_date_conv (ei->pos->sheet->workbook);
sheet_date_conv (ei->pos->sheet);
investment = value_get_as_float (argv[2]);
redemption = value_get_as_float (argv[3]);
......@@ -542,7 +542,7 @@ gnumeric_received (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
gnm_float investment, discount, a, d, n;
int basis;
GODateConventions const *date_conv =
workbook_date_conv (ei->pos->sheet->workbook);
sheet_date_conv (ei->pos->sheet);
investment = value_get_as_float (argv[2]);
discount = value_get_as_float (argv[3]);
......@@ -582,7 +582,7 @@ gnumeric_pricedisc (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
gnm_float discount, redemption, a, d;
int basis;
GODateConventions const *date_conv =
workbook_date_conv (ei->pos->sheet->workbook);
sheet_date_conv (ei->pos->sheet);
discount = value_get_as_float (argv[2]);
redemption = value_get_as_float (argv[3]);
......@@ -619,7 +619,7 @@ gnumeric_pricemat (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
gnm_float discount, yield, a, b, dsm, dim, n;
int basis;
GODateConventions const *date_conv =
workbook_date_conv (ei->pos->sheet->workbook);
sheet_date_conv (ei->pos->sheet);
discount = value_get_as_float (argv[3]);
yield = value_get_as_float (argv[4]);
......@@ -664,7 +664,7 @@ gnumeric_disc (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
gnm_float par, redemption, dsm, b;
int basis;
GODateConventions const *date_conv =
workbook_date_conv (ei->pos->sheet->workbook);
sheet_date_conv (ei->pos->sheet);
par = value_get_as_float (argv[2]);
redemption = value_get_as_float (argv[3]);
......@@ -1098,7 +1098,7 @@ gnumeric_tbilleq (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
gnm_float settlement, maturity, discount;
gnm_float dsm, divisor;
GODateConventions const *date_conv =
workbook_date_conv (ei->pos->sheet->workbook);
sheet_date_conv (ei->pos->sheet);
settlement = datetime_value_to_serial (argv[0], date_conv);
maturity = datetime_value_to_serial (argv[1], date_conv);
......@@ -1136,7 +1136,7 @@ gnumeric_tbillprice (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
gnm_float settlement, maturity, discount;
gnm_float res, dsm;
GODateConventions const *date_conv =
workbook_date_conv (ei->pos->sheet->workbook);
sheet_date_conv (ei->pos->sheet);
settlement = datetime_value_to_serial (argv[0], date_conv);
maturity = datetime_value_to_serial (argv[1], date_conv);
......@@ -1170,7 +1170,7 @@ gnumeric_tbillyield (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
gnm_float settlement, maturity, pr;
gnm_float res, dsm;
GODateConventions const *date_conv =
workbook_date_conv (ei->pos->sheet->workbook);
sheet_date_conv (ei->pos->sheet);
settlement = datetime_value_to_serial (argv[0], date_conv);
maturity = datetime_value_to_serial (argv[1], date_conv);
......@@ -1911,7 +1911,7 @@ gnumeric_duration (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
gnm_float fNumOfCoups;
GoCouponConvention conv;
conv.date_conv = workbook_date_conv (ei->pos->sheet->workbook);
conv.date_conv = sheet_date_conv (ei->pos->sheet);
conv.eom = TRUE;
fCoup = value_get_as_float (argv[2]);
......@@ -2274,7 +2274,7 @@ gnumeric_price (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
gnm_float rate, yield, redemption;
GoCouponConvention conv;
conv.date_conv = workbook_date_conv (ei->pos->sheet->workbook);
conv.date_conv = sheet_date_conv (ei->pos->sheet);
rate = value_get_as_float (argv[2]);
yield = value_get_as_float (argv[3]);
......@@ -2347,7 +2347,7 @@ gnumeric_yield (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
udata.conv.freq = value_get_freq (argv[5]);
udata.conv.basis = value_get_basis (argv[6], GO_BASIS_MSRB_30_360);
udata.conv.eom = TRUE;
udata.conv.date_conv = workbook_date_conv (ei->pos->sheet->workbook);
udata.conv.date_conv = sheet_date_conv (ei->pos->sheet);
if (!datetime_value_to_g (&udata.settlement, argv[0], udata.conv.date_conv) ||
!datetime_value_to_g (&udata.maturity, argv[1], udata.conv.date_conv))
......@@ -2431,7 +2431,7 @@ gnumeric_yielddisc (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
gint basis;
gnm_float ret, yfrac;
GODateConventions const *date_conv =
workbook_date_conv (ei->pos->sheet->workbook);
sheet_date_conv (ei->pos->sheet);
fPrice = value_get_as_float (argv[2]);
fRedemp = value_get_as_float (argv[3]);
......@@ -2476,7 +2476,7 @@ gnumeric_yieldmat (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
gnm_float fRate, fPrice;
gint basis;
GODateConventions const *date_conv =
workbook_date_conv (ei->pos->sheet->workbook);
sheet_date_conv (ei->pos->sheet);
fRate = value_get_as_float (argv[3]);
fPrice = value_get_as_float (argv[4]);
......@@ -2618,7 +2618,7 @@ gnumeric_oddfprice (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
conv.eom = TRUE;
conv.freq = value_get_freq (argv[7]);
conv.basis = value_get_basis (argv[8], GO_BASIS_MSRB_30_360);
conv.date_conv = workbook_date_conv (ei->pos->sheet->workbook);
conv.date_conv = sheet_date_conv (ei->pos->sheet);
if (!datetime_value_to_g (&settlement, argv[0], conv.date_conv) ||
!datetime_value_to_g (&maturity, argv[1], conv.date_conv) ||
......@@ -2696,7 +2696,7 @@ gnumeric_oddfyield (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
udata.conv.eom = TRUE;
udata.conv.freq = value_get_freq (argv[7]);
udata.conv.basis = value_get_basis (argv[8], GO_BASIS_MSRB_30_360);
udata.conv.date_conv = workbook_date_conv (ei->pos->sheet->workbook);
udata.conv.date_conv = sheet_date_conv (ei->pos->sheet);
if (!datetime_value_to_g (&udata.settlement, argv[0], udata.conv.date_conv) ||
!datetime_value_to_g (&udata.maturity, argv[1], udata.conv.date_conv) ||
......@@ -2794,7 +2794,7 @@ gnumeric_oddlprice (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
conv.eom = TRUE;
conv.freq = value_get_freq (argv[6]);
conv.basis = value_get_basis (argv[7], GO_BASIS_MSRB_30_360);
conv.date_conv = workbook_date_conv (ei->pos->sheet->workbook);
conv.date_conv = sheet_date_conv (ei->pos->sheet);
if (!datetime_value_to_g (&settlement, argv[0], conv.date_conv) ||
!datetime_value_to_g (&maturity, argv[1], conv.date_conv) ||
......@@ -2872,7 +2872,7 @@ gnumeric_oddlyield (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
conv.eom = TRUE;
conv.freq = value_get_freq (argv[6]);
conv.basis = value_get_basis (argv[7], GO_BASIS_MSRB_30_360);
conv.date_conv = workbook_date_conv (ei->pos->sheet->workbook);
conv.date_conv = sheet_date_conv (ei->pos->sheet);
if (!datetime_value_to_g (&settlement, argv[0], conv.date_conv) ||
!datetime_value_to_g (&maturity, argv[1], conv.date_conv) ||
......@@ -2932,7 +2932,7 @@ gnumeric_amordegrc (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
gnm_float fRestVal, fRate, fCost;
gint basis, nPer;
GODateConventions const *date_conv =
workbook_date_conv (ei->pos->sheet->workbook);
sheet_date_conv (ei->pos->sheet);
fCost = value_get_as_float (argv[0]);
fRestVal = value_get_as_float (argv[3]);
......@@ -2978,7 +2978,7 @@ gnumeric_amorlinc (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
gnm_float fCost, fRestVal, fRate;
gint nPer, basis;
GODateConventions const *date_conv =
workbook_date_conv (ei->pos->sheet->workbook);
sheet_date_conv (ei->pos->sheet);
fCost = value_get_as_float (argv[0]);
fRestVal = value_get_as_float (argv[3]);
......@@ -3259,7 +3259,7 @@ gnumeric_mduration (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
gnm_float fNumOfCoups;
GoCouponConvention conv;
conv.date_conv = workbook_date_conv (ei->pos->sheet->workbook);
conv.date_conv = sheet_date_conv (ei->pos->sheet);
conv.eom = TRUE;
fCoup = value_get_as_float (argv[2]);
......
......@@ -46,7 +46,7 @@
GNM_PLUGIN_MODULE_HEADER;
#define DATE_CONV(ep) workbook_date_conv ((ep)->sheet->workbook)
#define DATE_CONV(ep) sheet_date_conv ((ep)->sheet)
#define UNICODE_MONTH_PREFIX "\xd7\x91\xd6\xbc\xd6\xb0"
static void
......
......@@ -1750,7 +1750,7 @@ gnumeric_n (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
v = format_match_number (value_peek_string (argv[0]),
NULL,
workbook_date_conv (ei->pos->sheet->workbook));
sheet_date_conv (ei->pos->sheet));
if (v != NULL)
return v;
......
......@@ -65,7 +65,7 @@ oldstyle_if_func (GnmFuncEvalInfo *ei, GnmValue const * const *argv,
GPtrArray *crits = g_ptr_array_new_with_free_func ((GDestroyNotify)gnm_criteria_unref);
GPtrArray *data = g_ptr_array_new ();
GODateConventions const *date_conv =
workbook_date_conv (ei->pos->sheet->workbook);
sheet_date_conv (ei->pos->sheet);
GnmValue *res;
gboolean insanity;
GnmValue const *vals;
......@@ -112,7 +112,7 @@ newstyle_if_func (GnmFuncEvalInfo *ei, int argc, GnmExprConstPtr const *argv,
GPtrArray *crits = g_ptr_array_new_with_free_func ((GDestroyNotify)gnm_criteria_unref);
GPtrArray *data = g_ptr_array_new_with_free_func ((GDestroyNotify)value_release);
GODateConventions const *date_conv =
workbook_date_conv (ei->pos->sheet->workbook);
sheet_date_conv (ei->pos->sheet);
GnmValue *res;
GnmValue *vals = NULL;
int i;
......
......@@ -881,7 +881,7 @@ gnumeric_fixed (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
g_string_free (format, TRUE);
res = format_value (fmt, v, -1,
workbook_date_conv (ei->pos->sheet->workbook));
sheet_date_conv (ei->pos->sheet));
go_format_unref (fmt);
value_release (v);
......@@ -1079,7 +1079,7 @@ gnumeric_text (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
GnmValue *res, *match = NULL;
GnmValue const *v = argv[0];
GODateConventions const *conv =
workbook_date_conv (ei->pos->sheet->workbook);
sheet_date_conv (ei->pos->sheet);
char *lfmt;
/* Why do we have to do these here? */
......@@ -1186,7 +1186,7 @@ gnumeric_value (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
p = g_utf8_next_char (p);
v = format_match_number (p, NULL,
workbook_date_conv (ei->pos->sheet->workbook));
sheet_date_conv (ei->pos->sheet));
if (v != NULL)
return v;
......@@ -1245,7 +1245,7 @@ gnumeric_numbervalue (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
if (v == NULL)
v = format_match_number
(p, NULL,
workbook_date_conv (ei->pos->sheet->workbook));
sheet_date_conv (ei->pos->sheet));
if (v != NULL)
return v;
......@@ -1390,7 +1390,7 @@ gnumeric_dollar (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
v = value_new_float (number);
s = format_value (sf, v, -1,
workbook_date_conv (ei->pos->sheet->workbook));
sheet_date_conv (ei->pos->sheet));
value_release (v);
go_format_unref (sf);
......
......@@ -157,7 +157,7 @@ display_recordset (GdaDataModel *recset, GnmFuncEvalInfo *ei)
if (rowcount >= gnm_sheet_get_max_rows (ei->pos->sheet))
return value_new_error (ei->pos, _("Too much data returned"));
date_conv = workbook_date_conv (ei->pos->sheet->workbook);
date_conv = sheet_date_conv (ei->pos->sheet);
array = value_new_array_empty (fieldcount, rowcount);
for (row = 0; row < rowcount; row++) {
for (col = 0; col < fieldcount; col++) {
......
......@@ -731,7 +731,7 @@ gnm_cell_get_entered_text (GnmCell const *cell)
v = cell->value;
if (v != NULL) {
GODateConventions const *date_conv =
workbook_date_conv (sheet->workbook);
sheet_date_conv (sheet);
if (VALUE_IS_STRING (v)) {
/* Try to be reasonably smart about adding a leading quote */
......@@ -830,7 +830,7 @@ gnm_cell_get_text_for_editing (GnmCell const * cell,
if (quoted)
*quoted = FALSE;
date_conv = workbook_date_conv (cell->base.sheet->workbook);
date_conv = sheet_date_conv (cell->base.sheet);
if (!gnm_cell_is_array (cell) &&
!gnm_cell_has_expr (cell) && VALUE_IS_FLOAT (cell->value)) {
......
......@@ -302,7 +302,7 @@ paste_cell (int target_col, int target_row,
gnm_float fnew = go_date_conv_translate
(value_get_as_float (oldval),
dat->cr->date_conv,
workbook_date_conv (dst_sheet->workbook));
sheet_date_conv (dst_sheet));
newval = value_new_float (fnew);
value_set_fmt (newval, VALUE_FMT (oldval));
}
......@@ -554,7 +554,7 @@ clipboard_paste_region (GnmCellRegion const *cr,
}
dat.translate_dates = cr->date_conv &&
!go_date_conv_equal (cr->date_conv, workbook_date_conv (pt->sheet->workbook));
!go_date_conv_equal (cr->date_conv, sheet_date_conv (pt->sheet));
for (i = 0; i < repeat_horizontal ; i++)
for (j = 0; j < repeat_vertical ; j++) {
......@@ -894,7 +894,7 @@ gnm_cell_region_new (Sheet *origin_sheet)
GnmCellRegion *cr = g_new0 (GnmCellRegion, 1);
cr->origin_sheet = origin_sheet;
cr->date_conv = origin_sheet && origin_sheet->workbook
? workbook_date_conv (origin_sheet->workbook)
? sheet_date_conv (origin_sheet)
: NULL;
cr->cols = cr->rows = -1;
cr->not_as_contents = FALSE;
......
......@@ -490,7 +490,7 @@ collect_floats (int argc, GnmExprConstPtr const *argv,
cl.count = 0;
cl.flags = flags;
cl.info = NULL;
cl.date_conv = workbook_date_conv (ep->sheet->workbook);
cl.date_conv = sheet_date_conv (ep->sheet);
*error = function_iterate_argument_values
(ep, &callback_function_collect, &cl,
......
......@@ -400,8 +400,7 @@ parse_criteria_range (Sheet *sheet, int b_col, int b_row, int e_col, int e_row,
int *field_ind, gboolean anchor_end)
{
GSList *criterias = NULL;
GODateConventions const *date_conv =
workbook_date_conv (sheet->workbook);
GODateConventions const *date_conv = sheet_date_conv (sheet);
int i, j;
for (i = b_row; i <= e_row; i++) {
......
......@@ -460,8 +460,7 @@ static void
fmt_dialog_init_format_page (FormatState *state)
{
GOFormatSel *gfs;
GODateConventions const *date_conv =
workbook_date_conv (state->sheet->workbook);
GODateConventions const *date_conv = sheet_date_conv (state->sheet);
state->format_sel = gnm_format_sel_new ();
gfs = GO_FORMAT_SEL (state->format_sel);
......@@ -860,8 +859,7 @@ fmt_dialog_init_font_page (FormatState *state)
GtkWidget *font_widget;
gboolean strikethrough = FALSE;
GOFontScript script = GO_FONT_SCRIPT_STANDARD;
GODateConventions const *date_conv =
workbook_date_conv (state->sheet->workbook);
GODateConventions const *date_conv = sheet_date_conv (state->sheet);
GnmColor *mcolor = NULL;
GnmColor *def_sc;
GtkWidget *up;
......
......@@ -687,8 +687,7 @@ make_expr_example (Sheet *sheet, const char *text,
if (!fmt)
fmt = gnm_auto_style_format_suggest (texpr, &ep);
vtxt = format_value (fmt, val, -1,
workbook_date_conv (sheet->workbook));
vtxt = format_value (fmt, val, -1, sheet_date_conv (sheet));
gnm_expr_top_unref (texpr);
value_release (val);
......
......@@ -904,7 +904,7 @@ cb_bin_arith (GnmEvalPos const *ep, GnmValue const *a, GnmValue const *b,
a = va = (GnmValue *)value_zero;
else if (VALUE_IS_STRING (a)) {
va = format_match_number (value_peek_string (a), NULL,
workbook_date_conv (ep->sheet->workbook));
sheet_date_conv (ep->sheet));
if (va == NULL)
return value_new_error_VALUE (ep);
} else if (!VALUE_IS_NUMBER (a))
......@@ -915,7 +915,7 @@ cb_bin_arith (GnmEvalPos const *ep, GnmValue const *a, GnmValue const *b,
b = vb = (GnmValue *)value_zero;
else if (VALUE_IS_STRING (b)) {
vb = format_match_number (value_peek_string (b), NULL,
workbook_date_conv (ep->sheet->workbook));
sheet_date_conv (ep->sheet));
if (vb == NULL) {
if (va != a)
value_release (va);
......@@ -1119,7 +1119,7 @@ cb_iter_unary_neg (GnmValueIter const *v_iter, GnmValue *res)
else if (VALUE_IS_STRING (v)) {
GnmValue *conv = format_match_number (
value_peek_string (v), NULL,
workbook_date_conv (v_iter->ep->sheet->workbook));
sheet_date_conv (v_iter->ep->sheet));
if (conv != NULL) {
tmp = negate_value (conv);
value_release (conv);
......@@ -1150,7 +1150,7 @@ cb_iter_percentage (GnmValueIter const *v_iter, GnmValue *res)
if (VALUE_IS_STRING (v)) {
conv = format_match_number (
value_peek_string (v), NULL,
workbook_date_conv (v_iter->ep->sheet->workbook));
sheet_date_conv (v_iter->ep->sheet));
if (conv != NULL)
v = conv;
}
......@@ -1301,7 +1301,7 @@ gnm_expr_eval (GnmExpr const *expr, GnmEvalPos const *pos,
/* 2) #!VALUE error if A is not a number */
if (VALUE_IS_STRING (a)) {
GnmValue *tmp = format_match_number (value_peek_string (a), NULL,
workbook_date_conv (pos->sheet->workbook));
sheet_date_conv (pos->sheet));
value_release (a);
if (tmp == NULL)
......@@ -1311,7 +1311,7 @@ gnm_expr_eval (GnmExpr const *expr, GnmEvalPos const *pos,
b = gnm_expr_eval (expr->binary.value_b, pos, flags);
if (VALUE_IS_STRING (b)) {
res = format_match_number (value_peek_string (b), NULL,
workbook_date_conv (pos->sheet->workbook));
sheet_date_conv (pos->sheet));
value_release (b);
b = (res == NULL) ? value_new_error_VALUE (pos) : res;
}
......@@ -1333,7 +1333,7 @@ gnm_expr_eval (GnmExpr const *expr, GnmEvalPos const *pos,
/* 4) #!VALUE error if B is not a number */
if (VALUE_IS_STRING (b)) {
GnmValue *tmp = format_match_number (value_peek_string (b), NULL,
workbook_date_conv (pos->sheet->workbook));
sheet_date_conv (pos->sheet));
value_release (b);
if (tmp == NULL) {
......@@ -1377,7 +1377,7 @@ gnm_expr_eval (GnmExpr const *expr, GnmEvalPos const *pos,
/* 2) #!VALUE error if A is not a number */
if (VALUE_IS_STRING (a)) {
GnmValue *tmp = format_match_number (value_peek_string (a), NULL,
workbook_date_conv (pos->sheet->workbook));
sheet_date_conv (pos->sheet));
value_release (a);
if (tmp == NULL)
......
......@@ -1236,7 +1236,7 @@ function_call_with_exprs (GnmFuncEvalInfo *ei)
case 'f':
if (VALUE_IS_STRING (tmp)) {
tmp = format_match_number (value_peek_string (tmp), NULL,
workbook_date_conv (ei->pos->sheet->workbook));
sheet_date_conv (ei->pos->sheet));
if (tmp == NULL) {
free_values (args, i + 1);
return value_new_error_VALUE (ei->pos);
......@@ -1299,7 +1299,7 @@ function_call_with_exprs (GnmFuncEvalInfo *ei)
elem = value_zero;
else if (VALUE_IS_STRING (elem)) {
tmp = format_match_number (value_peek_string (elem), NULL,
workbook_date_conv (ei->pos->sheet->workbook));
sheet_date_conv (ei->pos->sheet));
if (tmp != NULL) {
args [iter_item[i]] = iter_args [i] = tmp;
continue;
......
......@@ -82,7 +82,7 @@ render_val (GnmValue const *v, int i, int j,
if (!v)
return NULL;
date_conv = ep->sheet ? workbook_date_conv (ep->sheet->workbook) : NULL;
date_conv = ep->sheet ? sheet_date_conv (ep->sheet) : NULL;
#if 0
g_printerr ("Rendering %s with fmt=%s\n",
......@@ -181,7 +181,7 @@ gnm_go_data_date_conv (GOData const *dat)
if (!dep->sheet)
return NULL;
return workbook_date_conv (dep->sheet->workbook);
return sheet_date_conv (dep->sheet);
}
static char *
......@@ -690,7 +690,7 @@ gnm_go_data_vector_load_values (GODataVector *dat)
return;
}
closure.date_conv = workbook_date_conv (vec->dep.sheet->workbook);
closure.date_conv = sheet_date_conv (vec->dep.sheet);
if (dat->values == NULL)
dat->values = g_new (double, dat->len);
......@@ -914,7 +914,7 @@ gnm_go_data_vector_get_str (GODataVector *dat, unsigned i)
int x = 0, y = vec->val->v_array.y;
struct string_closure closure;
closure.strs = vec->strs = g_ptr_array_new_with_free_func (g_free);
closure.date_conv = ep.sheet ? workbook_date_conv (ep.sheet->workbook) : NULL;
closure.date_conv = ep.sheet ? sheet_date_conv (ep.sheet) : NULL;
while (len-- > 0) {
if (x == 0) {
x = vec->val->v_array.x;
......@@ -956,7 +956,7 @@ gnm_go_data_vector_get_str (GODataVector *dat, unsigned i)
if (vec->strs == NULL) {
struct string_closure closure;
closure.strs = vec->strs = g_ptr_array_new_with_free_func (g_free);
closure.date_conv = ep.sheet ? workbook_date_conv (ep.sheet->workbook) : NULL;
closure.date_conv = ep.sheet ? sheet_date_conv (ep.sheet) : NULL;
gnm_rangeref_normalize (&vec->val->v_range.cell,
eval_pos_init_dep (&ep, &vec->dep),
&start_sheet, &end_sheet, &r);
......@@ -1319,7 +1319,7 @@ gnm_go_data_matrix_load_values (GODataMatrix *dat)
return;
}
closure.date_conv = workbook_date_conv (mat->dep.sheet->workbook);
closure.date_conv = sheet_date_conv (mat->dep.sheet);
if (dat->values == NULL)
dat->values = g_new (double, size.rows * size.columns);
......
......@@ -22,7 +22,7 @@
/*
* NOTE 2: the pbeta (and support) code comes from Ian Smith. (Translated
* into C, adapted to Gnumeric naming convensions, and R's API conventions
* into C, adapted to Gnumeric naming conventions, and R's API conventions
* by Morten Welinder. Blame me for problems.)
*
* Copyright © Ian Smith 2002-2003
......
......@@ -832,7 +832,7 @@ parse_text_value_or_expr (GnmParsePos const *pos, char const *text,
/* Determine context information. */
date_conv =
pos->sheet
? workbook_date_conv (pos->sheet->workbook)
? sheet_date_conv (pos->sheet)
: (pos->wb
? workbook_date_conv (pos->wb)
: NULL);
......
......@@ -447,7 +447,7 @@ gnm_rendered_value_new (GnmCell const *cell,
int col_width = -1;
GOFormat const *format = gnm_style_get_format (mstyle);
GODateConventions const *date_conv = sheet->workbook
? workbook_date_conv (sheet->workbook)
? sheet_date_conv (sheet)
: NULL;
GnmFont *font = gnm_style_get_font (mstyle, context);
gboolean is_rotated = (rotation != 0);
......
......@@ -76,8 +76,7 @@ gnm_search_normalize_result (const char *txt)
static gboolean
check_number (GnmSearchReplace *sr)
{
GODateConventions const *date_conv =
workbook_date_conv (sr->sheet->workbook);
GODateConventions const *date_conv = sheet_date_conv (sr->sheet);
GOSearchReplace *gosr = (GOSearchReplace *)sr;
GnmValue *v = format_match_number (gosr->search_text, NULL, date_conv);
......
......@@ -165,7 +165,7 @@ afa_teach_cell (AutoFiller *af, const GnmCell *cell, int n)
switch (n) {
case 0:
afa->dateconv = workbook_date_conv (cell->base.sheet->workbook);
afa->dateconv = sheet_date_conv (cell->base.sheet);
afa->base = f;
if (afa->singleton) {
afa->step = 1;
......@@ -546,7 +546,7 @@ afm_teach_cell (AutoFiller *af, const GnmCell *cell, int n)
if (gnm_format_is_date_for_value (sf, value) != 1)
goto bad;
afm->dateconv = workbook_date_conv (cell->base.sheet->workbook);
afm->dateconv = sheet_date_conv (cell->base.sheet);
if (!datetime_value_to_g (&d, value, afm->dateconv))
goto bad;
......@@ -902,7 +902,7 @@ afc_set_cell_hint (AutoFiller *af, GnmCell *cell, GnmCellPos const *pos,
else {
Sheet const *sheet = src->base.sheet;
GODateConventions const *dateconv =
workbook_date_conv (sheet->workbook);
sheet_date_conv (sheet);
GOFormat const *format = gnm_cell_get_format (src);
return format_value (format, src->value, -1,
dateconv);
......
......@@ -4504,10 +4504,9 @@ static void
scg_drag_send_text (SheetControlGUI *scg, GtkSelectionData *sd)
{
Sheet *sheet = scg_sheet (scg);
Workbook *wb = sheet->workbook;
GnmRange range = sheet_get_extent (sheet, TRUE, TRUE);
GnmCellRegion *reg = clipboard_copy_range (sheet, &range);
GString *s = cellregion_to_string (reg, TRUE, workbook_date_conv (wb));
GString *s = cellregion_to_string (reg, TRUE, sheet_date_conv (sheet));
cellregion_unref (reg);
if (!s)
......
......@@ -191,7 +191,7 @@ filter_expr_init (FilterExpr *fexpr, unsigned i,
GnmFilterOp op = cond->op[i];
char const *str = value_peek_string (tmp);
GODateConventions const *date_conv =
workbook_date_conv (filter->sheet->workbook);
sheet_date_conv (filter->sheet);
if ((op == GNM_FILTER_OP_EQUAL || op == GNM_FILTER_OP_NOT_EQUAL) &&
gnm_regcomp_XL (fexpr->regexp + i, str, GO_REG_ICASE, TRUE, TRUE) == GO_REG_OK) {
......@@ -221,7 +221,7 @@ filter_cell_contents (GnmCell *cell)
{
GOFormat const *format = gnm_cell_get_format (cell);
GODateConventions const *date_conv =
workbook_date_conv (cell->base.sheet->workbook);
sheet_date_conv (cell->base.sheet);
return format_value (format, cell->value, -1, date_conv);
}
......@@ -258,7 +258,7 @@ filter_expr_eval (GnmFilterOp op, GnmValue const *src, GORegexp const *regexp,
if (VALUE_IS_STRING (target) && VALUE_IS_NUMBER (src)) {
GODateConventions const *date_conv =
workbook_date_conv (cell->base.sheet->workbook);
sheet_date_conv (cell->base.sheet);
char *str = format_value (NULL, src, -1, date_conv);
fake_val = value_new_string_nocopy (str);
src = fake_val;
......
......@@ -3197,7 +3197,7 @@ static GnmValue *
so_parse_value (SheetObject *so, const char *s)
{
Sheet *sheet = so->sheet;
return format_match (s, NULL, workbook_date_conv (sheet->workbook));
return format_match (s, NULL, sheet_date_conv (sheet));
}
static void
......
......@@ -6669,3 +6669,19 @@ gnm_sheet_find_sort_setup (Sheet *sheet, char const *key)