6
6
* Jody Goldberg 2000-2006 (jody@gnome.org)
7
7
* Miguel de Icaza 1998, 1999 (miguel@kernel.org)
8
* Copyright (C) 2000-2009 Morten Welinder (terra@gnome.org)
9
10
#include <gnumeric-config.h>
10
11
#include "gnumeric.h"
348
348
gnm_cell_is_blank (GnmCell const * cell)
350
350
return gnm_cell_is_empty (cell) ||
351
(VALUE_IS_STRING (cell->value) && *(cell->value->v_str.val->str) == '\0');
351
(VALUE_IS_STRING (cell->value) &&
352
*value_peek_string (cell->value) == '\0');
440
441
gnm_cell_is_nonsingleton_array (GnmCell const *cell)
442
GnmExprArrayCorner const *corner = gnm_cell_is_array_corner (cell);
443
GnmExprArrayCorner const *corner;
445
if ((cell == NULL) || !gnm_cell_has_expr (cell))
447
if (gnm_expr_top_is_array_elem (cell->base.texpr, NULL, NULL))
450
corner = gnm_expr_top_get_array_corner (cell->base.texpr);
444
451
return corner && (corner->cols > 1 || corner->rows > 1);
527
534
gnm_cell_get_entered_text (GnmCell const *cell)
529
539
g_return_val_if_fail (cell != NULL, NULL);
541
sheet = cell->base.sheet;
531
543
if (gnm_cell_has_expr (cell)) {
533
545
GnmConventionsOut out;
535
547
out.accum = g_string_new ("=");
536
548
out.pp = parse_pos_init_cell (&pp, cell);
537
out.convs = cell->base.sheet->convs;
549
out.convs = sheet->convs;
539
551
gnm_expr_top_as_gstring (cell->base.texpr, &out);
540
552
return g_string_free (out.accum, FALSE);
543
if (cell->value != NULL) {
544
if (VALUE_IS_STRING (cell->value)) {
557
GODateConventions const *date_conv =
558
workbook_date_conv (sheet->workbook);
560
if (VALUE_IS_STRING (v)) {
545
561
/* Try to be reasonably smart about adding a leading quote */
546
char const *tmp = cell->value->v_str.val->str;
562
char const *tmp = value_peek_string (v);
548
564
if (tmp[0] != '\'' && !gnm_expr_char_start_p (tmp)) {
549
GnmValue *val = format_match_number (tmp,
550
gnm_cell_get_format (cell),
551
workbook_date_conv (cell->base.sheet->workbook));
565
GnmValue *val = format_match_number
567
gnm_cell_get_format (cell),
553
570
return g_strdup (tmp);
554
571
value_release (val);
556
573
return g_strconcat ("\'", tmp, NULL);
575
GOFormat const *fmt = gnm_cell_get_format (cell);
576
return format_value (fmt, v, NULL, -1, date_conv);
558
return format_value (NULL, cell->value, NULL, -1,
559
workbook_date_conv (cell->base.sheet->workbook));
562
580
g_warning ("A cell with no expression, and no value ??");
624
642
* Get the display format. If the assigned format is General,
625
643
* the format of the value will be used.
628
646
gnm_cell_get_format (GnmCell const *cell)
632
650
g_return_val_if_fail (cell != NULL, go_format_general ());
654
672
gnm_cell_set_format (GnmCell *cell, char const *format)
657
GnmStyle *mstyle = gnm_style_new ();
659
g_return_if_fail (mstyle != NULL);
677
g_return_if_fail (cell != NULL);
678
g_return_if_fail (format != NULL);
680
mstyle = gnm_style_new ();
661
681
gnm_style_set_format_text (mstyle, format);
663
683
r.start = r.end = cell->pos;