Commit 41091d68 authored by Morten Welinder's avatar Morten Welinder Committed by Morten Welinder

New function. don't include str.h unless we have to.

2009-04-01  Morten Welinder  <terra@gnome.org>

	* src/expr-name.c (expr_name_name): New function.
	* */*.c: don't include str.h unless we have to.


svn path=/trunk/; revision=17275
parent 4c361520
2009-04-01 Morten Welinder <terra@gnome.org>
* src/expr-name.c (expr_name_name): New function.
* */*.c: don't include str.h unless we have to.
2009-04-01 Morten Welinder <terra@gnome.org>
* src/sheet.c (gnm_sheet_class_init): Install new workbook
......
......@@ -11,6 +11,8 @@ Morten:
[#577348] [#577351] [#577399] [#577400] [#577503] [#577504]
* Add sorted sheet list to tab menu.
* Fix criticals during Lotus load.
* Clean up Sheet object.
* Clean up str.h usage.
--------------------------------------------------------------------------
Gnumeric 1.9.5
......
......@@ -25,7 +25,6 @@
#include <value.h>
#include <gutils.h>
#include <graph.h>
#include <str.h>
#include <style-color.h>
#include <sheet-object-graph.h>
#include <workbook-view.h>
......@@ -5409,7 +5408,7 @@ chart_write_siindex (XLChartWriteState *s, guint msdim)
GSF_LE_SET_GUINT16 (dat + 4, 0);
ms_biff_put_var_write (s->bp, (guint8*) dat, 6);
excel_write_string (s->bp, STR_TWO_BYTE_LENGTH,
value->v_str.val->str);
value_peek_string (value));
ms_biff_put_commit (s->bp);
continue;
default:
......
......@@ -18,7 +18,6 @@
#include "ms-excel-util.h"
#include <expr-name.h>
#include <str.h>
#include <value.h>
#include <gsf/gsf-utils.h>
......
......@@ -54,6 +54,7 @@
#include <input-msg.h>
#include <parse-util.h> /* for cell_name */
#include <ranges.h>
#include <str.h>
#include <expr.h>
#include <expr-name.h>
#include <value.h>
......
......@@ -22,7 +22,6 @@
#include <value.h>
#include <expr-impl.h>
#include <expr-name.h>
#include <str.h>
#include <parse-util.h>
#include <sheet.h>
#include <workbook.h>
......@@ -643,9 +642,9 @@ make_function (GnmExprList **stack, int fn_idx, int numargs, Workbook *wb)
if (tmp != NULL) {
if (GNM_EXPR_GET_OPER (tmp) == GNM_EXPR_OP_CONSTANT &&
VALUE_IS_STRING (tmp->constant.value))
f_name = tmp->constant.value->v_str.val->str;
f_name = value_peek_string (tmp->constant.value);
else if (GNM_EXPR_GET_OPER (tmp) == GNM_EXPR_OP_NAME)
f_name = tmp->name.name->name->str;
f_name = expr_name_name (tmp->name.name);
}
if (f_name == NULL) {
......
......@@ -29,7 +29,6 @@
#include <expr.h>
#include <expr-impl.h>
#include <expr-name.h>
#include <str.h>
#include <parse-util.h>
#include <goffice/app/io-context.h>
......@@ -742,7 +741,7 @@ write_node (PolishData *pd, GnmExpr const *expr, int paren_level,
}
case VALUE_STRING:
write_string (pd, v->v_str.val->str);
write_string (pd, value_peek_string (v));
break;
case VALUE_CELLRANGE:
......
......@@ -33,6 +33,7 @@
#include "gnm-format.h"
#include "cell.h"
#include "position.h"
#include "str.h"
#include "expr.h"
#include "expr-name.h"
#include "print-info.h"
......
......@@ -20,17 +20,16 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <gnumeric-config.h>
#include <gnumeric.h>
#include <func.h>
#include <parse-util.h>
#include <str.h>
#include <cell.h>
#include <sheet.h>
#include <workbook.h>
#include <value.h>
#include <number-match.h>
#include <collect.h>
#include <rangefunc.h>
#include <gnm-i18n.h>
......
......@@ -26,7 +26,6 @@
#include <func.h>
#include <parse-util.h>
#include <str.h>
#include <cell.h>
#include <gnm-datetime.h>
#include <value.h>
......
......@@ -27,7 +27,6 @@
#include <parse-util.h>
#include <complex.h>
#include <str.h>
#include <value.h>
#include <mathfunc.h>
#include <collect.h>
......
......@@ -28,7 +28,6 @@
#include <gnumeric.h>
#include <func.h>
#include <parse-util.h>
#include <str.h>
#include <cell.h>
#include <value.h>
#include <mathfunc.h>
......
......@@ -30,7 +30,6 @@
#include <tools/goal-seek.h>
#include <collect.h>
#include <value.h>
#include <str.h>
#include <mathfunc.h>
#include <gnm-format.h>
#include <workbook.h>
......
......@@ -29,12 +29,12 @@
* attributes, and the comments on their behviour are. Hence he holds partial
* copyright on the CELL implementation.
*/
#include <gnumeric-config.h>
#include <gnumeric.h>
#include <func.h>
#include <parse-util.h>
#include <cell.h>
#include <str.h>
#include <ranges.h>
#include <sheet.h>
#include <workbook.h>
......
......@@ -30,7 +30,6 @@
#include <parse-util.h>
#include <dependent.h>
#include <cell.h>
#include <str.h>
#include <sheet.h>
#include <value.h>
#include <ranges.h>
......
......@@ -28,7 +28,6 @@
#include <parse-util.h>
#include <cell.h>
#include <gnm-format.h>
#include <str.h>
#include <gutils.h>
#include <sheet.h>
#include <workbook.h>
......
......@@ -17,7 +17,6 @@
#include "expr-impl.h"
#include "rendered-value.h"
#include "value.h"
#include "str.h"
#include "style.h"
#include "ranges.h"
#include "gnm-format.h"
......@@ -348,7 +347,8 @@ gboolean
gnm_cell_is_blank (GnmCell const * cell)
{
return gnm_cell_is_empty (cell) ||
(VALUE_IS_STRING (cell->value) && *(cell->value->v_str.val->str) == '\0');
(VALUE_IS_STRING (cell->value) &&
*value_peek_string (cell->value) == '\0');
}
GnmValue *
......
......@@ -5787,7 +5787,7 @@ cmd_remove_name_undo (GnmCommand *cmd,
{
CmdRemoveName *me = CMD_REMOVE_NAME (cmd);
GnmNamedExpr *nexpr =
expr_name_add (&me->nexpr->pos, me->nexpr->name->str,
expr_name_add (&me->nexpr->pos, expr_name_name (me->nexpr),
me->texpr, NULL, TRUE, NULL);
if (nexpr) {
me->texpr = NULL;
......@@ -5851,7 +5851,8 @@ cmd_remove_name (WorkbookControl *wbc, GnmNamedExpr *nexpr)
me->texpr = NULL;
me->cmd.sheet = wb_control_cur_sheet (wbc);
me->cmd.size = 1;
me->cmd.cmd_descriptor = g_strdup_printf (_("Remove Name %s"), nexpr->name->str);
me->cmd.cmd_descriptor = g_strdup_printf (_("Remove Name %s"),
expr_name_name (nexpr));
return command_push_undo (wbc, G_OBJECT (me));
}
......
......@@ -16,7 +16,6 @@
#include "sheet.h"
#include "cell.h"
#include "str.h"
#include "value.h"
#include "parse-util.h"
......
......@@ -33,7 +33,6 @@
#include "selection.h"
#include "sheet.h"
#include "value.h"
#include "str.h"
#include "workbook.h"
#include "workbook-control.h"
......
......@@ -129,7 +129,7 @@ name_guru_in_list (NameGuruState *state, char const *name,
g_return_val_if_fail (nexpr != NULL, NULL);
g_return_val_if_fail (nexpr->name != NULL, NULL);
g_return_val_if_fail (nexpr->name->str != NULL, NULL);
g_return_val_if_fail (expr_name_name (nexpr) != NULL, NULL);
if (ignore_placeholders && expr_name_is_placeholder (nexpr))
continue;
......@@ -137,7 +137,7 @@ name_guru_in_list (NameGuruState *state, char const *name,
continue;
/* no need for UTF-8 or collation magic, just equality */
if (strcmp (name, nexpr->name->str) == 0)
if (strcmp (name, expr_name_name (nexpr)) == 0)
return nexpr;
}
......@@ -153,7 +153,7 @@ name_guru_set_expr (NameGuruState *state, GnmNamedExpr *nexpr)
gnm_conventions_default);
gnm_expr_entry_load_from_text (state->expr_entry, txt);
g_free (txt);
gtk_entry_set_text (state->name, nexpr->name->str);
gtk_entry_set_text (state->name, expr_name_name (nexpr));
} else {
gnm_expr_entry_load_from_text (state->expr_entry, "");
gtk_entry_set_text (state->name, "");
......@@ -211,7 +211,7 @@ name_guru_update_sensitivity (NameGuruState *state, gboolean update_entries)
if (nexpr != NULL )
switchscope = !nexpr->is_permanent &&
(NULL == name_guru_in_list (state, nexpr->name->str,
(NULL == name_guru_in_list (state, expr_name_name (nexpr),
TRUE, (nexpr->pos.sheet == NULL)));
}
......@@ -265,13 +265,16 @@ name_guru_populate_list (NameGuruState *state)
if (nexpr->pos.sheet != NULL) {
char *name = g_strdup_printf ("%s!%s",
nexpr->pos.sheet->name_unquoted,
nexpr->name->str);
expr_name_name (nexpr));
gtk_list_store_set (state->model,
&iter, 0, name, 1, nexpr, -1);
g_free (name);
} else
gtk_list_store_set (state->model,
&iter, 0, nexpr->name->str, 1, nexpr, -1);
&iter,
0, expr_name_name (nexpr),
1, nexpr,
-1);
}
name_guru_update_sensitivity (state, TRUE);
}
......@@ -311,7 +314,7 @@ cb_name_guru_select_name (G_GNUC_UNUSED GtkTreeSelection *ignored,
g_return_if_fail (nexpr != NULL);
g_return_if_fail (nexpr->name != NULL);
g_return_if_fail (nexpr->name->str != NULL);
g_return_if_fail (expr_name_name (nexpr) != NULL);
state->cur_name = nexpr;
......
......@@ -142,12 +142,12 @@ cb_load_names (G_GNUC_UNUSED gpointer key,
if (nexpr->pos.sheet != NULL)
expr_name = g_strdup_printf ("%s!%s",
nexpr->pos.sheet->name_unquoted,
nexpr->name->str);
expr_name_name (nexpr));
gtk_tree_store_set (user->state->model, &iter,
ITEM_NAME, expr_name ? expr_name : nexpr->name->str,
SHEET_POINTER, nexpr->pos.sheet,
EXPRESSION, nexpr,
-1);
ITEM_NAME, expr_name ? expr_name : expr_name_name (nexpr),
SHEET_POINTER, nexpr->pos.sheet,
EXPRESSION, nexpr,
-1);
g_free (expr_name);
}
......
......@@ -27,7 +27,6 @@
#include "help.h"
#include <expr.h>
#include <str.h>
#include <expr-name.h>
#include <sheet.h>
#include <sheet-view.h>
......
......@@ -633,6 +633,13 @@ expr_name_remove (GnmNamedExpr *nexpr)
nexpr->name->str);
}
const char *
expr_name_name (GnmNamedExpr const *nexpr)
{
g_return_val_if_fail (nexpr != NULL, NULL);
return nexpr->name->str;
}
/**
* expr_name_as_string :
* @nexpr :
......
......@@ -41,6 +41,7 @@ void expr_name_unref (GnmNamedExpr *nexpr);
void expr_name_remove (GnmNamedExpr *nexpr);
GnmValue*expr_name_eval (GnmNamedExpr const *ne, GnmEvalPos const *ep,
GnmExprEvalFlags flags);
const char *expr_name_name (GnmNamedExpr const *nexpr);
char *expr_name_as_string (GnmNamedExpr const *ne, GnmParsePos const *pp,
GnmConventions const *fmt);
char *expr_name_set_scope (GnmNamedExpr *ne, Sheet *sheet);
......
......@@ -30,7 +30,6 @@
#include "func.h"
#include "cell.h"
#include "sheet.h"
#include "str.h"
#include "value.h"
#include "parse-util.h"
#include "ranges.h"
......@@ -838,7 +837,7 @@ cb_bin_arith (GnmEvalPos const *ep, GnmValue const *a, GnmValue const *b,
if (VALUE_IS_EMPTY (a))
a = va = (GnmValue *)value_zero;
else if (VALUE_IS_STRING (a)) {
va = format_match_number (a->v_str.val->str, NULL,
va = format_match_number (value_peek_string (a), NULL,
workbook_date_conv (ep->sheet->workbook));
if (va == NULL)
return value_new_error_VALUE (ep);
......@@ -849,7 +848,7 @@ cb_bin_arith (GnmEvalPos const *ep, GnmValue const *a, GnmValue const *b,
if (VALUE_IS_EMPTY (b))
b = vb = (GnmValue *)value_zero;
else if (VALUE_IS_STRING (b)) {
vb = format_match_number (b->v_str.val->str, NULL,
vb = format_match_number (value_peek_string (b), NULL,
workbook_date_conv (ep->sheet->workbook));
if (vb == NULL) {
if (va != a)
......@@ -1237,7 +1236,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 (a->v_str.val->str, NULL,
GnmValue *tmp = format_match_number (value_peek_string (a), NULL,
workbook_date_conv (pos->sheet->workbook));
value_release (a);
......@@ -1247,7 +1246,7 @@ gnm_expr_eval (GnmExpr const *expr, GnmEvalPos const *pos,
} else if (a->type == VALUE_CELLRANGE || a->type == VALUE_ARRAY) {
b = gnm_expr_eval (expr->binary.value_b, pos, flags);
if (VALUE_IS_STRING (b)) {
res = format_match_number (b->v_str.val->str, NULL,
res = format_match_number (value_peek_string (b), NULL,
workbook_date_conv (pos->sheet->workbook));
value_release (b);
b = (res == NULL) ? value_new_error_VALUE (pos) : res;
......@@ -1269,7 +1268,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 (b->v_str.val->str, NULL,
GnmValue *tmp = format_match_number (value_peek_string (b), NULL,
workbook_date_conv (pos->sheet->workbook));
value_release (b);
......@@ -1312,7 +1311,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 (a->v_str.val->str, NULL,
GnmValue *tmp = format_match_number (value_peek_string (a), NULL,
workbook_date_conv (pos->sheet->workbook));
value_release (a);
......@@ -2047,7 +2046,7 @@ gnm_expr_relocate (GnmExpr const *expr, RelocInfoInternal const *rinfo)
parse_pos_init_sheet (&pos, rinfo->details->target_sheet);
/* If the name is not available in the new scope explicitly scope it */
new_nexpr = expr_name_lookup (&pos, nexpr->name->str);
new_nexpr = expr_name_lookup (&pos, expr_name_name (nexpr));
if (new_nexpr == NULL) {
if (nexpr->pos.sheet != NULL)
return gnm_expr_new_name (nexpr, nexpr->pos.sheet, NULL);
......
......@@ -2,7 +2,6 @@
#ifndef _GNM_STYLE_IMPL_H_
# define _GNM_STYLE_IMPL_H_
#include "str.h"
#include "style-border.h"
#include "style-color.h"
#include "style-font.h"
......
......@@ -17,6 +17,7 @@
#include "style-conditions.h"
#include "application.h"
#include "gutils.h"
#include "str.h"
#include "gnumeric-gconf.h"
#include <goffice/utils/go-glib-extras.h>
#include <goffice/utils/go-font.h>
......
......@@ -24,7 +24,6 @@
#include "gnm-format.h"
#include "value.h"
#include "mathfunc.h"
#include "str.h"
#include "numbers.h"
#include <goffice/utils/regutf8.h>
#include <goffice/utils/datetime.h>
......
......@@ -1216,7 +1216,7 @@ std_expr_name_handler (GnmConventionsOut *out, GnmExprName const *name)
g_string_append_unichar (target, out->convs->sheet_name_sep);
}
g_string_append (target, thename->name->str);
g_string_append (target, expr_name_name (thename));
}
static void
......
......@@ -16,6 +16,7 @@
#include <glib/gi18n-lib.h>
#include "gnumeric.h"
#include "number-match.h"
#include "str.h"
#include "expr.h"
#include "expr-impl.h"
#include "expr-name.h"
......@@ -27,7 +28,6 @@
#include "gutils.h"
#include "style.h"
#include "value.h"
#include "str.h"
#include <goffice/utils/go-glib-extras.h>
#include <goffice/app/go-doc.h>
#include <goffice/utils/go-locale.h>
......@@ -457,7 +457,7 @@ build_set (GnmExprList *list)
static GnmExpr *
parse_string_as_value (GnmExpr *str)
{
GnmValue *v = format_match_simple (str->constant.value->v_str.val->str);
GnmValue *v = format_match_simple (value_peek_string (str->constant.value));
if (v != NULL) {
unregister_allocation (str);
......@@ -478,7 +478,7 @@ static GnmExpr *
parser_simple_val_or_name (GnmExpr *str_expr)
{
GnmExpr const *res;
char const *str = str_expr->constant.value->v_str.val->str;
char const *str = value_peek_string (str_expr->constant.value);
GnmValue *v = format_match_simple (str);
/* if it is not a simple value see if it is a name */
......@@ -513,7 +513,7 @@ parser_simple_val_or_name (GnmExpr *str_expr)
static Sheet *
parser_sheet_by_name (Workbook *wb, GnmExpr *name_expr)
{
char const *name = name_expr->constant.value->v_str.val->str;
char const *name = value_peek_string (name_expr->constant.value);
Sheet *sheet = NULL;
if (wb == NULL)
......@@ -668,7 +668,7 @@ exp: CONSTANT { $$ = $1; }
| function
| sheetref STRING {
GnmNamedExpr *nexpr = NULL;
char const *name = $2->constant.value->v_str.val->str;
char const *name = value_peek_string ($2->constant.value);
GnmParsePos pos = *state->pos;
pos.sheet = $1;
......@@ -686,7 +686,7 @@ exp: CONSTANT { $$ = $1; }
}
| workbookref STRING {
GnmNamedExpr *nexpr = NULL;
char const *name = $2->constant.value->v_str.val->str;
char const *name = value_peek_string ($2->constant.value);
GnmParsePos pos = *state->pos;
pos.sheet = NULL;
......@@ -706,7 +706,7 @@ exp: CONSTANT { $$ = $1; }
;
function : STRING '(' arg_list ')' {
char const *name = $1->constant.value->v_str.val->str;
char const *name = value_peek_string ($1->constant.value);
GnmExpr const *f_call = (*state->convs->input.func) (
state->convs, state->pos->wb, name, $3);
......@@ -727,7 +727,7 @@ string_opt_quote : STRING
;
workbookref : '[' string_opt_quote ']' {
char const *wb_name = $2->constant.value->v_str.val->str;
char const *wb_name = value_peek_string ($2->constant.value);
Workbook *ref_wb = state->pos
? (state->pos->wb
? state->pos->wb
......
......@@ -29,7 +29,6 @@
#include "sheet-style.h"
#include "sheet-merge.h"
#include "rendered-value.h"
#include "str.h"
#include "cell-draw.h"
#include <string.h>
......
......@@ -32,7 +32,6 @@
#include "value.h"
#include "gnm-format.h"
#include "ranges.h"
#include "str.h"
#include "number-match.h"
#include "gutils.h"
#include "sheet-object.h"
......
......@@ -26,7 +26,6 @@
#include "gnm-pane-impl.h"
#include "sheet-control-gui.h"
#include "str.h"
#include "gui-util.h"
#include "gui-file.h"
#include "gnm-graph-window.h"
......
......@@ -5070,7 +5070,7 @@ sheet_dup_names (Sheet const *src, Sheet *dst)
/* Pass 1: add placeholders. */
for (l = names; l; l = l->next) {
GnmNamedExpr *src_nexpr = l->data;
char const *name = src_nexpr->name->str;
char const *name = expr_name_name (src_nexpr);
GnmNamedExpr *dst_nexpr =
gnm_named_expr_collection_lookup (dst->names, name);
GnmExprTop const *texpr;
......@@ -5085,7 +5085,7 @@ sheet_dup_names (Sheet const *src, Sheet *dst)
/* Pass 2: assign the right expression. */
for (l = names; l; l = l->next) {
GnmNamedExpr *src_nexpr = l->data;
char const *name = src_nexpr->name->str;
char const *name = expr_name_name (src_nexpr);
GnmNamedExpr *dst_nexpr =
gnm_named_expr_collection_lookup (dst->names, name);
GnmExprTop const *texpr;
......
......@@ -33,6 +33,7 @@
#include "sheet.h"
#include "cell.h"
#include "value.h"
#include "str.h"
#include "workbook-control.h"
#include "parse-util.h"
......
......@@ -3,7 +3,6 @@
# define _GNM_VALIDATION_H_
#include "gnumeric.h"
#include "str.h"
G_BEGIN_DECLS
......
......@@ -30,7 +30,6 @@
#include "sheet-view.h"
#include "sheet-merge.h"
#include "sheet-style.h"
#include "str.h"
#include "gnm-format.h"
#include "func.h"
#include "expr.h"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment