functions.c (gnumeric-1.12.49.tar.xz) | : | functions.c (gnumeric-1.12.50.tar.xz) | ||
---|---|---|---|---|
skipping to change at line 106 | skipping to change at line 106 | |||
{ GNM_FUNC_HELP_EXAMPLES, "=CELL(\"width\",A1)" }, | { GNM_FUNC_HELP_EXAMPLES, "=CELL(\"width\",A1)" }, | |||
{ GNM_FUNC_HELP_SEEALSO, "INDIRECT"}, | { GNM_FUNC_HELP_SEEALSO, "INDIRECT"}, | |||
{ GNM_FUNC_HELP_END} | { GNM_FUNC_HELP_END} | |||
}; | }; | |||
typedef struct { | typedef struct { | |||
char const *format; | char const *format; | |||
char const *output; | char const *output; | |||
} translate_t; | } translate_t; | |||
static const translate_t translate_table[] = { | static const translate_t translate_table[] = { | |||
#if 0 | ||||
{ "General", "G" }, | { "General", "G" }, | |||
{ "0", "F0" }, | { "0", "F0" }, | |||
{ "#,##0", ",0" }, | { "#,##0", ",0" }, | |||
{ "0.00", "F2" }, | { "0.00", "F2" }, | |||
{ "#,##0.00", ",2" }, | { "#,##0.00", ",2" }, | |||
{ "\"$\"#,##0_);\\(\"$\"#,##0\\)", "C0" }, | { "\"$\"#,##0_);\\(\"$\"#,##0\\)", "C0" }, | |||
{ "\"$\"#,##0_);[Red]\\(\"$\"#,##0\\)", "C0-" }, | { "\"$\"#,##0_);[Red]\\(\"$\"#,##0\\)", "C0-" }, | |||
{ "\"$\"#,##0.00_);\\(\"$\"#,##0.00\\)", "C2" }, | { "\"$\"#,##0.00_);\\(\"$\"#,##0.00\\)", "C2" }, | |||
{ "\"$\"#,##0.00_);[Red]\\(\"$\"#,##0.00\\)", "C2-" }, | { "\"$\"#,##0.00_);[Red]\\(\"$\"#,##0.00\\)", "C2-" }, | |||
{ "0%", "P0" }, | { "0%", "P0" }, | |||
{ "0.00%", "P2" }, | { "0.00%", "P2" }, | |||
{ "0.00e+00", "S2" }, | { "0.00e+00", "S2" }, | |||
{ "# ?/?", "G" }, | { "# ?/?", "G" }, | |||
{ "# ?" "?/?" "?", "G" }, /* Don't accidentally use trigraphs here. */ | { "# ?" "?/?" "?", "G" }, /* Don't accidentally use trigraphs here. */ | |||
#endif | ||||
{ "m/d/yy", "D4" }, | { "m/d/yy", "D4" }, | |||
{ "m/d/yy h:mm", "D4" }, | { "m/d/yy h:mm", "D4" }, | |||
{ "mm/dd/yy", "D4" }, | { "mm/dd/yy", "D4" }, | |||
{ "d-mmm-yy", "D1" }, | { "d-mmm-yy", "D1" }, | |||
{ "dd-mmm-yy", "D1" }, | { "dd-mmm-yy", "D1" }, | |||
{ "d-mmm", "D2" }, | { "d-mmm", "D2" }, | |||
{ "dd-mmm", "D2" }, | { "dd-mmm", "D2" }, | |||
{ "mmm-yy", "D3" }, | { "mmm-yy", "D3" }, | |||
{ "mm/dd", "D5" }, | { "mm/dd", "D5" }, | |||
{ "h:mm am/pm", "D7" }, | { "h:mm am/pm", "D7" }, | |||
skipping to change at line 141 | skipping to change at line 143 | |||
{ "h:mm", "D9" }, | { "h:mm", "D9" }, | |||
{ "h:mm:ss", "D8" } | { "h:mm:ss", "D8" } | |||
}; | }; | |||
static GnmValue * | static GnmValue * | |||
translate_cell_format (GOFormat const *format) | translate_cell_format (GOFormat const *format) | |||
{ | { | |||
int i; | int i; | |||
const char *fmt; | const char *fmt; | |||
const int translate_table_count = G_N_ELEMENTS (translate_table); | const int translate_table_count = G_N_ELEMENTS (translate_table); | |||
gboolean exact; | ||||
GOFormatDetails details; | ||||
if (format == NULL) | if (format == NULL) | |||
return value_new_string ("G"); | goto fallback; | |||
fmt = go_format_as_XL (format); | fmt = go_format_as_XL (format); | |||
/* | /* | |||
* TODO : What does this do in different locales ?? | * TODO : What does this do in different locales ?? | |||
*/ | */ | |||
for (i = 0; i < translate_table_count; i++) { | for (i = 0; i < translate_table_count; i++) { | |||
const translate_t *t = &translate_table[i]; | const translate_t *t = &translate_table[i]; | |||
if (!g_ascii_strcasecmp (fmt, t->format)) { | if (!g_ascii_strcasecmp (fmt, t->format)) { | |||
return value_new_string (t->output); | return value_new_string (t->output); | |||
} | } | |||
} | } | |||
#warning "FIXME: CELL('format',...) isn't right" | go_format_get_details (format, &details, &exact); | |||
/* | if (0 && !exact) { | |||
* 1. The above lookup should be done with respect to just the | g_printerr ("Inexact for %s\n", fmt); | |||
* first of format alternatives. | goto fallback; | |||
* 2. I don't think colour should count. | } | |||
* 3. We should add a dash if there are more alternatives. | ||||
*/ | switch (details.family) { | |||
case GO_FORMAT_NUMBER: | ||||
return value_new_string_nocopy | ||||
(g_strdup_printf | ||||
("%c%d", | ||||
details.thousands_sep ? ',' : 'F', | ||||
details.num_decimals)); | ||||
case GO_FORMAT_CURRENCY: | ||||
case GO_FORMAT_ACCOUNTING: | ||||
return value_new_string_nocopy | ||||
(g_strdup_printf | ||||
("C%d%s", | ||||
details.num_decimals, | ||||
details.negative_red ? "-" : "")); | ||||
case GO_FORMAT_PERCENTAGE: | ||||
return value_new_string_nocopy | ||||
(g_strdup_printf | ||||
("P%d", | ||||
details.num_decimals)); | ||||
case GO_FORMAT_SCIENTIFIC: | ||||
return value_new_string_nocopy | ||||
(g_strdup_printf | ||||
("S%d", | ||||
details.num_decimals)); | ||||
default: | ||||
goto fallback; | ||||
} | ||||
fallback: | ||||
return value_new_string ("G"); | return value_new_string ("G"); | |||
} | } | |||
/* TODO : turn this into a range based routine */ | /* TODO : turn this into a range based routine */ | |||
static GnmValue * | static GnmValue * | |||
gnumeric_cell (GnmFuncEvalInfo *ei, GnmValue const * const *argv) | gnumeric_cell (GnmFuncEvalInfo *ei, GnmValue const * const *argv) | |||
{ | { | |||
char const *info_type = value_peek_string (argv[0]); | char const *info_type = value_peek_string (argv[0]); | |||
GnmCellRef const *ref; | GnmCellRef const *ref; | |||
const Sheet *sheet; | const Sheet *sheet; | |||
End of changes. 6 change blocks. | ||||
8 lines changed or deleted | 39 lines changed or added |