View | Details | Raw Unified | Return to bug 139466
Collapse All | Expand All

(-)README (-1 / +1 lines)
Lines 18-24 You need: Debian package name Link Here
18
	gtk+		>= 2.4.0	libgtk2.0-dev
18
	gtk+		>= 2.4.0	libgtk2.0-dev
19
	libgnomeprint	>= 2.5.2	libgnomeprint2.2-dev
19
	libgnomeprint	>= 2.5.2	libgnomeprint2.2-dev
20
	libgnomeprintui	>= 2.5.2	libgnomeprintui2.2-dev
20
	libgnomeprintui	>= 2.5.2	libgnomeprintui2.2-dev
21
	libgsf		>= 1.10.0	libgsf-1-dev
21
	libgsf		== 1.12.1	libgsf-1-dev
22
	libglade	>= 2.3.6	libglade2-dev
22
	libglade	>= 2.3.6	libglade2-dev
23
	intltool	>= 0.27.2	intltool
23
	intltool	>= 0.27.2	intltool
24
	gnome-xml   	>= 2.4.12	libxml2-dev
24
	gnome-xml   	>= 2.4.12	libxml2-dev
(-)configure.in (-17 / +19 lines)
Lines 98-104 gnumeric_reqs=" Link Here
98
	glib-2.0		>= 2.4.0
98
	glib-2.0		>= 2.4.0
99
	gobject-2.0		>= 2.4.0
99
	gobject-2.0		>= 2.4.0
100
	gmodule-2.0		>= 2.4.0
100
	gmodule-2.0		>= 2.4.0
101
	libgsf-1		>= 1.10.0
101
	libgsf-1		== 1.12.1
102
	libxml-2.0		>= 2.4.12
102
	libxml-2.0		>= 2.4.12
103
	pango			>= 1.4.0
103
	pango			>= 1.4.0
104
	pangoft2		>= 1.4.0
104
	pangoft2		>= 1.4.0
Lines 117-123 gnumeric_gnome_reqs=" Link Here
117
	libbonoboui-2.0		>= 2.2.0
117
	libbonoboui-2.0		>= 2.2.0
118
	libgnome-2.0		>= 2.0.0
118
	libgnome-2.0		>= 2.0.0
119
	libgnomeui-2.0		>= 2.0.0
119
	libgnomeui-2.0		>= 2.0.0
120
	libgsf-gnome-1		>= 1.10.0
120
	libgsf-gnome-1		== 1.12.1
121
"
121
"
122
122
123
ui_msg=
123
ui_msg=
Lines 188-212 case $host_os in Link Here
188
    ;;
188
    ;;
189
esac
189
esac
190
AM_CONDITIONAL(WITH_WIN32, test x"$win32" = "xyes")
190
AM_CONDITIONAL(WITH_WIN32, test x"$win32" = "xyes")
191
AM_CONDITIONAL(CROSS_COMPILING, test x"$cross_compiling" != "xno")
191
192
192
GNUMERIC_PLUGIN_LDFLAGS="-avoid-version $GNUMERIC_PLUGIN_LDFLAGS"
193
GNUMERIC_PLUGIN_LDFLAGS="-avoid-version $GNUMERIC_PLUGIN_LDFLAGS"
193
AC_SUBST(GNUMERIC_PLUGIN_LDFLAGS)
194
AC_SUBST(GNUMERIC_PLUGIN_LDFLAGS)
194
195
195
dnl disable for in stable release, re-enable for development series
196
dnl disable for in stable release, re-enable for development series
196
CFLAGS="$CFLAGS -DG_DISABLE_DEPRECATED"
197
dnl CFLAGS="$CFLAGS -DG_DISABLE_DEPRECATED"
197
CFLAGS="$CFLAGS -DPANGO_DISABLE_DEPRECATED"
198
dnl CFLAGS="$CFLAGS -DPANGO_DISABLE_DEPRECATED"
198
if test "x$gnumeric_with_gtk" = "xtrue"; then
199
dnl if test "x$gnumeric_with_gtk" = "xtrue"; then
199
	CFLAGS="$CFLAGS -DGDK_PIXBUF_DISABLE_DEPRECATED"
200
dnl 	CFLAGS="$CFLAGS -DGDK_PIXBUF_DISABLE_DEPRECATED"
200
	CFLAGS="$CFLAGS -DGDK_DISABLE_DEPRECATED"
201
dnl 	CFLAGS="$CFLAGS -DGDK_DISABLE_DEPRECATED"
201
	CFLAGS="$CFLAGS -DGDK_MULTIHEAD_SAFE"
202
dnl 	CFLAGS="$CFLAGS -DGDK_MULTIHEAD_SAFE"
202
	CFLAGS="$CFLAGS -DGTK_DISABLE_DEPRECATED"
203
dnl 	CFLAGS="$CFLAGS -DGTK_DISABLE_DEPRECATED"
203
	CFLAGS="$CFLAGS -DLIBGLADE_DISABLE_DEPRECATED"
204
dnl 	CFLAGS="$CFLAGS -DLIBGLADE_DISABLE_DEPRECATED"
204
fi
205
dnl fi
205
if test "x$gnumeric_with_gnome" = "xtrue"; then
206
dnl if test "x$gnumeric_with_gnome" = "xtrue"; then
206
	CFLAGS="$CFLAGS -DGNOME_DISABLE_DEPRECATED"
207
dnl 	CFLAGS="$CFLAGS -DGNOME_DISABLE_DEPRECATED"
207
	CFLAGS="$CFLAGS -DBONOBO_DISABLE_DEPRECATED"
208
dnl 	CFLAGS="$CFLAGS -DBONOBO_DISABLE_DEPRECATED"
208
	CFLAGS="$CFLAGS -DBONOBO_UI_DISABLE_DEPRECATED"
209
dnl 	CFLAGS="$CFLAGS -DBONOBO_UI_DISABLE_DEPRECATED"
209
fi
210
dnl fi
210
211
211
dnl ==============================================
212
dnl ==============================================
212
dnl GNOME Specific extensions
213
dnl GNOME Specific extensions
Lines 258-264 ifdef([GNOME_COMPILE_WARNINGS], Link Here
258
)
259
)
259
set_more_warnings=yes
260
set_more_warnings=yes
260
if test "$GCC" = "yes" -a "x$set_more_warnings" != "xno"; then
261
if test "$GCC" = "yes" -a "x$set_more_warnings" != "xno"; then
261
	for option in -Wsign-compare -Wpointer-arith -Wnested-externs -Wchar-subscripts -Wwrite-strings; do
262
	for option in -Wno-pointer-sign -Wsign-compare -Wpointer-arith -Wnested-externs -Wchar-subscripts -Wwrite-strings; do
262
		SAVE_CFLAGS="$CFLAGS"
263
		SAVE_CFLAGS="$CFLAGS"
263
		CFLAGS="$CFLAGS $option"
264
		CFLAGS="$CFLAGS $option"
264
		AC_MSG_CHECKING([whether gcc understands $option])
265
		AC_MSG_CHECKING([whether gcc understands $option])
Lines 1010-1015 templates/Makefile Link Here
1010
templates/english/Makefile
1011
templates/english/Makefile
1011
templates/autoformat/Makefile
1012
templates/autoformat/Makefile
1012
stamp.h
1013
stamp.h
1014
tools/Makefile
1013
])
1015
])
1014
1016
1015
echo "
1017
echo "
(-)gnumeric.spec.in (-1 / +1 lines)
Lines 18-24 Source: ftp://ftp.gnome.org/pub/GNOME/so Link Here
18
Url:		http://www.gnome.org/gnumeric
18
Url:		http://www.gnome.org/gnumeric
19
BuildRoot:	%{_tmppath}/%{name}-%{PACKAGE_VERSION}-root
19
BuildRoot:	%{_tmppath}/%{name}-%{PACKAGE_VERSION}-root
20
BuildRequires:	glib2-devel		>= 2.4.0
20
BuildRequires:	glib2-devel		>= 2.4.0
21
BuildRequires:	libgsf-devel		>= 1.10.0
21
BuildRequires:	libgsf-devel		>= 1.12.1
22
BuildRequires:	gtk2-devel		>= 2.4.0
22
BuildRequires:	gtk2-devel		>= 2.4.0
23
BuildRequires:	libxml2-devel		>= 2.4.12
23
BuildRequires:	libxml2-devel		>= 2.4.12
24
BuildRequires:	libglade2-devel		>= 2.3.6
24
BuildRequires:	libglade2-devel		>= 2.3.6
(-)doc/make-func-list.pl (+5 lines)
Lines 7-12 my $func = ""; Link Here
7
while (<>) {
7
while (<>) {
8
    s/\s+$//;
8
    s/\s+$//;
9
    if (/^\@CATEGORY=(.*)/) {
9
    if (/^\@CATEGORY=(.*)/) {
10
	if ($state) {
11
	    print "    </refsect1>\n";
12
	    print "  </refentry>\n\n";
13
	}
10
	if ($cat ne $1) {
14
	if ($cat ne $1) {
11
	    if ($cat ne "") {
15
	    if ($cat ne "") {
12
		print "</sect1>\n";
16
		print "</sect1>\n";
Lines 128-133 sub markup_stuff { Link Here
128
    $str = &quote_stuff ($str);
132
    $str = &quote_stuff ($str);
129
133
130
    $str =~ s/\b$func\b/<function>$func<\/function>/g;
134
    $str =~ s/\b$func\b/<function>$func<\/function>/g;
135
    $str =~ s/\@\{(\w*)\}/<parameter>\1<\/parameter>/g;
131
    $str =~ s/\@(\w*)\b/<parameter>\1<\/parameter>/g;
136
    $str =~ s/\@(\w*)\b/<parameter>\1<\/parameter>/g;
132
137
133
    return $str;
138
    return $str;
(-)doc/C/appendix-keybindings.xml (-2 / +2 lines)
Lines 92-98 Link Here
92
92
93
    <listitem>
93
    <listitem>
94
      <para>
94
      <para>
95
	<keycap>Ctrl-~</keycap> Formats the current selection as a number.
95
	<keycap>Ctrl-~</keycap> Formats the current selection as a 'General'.
96
      </para>
96
      </para>
97
    </listitem>
97
    </listitem>
98
    <listitem>
98
    <listitem>
Lines 117-123 Link Here
117
    </listitem>
117
    </listitem>
118
    <listitem>
118
    <listitem>
119
      <para>
119
      <para>
120
	<keycap>Ctrl-!</keycap> Formats the current selection with the default accounting format
120
	<keycap>Ctrl-!</keycap> Formats the current selection as a number with 2 decimal places.
121
      </para>
121
      </para>
122
    </listitem>
122
    </listitem>
123
    <listitem>
123
    <listitem>
(-)doc/C/gnumeric.1 (-1 / +1 lines)
Lines 51-57 Displays a brief usage message. Link Here
51
.SS "Gnumeric options"
51
.SS "Gnumeric options"
52
.TP
52
.TP
53
.B \-v, \-\-version
53
.B \-v, \-\-version
54
Displays the version number of the isntalled instance of
54
Displays the version number of the installed instance of
55
\fBgnumeric\fR.
55
\fBgnumeric\fR.
56
.TP
56
.TP
57
.B \-\-no-splash
57
.B \-\-no-splash
(-)plugins/derivatives/options.c (-1 / +1 lines)
Lines 2039-2045 opt_fixed_strk_lkbk(FunctionEvalInfo *ei Link Here
2039
2039
2040
	if(OS_Call == call_put_flag)
2040
	if(OS_Call == call_put_flag)
2041
		m = s_max;
2041
		m = s_max;
2042
	else if(OS_Put == call_put_flag)
2042
	else /* if (OS_Put == call_put_flag) default to being a put */
2043
		m = s_min;
2043
		m = s_min;
2044
2044
2045
	d1 = (loggnum(s / x) + (b + (v * v) / 2.0) * t) / (v * sqrtgnum(t));
2045
	d1 = (loggnum(s / x) + (b + (v * v) / 2.0) * t) / (v * sqrtgnum(t));
(-)plugins/excel/Makefile.am (-2 lines)
Lines 11-18 excel_la_LIBADD = $(Z_LIBS) Link Here
11
excel_la_SOURCES =		\
11
excel_la_SOURCES =		\
12
	boot.c			\
12
	boot.c			\
13
	boot.h			\
13
	boot.h			\
14
	excel-xml-read.c	\
15
	excel-xml-read.h	\
16
	excel.h			\
14
	excel.h			\
17
	formula-types.h		\
15
	formula-types.h		\
18
	ms-excel-biff.h		\
16
	ms-excel-biff.h		\
(-)plugins/excel/boot.c (-2 lines)
Lines 308-314 void Link Here
308
plugin_init (void)
305
plugin_init (void)
309
{
306
{
310
	excel_read_init ();
307
	excel_read_init ();
311
	excel_xml_read_init ();
312
308
313
#if 0
309
#if 0
314
{
310
{
Lines 359-363 plugin_cleanup (void) Link Here
359
{
355
{
360
	destroy_xl_font_widths ();
356
	destroy_xl_font_widths ();
361
	excel_read_cleanup ();
357
	excel_read_cleanup ();
362
	excel_xml_read_cleanup ();
363
}
358
}
(-)plugins/excel/ms-chart.c (-1 / +1 lines)
Lines 1137-1143 BC_R(lineformat)(XLChartHandler const *h Link Here
1137
	guint16 const flags = GSF_LE_GET_GUINT16 (q->data+8);
1137
	guint16 const flags = GSF_LE_GET_GUINT16 (q->data+8);
1138
1138
1139
	BC_R(get_style) (s);
1139
	BC_R(get_style) (s);
1140
	switch (GSF_LE_GET_GUINT16 (q->data+6)) {
1140
	switch (GSF_LE_GET_GINT16 (q->data+6)) {
1141
	default :
1141
	default :
1142
	case -1 : s->style->line.width = 0; /* hairline */
1142
	case -1 : s->style->line.width = 0; /* hairline */
1143
		break;
1143
		break;
(-)plugins/excel/ms-excel-read.c (-43 / +16 lines)
Lines 393-399 ms_sheet_realize_obj (MSContainer *conta Link Here
393
393
394
	case 0x09:
394
	case 0x09:
395
		g_object_set (G_OBJECT (so), "points",
395
		g_object_set (G_OBJECT (so), "points",
396
			ms_obj_attr_get_array (obj->attrs, MS_OBJ_ATTR_POLYGON_COORDS, NULL),
396
			ms_obj_attr_get_array (obj->attrs, MS_OBJ_ATTR_POLYGON_COORDS, NULL, TRUE),
397
			NULL);
397
			NULL);
398
		   /* fallthrough */
398
		   /* fallthrough */
399
399
Lines 2277-2283 excel_read_FORMULA (BiffQuery *q, ExcelR Link Here
2277
	guint16 const row      = XL_GETROW (q);
2277
	guint16 const row      = XL_GETROW (q);
2278
	guint16 const options  = GSF_LE_GET_GUINT16 (q->data + 14);
2278
	guint16 const options  = GSF_LE_GET_GUINT16 (q->data + 14);
2279
	guint16 expr_length;
2279
	guint16 expr_length;
2280
	guint offset, val_offset;
2280
	guint offset;
2281
	guint8 const *val_dat = q->data + 6;
2281
	GnmExpr const *expr;
2282
	GnmExpr const *expr;
2282
	GnmCell	 *cell;
2283
	GnmCell	 *cell;
2283
	GnmValue *val = NULL;
2284
	GnmValue *val = NULL;
Lines 2297-2309 excel_read_FORMULA (BiffQuery *q, ExcelR Link Here
2297
	 */
2298
	 */
2298
	if (esheet->container.ver >= MS_BIFF_V5) {
2299
	if (esheet->container.ver >= MS_BIFF_V5) {
2299
		expr_length = GSF_LE_GET_GUINT16 (q->data + 20);
2300
		expr_length = GSF_LE_GET_GUINT16 (q->data + 20);
2300
		offset = 22; val_offset = 6;
2301
		offset = 22;
2301
	} else if (esheet->container.ver >= MS_BIFF_V3) {
2302
	} else if (esheet->container.ver >= MS_BIFF_V3) {
2302
		expr_length = GSF_LE_GET_GUINT16 (q->data + 16);
2303
		expr_length = GSF_LE_GET_GUINT16 (q->data + 16);
2303
		offset = 18; val_offset = 6;
2304
		offset = 18;
2304
	} else {
2305
	} else {
2305
		expr_length = GSF_LE_GET_GUINT8 (q->data + 16);
2306
		expr_length = GSF_LE_GET_GUINT8 (q->data + 16);
2306
		offset = 17; val_offset = 7;
2307
		offset = 17;
2308
		val_dat++;	/* compensate for the 3 byte style */
2307
	}
2309
	}
2308
2310
2309
	if (q->length < offset) {
2311
	if (q->length < offset) {
Lines 2321-2370 excel_read_FORMULA (BiffQuery *q, ExcelR Link Here
2321
		return;
2323
		return;
2322
	}
2324
	}
2323
2325
2324
	/*
2326
	/* Get the current value so that we can format, do this BEFORE handling
2325
	 * Get the current value so that we can format, do this BEFORE handling
2326
	 * shared/array formulas or strings in case we need to go to the next
2327
	 * shared/array formulas or strings in case we need to go to the next
2327
	 * record
2328
	 * record */
2328
	 */
2329
	if (GSF_LE_GET_GUINT16 (val_dat + 6) != 0xffff) {
2329
	if (GSF_LE_GET_GUINT16 (q->data + 12) != 0xffff) {
2330
		val = value_new_float (gsf_le_get_double (val_dat));
2330
		double const num = gsf_le_get_double (q->data + val_offset);
2331
		val = value_new_float (num);
2332
	} else {
2331
	} else {
2333
		guint8 const val_type = GSF_LE_GET_GUINT8 (q->data + val_offset);
2332
		guint8 const val_type = GSF_LE_GET_GUINT8 (val_dat);
2334
		switch (val_type) {
2333
		switch (val_type) {
2335
		case 0: /* String */
2334
		case 0: is_string = TRUE; break;
2336
			is_string = TRUE;
2335
		case 1: val = value_new_bool (GSF_LE_GET_GUINT8 (val_dat + 2) != 0);
2337
			break;
2338
2339
		case 1: { /* Boolean */
2340
			guint8 v = GSF_LE_GET_GUINT8 (q->data + val_offset + 2);
2341
			val = value_new_bool (v ? TRUE : FALSE);
2342
			break;
2336
			break;
2343
		}
2337
		case 2: val = biff_get_error (NULL, GSF_LE_GET_GUINT8 (val_dat + 2));
2344
2345
		case 2: { /* Error */
2346
			guint8 const v = GSF_LE_GET_GUINT8 (q->data + val_offset + 2);
2347
			val = biff_get_error (NULL, v);
2348
			break;
2338
			break;
2349
		}
2339
		case 3: val = value_new_empty (); /* Empty (Undocumented) */
2350
2351
		case 3: /* Empty */
2352
			/* TODO TODO TODO
2353
			 * This is undocumented and a big guess, but it seems
2354
			 * accurate.
2355
			 */
2356
			d (0, {
2357
				fprintf (stderr,"%s:%s: has type 3 contents.  "
2358
					"Is it an empty cell?\n",
2359
					esheet->sheet->name_unquoted,
2360
					cell_name (cell));
2361
				if (ms_excel_read_debug > 5)
2362
					gsf_mem_dump (q->data + 6, 8);
2363
			});
2364
2365
			val = value_new_empty ();
2366
			break;
2340
			break;
2367
2368
		default:
2341
		default:
2369
			fprintf (stderr,"Unknown type (%x) for cell's (%s) current val\n",
2342
			fprintf (stderr,"Unknown type (%x) for cell's (%s) current val\n",
2370
				val_type, cell_name (cell));
2343
				val_type, cell_name (cell));
(-)plugins/excel/ms-excel-write.c (-7 / +9 lines)
Lines 3361-3366 blipinf_new (SheetObjectImage *soi) Link Here
3361
{
3361
{
3362
	BlipInf *blip;
3362
	BlipInf *blip;
3363
	GByteArray *bytes;
3363
	GByteArray *bytes;
3364
	const char *blip_type;
3364
3365
3365
	blip = g_new0 (BlipInf, 1);
3366
	blip = g_new0 (BlipInf, 1);
3366
	blip->uncomp_len = -1;
3367
	blip->uncomp_len = -1;
Lines 3372-3385 blipinf_new (SheetObjectImage *soi) Link Here
3372
		      "image-data", &bytes,
3373
		      "image-data", &bytes,
3373
		      NULL);
3374
		      NULL);
3374
	blip->bytes = *bytes;	/* Need to copy, we may change it. */
3375
	blip->bytes = *bytes;	/* Need to copy, we may change it. */
3376
	blip_type = blip->type ? blip->type : "?";
3375
	
3377
	
3376
	if (strcmp (blip->type, "jpeg") == 0 || /* Raster format */
3378
	if (strcmp (blip_type, "jpeg") == 0 || /* Raster format */
3377
	    strcmp (blip->type, "png")  == 0 ||	/* understood by Excel */
3379
	    strcmp (blip_type, "png")  == 0 ||	/* understood by Excel */
3378
	    strcmp (blip->type, "dib")  == 0) {
3380
	    strcmp (blip_type, "dib")  == 0) {
3379
		blip->header_len = BSE_HDR_LEN + RASTER_BLIP_HDR_LEN;
3381
		blip->header_len = BSE_HDR_LEN + RASTER_BLIP_HDR_LEN;
3380
	} else if (strcmp (blip->type, "wmf") == 0 || /* Vector format */
3382
	} else if (strcmp (blip_type, "wmf") == 0 || /* Vector format */
3381
		   strcmp (blip->type, "emf") == 0 || /* - compress */
3383
		   strcmp (blip_type, "emf") == 0 || /* - compress */
3382
		   strcmp (blip->type, "pict") == 0) { 
3384
		   strcmp (blip_type, "pict") == 0) { 
3383
3385
3384
		int res;
3386
		int res;
3385
		gulong dest_len = blip->bytes.len * 1.01 + 12;
3387
		gulong dest_len = blip->bytes.len * 1.01 + 12;
Lines 3422-3428 blipinf_new (SheetObjectImage *soi) Link Here
3422
		} else {
3424
		} else {
3423
			g_warning 
3425
			g_warning 
3424
				("Unable to export %s image as png to Excel", 
3426
				("Unable to export %s image as png to Excel", 
3425
				 blip->type);
3427
				 blip_type);
3426
			g_free (blip);
3428
			g_free (blip);
3427
			blip = NULL;
3429
			blip = NULL;
3428
		}
3430
		}
(-)plugins/excel/ms-formula-read.c (-122 / +52 lines)
Lines 469-475 ExcelFuncDesc const excel_func_desc [] = Link Here
469
int excel_func_desc_size = G_N_ELEMENTS (excel_func_desc);
469
int excel_func_desc_size = G_N_ELEMENTS (excel_func_desc);
470
470
471
static GnmExpr const *
471
static GnmExpr const *
472
expr_tree_error (ExcelReadSheet const *esheet, int col, int row,
472
xl_expr_err (ExcelReadSheet const *esheet, int col, int row,
473
		 char const *msg, char const *str)
473
		 char const *msg, char const *str)
474
{
474
{
475
	if (esheet != NULL && esheet->sheet != NULL) {
475
	if (esheet != NULL && esheet->sheet != NULL) {
Lines 570-578 parse_list_push (GnmExprList **list, Gnm Link Here
570
	d (5, fprintf (stderr, "Push 0x%p\n", pd););
570
	d (5, fprintf (stderr, "Push 0x%p\n", pd););
571
	if (pd == NULL) {
571
	if (pd == NULL) {
572
		g_warning ("FIXME: Pushing nothing onto excel function stack");
572
		g_warning ("FIXME: Pushing nothing onto excel function stack");
573
		pd = expr_tree_error (NULL, -1, -1,
573
		pd = xl_expr_err (NULL, -1, -1,
574
			"Incorrect number of parsed formula arguments",
574
			"Incorrect number of parsed formula arguments",
575
			"#WrongArgs");
575
			"#WrongArgs!");
576
	}
576
	}
577
	*list = gnm_expr_list_prepend (*list, pd);
577
	*list = gnm_expr_list_prepend (*list, pd);
578
}
578
}
Lines 595-603 parse_list_pop (GnmExprList **list) Link Here
595
		return ans;
595
		return ans;
596
	}
596
	}
597
597
598
	return expr_tree_error (NULL, -1, -1,
598
	return xl_expr_err (NULL, -1, -1,
599
		"Incorrect number of parsed formula arguments",
599
		"Incorrect number of parsed formula arguments",
600
		"#WrongArgs");
600
		"#WrongArgs!");
601
}
601
}
602
602
603
/**
603
/**
Lines 668-680 make_function (GnmExprList **stack, int Link Here
668
		d (2, fprintf (stderr, "Function '%s', %d, expected args: %d flags = 0x%x\n",
668
		d (2, fprintf (stderr, "Function '%s', %d, expected args: %d flags = 0x%x\n",
669
			       fd->name, numargs, fd->num_known_args, fd->flags););
669
			       fd->name, numargs, fd->num_known_args, fd->flags););
670
670
671
		if ((fd->flags & XL_VARARG) && numargs < 0)
671
		if (numargs < 0) { /* fixed, use the built in */
672
			g_warning ("We think '%s' is vararg, and XL doesn't", fd->name);
673
		if ((fd->flags & XL_FIXED) && numargs >= 0)
674
			g_warning ("We think '%s' is fixed, and XL doesn't", fd->name);
675
676
		/* Right args for multi-arg funcs. */
677
		if (fd->flags & XL_FIXED) {
678
			int const available_args =
672
			int const available_args =
679
			    (*stack != NULL) ? g_slist_length(*stack) : 0;
673
			    (*stack != NULL) ? g_slist_length(*stack) : 0;
680
			numargs = fd->num_known_args;
674
			numargs = fd->num_known_args;
Lines 695-701 make_function (GnmExprList **stack, int Link Here
695
		if (fd->name) {
689
		if (fd->name) {
696
			name = gnm_func_lookup (fd->name, wb);
690
			name = gnm_func_lookup (fd->name, wb);
697
			if (name == NULL)
691
			if (name == NULL)
698
				name = gnm_func_add_placeholder (wb, fd->name, "0NKNOWN", TRUE);
692
				name = gnm_func_add_placeholder (wb, fd->name, "UNKNOWN", TRUE);
699
		}
693
		}
700
		/* This should not happen */
694
		/* This should not happen */
701
		if (!name) {
695
		if (!name) {
Lines 904-910 excel_parse_formula (MSContainer const * Link Here
904
			GnmCellPos top_left;
898
			GnmCellPos top_left;
905
899
906
			top_left.row = GSF_LE_GET_GUINT16 (cur+0);
900
			top_left.row = GSF_LE_GET_GUINT16 (cur+0);
907
			top_left.col = GSF_LE_GET_GUINT16 (cur+2);
901
			top_left.col = (ver >= MS_BIFF_V3) ? GSF_LE_GET_GUINT16 (cur+2) : GSF_LE_GET_GUINT8 (cur+2);
908
			sf = excel_sheet_shared_formula (esheet, &top_left);
902
			sf = excel_sheet_shared_formula (esheet, &top_left);
909
903
910
			if (sf == NULL) {
904
			if (sf == NULL) {
Lines 926-936 excel_parse_formula (MSContainer const * Link Here
926
				return NULL;
920
				return NULL;
927
			}
921
			}
928
922
929
#ifndef NO_DEBUG_EXCEL
923
			d (0, fprintf (stderr, "Parse shared formula\n"););
930
			if (ms_excel_formula_debug > 0) {
931
				fprintf (stderr, "Parse shared formula\n");
932
			}
933
#endif
934
			expr = excel_parse_formula (container, esheet, fn_col, fn_row,
924
			expr = excel_parse_formula (container, esheet, fn_col, fn_row,
935
				sf->data, sf->data_len, TRUE, array_element);
925
				sf->data, sf->data_len, TRUE, array_element);
936
926
Lines 1009-1109 excel_parse_formula (MSContainer const * Link Here
1009
				ptg_length = 2;
999
				ptg_length = 2;
1010
			}
1000
			}
1011
			if (grbit == 0x00) {
1001
			if (grbit == 0x00) {
1012
				static gboolean warned_a = FALSE;
1002
#if 0
1013
				static gboolean warned_3 = FALSE;
1014
				if (w == 0xa) {
1015
					if (warned_a)
1016
						break;
1017
					warned_a = TRUE;
1018
				} else if (w == 3) {
1019
					if (warned_3)
1020
						break;
1021
					warned_3 = TRUE;
1022
				} /* else always warn */
1023
1024
				ms_excel_dump_cellname (container->ewb, esheet, fn_col, fn_row);
1003
				ms_excel_dump_cellname (container->ewb, esheet, fn_col, fn_row);
1025
				fprintf (stderr, "Hmm, ptgAttr of type 0 ??\n"
1004
				fprintf (stderr, "Hmm, ptgAttr of type 0 ??\n"
1026
					"I've seen a case where an instance of this with flag A and another with flag 3\n"
1005
					"I've seen a case where an instance of this with flag A and another with flag 3\n"
1027
					"bracket a 1x1 array formula.  please send us this file.\n"
1006
					"bracket a 1x1 array formula.  please send us this file.\n"
1028
					"Flags = 0x%X\n", w);
1007
					"Flags = 0x%X\n", w);
1029
			} else if (grbit & 0x01) {
1030
#ifndef NO_DEBUG_EXCEL
1031
				if (ms_excel_formula_debug > 0) {
1032
					fprintf (stderr, "A volatile function: so what\n");
1033
				}
1034
#endif
1035
			} else if (grbit & 0x02) { /* AttrIf: 'optimised' IF function */
1036
				/* Who cares if the TRUE expr has a goto at the end */
1037
				GnmExpr const *tr;
1038
#ifndef NO_DEBUG_EXCEL
1039
				if (ms_excel_formula_debug > 2) {
1040
					fprintf (stderr, "Optimised IF 0x%x 0x%x\n", grbit, w);
1041
					gsf_mem_dump (mem, length);
1042
				}
1043
#endif
1008
#endif
1044
				tr = w ? excel_parse_formula (container, esheet, fn_col, fn_row,
1009
			} else if (grbit & 0x01) {
1045
					   cur+ptg_length, w, shared, NULL)
1010
				d (2, fprintf (stderr, "A volatile function\n"););
1046
					: gnm_expr_new_constant (value_new_string (""));
1047
				parse_list_push (&stack, tr);
1048
				ptg_length += w;
1049
			} else if (grbit & 0x04) { /* AttrChoose 'optimised' my foot. */
1050
				guint16 len, lp;
1051
				guint32 offset=0;
1052
				guint8 const *data=cur+3;
1053
				GnmExpr const *tr;
1054
1011
1055
#ifndef NO_DEBUG_EXCEL
1012
			/* AttrIf: stores jump to FALSE condition */
1056
				if (ms_excel_formula_debug > 1) {
1013
			} else if (grbit & 0x02) {
1057
					fprintf (stderr, "'Optimised' choose\n");
1014
				/* Ignore cached result */
1058
					gsf_mem_dump (mem,length);
1015
				d (2, fprintf (stderr, "ATTR IF\n"););
1059
				}
1016
1060
#endif
1017
			/* AttrChoose : stores table of inputs */
1061
				for (lp=0;lp<w;lp++) { /* w = wCases */
1018
			} else if (grbit & 0x04) {
1062
					offset= GSF_LE_GET_GUINT16(data);
1019
				/* Ignore the optimzation to specify which arg to use */
1063
					len = GSF_LE_GET_GUINT16(data+2) - offset;
1020
				d (2, fprintf (stderr, "ATTR CHOOSE\n"););
1064
#ifndef NO_DEBUG_EXCEL
1021
				ptg_length = 2 * ((w + 1) /* args */ + 1 /* count */) + 1;
1065
					if (ms_excel_formula_debug > 1) {
1022
1066
						fprintf (stderr, "Get from %d len %d [ = 0x%x ]\n",
1023
			/* AttrGoto : bytes/words to skip during _evaluation_.
1067
							ptg_length+offset, len,
1024
			 * We still need to parse them */
1068
							*(cur+ptg_length+offset));
1025
			} else if (grbit & 0x08) {
1069
					}
1026
				d (2, fprintf (stderr, "ATTR GOTO\n"););
1070
#endif
1027
1071
					tr = excel_parse_formula (container, esheet, fn_col, fn_row,
1028
			/* AttrSum: 'optimised' SUM function */
1072
						cur+ptg_length+offset, len, shared, NULL);
1029
			} else if (grbit & 0x10) {
1073
					data += 2;
1030
				if (!make_function (&stack, 0x04, 1, container->ewb->gnum_wb)) {
1074
					parse_list_push (&stack, tr);
1075
				}
1076
				ptg_length+=GSF_LE_GET_GUINT16(data);
1077
			} else if (grbit & 0x08) { /* AttrGoto */
1078
#ifndef NO_DEBUG_EXCEL
1079
				if (ms_excel_formula_debug > 2) {
1080
					fprintf (stderr, "Goto %d: cur = 0x%x\n", w,
1081
						(int)(cur-mem));
1082
					gsf_mem_dump (mem, length);
1083
				}
1084
#endif
1085
				/* Not right prior to Excel 4.0 ? */
1086
				if (ver <= MS_BIFF_V3) break;
1087
				ptg_length = w;
1088
			} else if (grbit & 0x10) { /* AttrSum: 'optimised' SUM function */
1089
				if (!make_function (&stack, 0x04, 1, container->ewb->gnum_wb))
1090
				{
1091
					error = TRUE;
1031
					error = TRUE;
1092
					puts ("Error in optimised SUM");
1032
					fprintf (stderr, "Error in optimised SUM\n");
1093
				}
1033
				}
1094
			} else if (grbit & 0x40) { /* AttrSpace */
1034
1035
			/* AttrSpace */
1036
			} else if (grbit & 0x40) {
1095
				guint8 num_space = GSF_LE_GET_GUINT8(cur+2);
1037
				guint8 num_space = GSF_LE_GET_GUINT8(cur+2);
1096
				guint8 attrs     = GSF_LE_GET_GUINT8(cur+1);
1038
				guint8 attrs     = GSF_LE_GET_GUINT8(cur+1);
1097
				if (attrs == 00) /* bitFSpace : ignore it */
1039
				if (attrs == 0) /* bitFSpace : ignore it for now */
1098
				/* Could perhaps pop top arg & append space ? */;
1099
				else
1100
#ifndef NO_DEBUG_EXCEL
1101
					if (ms_excel_formula_debug > 1) {
1102
						fprintf (stderr, "Redundant whitespace in formula 0x%x count %d\n", attrs, num_space);
1103
					}
1104
#else
1105
				;
1040
				;
1106
#endif
1041
  				else
1042
					d (2, fprintf (stderr, "Redundant whitespace in formula 0x%x count %d\n", attrs, num_space););
1107
			} else {
1043
			} else {
1108
				ms_excel_dump_cellname (container->ewb, esheet, fn_col, fn_row);
1044
				ms_excel_dump_cellname (container->ewb, esheet, fn_col, fn_row);
1109
				fprintf (stderr, "Unknown PTG Attr gr = 0x%x, w = 0x%x ptg = 0x%x\n", grbit, w, ptg);
1045
				fprintf (stderr, "Unknown PTG Attr gr = 0x%x, w = 0x%x ptg = 0x%x\n", grbit, w, ptg);
Lines 1113-1156 excel_parse_formula (MSContainer const * Link Here
1113
		break;
1049
		break;
1114
1050
1115
		case FORMULA_PTG_SHEET: {
1051
		case FORMULA_PTG_SHEET: {
1052
			g_warning ("PTG_SHEET! please send us a copy of this file.");
1116
			ptg_length = 10;
1053
			ptg_length = 10;
1117
			external = TRUE;
1054
			external = TRUE;
1118
#ifndef NO_DEBUG_EXCEL
1119
			if (ms_excel_formula_debug > 1) {
1120
				fprintf (stderr, "External ref ignored\n");
1121
			}
1122
#endif
1123
			break;
1055
			break;
1124
		}
1056
		}
1125
1057
1126
		case FORMULA_PTG_SHEET_END: {
1058
		case FORMULA_PTG_SHEET_END:
1059
			g_warning ("PTG_SHEET_END! please send us a copy of this file.");
1127
			ptg_length = 4;
1060
			ptg_length = 4;
1128
			external = FALSE;
1061
			external = FALSE;
1129
			break;
1062
			break;
1130
		}
1131
1063
1132
		case FORMULA_PTG_ERR: {
1064
		case FORMULA_PTG_ERR:
1133
			parse_list_push_raw (&stack, biff_get_error (NULL, GSF_LE_GET_GUINT8 (cur)));
1065
			parse_list_push_raw (&stack, biff_get_error (NULL, GSF_LE_GET_GUINT8 (cur)));
1134
			ptg_length = 1;
1066
			ptg_length = 1;
1135
			break;
1067
			break;
1136
		}
1068
1137
		case FORMULA_PTG_INT: {
1069
		case FORMULA_PTG_INT:
1138
			guint16 num = GSF_LE_GET_GUINT16(cur);
1070
			parse_list_push_raw (&stack, value_new_int (GSF_LE_GET_GUINT16 (cur)));
1139
			parse_list_push_raw (&stack, value_new_int (num));
1140
			ptg_length = 2;
1071
			ptg_length = 2;
1141
			break;
1072
			break;
1142
		}
1073
1143
		case FORMULA_PTG_BOOL:
1074
		case FORMULA_PTG_BOOL:
1144
			parse_list_push_raw (&stack, value_new_bool (GSF_LE_GET_GUINT8(cur)));
1075
			parse_list_push_raw (&stack, value_new_bool (GSF_LE_GET_GUINT8(cur)));
1145
			ptg_length = 1;
1076
			ptg_length = 1;
1146
			break;
1077
			break;
1147
1078
1148
		case FORMULA_PTG_NUM: {
1079
		case FORMULA_PTG_NUM:
1149
			double tmp = gsf_le_get_double (cur);
1080
			parse_list_push_raw (&stack, value_new_float (gsf_le_get_double (cur)));
1150
			parse_list_push_raw (&stack, value_new_float (tmp));
1151
			ptg_length = 8;
1081
			ptg_length = 8;
1152
			break;
1082
			break;
1153
		}
1083
1154
		case FORMULA_PTG_STR: {
1084
		case FORMULA_PTG_STR: {
1155
			char *str;
1085
			char *str;
1156
			int len = GSF_LE_GET_GUINT8 (cur);
1086
			int len = GSF_LE_GET_GUINT8 (cur);
Lines 1673-1688 excel_parse_formula (MSContainer const * Link Here
1673
		gsf_mem_dump (mem, length);
1603
		gsf_mem_dump (mem, length);
1674
1604
1675
		parse_list_free (&stack);
1605
		parse_list_free (&stack);
1676
		return expr_tree_error (esheet, fn_col, fn_row,
1606
		return xl_expr_err (esheet, fn_col, fn_row,
1677
			"Unknown Formula/Array", "#Unknown formula");
1607
			"Unknown Formula/Array", "#Unknown formula");
1678
	}
1608
	}
1679
1609
1680
	if (stack == NULL)
1610
	if (stack == NULL)
1681
		return expr_tree_error (esheet, fn_col, fn_row,
1611
		return xl_expr_err (esheet, fn_col, fn_row,
1682
			"Stack too short - unusual", "#ShortStack");
1612
			"Stack too short - unusual", "#ShortStack");
1683
	if (gnm_expr_list_length (stack) > 1) {
1613
	if (gnm_expr_list_length (stack) > 1) {
1684
		parse_list_free (&stack);
1614
		parse_list_free (&stack);
1685
		return expr_tree_error (esheet, fn_col, fn_row,
1615
		return xl_expr_err (esheet, fn_col, fn_row,
1686
			"Too much data on stack - probable cause: fixed args function is var-arg, put '-1' in the table above",
1616
			"Too much data on stack - probable cause: fixed args function is var-arg, put '-1' in the table above",
1687
			"#LongStack");
1617
			"#LongStack");
1688
	}
1618
	}
(-)plugins/excel/ms-obj.c (-2 / +7 lines)
Lines 180-188 ms_obj_attr_get_ptr (MSObjAttrBag *attr Link Here
180
}
180
}
181
181
182
GArray *
182
GArray *
183
ms_obj_attr_get_array (MSObjAttrBag *attrs, MSObjAttrID id, GArray *default_value)
183
ms_obj_attr_get_array (MSObjAttrBag *attrs, MSObjAttrID id,
184
		       GArray *default_value, gboolean steal)
184
{
185
{
185
	MSObjAttr *attr;
186
	MSObjAttr *attr;
187
	GArray *res;
186
188
187
	g_return_val_if_fail (attrs != NULL, default_value);
189
	g_return_val_if_fail (attrs != NULL, default_value);
188
	g_return_val_if_fail (id & MS_OBJ_ATTR_IS_GARRAY_MASK, default_value);
190
	g_return_val_if_fail (id & MS_OBJ_ATTR_IS_GARRAY_MASK, default_value);
Lines 190-196 ms_obj_attr_get_array (MSObjAttrBag *att Link Here
190
	attr = ms_obj_attr_bag_lookup (attrs, id);
192
	attr = ms_obj_attr_bag_lookup (attrs, id);
191
	if (attr == NULL)
193
	if (attr == NULL)
192
		return default_value;
194
		return default_value;
193
	return attr->v.v_array;
195
	res = attr->v.v_array;
196
	if (steal)
197
		attr->v.v_array = NULL;
198
	return res;
194
}
199
}
195
200
196
GnmExpr const *
201
GnmExpr const *
(-)plugins/excel/ms-obj.h (-1 / +2 lines)
Lines 103-109 MSObjAttr *ms_obj_attr_bag_lookup (M Link Here
103
guint32   ms_obj_attr_get_uint	      (MSObjAttrBag *attrs, MSObjAttrID id, guint32 default_value);
103
guint32   ms_obj_attr_get_uint	      (MSObjAttrBag *attrs, MSObjAttrID id, guint32 default_value);
104
gint32    ms_obj_attr_get_int	      (MSObjAttrBag *attrs, MSObjAttrID id, gint32 default_value);
104
gint32    ms_obj_attr_get_int	      (MSObjAttrBag *attrs, MSObjAttrID id, gint32 default_value);
105
gpointer  ms_obj_attr_get_ptr	      (MSObjAttrBag *attrs, MSObjAttrID id, gpointer default_value);
105
gpointer  ms_obj_attr_get_ptr	      (MSObjAttrBag *attrs, MSObjAttrID id, gpointer default_value);
106
GArray   *ms_obj_attr_get_array	      (MSObjAttrBag *attrs, MSObjAttrID id, GArray *default_value);
106
GArray	      *ms_obj_attr_get_array  (MSObjAttrBag *ab, MSObjAttrID id,
107
				       GArray *default_value, gboolean steal);
107
GnmExpr const *ms_obj_attr_get_expr   (MSObjAttrBag *attrs, MSObjAttrID id, GnmExpr const *default_value);
108
GnmExpr const *ms_obj_attr_get_expr   (MSObjAttrBag *attrs, MSObjAttrID id, GnmExpr const *default_value);
108
PangoAttrList *ms_obj_attr_get_markup (MSObjAttrBag *attrs, MSObjAttrID id, PangoAttrList *default_value);
109
PangoAttrList *ms_obj_attr_get_markup (MSObjAttrBag *attrs, MSObjAttrID id, PangoAttrList *default_value);
109
110
(-)plugins/fn-date/functions.c (-21 / +64 lines)
Lines 56-61 make_date (GnmValue *res) Link Here
56
	return res;
56
	return res;
57
}
57
}
58
58
59
static int
60
float_to_secs (gnm_float d)
61
{
62
	int secs;
63
64
	/* Ok, we have a positive number.  Add epsilon before we scale
65
	   and translate because otherwise it will not be enough.  */
66
	d = gnumeric_add_epsilon (d);
67
68
	/* Get the number down between 0 and 1 before we scale.  */
69
	d -= floorgnum (d);
70
71
	/* Scale and round.  */
72
	secs = (int)(gnumeric_add_epsilon (d) * DAY_SECONDS + 0.5);
73
74
	/* We rounded, so we might have gone too far.  */
75
	if (secs >= DAY_SECONDS)
76
		secs -= DAY_SECONDS;
77
78
	return secs;
79
}
80
81
59
/***************************************************************************/
82
/***************************************************************************/
60
83
61
static char const *help_date = {
84
static char const *help_date = {
Lines 82-118 static char const *help_date = { Link Here
82
static GnmValue *
105
static GnmValue *
83
gnumeric_date (FunctionEvalInfo *ei, GnmValue **argv)
106
gnumeric_date (FunctionEvalInfo *ei, GnmValue **argv)
84
{
107
{
85
	int year, month, day;
108
	gnm_float year  = value_get_as_float (argv [0]);
109
	gnm_float month = value_get_as_float (argv [1]);
110
	gnm_float day   = value_get_as_float (argv [2]);
86
	GDate date;
111
	GDate date;
87
	GnmDateConventions const *conv = DATE_CONV (ei->pos);
112
	GnmDateConventions const *conv = DATE_CONV (ei->pos);
88
113
89
	year  = value_get_as_int (argv [0]);
114
	if (year < 0 || year >= 10000)
90
	month = value_get_as_int (argv [1]);
91
	day   = value_get_as_int (argv [2]);
92
93
	if (year < 0 || year > 9999)
94
		goto error;
115
		goto error;
95
96
	if (year < 1900) /* 1900, not 100.  Ick!  */
116
	if (year < 1900) /* 1900, not 100.  Ick!  */
97
		year += 1900;
117
		year += 1900;
98
118
119
	/* This uses floor and not trunc on purpose.  */
120
	month = floorgnum (month);
121
	if (gnumabs (month) > 120000)  /* Actual number not critical.  */
122
		goto error;
123
124
	/* This uses floor and not trunc on purpose.  */
125
	day = floorgnum (day);
126
	if (day < -32768 || day >= 32768)
127
		day = 32767;  /* Absurd, but yes.  */
128
99
        g_date_clear (&date, 1);
129
        g_date_clear (&date, 1);
100
130
101
	g_date_set_dmy (&date, 1, 1, year);
131
	g_date_set_dmy (&date, 1, 1, (int)year);
102
	if (!g_date_valid (&date))
132
	if (!g_date_valid (&date))
103
		goto error;
133
		goto error;
104
134
105
	if (month > 0)
135
	if ((int)month > 0)
106
		g_date_add_months (&date, month - 1);
136
		g_date_add_months (&date, (int)month - 1);
107
	else
137
	else
108
		g_date_subtract_months (&date, 1 - month);
138
		g_date_subtract_months (&date, 1 - (int)month);
109
	if (!g_date_valid (&date))
139
	if (!g_date_valid (&date))
110
		goto error;
140
		goto error;
111
141
112
	if (day > 0)
142
	if ((int)day > 0)
113
                g_date_add_days (&date, day - 1);
143
		g_date_add_days (&date, (int)day - 1);
114
	else
144
	else
115
		g_date_subtract_days (&date, 1 - day);
145
		g_date_subtract_days (&date, 1 - (int)day);
116
	if (!g_date_valid (&date))
146
	if (!g_date_valid (&date))
117
		goto error;
147
		goto error;
118
148
Lines 547-556 static char const *help_hour = { Link Here
547
static GnmValue *
577
static GnmValue *
548
gnumeric_hour (FunctionEvalInfo *ei, GnmValue **argv)
578
gnumeric_hour (FunctionEvalInfo *ei, GnmValue **argv)
549
{
579
{
550
	int secs;
580
	gnm_float d = value_get_as_float (argv[0]);
551
	secs = datetime_value_to_seconds (argv[0]);
581
582
	if (d < 0)
583
		return value_new_error_NUM (ei->pos);
584
	else {
585
		int secs = float_to_secs (d);
552
	return value_new_int (secs / 3600);
586
	return value_new_int (secs / 3600);
553
}
587
}
588
}
554
589
555
/***************************************************************************/
590
/***************************************************************************/
556
591
Lines 576-585 static char const *help_minute = { Link Here
576
static GnmValue *
611
static GnmValue *
577
gnumeric_minute (FunctionEvalInfo *ei, GnmValue **argv)
612
gnumeric_minute (FunctionEvalInfo *ei, GnmValue **argv)
578
{
613
{
579
	int secs;
614
	gnm_float d = value_get_as_float (argv[0]);
580
615
581
	secs = datetime_value_to_seconds (argv[0]);
616
	if (d < 0)
582
	return value_new_int ((secs / 60) % 60);
617
		return value_new_error_NUM (ei->pos);
618
	else {
619
		int secs = float_to_secs (d);
620
		return value_new_int (secs / 60 % 60);
621
	}
583
}
622
}
584
623
585
/***************************************************************************/
624
/***************************************************************************/
Lines 606-615 static char const *help_second = { Link Here
606
static GnmValue *
645
static GnmValue *
607
gnumeric_second (FunctionEvalInfo *ei, GnmValue **argv)
646
gnumeric_second (FunctionEvalInfo *ei, GnmValue **argv)
608
{
647
{
609
	int secs;
648
	gnm_float d = value_get_as_float (argv[0]);
610
649
611
	secs = datetime_value_to_seconds (argv[0]);
650
	if (d < 0)
651
		return value_new_error_NUM (ei->pos);
652
	else {
653
		int secs = float_to_secs (d);
612
	return value_new_int (secs % 60);
654
	return value_new_int (secs % 60);
655
	}
613
}
656
}
614
657
615
/***************************************************************************/
658
/***************************************************************************/
(-)plugins/fn-eng/functions.c (-57 / +173 lines)
Lines 32-43 Link Here
32
#include <value.h>
32
#include <value.h>
33
#include <mathfunc.h>
33
#include <mathfunc.h>
34
#include <collect.h>
34
#include <collect.h>
35
#include <number-match.h>
36
#include <workbook.h>
37
#include <sheet.h>
35
38
36
#include <math.h>
39
#include <math.h>
37
#include <limits.h>
40
#include <limits.h>
38
#include <string.h>
41
#include <string.h>
39
#include <stdio.h>
42
#include <stdio.h>
40
#include <stdlib.h>
43
#include <stdlib.h>
44
#include <errno.h>
41
45
42
#include "plugin.h"
46
#include "plugin.h"
43
#include "plugin-util.h"
47
#include "plugin-util.h"
Lines 45-104 Link Here
45
49
46
GNUMERIC_MODULE_PLUGIN_INFO_DECL;
50
GNUMERIC_MODULE_PLUGIN_INFO_DECL;
47
51
52
53
typedef enum {
54
	V2B_STRINGS_GENERAL = 1,        /* Allow "1/1/2000" as number.  */
55
	V2B_STRINGS_0XH = 2,            /* Allow "4444h" and "0xABCD".  */
56
	V2B_STRINGS_MAXLEN = 4,         /* Impose 10 character input length.  */
57
	V2B_STRINGS_BLANK_ZERO = 8,     /* Treat "" as "0".  */
58
	V2B_KILLME
59
} Val2BaseFlags;
60
48
/**
61
/**
49
 * FIXME: In the long term this needs optimising.
62
 * FIXME: In the long term this needs optimising.
50
 **/
63
 **/
51
static GnmValue *
64
static GnmValue *
52
val_to_base (FunctionEvalInfo *ei,
65
val_to_base (FunctionEvalInfo *ei,
53
	     GnmValue **argv, int num_argv,
66
	     GnmValue const *value,
67
	     GnmValue const *aplaces,
54
	     int src_base, int dest_base,
68
	     int src_base, int dest_base,
55
	     gboolean relaxed)
69
	     gnm_float min_value, gnm_float max_value,
70
	     Val2BaseFlags flags)
56
{
71
{
57
	GnmValue *value;
72
	int digit, min, max, places;
58
	int digit, max, places;
59
	char *err;
60
	char const *str;
61
	gnm_float v, b10;
73
	gnm_float v, b10;
62
	gboolean ok, had_hex_prefix = FALSE;
63
	GString *buffer;
74
	GString *buffer;
75
	GnmValue *vstring = NULL;
64
76
65
	g_return_val_if_fail (src_base > 1 && src_base <= 36,
77
	g_return_val_if_fail (src_base > 1 && src_base <= 36,
66
			      value_new_error_VALUE (ei->pos));
78
			      value_new_error_VALUE (ei->pos));
67
	g_return_val_if_fail (dest_base > 1 && dest_base <= 36,
79
	g_return_val_if_fail (dest_base > 1 && dest_base <= 36,
68
			      value_new_error_VALUE (ei->pos));
80
			      value_new_error_VALUE (ei->pos));
69
81
70
	value = argv[0];
82
	/* func.c ought to take care of this.  */
71
	if (VALUE_IS_EMPTY (value))
83
 	if (VALUE_TYPE (value) == VALUE_BOOLEAN)
84
 		return value_new_error_VALUE (ei->pos);
85
 	if (aplaces && VALUE_TYPE (aplaces) == VALUE_BOOLEAN)
86
 		return value_new_error_VALUE (ei->pos);
87
 
88
 	switch (VALUE_TYPE (value)) {
89
 	default:
72
		return value_new_error_NUM (ei->pos);
90
		return value_new_error_NUM (ei->pos);
73
	else if (VALUE_IS_EMPTY_OR_ERROR (value))
74
		return value_dup (value);
75
91
76
	places = (num_argv >= 2 && argv[1]) ? value_get_as_int (argv[1]) : 0;
92
	case VALUE_INTEGER: {
93
		int val = value_get_as_int (value);
94
		char buf[4 * sizeof (int)];
95
		char *err;
77
96
78
	str = value_peek_string (value);
97
		if (val < min_value || val > max_value)
79
	if (relaxed) {
98
			value_new_error_NUM (ei->pos);
80
		while (*str == ' ' || *str == '\t')
99
81
			str++;
100
		sprintf (buf, "%d", val);
82
		if (src_base == 16 &&
101
		v = strtol (buf, &err, src_base);
83
		    str[0] == '0' &&
102
		if (*err != 0)
84
		    (str[1] == 'x' || str[1] == 'X')) {
103
			return value_new_error_NUM (ei->pos);
85
			str += 2;
104
86
			had_hex_prefix = TRUE;
105
		break;
87
		}
106
		}
107
 
108
 	case VALUE_STRING:
109
 		if (flags & V2B_STRINGS_GENERAL) {
110
 			vstring = format_match_number
111
 				(value_peek_string (value), NULL,
112
 				 workbook_date_conv (ei->pos->sheet->workbook));
113
 			if (!vstring ||
114
 			    VALUE_TYPE (vstring) == VALUE_BOOLEAN ||
115
 			    !VALUE_IS_NUMBER (vstring)) {
116
 				if (vstring)
117
 					value_release (vstring);
118
 				return value_new_error_VALUE (ei->pos);
88
	}
119
	}
120
 		} else {
121
 			const char *str = value_peek_string (value);
122
 			size_t len;
123
 			gboolean hsuffix = FALSE;
124
 			char *err;
125
 
126
 			if ((flags & V2B_STRINGS_BLANK_ZERO) && *str == 0)
127
 				str = "0";
128
 
129
 			/* This prevents leading spaces, signs, etc, and "".  */
130
 			if (!g_ascii_isalnum (*str))
131
 				return value_new_error_NUM (ei->pos);
132
 
133
 			len = strlen (str);
134
 			/* We check length in bytes.  Since we are going to
135
 			   require nothing but digits, that is fine.  */
136
 			if ((flags & V2B_STRINGS_MAXLEN) && len > 10)
137
 				return value_new_error_NUM (ei->pos);
138
 
139
 			if (flags & V2B_STRINGS_0XH) {
140
 				if (str[0] == '0' && (str[1] == 'x' || str[1] == 'X'))
141
 					str += 2;
142
 				else if (str[len - 1] == 'h' || str[len - 1] == 'H')
143
 					hsuffix = TRUE;
144
			}
145
 
89
	v = strtol (str, &err, src_base);
146
	v = strtol (str, &err, src_base);
90
147
91
	ok = (err != str && *err == 0);
148
 			if (err == str || err[hsuffix] != 0)
92
	if (!ok && relaxed && err != str) {
149
 				return value_new_error_NUM (ei->pos);
93
		if (src_base == 16 &&
150
 
94
		    !had_hex_prefix &&
151
 			break;
95
		    (err[0] == 'h' || err[0] == 'H') &&
96
		    err[1] == 0)
97
			ok = TRUE;
98
	}
152
	}
153
 		/* Fall through.  */
154
 
155
		case VALUE_FLOAT: {
156
			gnm_float val = gnumeric_fake_trunc (value_get_as_float (vstring ? vstring : value));
157
			char buf[GNUM_MANT_DIG + 10];
158
			char *err;
159
	 
160
			if (vstring)
161
				value_release (vstring);
162
	 
163
			if (val < min_value || val > max_value)
164
				return value_new_error_NUM (ei->pos);
99
165
100
	if (!ok)
166
			g_ascii_formatd (buf, sizeof (buf) - 1,
167
					 "%.0" GNUM_FORMAT_f,
168
					 val);
169
 
170
			v = strtol (buf, &err, src_base);
171
			if (*err != 0)
101
		return value_new_error_NUM (ei->pos);
172
		return value_new_error_NUM (ei->pos);
173
			break;
174
		}
175
	}
102
176
103
	b10 = powgnum (src_base, 10);
177
	b10 = powgnum (src_base, 10);
104
	if (v >= b10 / 2) /* N's complement */
178
	if (v >= b10 / 2) /* N's complement */
Lines 108-125 val_to_base (FunctionEvalInfo *ei, Link Here
108
		return value_new_int (v);
182
		return value_new_int (v);
109
183
110
	if (v < 0) {
184
	if (v < 0) {
185
		min = 1;
111
		max = 10;
186
		max = 10;
112
		v += powgnum (dest_base, max);
187
		v += powgnum (dest_base, max);
113
	} else {
188
	} else {
114
		if (v == 0)
189
		if (v == 0)
115
			max = 1;
190
			min = max = 1;
116
		else
191
		else
117
			max = (int)(loggnum (v + 0.5) /
192
			min = max = (int)(loggnum (v + 0.5) /
118
				    loggnum (dest_base)) + 1;
193
				    loggnum (dest_base)) + 1;
119
	}
194
	}
120
195
121
	if (places > max)
196
 	if (aplaces) {
197
 		places = value_get_as_int (aplaces);
198
 		if (places < min || places > 10)
199
 			return value_new_error_NUM (ei->pos);
200
 		if (v >= 0 && places > max)
122
		max = places;
201
		max = places;
202
 	} else
203
 		places = 1;
204
  
123
205
124
	buffer = g_string_sized_new (max);
206
	buffer = g_string_sized_new (max);
125
	g_string_set_size (buffer, max);
207
	g_string_set_size (buffer, max);
Lines 158-172 static char const *help_base = { Link Here
158
static GnmValue *
240
static GnmValue *
159
gnumeric_base (FunctionEvalInfo *ei, GnmValue **argv)
241
gnumeric_base (FunctionEvalInfo *ei, GnmValue **argv)
160
{
242
{
161
	GnmValue *argv2[2];
243
 	static gnm_float const max = 1 / GNUM_EPSILON;
162
	int base = value_get_as_int (argv[1]);
244
	int base = value_get_as_int (argv[1]);
163
245
164
	if (base < 2 || base > 36)
246
	if (base < 2 || base > 36)
165
		return value_new_error_NUM (ei->pos);
247
		return value_new_error_NUM (ei->pos);
166
248
 	return val_to_base (ei, argv[0], argv[2], 10, base,
167
	argv2[0] = argv[0];
249
 			    -max, +max,
168
	argv2[1] = argv[2];
250
 			    V2B_STRINGS_GENERAL | V2B_STRINGS_0XH);
169
	return val_to_base (ei, argv2, 2, 10, base, FALSE);
170
}
251
}
171
252
172
/***************************************************************************/
253
/***************************************************************************/
Lines 189-195 static char const *help_bin2dec = { Link Here
189
static GnmValue *
270
static GnmValue *
190
gnumeric_bin2dec (FunctionEvalInfo *ei, GnmValue **argv)
271
gnumeric_bin2dec (FunctionEvalInfo *ei, GnmValue **argv)
191
{
272
{
192
	return val_to_base (ei, argv, 1, 2, 10, FALSE);
273
	return val_to_base (ei, argv[0], NULL,
274
			    2, 10,
275
			    0, GNM_const(1111111111.0),
276
			    V2B_STRINGS_MAXLEN | V2B_STRINGS_BLANK_ZERO);
193
}
277
}
194
278
195
/***************************************************************************/
279
/***************************************************************************/
Lines 215-221 static char const *help_bin2oct = { Link Here
215
static GnmValue *
299
static GnmValue *
216
gnumeric_bin2oct (FunctionEvalInfo *ei, GnmValue **argv)
300
gnumeric_bin2oct (FunctionEvalInfo *ei, GnmValue **argv)
217
{
301
{
218
	return val_to_base (ei, argv, 2, 2, 8, FALSE);
302
	return val_to_base (ei, argv[0], argv[1],
303
			    2, 8,
304
			    0, GNM_const(1111111111.0),
305
			    V2B_STRINGS_MAXLEN | V2B_STRINGS_BLANK_ZERO);
219
}
306
}
220
307
221
/***************************************************************************/
308
/***************************************************************************/
Lines 241-247 static char const *help_bin2hex = { Link Here
241
static GnmValue *
328
static GnmValue *
242
gnumeric_bin2hex (FunctionEvalInfo *ei, GnmValue **argv)
329
gnumeric_bin2hex (FunctionEvalInfo *ei, GnmValue **argv)
243
{
330
{
244
	return val_to_base (ei, argv, 2, 2, 16, FALSE);
331
	return val_to_base (ei, argv[0], argv[1],
332
			    2, 16,
333
			    0, GNM_const(1111111111.0),
334
			    V2B_STRINGS_MAXLEN | V2B_STRINGS_BLANK_ZERO);
245
}
335
}
246
336
247
/***************************************************************************/
337
/***************************************************************************/
Lines 267-273 static char const *help_dec2bin = { Link Here
267
static GnmValue *
357
static GnmValue *
268
gnumeric_dec2bin (FunctionEvalInfo *ei, GnmValue **argv)
358
gnumeric_dec2bin (FunctionEvalInfo *ei, GnmValue **argv)
269
{
359
{
270
	return val_to_base (ei, argv, 2, 10, 2, FALSE);
360
	return val_to_base (ei, argv[0], argv[1],
361
			    10, 2,
362
			    -512, 511,
363
			    V2B_STRINGS_GENERAL);
271
}
364
}
272
365
273
/***************************************************************************/
366
/***************************************************************************/
Lines 293-299 static char const *help_dec2oct = { Link Here
293
static GnmValue *
386
static GnmValue *
294
gnumeric_dec2oct (FunctionEvalInfo *ei, GnmValue **argv)
387
gnumeric_dec2oct (FunctionEvalInfo *ei, GnmValue **argv)
295
{
388
{
296
	return val_to_base (ei, argv, 2, 10, 8, FALSE);
389
	return val_to_base (ei, argv[0], argv[1],
390
			    10, 8,
391
			    -536870912, 536870911,
392
			    V2B_STRINGS_GENERAL);
297
}
393
}
298
394
299
/***************************************************************************/
395
/***************************************************************************/
Lines 319-325 static char const *help_dec2hex = { Link Here
319
static GnmValue *
415
static GnmValue *
320
gnumeric_dec2hex (FunctionEvalInfo *ei, GnmValue **argv)
416
gnumeric_dec2hex (FunctionEvalInfo *ei, GnmValue **argv)
321
{
417
{
322
	return val_to_base (ei, argv, 2, 10, 16, FALSE);
418
	return val_to_base (ei, argv[0], argv[1],
419
			    10, 16,
420
			    GNM_const(-549755813888.0), GNM_const(549755813887.0),
421
			    V2B_STRINGS_GENERAL);
323
}
422
}
324
423
325
/***************************************************************************/
424
/***************************************************************************/
Lines 371-377 static char const *help_oct2dec = { Link Here
371
static GnmValue *
470
static GnmValue *
372
gnumeric_oct2dec (FunctionEvalInfo *ei, GnmValue **argv)
471
gnumeric_oct2dec (FunctionEvalInfo *ei, GnmValue **argv)
373
{
472
{
374
	return val_to_base (ei, argv, 1, 8, 10, FALSE);
473
	return val_to_base (ei, argv[0], NULL,
474
			    8, 10,
475
			    0, GNM_const(7777777777.0),
476
			    V2B_STRINGS_MAXLEN | V2B_STRINGS_BLANK_ZERO);
375
}
477
}
376
478
377
/***************************************************************************/
479
/***************************************************************************/
Lines 397-403 static char const *help_oct2bin = { Link Here
397
static GnmValue *
499
static GnmValue *
398
gnumeric_oct2bin (FunctionEvalInfo *ei, GnmValue **argv)
500
gnumeric_oct2bin (FunctionEvalInfo *ei, GnmValue **argv)
399
{
501
{
400
	return val_to_base (ei, argv, 2, 8, 2, FALSE);
502
	return val_to_base (ei, argv[0], argv[1],
503
			    8, 2,
504
			    0, GNM_const(7777777777.0),
505
			    V2B_STRINGS_MAXLEN | V2B_STRINGS_BLANK_ZERO);
401
}
506
}
402
507
403
/***************************************************************************/
508
/***************************************************************************/
Lines 423-429 static char const *help_oct2hex = { Link Here
423
static GnmValue *
528
static GnmValue *
424
gnumeric_oct2hex (FunctionEvalInfo *ei, GnmValue **argv)
529
gnumeric_oct2hex (FunctionEvalInfo *ei, GnmValue **argv)
425
{
530
{
426
	return val_to_base (ei, argv, 2, 8, 16, FALSE);
531
	return val_to_base (ei, argv[0], argv[1],
532
			    8, 16,
533
			    0, GNM_const(7777777777.0),
534
			    V2B_STRINGS_MAXLEN | V2B_STRINGS_BLANK_ZERO);
427
}
535
}
428
536
429
/***************************************************************************/
537
/***************************************************************************/
Lines 449-455 static char const *help_hex2bin = { Link Here
449
static GnmValue *
557
static GnmValue *
450
gnumeric_hex2bin (FunctionEvalInfo *ei, GnmValue **argv)
558
gnumeric_hex2bin (FunctionEvalInfo *ei, GnmValue **argv)
451
{
559
{
452
	return val_to_base (ei, argv, 2, 16, 2, FALSE);
560
	return val_to_base (ei, argv[0], argv[1],
561
			    16, 2,
562
			    0, GNM_const(9999999999.0),
563
			    V2B_STRINGS_MAXLEN | V2B_STRINGS_BLANK_ZERO);
453
}
564
}
454
565
455
/***************************************************************************/
566
/***************************************************************************/
Lines 475-481 static char const *help_hex2oct = { Link Here
475
static GnmValue *
586
static GnmValue *
476
gnumeric_hex2oct (FunctionEvalInfo *ei, GnmValue **argv)
587
gnumeric_hex2oct (FunctionEvalInfo *ei, GnmValue **argv)
477
{
588
{
478
	return val_to_base (ei, argv, 2, 16, 8, FALSE);
589
	return val_to_base (ei, argv[0], argv[1],
590
			    16, 8,
591
			    0, GNM_const(9999999999.0),
592
			    V2B_STRINGS_MAXLEN | V2B_STRINGS_BLANK_ZERO);
479
}
593
}
480
594
481
/***************************************************************************/
595
/***************************************************************************/
Lines 498-504 static char const *help_hex2dec = { Link Here
498
static GnmValue *
612
static GnmValue *
499
gnumeric_hex2dec (FunctionEvalInfo *ei, GnmValue **argv)
613
gnumeric_hex2dec (FunctionEvalInfo *ei, GnmValue **argv)
500
{
614
{
501
	return val_to_base (ei, argv, 1, 16, 10, FALSE);
615
	return val_to_base (ei, argv[0], NULL,
616
			    16, 10,
617
			    0, GNM_const(9999999999.0),
618
			    V2B_STRINGS_MAXLEN | V2B_STRINGS_BLANK_ZERO);
502
}
619
}
503
620
504
/***************************************************************************/
621
/***************************************************************************/
Lines 800-806 get_constant_of_unit(const eng_convert_u Link Here
800
917
801
/* See also http://physics.nist.gov/cuu/Units/prefixes.html */
918
/* See also http://physics.nist.gov/cuu/Units/prefixes.html */
802
919
803
static GnmValue *
920
static gboolean
804
convert (const eng_convert_unit_t units[],
921
convert (const eng_convert_unit_t units[],
805
	 const eng_convert_unit_t prefixes[],
922
	 const eng_convert_unit_t prefixes[],
806
	 char const *from_unit, char const *to_unit,
923
	 char const *from_unit, char const *to_unit,
Lines 813-829 convert (const eng_convert_unit_t units[ Link Here
813
930
814
	        if (!get_constant_of_unit (units, prefixes,
931
	        if (!get_constant_of_unit (units, prefixes,
815
					   to_unit, &to_c, &to_prefix))
932
					   to_unit, &to_c, &to_prefix))
816
			return value_new_error_NUM (ep);
933
			*v = value_new_error_NUM (ep);
817
934
	        else if (from_c == 0 || to_prefix == 0)
818
	        if (from_c == 0 || to_prefix == 0)
935
	                *v = value_new_error_NUM (ep);
819
	                return value_new_error_NUM (ep);
936
		else
820
821
		*v = value_new_float (((n * from_prefix) / from_c) *
937
		*v = value_new_float (((n * from_prefix) / from_c) *
822
				 to_c / to_prefix);
938
				 to_c / to_prefix);
823
		return *v;
939
		return TRUE;
824
	}
940
	}
825
941
826
	return NULL;
942
	return FALSE;
827
}
943
}
828
944
829
static GnmValue *
945
static GnmValue *
(-)plugins/fn-financial/functions.c (-111 / +197 lines)
Lines 50-57 Link Here
50
50
51
GNUMERIC_MODULE_PLUGIN_INFO_DECL;
51
GNUMERIC_MODULE_PLUGIN_INFO_DECL;
52
52
53
#define is_valid_basis(B) (B >= 0 && B <= 5)
53
#define is_valid_basis(B) ((B) >= 0 && (B) <= 5)
54
#define is_valid_freq(F) (F == 1 || F == 2 || F == 4)
54
#define is_valid_freq(F) ((F) == 1 || (F) == 2 || (F) == 4)
55
#define is_valid_paytype(t) ((t) == 0 || (t) == 1)
56
57
static int
58
value_get_basis (const GnmValue *v, int defalt)
59
{
60
	if (v) {
61
		gnm_float b = value_get_as_float (v);
62
63
		if (b < 0 || b >= 6)
64
			return -1;
65
		return (int)b;
66
	} else
67
		return defalt;
68
}
69
70
static int
71
value_get_freq (const GnmValue *v)
72
{
73
	gnm_float f;
74
75
	g_return_val_if_fail (v != NULL, -1);
76
77
	f = value_get_as_float (v);
78
	if (f < 1 || f >= 5)
79
		return -1;
80
	else {
81
		int i = (int)f;
82
		return i == 3 ? -1 : i;
83
	}
84
}
85
86
static int
87
value_get_paytype (const GnmValue *v)
88
{
89
	if (v) {
90
		gnm_float f = value_get_as_float (v);
91
		if (f < 0 || f >= 2)
92
			return -1;
93
		else
94
			return (int)f;
95
	} else
96
		return 0;
97
}
55
98
56
/***************************************************************************
99
/***************************************************************************
57
 *
100
 *
Lines 241-260 price (GDate *settlement, GDate *maturit Link Here
241
       gnm_float redemption, GnmCouponConvention const *conv)
284
       gnm_float redemption, GnmCouponConvention const *conv)
242
{
285
{
243
	gnm_float a, d, e, sum, den, basem1, exponent, first_term, last_term;
286
	gnm_float a, d, e, sum, den, basem1, exponent, first_term, last_term;
244
	gint       k, n;
287
	int       n;
245
288
246
	a = coupdaybs (settlement, maturity, conv);
289
	a = coupdaybs (settlement, maturity, conv);
247
	d = coupdaysnc (settlement, maturity, conv);
290
	d = coupdaysnc (settlement, maturity, conv);
248
	e = coupdays (settlement, maturity, conv);
291
	e = coupdays (settlement, maturity, conv);
249
	n = coupnum (settlement, maturity, conv);
292
	n = coupnum (settlement, maturity, conv);
250
293
251
	sum = 0.0;
252
	den = 100.0 * rate / conv->freq;
294
	den = 100.0 * rate / conv->freq;
253
	basem1 = yield / conv->freq;
295
	basem1 = yield / conv->freq;
254
	exponent = d / e;
296
	exponent = d / e;
255
	/* FIXME: Eliminate loop.  */
297
256
	for (k = 0; k < n; k++)
298
	if (n == 1)
257
	        sum += den / pow1p (basem1, exponent + k);
299
		return (redemption + den) / (1 + exponent * basem1) -
300
			a / e * den;
301
302
	sum = den * pow1p (basem1, 1 - n - exponent) *
303
		pow1pm1 (basem1, n) / basem1;
258
304
259
	first_term = redemption / pow1p (basem1, (n - 1.0 + d / e));
305
	first_term = redemption / pow1p (basem1, (n - 1.0 + d / e));
260
	last_term = a / e * den;
306
	last_term = a / e * den;
Lines 276-290 func_coup (FunctionEvalInfo *ei, GnmValu Link Here
276
{
322
{
277
        GDate   settlement, maturity;
323
        GDate   settlement, maturity;
278
	GnmCouponConvention conv;
324
	GnmCouponConvention conv;
279
	gboolean err = FALSE;
280
325
281
        conv.freq  = value_get_as_int (argv[2]);
326
        conv.freq  = value_get_freq (argv[2]);
282
	conv.basis = argv[3] ? value_get_as_int (argv[3]) : BASIS_MSRB_30_360;
327
	conv.basis = value_get_basis (argv[3], BASIS_MSRB_30_360);
283
	conv.eom   = argv[4] ? value_get_as_bool (argv[4], &err) : TRUE;
328
	conv.eom   = argv[4] ? value_get_as_checked_bool (argv[4]) : TRUE;
284
	conv.date_conv = workbook_date_conv (ei->pos->sheet->workbook);
329
	conv.date_conv = workbook_date_conv (ei->pos->sheet->workbook);
285
330
286
        if (err ||
331
        if (!datetime_value_to_g (&settlement, argv[0], conv.date_conv) ||
287
	    !datetime_value_to_g (&settlement, argv[0], conv.date_conv) ||
288
	    !datetime_value_to_g (&maturity, argv[1], conv.date_conv))
332
	    !datetime_value_to_g (&maturity, argv[1], conv.date_conv))
289
		return value_new_error_VALUE (ei->pos);
333
		return value_new_error_VALUE (ei->pos);
290
334
Lines 359-366 gnumeric_accrint (FunctionEvalInfo *ei, Link Here
359
403
360
	rate           = value_get_as_float (argv[3]);
404
	rate           = value_get_as_float (argv[3]);
361
	par            = value_get_as_float (argv[4]);
405
	par            = value_get_as_float (argv[4]);
362
	freq           = value_get_as_float (argv[5]);
406
	freq           = value_get_freq (argv[5]);
363
	basis          = argv[6] ? value_get_as_int (argv[6]) : 0;
407
	basis          = value_get_basis (argv[6], BASIS_MSRB_30_360);
364
408
365
        if (rate <= 0.	||
409
        if (rate <= 0.	||
366
	    par <= 0.	||
410
	    par <= 0.	||
Lines 429-435 gnumeric_accrintm (FunctionEvalInfo *ei, Link Here
429
473
430
	rate  = value_get_as_float (argv[2]);
474
	rate  = value_get_as_float (argv[2]);
431
	par   = argv[3] ? value_get_as_float (argv[3]) : 1000;
475
	par   = argv[3] ? value_get_as_float (argv[3]) : 1000;
432
	basis = argv[4] ? value_get_as_int (argv[4]) : 0;
476
	basis = value_get_basis (argv[4], BASIS_MSRB_30_360);
433
477
434
	a = days_monthly_basis (argv[0], argv[1], basis, date_conv);
478
	a = days_monthly_basis (argv[0], argv[1], basis, date_conv);
435
	d = annual_year_basis (argv[0], basis, date_conv);
479
	d = annual_year_basis (argv[0], basis, date_conv);
Lines 491-497 gnumeric_intrate (FunctionEvalInfo *ei, Link Here
491
535
492
	investment = value_get_as_float (argv[2]);
536
	investment = value_get_as_float (argv[2]);
493
	redemption = value_get_as_float (argv[3]);
537
	redemption = value_get_as_float (argv[3]);
494
	basis      = argv[4] ? value_get_as_int (argv[4]) : 0;
538
	basis      = value_get_basis (argv[4], BASIS_MSRB_30_360);
495
539
496
	a = days_monthly_basis (argv[0], argv[1], basis, date_conv);
540
	a = days_monthly_basis (argv[0], argv[1], basis, date_conv);
497
	d = annual_year_basis (argv[0], basis, date_conv);
541
	d = annual_year_basis (argv[0], basis, date_conv);
Lines 547-553 gnumeric_received (FunctionEvalInfo *ei, Link Here
547
591
548
	investment = value_get_as_float (argv[2]);
592
	investment = value_get_as_float (argv[2]);
549
	discount   = value_get_as_float (argv[3]);
593
	discount   = value_get_as_float (argv[3]);
550
	basis      = argv[4] ? value_get_as_int (argv[4]) : 0;
594
	basis      = value_get_basis (argv[4], BASIS_MSRB_30_360);
551
595
552
	a = days_monthly_basis (argv[0], argv[1], basis, date_conv);
596
	a = days_monthly_basis (argv[0], argv[1], basis, date_conv);
553
	d = annual_year_basis (argv[0], basis, date_conv);
597
	d = annual_year_basis (argv[0], basis, date_conv);
Lines 605-611 gnumeric_pricedisc (FunctionEvalInfo *ei Link Here
605
649
606
	discount   = value_get_as_float (argv[2]);
650
	discount   = value_get_as_float (argv[2]);
607
	redemption = value_get_as_float (argv[3]);
651
	redemption = value_get_as_float (argv[3]);
608
	basis      = argv[4] ? value_get_as_int (argv[4]) : 0;
652
	basis      = value_get_basis (argv[4], BASIS_MSRB_30_360);
609
653
610
	a = days_monthly_basis (argv[0], argv[1], basis, date_conv);
654
	a = days_monthly_basis (argv[0], argv[1], basis, date_conv);
611
	d = annual_year_basis (argv[0], basis, date_conv);
655
	d = annual_year_basis (argv[0], basis, date_conv);
Lines 658-664 gnumeric_pricemat (FunctionEvalInfo *ei, Link Here
658
702
659
	discount = value_get_as_float (argv[3]);
703
	discount = value_get_as_float (argv[3]);
660
	yield    = value_get_as_float (argv[4]);
704
	yield    = value_get_as_float (argv[4]);
661
	basis    = argv[5] ? value_get_as_int (argv[5]) : 0;
705
	basis    = value_get_basis (argv[5], BASIS_MSRB_30_360);
662
706
663
	dsm = days_monthly_basis (argv[0], argv[1], basis, date_conv);
707
	dsm = days_monthly_basis (argv[0], argv[1], basis, date_conv);
664
	dim = days_monthly_basis (argv[2], argv[1], basis, date_conv);
708
	dim = days_monthly_basis (argv[2], argv[1], basis, date_conv);
Lines 718-724 gnumeric_disc (FunctionEvalInfo *ei, Gnm Link Here
718
762
719
	par        = value_get_as_float (argv[2]);
763
	par        = value_get_as_float (argv[2]);
720
	redemption = value_get_as_float (argv[3]);
764
	redemption = value_get_as_float (argv[3]);
721
	basis      = argv[4] ? value_get_as_int (argv[4]) : 0;
765
	basis      = value_get_basis (argv[4], BASIS_MSRB_30_360);
722
766
723
	b = annual_year_basis (argv[0], basis, date_conv);
767
	b = annual_year_basis (argv[0], basis, date_conv);
724
	dsm = days_monthly_basis (argv[0], argv[1], basis, date_conv);
768
	dsm = days_monthly_basis (argv[0], argv[1], basis, date_conv);
Lines 1417-1429 gnumeric_rate (FunctionEvalInfo *ei, Gnm Link Here
1417
	udata.pmt  = value_get_as_float (argv[1]);
1461
	udata.pmt  = value_get_as_float (argv[1]);
1418
	udata.pv   = value_get_as_float (argv[2]);
1462
	udata.pv   = value_get_as_float (argv[2]);
1419
	udata.fv   = argv[3] ? value_get_as_float (argv[3]) : 0.0;
1463
	udata.fv   = argv[3] ? value_get_as_float (argv[3]) : 0.0;
1420
	udata.type = argv[4] ? value_get_as_int (argv[4]) : 0;
1464
	udata.type = value_get_paytype (argv[4]);
1421
	rate0      = argv[5] ?  value_get_as_float (argv[5]) : 0.1;
1465
	rate0      = argv[5] ?  value_get_as_float (argv[5]) : 0.1;
1422
1466
1423
	if (udata.nper <= 0)
1467
	if (udata.nper <= 0)
1424
		return value_new_error_NUM (ei->pos);
1468
		return value_new_error_NUM (ei->pos);
1425
1469
1426
	if (udata.type != 0 && udata.type != 1)
1470
	if (!is_valid_paytype (udata.type))
1427
		return value_new_error_VALUE (ei->pos);
1471
		return value_new_error_VALUE (ei->pos);
1428
1472
1429
#if 0
1473
#if 0
Lines 1499-1541 typedef struct { Link Here
1499
static GoalSeekStatus
1543
static GoalSeekStatus
1500
irr_npv (gnm_float rate, gnm_float *y, void *user_data)
1544
irr_npv (gnm_float rate, gnm_float *y, void *user_data)
1501
{
1545
{
1502
	gnumeric_irr_t *p = user_data;
1546
	const gnumeric_irr_t *p = user_data;
1503
	gnm_float *values, sum;
1547
	const gnm_float *values = p->values;
1504
        int i, n;
1548
        int n = p->n;
1505
1549
	gnm_float sum = 0;
1506
	values = p->values;
1550
	gnm_float f = 1;
1507
	n = p->n;
1551
	gnm_float ff = 1 / (rate + 1);
1508
1552
        int i;
1509
	sum = 0;
1510
	for (i = 0; i < n; i++)
1511
	        sum += values[i] * pow1p (rate, n - i);
1512
1553
1513
	/*
1554
	for (i = 0; i < n; i++) {
1514
	 * I changed the formula above by multiplying all terms by (1+r)^n.
1555
	        sum += values[i] * f;
1515
	 * Since we're looking for zeros, that should not matter.  It does
1556
		f *= ff;
1516
	 * make the derivative below simpler, though.  -- MW.
1557
	}
1517
	 */
1518
1558
1519
	*y = sum;
1559
	*y = sum;
1520
	return GOAL_SEEK_OK;
1560
	return finitegnum (sum) ? GOAL_SEEK_OK : GOAL_SEEK_ERROR;
1521
}
1561
}
1522
1562
1523
static GoalSeekStatus
1563
static GoalSeekStatus
1524
irr_npv_df (gnm_float rate, gnm_float *y, void *user_data)
1564
irr_npv_df (gnm_float rate, gnm_float *y, void *user_data)
1525
{
1565
{
1526
	gnumeric_irr_t *p = user_data;
1566
	const gnumeric_irr_t *p = user_data;
1527
	gnm_float *values, sum;
1567
	const gnm_float *values = p->values;
1528
        int i, n;
1568
        int n = p->n;
1529
1569
	gnm_float sum = 0;
1530
	values = p->values;
1570
	gnm_float f = 1;
1531
	n = p->n;
1571
	gnm_float ff = 1 / (rate + 1);
1572
        int i;
1532
1573
1533
	sum = 0;
1574
	for (i = 1; i < n; i++) {
1534
	for (i = 0; i < n - 1; i++)
1575
	        sum += values[i] * (-i) * f;
1535
	        sum += values[i] * (n - i) * pow1p (rate, n - i - 1);
1576
		f *= ff;
1577
	}
1536
1578
1537
	*y = sum;
1579
	*y = sum;
1538
	return GOAL_SEEK_OK;
1580
	return finitegnum (sum) ? GOAL_SEEK_OK : GOAL_SEEK_ERROR;
1539
}
1581
}
1540
1582
1541
static GnmValue *
1583
static GnmValue *
Lines 1560-1580 gnumeric_irr (FunctionEvalInfo *ei, GnmV Link Here
1560
1602
1561
	goal_seek_initialize (&data);
1603
	goal_seek_initialize (&data);
1562
1604
1563
	data.xmin = MAX (data.xmin,
1605
	data.xmin = -1;
1564
			 -powgnum (DBL_MAX / 1e10, 1.0 / p.n) + 1);
1565
	data.xmax = MIN (data.xmax,
1606
	data.xmax = MIN (data.xmax,
1566
			 powgnum (DBL_MAX / 1e10, 1.0 / p.n) - 1);
1607
			 powgnum (DBL_MAX / 1e10, 1.0 / p.n) - 1);
1567
1608
1568
	status = goal_seek_newton (&irr_npv, &irr_npv_df, &data, &p, rate0);
1609
	status = goal_seek_newton (&irr_npv, &irr_npv_df, &data, &p, rate0);
1569
	if (status != GOAL_SEEK_OK) {
1610
	if (status != GOAL_SEEK_OK) {
1570
		int factor;
1611
		int i;
1612
		gnm_float s;
1613
1571
		/* Lay a net of test points around the guess.  */
1614
		/* Lay a net of test points around the guess.  */
1572
		for (factor = 2; !(data.havexneg && data.havexpos) &&
1615
		for (i = 0, s = 2; !(data.havexneg && data.havexpos) && i < 10; i++, s *= 2) {
1573
		       factor < 100; factor *= 2) {
1616
			goal_seek_point (&irr_npv, &data, &p, rate0 * s);
1574
			goal_seek_point (&irr_npv, &data, &p, rate0 * factor);
1617
			goal_seek_point (&irr_npv, &data, &p, rate0 / s);
1575
			goal_seek_point (&irr_npv, &data, &p, rate0 / factor);
1576
		}
1618
		}
1577
1619
1620
		/*
1621
		 * If the root is negative and the guess is positive is
1622
		 * is possible to get thrown out to the left of -100%
1623
		 * by the Newton method.
1624
		 */
1625
		if (!(data.havexneg && data.havexpos))
1626
			goal_seek_newton (&irr_npv, &irr_npv_df, &data, &p, -0.99);
1627
		if (!(data.havexneg && data.havexpos))
1628
			goal_seek_point (&irr_npv, &data, &p, 1 - GNUM_EPSILON);
1629
1578
		/* Pray we got both sides of the root.  */
1630
		/* Pray we got both sides of the root.  */
1579
		status = goal_seek_bisection (&irr_npv, &data, &p);
1631
		status = goal_seek_bisection (&irr_npv, &data, &p);
1580
	}
1632
	}
Lines 1615-1625 gnumeric_pv (FunctionEvalInfo *ei, GnmVa Link Here
1615
	gnm_float nper = value_get_as_float (argv[1]);
1667
	gnm_float nper = value_get_as_float (argv[1]);
1616
	gnm_float pmt  = value_get_as_float (argv[2]);
1668
	gnm_float pmt  = value_get_as_float (argv[2]);
1617
	gnm_float fv   = argv[3] ? value_get_as_float (argv[3]) : 0;
1669
	gnm_float fv   = argv[3] ? value_get_as_float (argv[3]) : 0;
1618
	int type = argv[4] ? !!value_get_as_int (argv[4]) : 0;
1670
	int type       = value_get_paytype (argv[4]);
1671
	gnm_float pvif, fvifa;
1672
1673
	if (!is_valid_paytype (type))
1674
		return value_new_error_VALUE (ei->pos);
1619
1675
1620
	/* Calculate the PVIF and FVIFA */
1676
	/* Calculate the PVIF and FVIFA */
1621
	gnm_float pvif  = calculate_pvif (rate, nper);
1677
	pvif  = calculate_pvif (rate, nper);
1622
	gnm_float fvifa = calculate_fvifa (rate, nper);
1678
	fvifa = calculate_fvifa (rate, nper);
1623
1679
1624
	if (pvif == 0)
1680
	if (pvif == 0)
1625
	        return value_new_error_DIV0 (ei->pos);
1681
	        return value_new_error_DIV0 (ei->pos);
Lines 1712-1725 gnumeric_xnpv (FunctionEvalInfo *ei, Gnm Link Here
1712
	sum = 0;
1768
	sum = 0;
1713
1769
1714
	payments = collect_floats_value (argv[1], ei->pos,
1770
	payments = collect_floats_value (argv[1], ei->pos,
1715
					 COLLECT_IGNORE_STRINGS |
1771
					 COLLECT_COERCE_STRINGS,
1716
					 COLLECT_IGNORE_BOOLS,
1717
					 &p_n, &result);
1772
					 &p_n, &result);
1718
	if (result)
1773
	if (result)
1719
		goto out;
1774
		goto out;
1720
1775
1721
	dates = collect_floats_value (argv[2], ei->pos,
1776
	dates = collect_floats_value (argv[2], ei->pos,
1722
				      COLLECT_DATES,
1777
				      COLLECT_COERCE_STRINGS,
1723
				      &d_n, &result);
1778
				      &d_n, &result);
1724
	if (result)
1779
	if (result)
1725
		goto out;
1780
		goto out;
Lines 1820-1826 gnumeric_xirr (FunctionEvalInfo *ei, Gnm Link Here
1820
	rate0 = argv[2] ? value_get_as_float (argv[2]) : 0.1;
1875
	rate0 = argv[2] ? value_get_as_float (argv[2]) : 0.1;
1821
1876
1822
	p.values = collect_floats_value (argv[0], ei->pos,
1877
	p.values = collect_floats_value (argv[0], ei->pos,
1823
					 COLLECT_IGNORE_STRINGS,
1878
					 COLLECT_COERCE_STRINGS,
1824
					 &n, &result);
1879
					 &n, &result);
1825
	p.dates = NULL;
1880
	p.dates = NULL;
1826
1881
Lines 1828-1840 gnumeric_xirr (FunctionEvalInfo *ei, Gnm Link Here
1828
		goto out;
1883
		goto out;
1829
1884
1830
	p.dates = collect_floats_value (argv[1], ei->pos,
1885
	p.dates = collect_floats_value (argv[1], ei->pos,
1831
					COLLECT_DATES,
1886
					COLLECT_COERCE_STRINGS,
1832
					&d_n, &result);
1887
					&d_n, &result);
1833
	if (result != NULL)
1888
	if (result != NULL)
1834
		goto out;
1889
		goto out;
1835
1890
1836
	p.n = n;
1891
	p.n = n;
1837
	status = goal_seek_newton (&xirr_npv, NULL, &data, &p, rate0);
1892
	status = goal_seek_newton (&xirr_npv, NULL, &data, &p, rate0);
1893
	if (status != GOAL_SEEK_OK) {
1894
		int i;
1895
		for (i = 1; i <= 1024; i += i) {
1896
			(void)goal_seek_point (&xirr_npv, &data, &p, -1 + 10.0 / (i + 9));
1897
			(void)goal_seek_point (&xirr_npv, &data, &p, i);
1898
			status = goal_seek_bisection (&xirr_npv, &data, &p);
1899
			if (status == GOAL_SEEK_OK)
1900
				break;
1901
		}
1902
	}
1838
1903
1839
	if (status == GOAL_SEEK_OK)
1904
	if (status == GOAL_SEEK_OK)
1840
		result = value_new_float (data.root);
1905
		result = value_new_float (data.root);
Lines 1876-1885 gnumeric_fv (FunctionEvalInfo *ei, GnmVa Link Here
1876
	gnm_float nper = value_get_as_float (argv[1]);
1941
	gnm_float nper = value_get_as_float (argv[1]);
1877
	gnm_float pmt  = value_get_as_float (argv[2]);
1942
	gnm_float pmt  = value_get_as_float (argv[2]);
1878
	gnm_float pv   = argv[3] ? value_get_as_float (argv[3]) : 0.;
1943
	gnm_float pv   = argv[3] ? value_get_as_float (argv[3]) : 0.;
1879
	int type = argv[4] ? !!value_get_as_int (argv[4]) : 0;
1944
	int type       = value_get_paytype (argv[4]);
1945
	gnm_float pvif, fvifa;
1880
1946
1881
	gnm_float pvif  = calculate_pvif (rate, nper);
1947
	if (!is_valid_paytype (type))
1882
	gnm_float fvifa = calculate_fvifa (rate, nper);
1948
		return value_new_error_VALUE (ei->pos);
1949
1950
	pvif  = calculate_pvif (rate, nper);
1951
	fvifa = calculate_fvifa (rate, nper);
1883
1952
1884
        return value_new_float (-((pv * pvif) + pmt *
1953
        return value_new_float (-((pv * pvif) + pmt *
1885
				  (1.0 + rate * type) * fvifa));
1954
				  (1.0 + rate * type) * fvifa));
Lines 1917-1923 gnumeric_pmt (FunctionEvalInfo *ei, GnmV Link Here
1917
	gnm_float nper = value_get_as_float (argv[1]);
1986
	gnm_float nper = value_get_as_float (argv[1]);
1918
	gnm_float pv   = value_get_as_float (argv[2]);
1987
	gnm_float pv   = value_get_as_float (argv[2]);
1919
	gnm_float fv   = argv[3] ? value_get_as_float (argv[3]) : 0;
1988
	gnm_float fv   = argv[3] ? value_get_as_float (argv[3]) : 0;
1920
	int type = argv[4] ? !!value_get_as_int (argv[4]) : 0;
1989
	int type       = value_get_paytype (argv[4]);
1990
1991
	if (!is_valid_paytype (type))
1992
		return value_new_error_VALUE (ei->pos);
1921
1993
1922
        return value_new_float (calculate_pmt (rate, nper, pv, fv, type));
1994
        return value_new_float (calculate_pmt (rate, nper, pv, fv, type));
1923
}
1995
}
Lines 1956-1962 gnumeric_ipmt (FunctionEvalInfo *ei, Gnm Link Here
1956
	gnm_float nper = value_get_as_float (argv[2]);
2028
	gnm_float nper = value_get_as_float (argv[2]);
1957
	gnm_float pv   = value_get_as_float (argv[3]);
2029
	gnm_float pv   = value_get_as_float (argv[3]);
1958
	gnm_float fv   = argv[4] ? value_get_as_float (argv[4]) : 0;
2030
	gnm_float fv   = argv[4] ? value_get_as_float (argv[4]) : 0;
1959
	int type = argv[5] ? !!value_get_as_int (argv[5]) : 0;
2031
	int type       = value_get_paytype (argv[5]);
1960
2032
1961
	/*
2033
	/*
1962
	 * It seems that with 20 periods, a period number of 20.99 is
2034
	 * It seems that with 20 periods, a period number of 20.99 is
Lines 1964-1970 gnumeric_ipmt (FunctionEvalInfo *ei, Gnm Link Here
1964
	 */
2036
	 */
1965
	if (per < 1 || per >= nper + 1)
2037
	if (per < 1 || per >= nper + 1)
1966
                return value_new_error_NUM (ei->pos);
2038
                return value_new_error_NUM (ei->pos);
1967
	else {
2039
2040
	if (!is_valid_paytype (type))
2041
		return value_new_error_VALUE (ei->pos);
2042
2043
	{
1968
		gnm_float pmt = calculate_pmt (rate, nper, pv, fv, type);
2044
		gnm_float pmt = calculate_pmt (rate, nper, pv, fv, type);
1969
		gnm_float ipmt = calculate_interest_part (pv, pmt, rate, per - 1);
2045
		gnm_float ipmt = calculate_interest_part (pv, pmt, rate, per - 1);
1970
2046
Lines 2006-2012 gnumeric_ppmt (FunctionEvalInfo *ei, Gnm Link Here
2006
	gnm_float nper = value_get_as_float (argv[2]);
2082
	gnm_float nper = value_get_as_float (argv[2]);
2007
	gnm_float pv   = value_get_as_float (argv[3]);
2083
	gnm_float pv   = value_get_as_float (argv[3]);
2008
	gnm_float fv   = argv[4] ? value_get_as_float (argv[4]) : 0;
2084
	gnm_float fv   = argv[4] ? value_get_as_float (argv[4]) : 0;
2009
	int type = argv[5] ? !!value_get_as_int (argv[5]) : 0;
2085
	int type       = value_get_paytype (argv[5]);
2010
2086
2011
	/*
2087
	/*
2012
	 * It seems that with 20 periods, a period number of 20.99 is
2088
	 * It seems that with 20 periods, a period number of 20.99 is
Lines 2014-2020 gnumeric_ppmt (FunctionEvalInfo *ei, Gnm Link Here
2014
	 */
2090
	 */
2015
	if (per < 1 || per >= nper + 1)
2091
	if (per < 1 || per >= nper + 1)
2016
                return value_new_error_NUM (ei->pos);
2092
                return value_new_error_NUM (ei->pos);
2017
	else {
2093
2094
	if (!is_valid_paytype (type))
2095
		return value_new_error_VALUE (ei->pos);
2096
2097
	{
2018
		gnm_float pmt = calculate_pmt (rate, nper, pv, fv, type);
2098
		gnm_float pmt = calculate_pmt (rate, nper, pv, fv, type);
2019
		gnm_float ipmt = calculate_interest_part (pv, pmt, rate, per - 1);
2099
		gnm_float ipmt = calculate_interest_part (pv, pmt, rate, per - 1);
2020
		return value_new_float (pmt - ipmt);
2100
		return value_new_float (pmt - ipmt);
Lines 2059-2065 gnumeric_nper (FunctionEvalInfo *ei, Gnm Link Here
2059
	gnm_float pmt  = value_get_as_float (argv[1]);
2139
	gnm_float pmt  = value_get_as_float (argv[1]);
2060
	gnm_float pv   = value_get_as_float (argv[2]);
2140
	gnm_float pv   = value_get_as_float (argv[2]);
2061
	gnm_float fv   = argv[3] ? value_get_as_float (argv[3]) : 0;
2141
	gnm_float fv   = argv[3] ? value_get_as_float (argv[3]) : 0;
2062
	int type = argv[4] ? !!value_get_as_int (argv[4]) : 0;
2142
	int type       = value_get_paytype (argv[4]);
2063
2143
2064
	if (rate == 0 && pmt != 0)
2144
	if (rate == 0 && pmt != 0)
2065
		return value_new_float (-(fv + pv) / pmt);
2145
		return value_new_float (-(fv + pv) / pmt);
Lines 2067-2072 gnumeric_nper (FunctionEvalInfo *ei, Gnm Link Here
2067
	if (rate <= 0.0)
2147
	if (rate <= 0.0)
2068
		return value_new_error_DIV0 (ei->pos);
2148
		return value_new_error_DIV0 (ei->pos);
2069
2149
2150
	if (!is_valid_paytype (type))
2151
		return value_new_error_VALUE (ei->pos);
2152
2070
	tmp = (pmt * (1.0 + rate * type) - fv * rate) /
2153
	tmp = (pmt * (1.0 + rate * type) - fv * rate) /
2071
	  (pv * rate + pmt * (1.0 + rate * type));
2154
	  (pv * rate + pmt * (1.0 + rate * type));
2072
	if (tmp <= 0.0)
2155
	if (tmp <= 0.0)
Lines 2120-2127 gnumeric_duration (FunctionEvalInfo *ei, Link Here
2120
2203
2121
	fCoup      = value_get_as_float (argv[2]);
2204
	fCoup      = value_get_as_float (argv[2]);
2122
	fYield     = value_get_as_float (argv[3]);
2205
	fYield     = value_get_as_float (argv[3]);
2123
	conv.freq  = value_get_as_float (argv[4]);
2206
	conv.freq  = value_get_freq (argv[4]);
2124
        conv.basis = argv[5] ? value_get_as_int (argv[5]) : 0;
2207
        conv.basis = value_get_basis (argv[5], BASIS_MSRB_30_360);
2125
2208
2126
        if (!datetime_value_to_g (&nSettle, argv[0], conv.date_conv) ||
2209
        if (!datetime_value_to_g (&nSettle, argv[0], conv.date_conv) ||
2127
	    !datetime_value_to_g (&nMat, argv[1], conv.date_conv) ||
2210
	    !datetime_value_to_g (&nMat, argv[1], conv.date_conv) ||
Lines 2417-2425 gnumeric_price (FunctionEvalInfo *ei, Gn Link Here
2417
	rate       = value_get_as_float (argv[2]);
2500
	rate       = value_get_as_float (argv[2]);
2418
	yield      = value_get_as_float (argv[3]);
2501
	yield      = value_get_as_float (argv[3]);
2419
	redemption = value_get_as_float (argv[4]);
2502
	redemption = value_get_as_float (argv[4]);
2420
        conv.freq  = value_get_as_int (argv[5]);
2503
        conv.freq  = value_get_freq (argv[5]);
2421
	conv.eom   = TRUE;
2504
	conv.eom   = TRUE;
2422
        conv.basis = argv[6] ? value_get_as_int (argv[6]) : 0;
2505
        conv.basis = value_get_basis (argv[6], BASIS_MSRB_30_360);
2423
2506
2424
	if (!datetime_value_to_g (&settlement, argv[0], conv.date_conv) ||
2507
	if (!datetime_value_to_g (&settlement, argv[0], conv.date_conv) ||
2425
	    !datetime_value_to_g (&maturity, argv[1], conv.date_conv))
2508
	    !datetime_value_to_g (&maturity, argv[1], conv.date_conv))
Lines 2493-2500 gnumeric_yield (FunctionEvalInfo *ei, Gn Link Here
2493
	udata.rate       = value_get_as_float (argv[2]);
2576
	udata.rate       = value_get_as_float (argv[2]);
2494
	udata.par        = value_get_as_float (argv[3]);
2577
	udata.par        = value_get_as_float (argv[3]);
2495
	udata.redemption = value_get_as_float (argv[4]);
2578
	udata.redemption = value_get_as_float (argv[4]);
2496
        udata.conv.freq  = value_get_as_int (argv[5]);
2579
        udata.conv.freq  = value_get_freq (argv[5]);
2497
        udata.conv.basis = argv[6] ? value_get_as_int (argv[6]) : 0;
2580
        udata.conv.basis = value_get_basis (argv[6], BASIS_MSRB_30_360);
2498
        udata.conv.eom   = TRUE;
2581
        udata.conv.eom   = TRUE;
2499
        udata.conv.date_conv = workbook_date_conv (ei->pos->sheet->workbook);
2582
        udata.conv.date_conv = workbook_date_conv (ei->pos->sheet->workbook);
2500
2583
Lines 2593-2608 gnumeric_yielddisc (FunctionEvalInfo *ei Link Here
2593
{
2676
{
2594
        GDate     settlement, maturity;
2677
        GDate     settlement, maturity;
2595
	gnm_float fPrice, fRedemp;
2678
	gnm_float fPrice, fRedemp;
2596
	gint      nBase;
2679
	gint      basis;
2597
	gnm_float ret, yfrac;
2680
	gnm_float ret, yfrac;
2598
	GnmDateConventions const *date_conv =
2681
	GnmDateConventions const *date_conv =
2599
		workbook_date_conv (ei->pos->sheet->workbook);
2682
		workbook_date_conv (ei->pos->sheet->workbook);
2600
2683
2601
	fPrice     = value_get_as_float (argv[2]);
2684
	fPrice     = value_get_as_float (argv[2]);
2602
	fRedemp    = value_get_as_float (argv[3]);
2685
	fRedemp    = value_get_as_float (argv[3]);
2603
        nBase      = argv[4] ? value_get_as_int (argv[4]) : 0;
2686
	basis      = value_get_basis (argv[4], BASIS_MSRB_30_360);
2604
2687
2605
        if (!is_valid_basis (nBase) ||
2688
        if (!is_valid_basis (basis) ||
2606
	    !datetime_value_to_g (&settlement, argv[0], date_conv) ||
2689
	    !datetime_value_to_g (&settlement, argv[0], date_conv) ||
2607
	    !datetime_value_to_g (&maturity, argv[1], date_conv))
2690
	    !datetime_value_to_g (&maturity, argv[1], date_conv))
2608
		return value_new_error_NUM (ei->pos);
2691
		return value_new_error_NUM (ei->pos);
Lines 2613-2619 gnumeric_yielddisc (FunctionEvalInfo *ei Link Here
2613
		return value_new_error_NUM (ei->pos);
2696
		return value_new_error_NUM (ei->pos);
2614
2697
2615
        ret = (fRedemp / fPrice) - 1;
2698
        ret = (fRedemp / fPrice) - 1;
2616
	yfrac = yearfrac (&settlement, &maturity, nBase);
2699
	yfrac = yearfrac (&settlement, &maturity, basis);
2617
2700
2618
	return value_new_float (ret / yfrac);
2701
	return value_new_float (ret / yfrac);
2619
}
2702
}
Lines 2653-2673 gnumeric_yieldmat (FunctionEvalInfo *ei, Link Here
2653
{
2736
{
2654
        GDate     nSettle, nMat, nIssue;
2737
        GDate     nSettle, nMat, nIssue;
2655
	gnm_float fRate, fPrice;
2738
	gnm_float fRate, fPrice;
2656
	gint      nBase;
2739
	gint      basis;
2657
	GnmDateConventions const *date_conv =
2740
	GnmDateConventions const *date_conv =
2658
		workbook_date_conv (ei->pos->sheet->workbook);
2741
		workbook_date_conv (ei->pos->sheet->workbook);
2659
2742
2660
	fRate      = value_get_as_float (argv[3]);
2743
	fRate      = value_get_as_float (argv[3]);
2661
	fPrice     = value_get_as_float (argv[4]);
2744
	fPrice     = value_get_as_float (argv[4]);
2662
        nBase      = argv[5] ? value_get_as_int (argv[5]) : 0;
2745
        basis      = value_get_basis (argv[5], BASIS_MSRB_30_360);
2663
2746
2664
        if (nBase < 0 || nBase > 4 || fRate < 0 ||
2747
	if (!is_valid_basis (basis) ||
2748
	    fRate < 0 ||
2665
	    !datetime_value_to_g (&nSettle, argv[0], date_conv) ||
2749
	    !datetime_value_to_g (&nSettle, argv[0], date_conv) ||
2666
	    !datetime_value_to_g (&nMat, argv[1], date_conv) ||
2750
	    !datetime_value_to_g (&nMat, argv[1], date_conv) ||
2667
	    !datetime_value_to_g (&nIssue, argv[2], date_conv))
2751
	    !datetime_value_to_g (&nIssue, argv[2], date_conv))
2668
		return value_new_error_NUM (ei->pos);
2752
		return value_new_error_NUM (ei->pos);
2669
2753
2670
	return get_yieldmat (&nSettle, &nMat, &nIssue, fRate, fPrice, nBase);
2754
	return get_yieldmat (&nSettle, &nMat, &nIssue, fRate, fPrice, basis);
2671
}
2755
}
2672
2756
2673
/***************************************************************************/
2757
/***************************************************************************/
Lines 2798-2805 gnumeric_oddfprice (FunctionEvalInfo *ei Link Here
2798
	redemption = value_get_as_float (argv[6]);
2882
	redemption = value_get_as_float (argv[6]);
2799
2883
2800
        conv.eom   = TRUE;
2884
        conv.eom   = TRUE;
2801
        conv.freq  = value_get_as_int (argv[7]);
2885
        conv.freq  = value_get_freq (argv[7]);
2802
        conv.basis = argv[8] ? value_get_as_int (argv[8]) : 0;
2886
        conv.basis = value_get_basis (argv[8], BASIS_MSRB_30_360);
2803
	conv.date_conv = workbook_date_conv (ei->pos->sheet->workbook);
2887
	conv.date_conv = workbook_date_conv (ei->pos->sheet->workbook);
2804
2888
2805
	if (!datetime_value_to_g (&settlement, argv[0], conv.date_conv) ||
2889
	if (!datetime_value_to_g (&settlement, argv[0], conv.date_conv) ||
Lines 2888-2895 gnumeric_oddfyield (FunctionEvalInfo *ei Link Here
2888
	udata.redemption = value_get_as_float (argv[6]);
2972
	udata.redemption = value_get_as_float (argv[6]);
2889
2973
2890
        udata.conv.eom   = TRUE;
2974
        udata.conv.eom   = TRUE;
2891
        udata.conv.freq  = value_get_as_int (argv[7]);
2975
        udata.conv.freq  = value_get_freq (argv[7]);
2892
        udata.conv.basis = argv[8] ? value_get_as_int (argv[8]) : 0;
2976
        udata.conv.basis = value_get_basis (argv[8], BASIS_MSRB_30_360);
2893
	udata.conv.date_conv = workbook_date_conv (ei->pos->sheet->workbook);
2977
	udata.conv.date_conv = workbook_date_conv (ei->pos->sheet->workbook);
2894
2978
2895
	if (!datetime_value_to_g (&udata.settlement, argv[0], udata.conv.date_conv) ||
2979
	if (!datetime_value_to_g (&udata.settlement, argv[0], udata.conv.date_conv) ||
Lines 2999-3006 gnumeric_oddlprice (FunctionEvalInfo *ei Link Here
2999
	redemption = value_get_as_float (argv[5]);
3083
	redemption = value_get_as_float (argv[5]);
3000
3084
3001
        conv.eom   = TRUE;
3085
        conv.eom   = TRUE;
3002
        conv.freq  = value_get_as_int (argv[6]);
3086
        conv.freq  = value_get_freq (argv[6]);
3003
        conv.basis = argv[7] ? value_get_as_int (argv[7]) : 0;
3087
        conv.basis = value_get_basis (argv[7], BASIS_MSRB_30_360);
3004
	conv.date_conv = workbook_date_conv (ei->pos->sheet->workbook);
3088
	conv.date_conv = workbook_date_conv (ei->pos->sheet->workbook);
3005
3089
3006
	if (!datetime_value_to_g (&settlement, argv[0], conv.date_conv) ||
3090
	if (!datetime_value_to_g (&settlement, argv[0], conv.date_conv) ||
Lines 3090-3097 gnumeric_oddlyield (FunctionEvalInfo *ei Link Here
3090
	redemption = value_get_as_float (argv[5]);
3174
	redemption = value_get_as_float (argv[5]);
3091
3175
3092
        conv.eom   = TRUE;
3176
        conv.eom   = TRUE;
3093
        conv.freq  = value_get_as_int (argv[6]);
3177
        conv.freq  = value_get_freq (argv[6]);
3094
        conv.basis = argv[7] ? value_get_as_int (argv[7]) : 0;
3178
        conv.basis = value_get_basis (argv[7], BASIS_MSRB_30_360);
3095
	conv.date_conv = workbook_date_conv (ei->pos->sheet->workbook);
3179
	conv.date_conv = workbook_date_conv (ei->pos->sheet->workbook);
3096
3180
3097
	if (!datetime_value_to_g (&settlement, argv[0], conv.date_conv) ||
3181
	if (!datetime_value_to_g (&settlement, argv[0], conv.date_conv) ||
Lines 3156-3162 gnumeric_amordegrc (FunctionEvalInfo *ei Link Here
3156
{
3240
{
3157
        GDate     nDate, nFirstPer;
3241
        GDate     nDate, nFirstPer;
3158
	gnm_float fRestVal, fRate, fCost;
3242
	gnm_float fRestVal, fRate, fCost;
3159
	gint      nBase, nPer;
3243
	gint      basis, nPer;
3160
	GnmDateConventions const *date_conv =
3244
	GnmDateConventions const *date_conv =
3161
		workbook_date_conv (ei->pos->sheet->workbook);
3245
		workbook_date_conv (ei->pos->sheet->workbook);
3162
3246
Lines 3164-3178 gnumeric_amordegrc (FunctionEvalInfo *ei Link Here
3164
	fRestVal   = value_get_as_float (argv[3]);
3248
	fRestVal   = value_get_as_float (argv[3]);
3165
        nPer       = value_get_as_int (argv[4]);
3249
        nPer       = value_get_as_int (argv[4]);
3166
	fRate      = value_get_as_float (argv[5]);
3250
	fRate      = value_get_as_float (argv[5]);
3167
        nBase      = argv[6] ? value_get_as_int (argv[6]) : 0;
3251
        basis      = value_get_basis (argv[6], BASIS_MSRB_30_360);
3168
3252
3169
        if (nBase < 0 || nBase > 4 || fRate < 0 ||
3253
        if (!is_valid_basis (basis) ||
3254
	    fRate < 0 ||
3170
	    !datetime_value_to_g (&nDate, argv[1], date_conv) ||
3255
	    !datetime_value_to_g (&nDate, argv[1], date_conv) ||
3171
	    !datetime_value_to_g (&nFirstPer, argv[2], date_conv))
3256
	    !datetime_value_to_g (&nFirstPer, argv[2], date_conv))
3172
		return value_new_error_NUM (ei->pos);
3257
		return value_new_error_NUM (ei->pos);
3173
3258
3174
	return get_amordegrc (fCost, &nDate, &nFirstPer,
3259
	return get_amordegrc (fCost, &nDate, &nFirstPer,
3175
			      fRestVal, nPer, fRate, nBase);
3260
			      fRestVal, nPer, fRate, basis);
3176
}
3261
}
3177
3262
3178
/***************************************************************************/
3263
/***************************************************************************/
Lines 3216-3222 gnumeric_amorlinc (FunctionEvalInfo *ei, Link Here
3216
{
3301
{
3217
        GDate     nDate, nFirstPer;
3302
        GDate     nDate, nFirstPer;
3218
	gnm_float fCost, fRestVal, fRate;
3303
	gnm_float fCost, fRestVal, fRate;
3219
	gint      nPer, nBase;
3304
	gint      nPer, basis;
3220
	GnmDateConventions const *date_conv =
3305
	GnmDateConventions const *date_conv =
3221
		workbook_date_conv (ei->pos->sheet->workbook);
3306
		workbook_date_conv (ei->pos->sheet->workbook);
3222
3307
Lines 3224-3238 gnumeric_amorlinc (FunctionEvalInfo *ei, Link Here
3224
	fRestVal   = value_get_as_float (argv[3]);
3309
	fRestVal   = value_get_as_float (argv[3]);
3225
        nPer       = value_get_as_int (argv[4]);
3310
        nPer       = value_get_as_int (argv[4]);
3226
	fRate      = value_get_as_float (argv[5]);
3311
	fRate      = value_get_as_float (argv[5]);
3227
        nBase      = argv[6] ? value_get_as_int (argv[6]) : 0;
3312
        basis      = value_get_basis (argv[6], BASIS_MSRB_30_360);
3228
3313
3229
        if (nBase < 0 || nBase > 4 || fRate < 0 ||
3314
        if (!is_valid_basis (basis) ||
3315
	    fRate < 0 ||
3230
	    !datetime_value_to_g (&nDate, argv[1], date_conv) ||
3316
	    !datetime_value_to_g (&nDate, argv[1], date_conv) ||
3231
	    !datetime_value_to_g (&nFirstPer, argv[2], date_conv))
3317
	    !datetime_value_to_g (&nFirstPer, argv[2], date_conv))
3232
		return value_new_error_NUM (ei->pos);
3318
		return value_new_error_NUM (ei->pos);
3233
3319
3234
	return get_amorlinc (fCost, &nDate, &nFirstPer,
3320
	return get_amorlinc (fCost, &nDate, &nFirstPer,
3235
			     fRestVal, nPer, fRate, nBase);
3321
			     fRestVal, nPer, fRate, basis);
3236
}
3322
}
3237
3323
3238
/***************************************************************************/
3324
/***************************************************************************/
Lines 3539-3549 gnumeric_cumipmt (FunctionEvalInfo *ei, Link Here
3539
	fVal        = value_get_as_float (argv[2]);
3625
	fVal        = value_get_as_float (argv[2]);
3540
        nStartPer   = value_get_as_int (argv[3]);
3626
        nStartPer   = value_get_as_int (argv[3]);
3541
        nEndPer     = value_get_as_int (argv[4]);
3627
        nEndPer     = value_get_as_int (argv[4]);
3542
        nPayType    = value_get_as_int (argv[5]);
3628
        nPayType    = value_get_paytype (argv[5]);
3543
3629
3544
        if ( nStartPer < 1 || nEndPer < nStartPer || fRate <= 0
3630
        if ( nStartPer < 1 || nEndPer < nStartPer || fRate <= 0
3545
	     || nEndPer > nNumPeriods || nNumPeriods <= 0
3631
	     || nEndPer > nNumPeriods || nNumPeriods <= 0
3546
	     || fVal <= 0 || (nPayType != 0 && nPayType != 1) ) {
3632
	     || fVal <= 0 || !is_valid_paytype (nPayType) ) {
3547
		result = value_new_error_NUM (ei->pos);
3633
		result = value_new_error_NUM (ei->pos);
3548
		goto out;
3634
		goto out;
3549
	}
3635
	}
Lines 3589-3599 gnumeric_cumprinc (FunctionEvalInfo *ei, Link Here
3589
	fVal        = value_get_as_float (argv[2]);
3675
	fVal        = value_get_as_float (argv[2]);
3590
        nStartPer   = value_get_as_int (argv[3]);
3676
        nStartPer   = value_get_as_int (argv[3]);
3591
        nEndPer     = value_get_as_int (argv[4]);
3677
        nEndPer     = value_get_as_int (argv[4]);
3592
        nPayType    = value_get_as_int (argv[5]);
3678
        nPayType    = value_get_paytype (argv[5]);
3593
3679
3594
        if ( nStartPer < 1 || nEndPer < nStartPer || fRate <= 0
3680
        if ( nStartPer < 1 || nEndPer < nStartPer || fRate <= 0
3595
	     || nEndPer > nNumPeriods || nNumPeriods <= 0
3681
	     || nEndPer > nNumPeriods || nNumPeriods <= 0
3596
	     || fVal <= 0 || (nPayType != 0 && nPayType != 1) ) {
3682
	     || fVal <= 0 || !is_valid_paytype (nPayType)) {
3597
		result = value_new_error_NUM (ei->pos);
3683
		result = value_new_error_NUM (ei->pos);
3598
		goto out;
3684
		goto out;
3599
	}
3685
	}
Lines 3648-3655 gnumeric_mduration (FunctionEvalInfo *ei Link Here
3648
3734
3649
	fCoup      = value_get_as_float (argv[2]);
3735
	fCoup      = value_get_as_float (argv[2]);
3650
	fYield     = value_get_as_float (argv[3]);
3736
	fYield     = value_get_as_float (argv[3]);
3651
	conv.freq  = value_get_as_float (argv[4]);
3737
	conv.freq  = value_get_freq (argv[4]);
3652
        conv.basis = argv[5] ? value_get_as_int (argv[5]) : 0;
3738
        conv.basis = value_get_basis (argv[5], BASIS_MSRB_30_360);
3653
        conv.eom   = FALSE;
3739
        conv.eom   = FALSE;
3654
3740
3655
        if (!is_valid_basis (conv.basis) ||
3741
        if (!is_valid_basis (conv.basis) ||
Lines 3695-3702 gnumeric_vdb (FunctionEvalInfo *ei, GnmV Link Here
3695
	life         = value_get_as_float (argv[2]);
3781
	life         = value_get_as_float (argv[2]);
3696
	start_period = value_get_as_float (argv[3]);
3782
	start_period = value_get_as_float (argv[3]);
3697
	end_period   = value_get_as_float (argv[4]);
3783
	end_period   = value_get_as_float (argv[4]);
3698
	factor       = value_get_as_float (argv[5]); /* Default could be 2.0 */
3784
	factor       = argv[5] ? value_get_as_float (argv[5]) : 2;
3699
        bflag        = argv[6] ? value_get_as_int (argv[6]) : FALSE;
3785
        bflag        = argv[6] ? value_get_as_int (argv[6]) : 0;
3700
3786
3701
        if ( start_period < 0 || end_period < start_period
3787
        if ( start_period < 0 || end_period < start_period
3702
	     || end_period > life || cost < 0 || salvage > cost
3788
	     || end_period > life || cost < 0 || salvage > cost
(-)plugins/fn-info/functions.c (-8 / +11 lines)
Lines 1228-1235 cb_countblank (Sheet *sheet, int col, in Link Here
1228
	       GnmCell *cell, void *user_data)
1228
	       GnmCell *cell, void *user_data)
1229
{
1229
{
1230
	cell_eval (cell);
1230
	cell_eval (cell);
1231
	if (!cell_is_empty (cell))
1231
	if (!cell_is_empty (cell)) {
1232
		const GnmValue *v = cell->value;
1233
		if (VALUE_IS_STRING (v) && value_peek_string (v)[0] == 0)
1234
			; /* Nothing -- the empty string is blank.  */
1235
		else
1232
		*((int *)user_data) -= 1;
1236
		*((int *)user_data) -= 1;
1237
	}
1233
	return NULL;
1238
	return NULL;
1234
}
1239
}
1235
1240
Lines 1759-1779 static char const *help_type = { Link Here
1759
static GnmValue *
1764
static GnmValue *
1760
gnumeric_type (FunctionEvalInfo *ei, GnmValue **argv)
1765
gnumeric_type (FunctionEvalInfo *ei, GnmValue **argv)
1761
{
1766
{
1762
	switch (argv[0]->type) {
1767
	const GnmValue *v = argv[0];
1763
	/* case VALUE_EMPTY : not possible, S arguments convert this to int(0)
1768
	switch (v ? VALUE_TYPE (v) : VALUE_EMPTY) {
1764
	 * This is XL compatible, although I don't really agree with it
1765
	 */
1766
	case VALUE_BOOLEAN:
1769
	case VALUE_BOOLEAN:
1767
		return value_new_int (4);
1770
		return value_new_int (4);
1771
	case VALUE_EMPTY:
1768
	case VALUE_INTEGER:
1772
	case VALUE_INTEGER:
1769
	case VALUE_FLOAT:
1773
	case VALUE_FLOAT:
1770
		return value_new_int (1);
1774
		return value_new_int (1);
1775
	case VALUE_CELLRANGE:
1771
	case VALUE_ERROR:
1776
	case VALUE_ERROR:
1772
		return value_new_int (16);
1777
		return value_new_int (16);
1773
	case VALUE_STRING:
1778
	case VALUE_STRING:
1774
		return value_new_int (2);
1779
		return value_new_int (2);
1775
	/* case VALUE_CELLRANGE: S argument handles this */
1776
#warning FIXME : S arguments will filter arrays
1777
	case VALUE_ARRAY:
1780
	case VALUE_ARRAY:
1778
		return value_new_int (64);
1781
		return value_new_int (64);
1779
	default:
1782
	default:
Lines 1844-1850 const GnmFuncDescriptor info_functions[] Link Here
1844
	{ "isnontext",	"E", N_("value"), &help_isnontext,
1847
	{ "isnontext",	"E", N_("value"), &help_isnontext,
1845
	  gnumeric_isnontext, NULL, NULL, NULL, NULL,
1848
	  gnumeric_isnontext, NULL, NULL, NULL, NULL,
1846
	  GNM_FUNC_SIMPLE, GNM_FUNC_IMPL_STATUS_COMPLETE, GNM_FUNC_TEST_STATUS_BASIC },
1849
	  GNM_FUNC_SIMPLE, GNM_FUNC_IMPL_STATUS_COMPLETE, GNM_FUNC_TEST_STATUS_BASIC },
1847
	{ "isnumber",	"B", N_("value"), &help_isnumber,
1850
 	{ "isnumber",	"E", N_("value"), &help_isnumber,
1848
	  gnumeric_isnumber, NULL, NULL, NULL, NULL,
1851
	  gnumeric_isnumber, NULL, NULL, NULL, NULL,
1849
	  GNM_FUNC_SIMPLE, GNM_FUNC_IMPL_STATUS_COMPLETE, GNM_FUNC_TEST_STATUS_BASIC },
1852
	  GNM_FUNC_SIMPLE, GNM_FUNC_IMPL_STATUS_COMPLETE, GNM_FUNC_TEST_STATUS_BASIC },
1850
	{ "isodd",	"S", N_("value"), &help_isodd,
1853
	{ "isodd",	"S", N_("value"), &help_isodd,
(-)plugins/fn-logical/functions.c (-3 / +9 lines)
Lines 72-82 static GnmValue * Link Here
72
callback_function_and (const GnmEvalPos *ep, GnmValue *value, void *closure)
72
callback_function_and (const GnmEvalPos *ep, GnmValue *value, void *closure)
73
{
73
{
74
	int *result = closure;
74
	int *result = closure;
75
	gboolean err;
76
75
76
	if (!VALUE_IS_STRING (value)) {
77
		gboolean err;
77
	*result = value_get_as_bool (value, &err) && *result;
78
	*result = value_get_as_bool (value, &err) && *result;
78
	if (err)
79
	if (err)
79
		return value_new_error_VALUE (ep);
80
		return value_new_error_VALUE (ep);
81
	}
80
82
81
	return NULL;
83
	return NULL;
82
}
84
}
Lines 159-169 static GnmValue * Link Here
159
callback_function_or (const GnmEvalPos *ep, GnmValue *value, void *closure)
161
callback_function_or (const GnmEvalPos *ep, GnmValue *value, void *closure)
160
{
162
{
161
	int *result = closure;
163
	int *result = closure;
162
	gboolean err;
163
164
165
	if (!VALUE_IS_STRING (value)) {
166
		gboolean err;
164
	*result = value_get_as_bool (value, &err) || *result == 1;
167
	*result = value_get_as_bool (value, &err) || *result == 1;
165
	if (err)
168
	if (err)
166
		return value_new_error_VALUE (ep);
169
		return value_new_error_VALUE (ep);
170
	}
167
171
168
	return NULL;
172
	return NULL;
169
}
173
}
Lines 216-226 static GnmValue * Link Here
216
callback_function_xor (const GnmEvalPos *ep, GnmValue *value, void *closure)
220
callback_function_xor (const GnmEvalPos *ep, GnmValue *value, void *closure)
217
{
221
{
218
	int *result = closure;
222
	int *result = closure;
219
	gboolean err;
220
223
224
	if (!VALUE_IS_STRING (value)) {
225
		gboolean err;
221
	*result = value_get_as_bool (value, &err) ^ (*result == 1);
226
	*result = value_get_as_bool (value, &err) ^ (*result == 1);
222
	if (err)
227
	if (err)
223
		return value_new_error_VALUE (ep);
228
		return value_new_error_VALUE (ep);
229
	}
224
230
225
	return NULL;
231
	return NULL;
226
}
232
}
(-)plugins/fn-lookup/functions.c (-4 / +4 lines)
Lines 1231-1237 GnmFuncDescriptor const lookup_functions Link Here
1231
	{ "columns",   "A",    N_("ref"),
1231
	{ "columns",   "A",    N_("ref"),
1232
	  &help_columns, gnumeric_columns, NULL, NULL, NULL, NULL,
1232
	  &help_columns, gnumeric_columns, NULL, NULL, NULL, NULL,
1233
	  GNM_FUNC_SIMPLE, GNM_FUNC_IMPL_STATUS_COMPLETE, GNM_FUNC_TEST_STATUS_BASIC },
1233
	  GNM_FUNC_SIMPLE, GNM_FUNC_IMPL_STATUS_COMPLETE, GNM_FUNC_TEST_STATUS_BASIC },
1234
	{ "hlookup",   "BAf|bb", N_("val,range,col_idx,approx,as_index"),
1234
 	{ "hlookup",   "EAf|bb", N_("val,range,col_idx,approx,as_index"),
1235
	  &help_hlookup, gnumeric_hlookup, NULL, NULL, NULL, NULL,
1235
	  &help_hlookup, gnumeric_hlookup, NULL, NULL, NULL, NULL,
1236
	  GNM_FUNC_SIMPLE, GNM_FUNC_IMPL_STATUS_COMPLETE, GNM_FUNC_TEST_STATUS_BASIC },
1236
	  GNM_FUNC_SIMPLE, GNM_FUNC_IMPL_STATUS_COMPLETE, GNM_FUNC_TEST_STATUS_BASIC },
1237
	{ "hyperlink", "s|s", N_("link_location, label"),
1237
	{ "hyperlink", "s|s", N_("link_location, label"),
Lines 1243-1252 GnmFuncDescriptor const lookup_functions Link Here
1243
	{ "index",     "A|fff",N_("reference,row,col,area"),
1243
	{ "index",     "A|fff",N_("reference,row,col,area"),
1244
	  &help_index,    NULL, gnumeric_index, NULL, NULL, NULL,
1244
	  &help_index,    NULL, gnumeric_index, NULL, NULL, NULL,
1245
	  GNM_FUNC_SIMPLE, GNM_FUNC_IMPL_STATUS_COMPLETE, GNM_FUNC_TEST_STATUS_BASIC },
1245
	  GNM_FUNC_SIMPLE, GNM_FUNC_IMPL_STATUS_COMPLETE, GNM_FUNC_TEST_STATUS_BASIC },
1246
	{ "lookup",    "BA|r", N_("val,range,range"),
1246
 	{ "lookup",    "EA|r", N_("val,range,range"),
1247
	  &help_lookup,   gnumeric_lookup, NULL, NULL, NULL, NULL,
1247
	  &help_lookup,   gnumeric_lookup, NULL, NULL, NULL, NULL,
1248
	  GNM_FUNC_SIMPLE, GNM_FUNC_IMPL_STATUS_COMPLETE, GNM_FUNC_TEST_STATUS_BASIC },
1248
	  GNM_FUNC_SIMPLE, GNM_FUNC_IMPL_STATUS_COMPLETE, GNM_FUNC_TEST_STATUS_BASIC },
1249
	{ "match",     "BA|f", N_("val,range,approx"),
1249
 	{ "match",     "EA|f", N_("val,range,approx"),
1250
	  &help_match,    gnumeric_match, NULL, NULL, NULL, NULL,
1250
	  &help_match,    gnumeric_match, NULL, NULL, NULL, NULL,
1251
	  GNM_FUNC_SIMPLE, GNM_FUNC_IMPL_STATUS_COMPLETE, GNM_FUNC_TEST_STATUS_BASIC },
1251
	  GNM_FUNC_SIMPLE, GNM_FUNC_IMPL_STATUS_COMPLETE, GNM_FUNC_TEST_STATUS_BASIC },
1252
	{ "offset",    "rff|ff",N_("ref,row,col,height,width"),
1252
	{ "offset",    "rff|ff",N_("ref,row,col,height,width"),
Lines 1261-1267 GnmFuncDescriptor const lookup_functions Link Here
1261
	{ "transpose", "A",    N_("array"),
1261
	{ "transpose", "A",    N_("array"),
1262
	  &help_transpose, gnumeric_transpose, NULL, NULL, NULL, NULL,
1262
	  &help_transpose, gnumeric_transpose, NULL, NULL, NULL, NULL,
1263
	  GNM_FUNC_RETURNS_NON_SCALAR, GNM_FUNC_IMPL_STATUS_COMPLETE, GNM_FUNC_TEST_STATUS_BASIC },
1263
	  GNM_FUNC_RETURNS_NON_SCALAR, GNM_FUNC_IMPL_STATUS_COMPLETE, GNM_FUNC_TEST_STATUS_BASIC },
1264
	{ "vlookup",   "BAf|bb", N_("val,range,col_idx,approx,as_index"),
1264
 	{ "vlookup",   "EAf|bb", N_("val,range,col_idx,approx,as_index"),
1265
	  &help_vlookup, gnumeric_vlookup, NULL, NULL, NULL, NULL,
1265
	  &help_vlookup, gnumeric_vlookup, NULL, NULL, NULL, NULL,
1266
	  GNM_FUNC_SIMPLE, GNM_FUNC_IMPL_STATUS_COMPLETE, GNM_FUNC_TEST_STATUS_BASIC },
1266
	  GNM_FUNC_SIMPLE, GNM_FUNC_IMPL_STATUS_COMPLETE, GNM_FUNC_TEST_STATUS_BASIC },
1267
1267
(-)plugins/fn-math/functions.c (-59 / +84 lines)
Lines 454-461 static char const *help_atan2 = { Link Here
454
static GnmValue *
454
static GnmValue *
455
gnumeric_atan2 (FunctionEvalInfo *ei, GnmValue **args)
455
gnumeric_atan2 (FunctionEvalInfo *ei, GnmValue **args)
456
{
456
{
457
	return value_new_float (atan2gnum (value_get_as_float (args [1]),
457
	gnm_float x = value_get_as_float (args [0]);
458
					   value_get_as_float (args [0])));
458
	gnm_float y = value_get_as_float (args [1]);
459
460
	if (x == 0 && y == 0)
461
		return value_new_error_DIV0 (ei->pos);
462
463
	return value_new_float (atan2gnum (y, x));
459
}
464
}
460
465
461
/***************************************************************************/
466
/***************************************************************************/
Lines 541-548 gnumeric_countif (FunctionEvalInfo *ei, Link Here
541
	 * 1) @range must be a range, arrays are not supported
546
	 * 1) @range must be a range, arrays are not supported
542
	 * 2) @range can not be 3d */
547
	 * 2) @range can not be 3d */
543
	if (r->type != VALUE_CELLRANGE ||
548
	if (r->type != VALUE_CELLRANGE ||
544
	    (sheet = eval_sheet (r->cell.a.sheet, ei->pos->sheet)) !=
549
	    ((sheet = eval_sheet (r->cell.a.sheet, ei->pos->sheet)) != r->cell.b.sheet &&
545
		    eval_sheet (r->cell.b.sheet, ei->pos->sheet) ||
550
	      r->cell.b.sheet != NULL) ||
546
	    (!VALUE_IS_NUMBER (argv[1]) && argv[1]->type != VALUE_STRING))
551
	    (!VALUE_IS_NUMBER (argv[1]) && argv[1]->type != VALUE_STRING))
547
	        return value_new_error_VALUE (ei->pos);
552
	        return value_new_error_VALUE (ei->pos);
548
553
Lines 638-645 gnumeric_sumif (FunctionEvalInfo *ei, Gn Link Here
638
	 * 1) @range must be a range, arrays are not supported
643
	 * 1) @range must be a range, arrays are not supported
639
	 * 2) @range can not be 3d */
644
	 * 2) @range can not be 3d */
640
	if (r->type != VALUE_CELLRANGE ||
645
	if (r->type != VALUE_CELLRANGE ||
641
	    (sheet = eval_sheet (r->cell.a.sheet, ei->pos->sheet)) !=
646
	    ((sheet = eval_sheet (r->cell.a.sheet, ei->pos->sheet)) != r->cell.b.sheet &&
642
		    eval_sheet (r->cell.b.sheet, ei->pos->sheet) ||
647
	      r->cell.b.sheet != NULL) ||
643
	    (!VALUE_IS_NUMBER (argv[1]) && argv[1]->type != VALUE_STRING))
648
	    (!VALUE_IS_NUMBER (argv[1]) && argv[1]->type != VALUE_STRING))
644
	        return value_new_error_VALUE (ei->pos);
649
	        return value_new_error_VALUE (ei->pos);
645
650
Lines 648-654 gnumeric_sumif (FunctionEvalInfo *ei, Gn Link Here
648
	if (NULL != argv[2]) {
653
	if (NULL != argv[2]) {
649
		GnmValueRange const *target = &argv[2]->v_range;
654
		GnmValueRange const *target = &argv[2]->v_range;
650
		res.target_sheet = eval_sheet (target->cell.a.sheet, ei->pos->sheet);
655
		res.target_sheet = eval_sheet (target->cell.a.sheet, ei->pos->sheet);
651
		if (res.target_sheet != eval_sheet (target->cell.b.sheet, ei->pos->sheet))
656
		if (target->cell.b.sheet && res.target_sheet != target->cell.b.sheet)
652
			return value_new_error_VALUE (ei->pos);
657
			return value_new_error_VALUE (ei->pos);
653
		res.offset.col = target->cell.a.col - r->cell.a.col;
658
		res.offset.col = target->cell.a.col - r->cell.a.col;
654
		res.offset.row = target->cell.a.row - r->cell.a.row;
659
		res.offset.row = target->cell.a.row - r->cell.a.row;
Lines 707-722 gnumeric_ceiling (FunctionEvalInfo *ei, Link Here
707
712
708
	if (argv[1] == NULL)
713
	if (argv[1] == NULL)
709
	        s = (number >= 0) ? 1.0 : -1.0;
714
	        s = (number >= 0) ? 1.0 : -1.0;
710
	else {
715
	else
711
	        s = value_get_as_float (argv[1]);
716
	        s = value_get_as_float (argv[1]);
712
	}
713
717
714
	if (number == 0)
718
	if (number == 0 || s == 0)
715
		return value_new_int (0);
719
		return value_new_int (0);
716
720
717
	if (s == 0)
718
		return value_new_error_DIV0 (ei->pos);
719
720
	if (number / s < 0)
721
	if (number / s < 0)
721
		return value_new_error_NUM (ei->pos);
722
		return value_new_error_NUM (ei->pos);
722
723
Lines 1585-1601 static char const *help_trunc = { Link Here
1585
static GnmValue *
1586
static GnmValue *
1586
gnumeric_trunc (FunctionEvalInfo *ei, GnmValue **argv)
1587
gnumeric_trunc (FunctionEvalInfo *ei, GnmValue **argv)
1587
{
1588
{
1588
        gnm_float number, p10;
1589
	gnm_float number = value_get_as_float (argv[0]);
1589
        int digits;
1590
	gnm_float digits = argv[1] ? value_get_as_float (argv[1]) : 0;
1590
1591
1591
	number = value_get_as_float (argv[0]);
1592
	if (digits >= 0) {
1592
	if (argv[1] == NULL)
1593
		if (digits <= GNUM_MAX_EXP) {
1593
	        digits = 0;
1594
			gnm_float p10 = gpow10 ((int)digits);
1594
	else
1595
			number = gnumeric_fake_trunc (number * p10) / p10;
1595
	        digits = value_get_as_int (argv[1]);
1596
		}
1597
	} else {
1598
		if (digits >= GNUM_MIN_EXP) {
1599
			/* Keep p10 integer.  */
1600
			gnm_float p10 = gpow10 ((int)-digits);
1601
			number = gnumeric_fake_trunc (number / p10) * p10;
1602
		} else
1603
			number = 0;
1604
	}
1596
1605
1597
	p10 = gpow10 (digits);
1606
	return value_new_float (number);
1598
	return value_new_float (gnumeric_fake_trunc (number * p10) / p10);
1599
}
1607
}
1600
1608
1601
/***************************************************************************/
1609
/***************************************************************************/
Lines 1700-1717 static GnmValue * Link Here
1700
gnumeric_factdouble (FunctionEvalInfo *ei, GnmValue **argv)
1708
gnumeric_factdouble (FunctionEvalInfo *ei, GnmValue **argv)
1701
1709
1702
{
1710
{
1703
        int number;
1711
	gnm_float number = value_get_as_float (argv[0]);
1704
	int n;
1712
	int inumber, n;
1705
	gnm_float product = 1;
1713
	gnm_float res;
1706
1714
1707
	number = value_get_as_int (argv[0]);
1708
	if (number < 0)
1715
	if (number < 0)
1709
		return value_new_error_NUM (ei->pos);
1716
		return value_new_error_NUM (ei->pos);
1710
1717
1711
	for (n = number; n > 0; n -= 2)
1718
	inumber = (int)MIN (number, (gnm_float)INT_MAX);
1712
	        product *= n;
1719
	n = (inumber + 1) / 2;
1720
1721
	if (inumber & 1) {
1722
		gnm_float lres = lgammagnum (n + 0.5) + n * M_LN2gnum;
1723
		/* Round as the result ought to be integer.  */
1724
		res = floorgnum (0.5 + expgnum (lres) / sqrtgnum (M_PIgnum));
1725
	} else
1726
		res = fact (n) * gpow2 (n);
1713
1727
1714
	return value_new_float (product);
1728
	return value_new_float (res);
1715
}
1729
}
1716
1730
1717
/***************************************************************************/
1731
/***************************************************************************/
Lines 1783-1792 static char const *help_quotient = { Link Here
1783
static GnmValue *
1797
static GnmValue *
1784
gnumeric_quotient (FunctionEvalInfo *ei, GnmValue **argv)
1798
gnumeric_quotient (FunctionEvalInfo *ei, GnmValue **argv)
1785
{
1799
{
1786
        gnm_float num, den;
1800
	gnm_float num = value_get_as_float (argv[0]);
1787
1801
	gnm_float den = value_get_as_float (argv[1]);
1788
	num = value_get_as_float (argv[0]);
1789
	den = value_get_as_float (argv[1]);
1790
1802
1791
	if (den == 0)
1803
	if (den == 0)
1792
	        return value_new_error_DIV0 (ei->pos);
1804
	        return value_new_error_DIV0 (ei->pos);
Lines 1888-1904 static char const *help_rounddown = { Link Here
1888
static GnmValue *
1900
static GnmValue *
1889
gnumeric_rounddown (FunctionEvalInfo *ei, GnmValue **argv)
1901
gnumeric_rounddown (FunctionEvalInfo *ei, GnmValue **argv)
1890
{
1902
{
1891
        gnm_float number, p10;
1903
 	return gnumeric_trunc (ei, argv);
1892
        int digits;
1893
1894
	number = value_get_as_float (argv[0]);
1895
	if (argv[1] == NULL)
1896
	        digits = 0;
1897
	else
1898
	        digits = value_get_as_int (argv[1]);
1899
1900
	p10 = gpow10 (digits);
1901
	return value_new_float (gnumeric_fake_floor (number * p10) / p10);
1902
}
1904
}
1903
1905
1904
/***************************************************************************/
1906
/***************************************************************************/
Lines 1932-1945 static char const *help_round = { Link Here
1932
static GnmValue *
1934
static GnmValue *
1933
gnumeric_round (FunctionEvalInfo *ei, GnmValue **argv)
1935
gnumeric_round (FunctionEvalInfo *ei, GnmValue **argv)
1934
{
1936
{
1935
        gnm_float number, p10;
1937
	gnm_float number = value_get_as_float (argv[0]);
1936
        int     digits;
1938
	gnm_float digits = argv[1] ? value_get_as_float (argv[1]) : 0;
1937
1939
1938
	number = value_get_as_float (argv[0]);
1940
	if (digits >= 0) {
1939
	digits = argv[1] ? value_get_as_int (argv[1]) : 0;
1941
		if (digits <= GNUM_MAX_EXP) {
1942
			gnm_float p10 = gpow10 ((int)digits);
1943
			number = gnumeric_fake_round (number * p10) / p10;
1944
		}
1945
	} else {
1946
		if (digits >= GNUM_MIN_EXP) {
1947
			/* Keep p10 integer.  */
1948
			gnm_float p10 = gpow10 ((int)-digits);
1949
			number = gnumeric_fake_round (number / p10) * p10;
1950
		} else
1951
			number = 0;
1952
	}
1940
1953
1941
	p10 = gpow10 (digits);
1954
	return value_new_float (number);
1942
	return value_new_float (gnumeric_fake_round (number * p10) / p10);
1943
}
1955
}
1944
1956
1945
/***************************************************************************/
1957
/***************************************************************************/
Lines 1970-1989 static char const *help_roundup = { Link Here
1970
	   "@SEEALSO=ROUND,ROUNDDOWN")
1982
	   "@SEEALSO=ROUND,ROUNDDOWN")
1971
};
1983
};
1972
1984
1985
static gnm_float
1986
gnm_fake_roundup (gnm_float x)
1987
{
1988
	return (x < 0) ? gnumeric_fake_floor (x) : gnumeric_fake_ceil (x);
1989
}
1990
1973
static GnmValue *
1991
static GnmValue *
1974
gnumeric_roundup (FunctionEvalInfo *ei, GnmValue **argv)
1992
gnumeric_roundup (FunctionEvalInfo *ei, GnmValue **argv)
1975
{
1993
{
1976
        gnm_float number, p10;
1994
	gnm_float number = value_get_as_float (argv[0]);
1977
        int digits;
1995
	gnm_float digits = argv[1] ? value_get_as_float (argv[1]) : 0;
1978
1996
1979
	number = value_get_as_float (argv[0]);
1997
	if (digits >= 0) {
1980
	if (argv[1] == NULL)
1998
		if (digits <= GNUM_MAX_EXP) {
1981
	        digits = 0;
1999
			gnm_float p10 = gpow10 ((int)digits);
1982
	else
2000
			number = gnm_fake_roundup (number * p10) / p10;
1983
	        digits = value_get_as_int (argv[1]);
2001
		}
2002
	} else {
2003
		if (digits >= GNUM_MIN_EXP) {
2004
			/* Keep p10 integer.  */
2005
			gnm_float p10 = gpow10 ((int)-digits);
2006
			number = gnm_fake_roundup (number / p10) * p10;
2007
		} else
2008
			number = 0;
2009
	}
1984
2010
1985
	p10 = gpow10 (digits);
2011
	return value_new_float (number);
1986
	return value_new_float (gnumeric_fake_ceil (number * p10) / p10);
1987
}
2012
}
1988
2013
1989
/***************************************************************************/
2014
/***************************************************************************/
(-)plugins/fn-stat/functions.c (-127 / +58 lines)
Lines 383-390 static char const *help_trimmean = { Link Here
383
static int
383
static int
384
range_trimmean (const gnm_float *xs, int n, gnm_float *res)
384
range_trimmean (const gnm_float *xs, int n, gnm_float *res)
385
{
385
{
386
	gnm_float p, sum = 0;
386
	gnm_float p;
387
	int tc, c, i;
387
	int tc, c;
388
388
389
	if (n < 2)
389
	if (n < 2)
390
		return 1;
390
		return 1;
Lines 393-399 range_trimmean (const gnm_float *xs, int Link Here
393
	if (p < 0 || p > 1)
393
	if (p < 0 || p > 1)
394
		return 1;
394
		return 1;
395
395
396
	tc = (n * p) / 2;
396
	tc = gnumeric_fake_floor ((n * p) / 2);
397
	c = n - 2 * tc;
397
	c = n - 2 * tc;
398
	if (c == 0)
398
	if (c == 0)
399
		return 1;
399
		return 1;
Lines 401-411 range_trimmean (const gnm_float *xs, int Link Here
401
	/* OK, so we ignore the constness here.  Tough.  */
401
	/* OK, so we ignore the constness here.  Tough.  */
402
	qsort ((gnm_float *) xs, n, sizeof (xs[0]), (void *) &float_compare);
402
	qsort ((gnm_float *) xs, n, sizeof (xs[0]), (void *) &float_compare);
403
403
404
	for (i = tc; i < n - tc; i++)
404
	return range_average (xs + tc, c, res);
405
		sum += xs[i];
406
407
	*res = sum / c;
408
	return 0;
409
}
405
}
410
406
411
static GnmValue *
407
static GnmValue *
Lines 508-519 static char const *help_negbinomdist = { Link Here
508
static GnmValue *
504
static GnmValue *
509
gnumeric_negbinomdist (FunctionEvalInfo *ei, GnmValue **argv)
505
gnumeric_negbinomdist (FunctionEvalInfo *ei, GnmValue **argv)
510
{
506
{
511
	int x, r;
507
	int x = value_get_as_int (argv[0]);
512
	gnm_float p;
508
	int r = value_get_as_int (argv[1]);
513
509
	gnm_float p = value_get_as_float (argv[2]);
514
	x = value_get_as_int (argv[0]);
515
	r = value_get_as_int (argv[1]);
516
	p = value_get_as_float (argv[2]);
517
510
518
	if ((x + r - 1) <= 0 || p < 0 || p > 1)
511
	if ((x + r - 1) <= 0 || p < 0 || p > 1)
519
		return value_new_error_NUM (ei->pos);
512
		return value_new_error_NUM (ei->pos);
Lines 1081-1100 static char const *help_expondist = { Link Here
1081
static GnmValue *
1074
static GnmValue *
1082
gnumeric_expondist (FunctionEvalInfo *ei, GnmValue **argv)
1075
gnumeric_expondist (FunctionEvalInfo *ei, GnmValue **argv)
1083
{
1076
{
1084
	gnm_float x, y;
1077
	gnm_float x = value_get_as_float (argv[0]);
1085
	int cuml;
1078
	gnm_float y = value_get_as_float (argv[1]);
1086
	gboolean err;
1079
	gboolean cuml = value_get_as_checked_bool (argv[2]);
1087
1088
	x = value_get_as_float (argv[0]);
1089
	y = value_get_as_float (argv[1]);
1090
1080
1091
	if (x < 0.0 || y <= 0.0)
1081
	if (x < 0.0 || y <= 0.0)
1092
		return value_new_error_NUM (ei->pos);
1082
		return value_new_error_NUM (ei->pos);
1093
1083
1094
	cuml = value_get_as_bool (argv[2], &err);
1095
	if (err)
1096
		return value_new_error_VALUE (ei->pos);
1097
1098
	if (cuml)
1084
	if (cuml)
1099
		return value_new_float (pexp (x, 1 / y, TRUE, FALSE));
1085
		return value_new_float (pexp (x, 1 / y, TRUE, FALSE));
1100
	else
1086
	else
Lines 1204-1220 static char const *help_gammadist = { Link Here
1204
static GnmValue *
1190
static GnmValue *
1205
gnumeric_gammadist (FunctionEvalInfo *ei, GnmValue **argv)
1191
gnumeric_gammadist (FunctionEvalInfo *ei, GnmValue **argv)
1206
{
1192
{
1207
	gnm_float x, alpha, beta;
1193
	gnm_float x = value_get_as_float (argv[0]);
1208
	int     cum;
1194
	gnm_float alpha = value_get_as_float (argv[1]);
1209
1195
	gnm_float beta = value_get_as_float (argv[2]);
1210
	x = value_get_as_float (argv[0]);
1196
	gboolean cum = value_get_as_checked_bool (argv[3]);
1211
	alpha = value_get_as_float (argv[1]);
1212
	beta = value_get_as_float (argv[2]);
1213
1197
1214
	if (x < 0 || alpha <= 0 || beta <= 0)
1198
	if (x < 0 || alpha <= 0 || beta <= 0)
1215
		return value_new_error_NUM (ei->pos);
1199
		return value_new_error_NUM (ei->pos);
1216
1200
1217
	cum = value_get_as_int (argv[3]);
1218
	if (cum)
1201
	if (cum)
1219
	        return value_new_float (pgamma (x, alpha, beta, TRUE, FALSE));
1202
	        return value_new_float (pgamma (x, alpha, beta, TRUE, FALSE));
1220
	else
1203
	else
Lines 1280-1290 static char const *help_chidist = { Link Here
1280
static GnmValue *
1263
static GnmValue *
1281
gnumeric_chidist (FunctionEvalInfo *ei, GnmValue **argv)
1264
gnumeric_chidist (FunctionEvalInfo *ei, GnmValue **argv)
1282
{
1265
{
1283
	gnm_float x;
1266
	gnm_float x = value_get_as_float (argv[0]);
1284
	int     dof;
1267
	int dof = value_get_as_int (argv[1]);
1285
1286
	x = value_get_as_float (argv[0]);
1287
	dof = value_get_as_int (argv[1]);
1288
1268
1289
	if (dof < 1)
1269
	if (dof < 1)
1290
		return value_new_error_NUM (ei->pos);
1270
		return value_new_error_NUM (ei->pos);
Lines 1314-1324 static char const *help_chiinv = { Link Here
1314
static GnmValue *
1294
static GnmValue *
1315
gnumeric_chiinv (FunctionEvalInfo *ei, GnmValue **argv)
1295
gnumeric_chiinv (FunctionEvalInfo *ei, GnmValue **argv)
1316
{
1296
{
1317
        gnm_float p;
1297
        gnm_float p = value_get_as_float (argv[0]);
1318
	int dof;
1298
	int dof = value_get_as_int (argv[1]);
1319
1320
        p = value_get_as_float (argv[0]);
1321
	dof = value_get_as_int (argv[1]);
1322
1299
1323
	if (p < 0 || p > 1 || dof < 1)
1300
	if (p < 0 || p > 1 || dof < 1)
1324
		return value_new_error_NUM (ei->pos);
1301
		return value_new_error_NUM (ei->pos);
Lines 1573-1584 static char const *help_tdist = { Link Here
1573
static GnmValue *
1550
static GnmValue *
1574
gnumeric_tdist (FunctionEvalInfo *ei, GnmValue **argv)
1551
gnumeric_tdist (FunctionEvalInfo *ei, GnmValue **argv)
1575
{
1552
{
1576
	gnm_float x;
1553
	gnm_float x = value_get_as_float (argv[0]);
1577
	int     dof, tails;
1554
	int dof = value_get_as_int (argv[1]);
1578
1555
	int tails = value_get_as_int (argv[2]);
1579
	x = value_get_as_float (argv[0]);
1580
	dof = value_get_as_int (argv[1]);
1581
	tails = value_get_as_int (argv[2]);
1582
1556
1583
	if (dof < 1 || (tails != 1 && tails != 2))
1557
	if (dof < 1 || (tails != 1 && tails != 2))
1584
		return value_new_error_NUM (ei->pos);
1558
		return value_new_error_NUM (ei->pos);
Lines 1609-1619 static char const *help_tinv = { Link Here
1609
static GnmValue *
1583
static GnmValue *
1610
gnumeric_tinv (FunctionEvalInfo *ei, GnmValue **argv)
1584
gnumeric_tinv (FunctionEvalInfo *ei, GnmValue **argv)
1611
{
1585
{
1612
        gnm_float p;
1586
        gnm_float p = value_get_as_float (argv[0]);
1613
	int dof;
1587
	int dof = value_get_as_int (argv[1]);
1614
1615
        p = value_get_as_float (argv[0]);
1616
	dof = value_get_as_int (argv[1]);
1617
1588
1618
	if (p < 0 || p > 1 || dof < 1)
1589
	if (p < 0 || p > 1 || dof < 1)
1619
		return value_new_error_NUM (ei->pos);
1590
		return value_new_error_NUM (ei->pos);
Lines 1645-1656 static char const *help_fdist = { Link Here
1645
static GnmValue *
1616
static GnmValue *
1646
gnumeric_fdist (FunctionEvalInfo *ei, GnmValue **argv)
1617
gnumeric_fdist (FunctionEvalInfo *ei, GnmValue **argv)
1647
{
1618
{
1648
	gnm_float x;
1619
	gnm_float x = value_get_as_float (argv[0]);
1649
	int     dof1, dof2;
1620
	int dof1 = value_get_as_int (argv[1]);
1650
1621
	int dof2 = value_get_as_int (argv[2]);
1651
	x = value_get_as_float (argv[0]);
1652
	dof1 = value_get_as_int (argv[1]);
1653
	dof2 = value_get_as_int (argv[2]);
1654
1622
1655
	if (x < 0 || dof1 < 1 || dof2 < 1)
1623
	if (x < 0 || dof1 < 1 || dof2 < 1)
1656
		return value_new_error_NUM (ei->pos);
1624
		return value_new_error_NUM (ei->pos);
Lines 1823-1834 static char const *help_finv = { Link Here
1823
static GnmValue *
1791
static GnmValue *
1824
gnumeric_finv (FunctionEvalInfo *ei, GnmValue **argv)
1792
gnumeric_finv (FunctionEvalInfo *ei, GnmValue **argv)
1825
{
1793
{
1826
        gnm_float p;
1794
        gnm_float p = value_get_as_float (argv[0]);
1827
	int dof1, dof2;
1795
	int dof1 = value_get_as_int (argv[1]);
1828
1796
	int dof2 = value_get_as_int (argv[2]);
1829
        p = value_get_as_float (argv[0]);
1830
	dof1 = value_get_as_int (argv[1]);
1831
	dof2 = value_get_as_int (argv[2]);
1832
1797
1833
	if (p < 0 || p > 1 || dof1 < 1 || dof2 < 1)
1798
	if (p < 0 || p > 1 || dof1 < 1 || dof2 < 1)
1834
		return value_new_error_NUM (ei->pos);
1799
		return value_new_error_NUM (ei->pos);
Lines 1864-1879 static char const *help_binomdist = { Link Here
1864
static GnmValue *
1829
static GnmValue *
1865
gnumeric_binomdist (FunctionEvalInfo *ei, GnmValue **argv)
1830
gnumeric_binomdist (FunctionEvalInfo *ei, GnmValue **argv)
1866
{
1831
{
1867
	int n, trials, cuml;
1832
	int n = value_get_as_int (argv[0]);
1868
	gboolean err;
1833
	int trials = value_get_as_int (argv[1]);
1869
	gnm_float p;
1834
	gnm_float p = value_get_as_float (argv[2]);
1835
	gboolean cuml = value_get_as_checked_bool (argv[3]);
1870
1836
1871
	n = value_get_as_int (argv[0]);
1837
	if (n < 0 || trials < 0 || p < 0 || p > 1 || n > trials)
1872
	trials = value_get_as_int (argv[1]);
1873
	p = value_get_as_float (argv[2]);
1874
	cuml = value_get_as_bool (argv[3], &err);
1875
1876
	if (n < 0 || trials < 0 || p < 0 || p > 1 || n > trials || err)
1877
		return value_new_error_NUM (ei->pos);
1838
		return value_new_error_NUM (ei->pos);
1878
1839
1879
	if (cuml)
1840
	if (cuml)
Lines 1906-1921 gnumeric_cauchy (FunctionEvalInfo *ei, G Link Here
1906
{
1867
{
1907
	gnm_float x = value_get_as_float (argv[0]);
1868
	gnm_float x = value_get_as_float (argv[0]);
1908
	gnm_float a = value_get_as_float (argv[1]);
1869
	gnm_float a = value_get_as_float (argv[1]);
1909
	int        cuml;
1870
	gboolean cuml = value_get_as_checked_bool (argv[2]);
1910
	gboolean   err;
1911
1871
1912
	if (a < 0)
1872
	if (a < 0)
1913
		return value_new_error_NUM (ei->pos);
1873
		return value_new_error_NUM (ei->pos);
1914
1874
1915
	cuml = value_get_as_bool (argv[2], &err);
1916
	if (err)
1917
		return value_new_error_VALUE (ei->pos);
1918
1919
	if (cuml)
1875
	if (cuml)
1920
		return value_new_float (pcauchy (x, 0, a, FALSE, FALSE));
1876
		return value_new_float (pcauchy (x, 0, a, FALSE, FALSE));
1921
	else
1877
	else
Lines 1949-1960 static char const *help_critbinom = { Link Here
1949
static GnmValue *
1905
static GnmValue *
1950
gnumeric_critbinom (FunctionEvalInfo *ei, GnmValue **argv)
1906
gnumeric_critbinom (FunctionEvalInfo *ei, GnmValue **argv)
1951
{
1907
{
1952
        int trials;
1908
        int trials = value_get_as_int (argv[0]);
1953
        gnm_float p, alpha;
1909
        gnm_float p = value_get_as_float (argv[1]);
1954
1910
        gnm_float alpha = value_get_as_float (argv[2]);
1955
        trials = value_get_as_int (argv[0]);
1956
        p = value_get_as_float (argv[1]);
1957
        alpha = value_get_as_float (argv[2]);
1958
1911
1959
        if (trials < 0 || p < 0 || p > 1 || alpha < 0 || alpha > 1)
1912
        if (trials < 0 || p < 0 || p > 1 || alpha < 0 || alpha > 1)
1960
	        return value_new_error_NUM (ei->pos);
1913
	        return value_new_error_NUM (ei->pos);
Lines 1986-1995 static char const *help_permut = { Link Here
1986
static GnmValue *
1939
static GnmValue *
1987
gnumeric_permut (FunctionEvalInfo *ei, GnmValue **argv)
1940
gnumeric_permut (FunctionEvalInfo *ei, GnmValue **argv)
1988
{
1941
{
1989
	int n, k;
1942
	int n = value_get_as_int (argv[0]);
1990
1943
	int k = value_get_as_int (argv[1]);
1991
	n = value_get_as_int (argv[0]);
1992
	k = value_get_as_int (argv[1]);
1993
1944
1994
	if (0 <= k && k <= n)
1945
	if (0 <= k && k <= n)
1995
		return value_new_float (permut (n, k));
1946
		return value_new_float (permut (n, k));
Lines 2030-2036 gnumeric_hypgeomdist (FunctionEvalInfo * Link Here
2030
	int n = value_get_as_int (argv[1]);
1981
	int n = value_get_as_int (argv[1]);
2031
	int M = value_get_as_int (argv[2]);
1982
	int M = value_get_as_int (argv[2]);
2032
	int N = value_get_as_int (argv[3]);
1983
	int N = value_get_as_int (argv[3]);
2033
	gboolean cum = argv[4] ? value_get_as_int (argv[4]) : FALSE;
1984
	gboolean cum = argv[4] ? value_get_as_checked_bool (argv[4]) : FALSE;
2034
1985
2035
	if (x < 0 || n < 0 || M < 0 || N < 0 || x > M || n > N)
1986
	if (x < 0 || n < 0 || M < 0 || N < 0 || x > M || n > N)
2036
		return value_new_error_NUM (ei->pos);
1987
		return value_new_error_NUM (ei->pos);
Lines 2145-2165 static char const *help_weibull = { Link Here
2145
static GnmValue *
2096
static GnmValue *
2146
gnumeric_weibull (FunctionEvalInfo *ei, GnmValue **argv)
2097
gnumeric_weibull (FunctionEvalInfo *ei, GnmValue **argv)
2147
{
2098
{
2148
        gnm_float x, alpha, beta;
2099
        gnm_float x = value_get_as_float (argv[0]);
2149
        int cuml;
2100
        gnm_float alpha = value_get_as_float (argv[1]);
2150
	gboolean err;
2101
        gnm_float beta = value_get_as_float (argv[2]);
2151
2102
	gboolean cuml = value_get_as_checked_bool (argv[3]);
2152
        x = value_get_as_float (argv[0]);
2153
        alpha = value_get_as_float (argv[1]);
2154
        beta = value_get_as_float (argv[2]);
2155
2103
2156
        if (x < 0 || alpha <= 0 || beta <= 0)
2104
        if (x < 0 || alpha <= 0 || beta <= 0)
2157
                return value_new_error_NUM (ei->pos);
2105
                return value_new_error_NUM (ei->pos);
2158
2106
2159
        cuml = value_get_as_bool (argv[3], &err);
2160
        if (err)
2161
                return value_new_error_VALUE (ei->pos);
2162
2163
        if (cuml)
2107
        if (cuml)
2164
                return value_new_float (pweibull (x, alpha, beta, TRUE, FALSE));
2108
                return value_new_float (pweibull (x, alpha, beta, TRUE, FALSE));
2165
        else
2109
        else
Lines 2190-2210 static char const *help_normdist = { Link Here
2190
static GnmValue *
2134
static GnmValue *
2191
gnumeric_normdist (FunctionEvalInfo *ei, GnmValue **argv)
2135
gnumeric_normdist (FunctionEvalInfo *ei, GnmValue **argv)
2192
{
2136
{
2193
        gnm_float x, mean, stddev;
2137
	gnm_float x = value_get_as_float (argv[0]);
2194
        int cuml;
2138
	gnm_float mean = value_get_as_float (argv[1]);
2195
	gboolean err;
2139
	gnm_float stddev = value_get_as_float (argv[2]);
2196
2140
	gboolean cuml = value_get_as_checked_bool (argv[3]);
2197
        x = value_get_as_float (argv[0]);
2198
        mean = value_get_as_float (argv[1]);
2199
        stddev = value_get_as_float (argv[2]);
2200
2141
2201
        if (stddev <= 0)
2142
        if (stddev <= 0)
2202
                return value_new_error_DIV0 (ei->pos);
2143
                return value_new_error_DIV0 (ei->pos);
2203
2144
2204
        cuml = value_get_as_bool (argv[3], &err);
2205
        if (err)
2206
                return value_new_error_VALUE (ei->pos);
2207
2208
        if (cuml)
2145
        if (cuml)
2209
		return value_new_float (pnorm (x, mean, stddev, TRUE, FALSE));
2146
		return value_new_float (pnorm (x, mean, stddev, TRUE, FALSE));
2210
        else
2147
        else
Lines 2236-2246 static char const *help_norminv = { Link Here
2236
static GnmValue *
2173
static GnmValue *
2237
gnumeric_norminv (FunctionEvalInfo *ei, GnmValue **argv)
2174
gnumeric_norminv (FunctionEvalInfo *ei, GnmValue **argv)
2238
{
2175
{
2239
        gnm_float p, mean, stddev;
2176
        gnm_float p = value_get_as_float (argv[0]);
2240
2177
	gnm_float mean = value_get_as_float (argv[1]);
2241
        p = value_get_as_float (argv[0]);
2178
	gnm_float stddev = value_get_as_float (argv[2]);
2242
	mean = value_get_as_float (argv[1]);
2243
	stddev = value_get_as_float (argv[2]);
2244
2179
2245
	if (p < 0 || p > 1 || stddev <= 0)
2180
	if (p < 0 || p > 1 || stddev <= 0)
2246
		return value_new_error_NUM (ei->pos);
2181
		return value_new_error_NUM (ei->pos);
Lines 2446-2460 static char const *help_poisson = { Link Here
2446
static GnmValue *
2381
static GnmValue *
2447
gnumeric_poisson (FunctionEvalInfo *ei, GnmValue **argv)
2382
gnumeric_poisson (FunctionEvalInfo *ei, GnmValue **argv)
2448
{
2383
{
2449
	gnm_float mean;
2384
	gnm_float x = value_get_as_int (argv[0]);
2450
	int x, cuml;
2385
	gnm_float mean = value_get_as_float (argv[1]);
2451
	gboolean err;
2386
	gboolean cuml = value_get_as_checked_bool (argv[2]);
2452
2453
	x = value_get_as_int (argv[0]);
2454
	mean = value_get_as_float (argv[1]);
2455
	cuml = value_get_as_bool (argv[2], &err);
2456
2387
2457
	if (x < 0 || mean <= 0 || err)
2388
	if (x < 0 || mean <= 0)
2458
		return value_new_error_NUM (ei->pos);
2389
		return value_new_error_NUM (ei->pos);
2459
2390
2460
	if (cuml)
2391
	if (cuml)
Lines 5403-5409 gnumeric_geomdist (FunctionEvalInfo *ei, Link Here
5403
{
5334
{
5404
	int        k   = value_get_as_int (argv[0]);
5335
	int        k   = value_get_as_int (argv[0]);
5405
	gnm_float p   = value_get_as_float (argv[1]);
5336
	gnm_float p   = value_get_as_float (argv[1]);
5406
	gboolean   cum = value_get_as_int (argv[2]);
5337
	gboolean  cum = value_get_as_checked_bool (argv[2]);
5407
5338
5408
	if (p < 0 || p > 1 || k < 0 || (cum != TRUE && cum != FALSE))
5339
	if (p < 0 || p > 1 || k < 0 || (cum != TRUE && cum != FALSE))
5409
		return value_new_error_NUM (ei->pos);
5340
		return value_new_error_NUM (ei->pos);
Lines 5660-5666 const GnmFuncDescriptor stat_functions[] Link Here
5660
	  &help_binomdist, gnumeric_binomdist, NULL, NULL, NULL, NULL,
5591
	  &help_binomdist, gnumeric_binomdist, NULL, NULL, NULL, NULL,
5661
	  GNM_FUNC_SIMPLE, GNM_FUNC_IMPL_STATUS_COMPLETE, GNM_FUNC_TEST_STATUS_BASIC },
5592
	  GNM_FUNC_SIMPLE, GNM_FUNC_IMPL_STATUS_COMPLETE, GNM_FUNC_TEST_STATUS_BASIC },
5662
5593
5663
        { "cauchy", "fff", N_("x,a,cum"),   &help_cauchy,
5594
	{ "cauchy", "ffb", N_("x,a,cum"),   &help_cauchy,
5664
	  gnumeric_cauchy, NULL, NULL, NULL, NULL,
5595
	  gnumeric_cauchy, NULL, NULL, NULL, NULL,
5665
	  GNM_FUNC_SIMPLE, GNM_FUNC_IMPL_STATUS_COMPLETE, GNM_FUNC_TEST_STATUS_BASIC },
5596
	  GNM_FUNC_SIMPLE, GNM_FUNC_IMPL_STATUS_COMPLETE, GNM_FUNC_TEST_STATUS_BASIC },
5666
5597
(-)plugins/fn-string/functions.c (-149 / +137 lines)
Lines 72-86 static char const *help_char = { Link Here
72
static GnmValue *
72
static GnmValue *
73
gnumeric_char (FunctionEvalInfo *ei, GnmValue **argv)
73
gnumeric_char (FunctionEvalInfo *ei, GnmValue **argv)
74
{
74
{
75
	int c = value_get_as_int (argv[0]);
75
	gnm_float c = value_get_as_float (argv[0]);
76
76
77
	if (c > 0 && c <= 127) {
77
	if (c >= 1 && c < 128) {
78
		char result[2];
78
		char result[2];
79
		result[0] = c;
79
		result[0] = (char)c;
80
		result[1] = 0;
80
		result[1] = 0;
81
		return value_new_string (result);
81
		return value_new_string (result);
82
	} else if (c >= 128 && c <= 255) {
82
	} else if (c >= 128 && c < 256) {
83
		char c2 = c;
83
		char c2 = (char)c;
84
		char *str = g_convert_with_iconv (&c2, 1, CHAR_iconv,
84
		char *str = g_convert_with_iconv (&c2, 1, CHAR_iconv,
85
						  NULL, NULL, NULL);
85
						  NULL, NULL, NULL);
86
		if (str) {
86
		if (str) {
Lines 88-96 gnumeric_char (FunctionEvalInfo *ei, Gnm Link Here
88
			if (len == 1)
88
			if (len == 1)
89
				return value_new_string_nocopy (str);
89
				return value_new_string_nocopy (str);
90
			g_warning ("iconv for CHAR(%d) produced a string of length %d",
90
			g_warning ("iconv for CHAR(%d) produced a string of length %d",
91
				   c, len);
91
				   c2, len);
92
			g_free (str);
92
		} else
93
		} else
93
			g_warning ("iconv failed for CHAR(%d)", c);
94
			g_warning ("iconv failed for CHAR(%d)", c2);
94
	}
95
	}
95
96
96
	return value_new_error_VALUE (ei->pos);
97
	return value_new_error_VALUE (ei->pos);
Lines 115-125 static char const *help_unichar = { Link Here
115
static GnmValue *
116
static GnmValue *
116
gnumeric_unichar (FunctionEvalInfo *ei, GnmValue **argv)
117
gnumeric_unichar (FunctionEvalInfo *ei, GnmValue **argv)
117
{
118
{
118
	int c = value_get_as_int (argv[0]);
119
	gnm_float c = value_get_as_float (argv[0]);
119
120
120
	if (g_unichar_validate (c)) {
121
	if (c >= 0 && c <= INT_MAX && g_unichar_validate ((gunichar)c)) {
121
		char utf8[8];
122
		char utf8[8];
122
		int len = g_unichar_to_utf8 (c, utf8);
123
		int len = g_unichar_to_utf8 ((gunichar)c, utf8);
123
		utf8[len] = 0;
124
		utf8[len] = 0;
124
		return value_new_string (utf8);
125
		return value_new_string (utf8);
125
	} else
126
	} else
Lines 288-306 static char const *help_left = { Link Here
288
static GnmValue *
289
static GnmValue *
289
gnumeric_left (FunctionEvalInfo *ei, GnmValue **argv)
290
gnumeric_left (FunctionEvalInfo *ei, GnmValue **argv)
290
{
291
{
291
	char const *peek;
292
	const guchar *peek = (const guchar *)value_peek_string (argv[0]);
292
	int         count, newlen;
293
	gnm_float count = argv[1] ? value_get_as_float (argv[1]) : 1.0;
293
294
	int icount, newlen;
294
	count = argv[1] ? value_get_as_int (argv[1]) : 1;
295
295
296
	if (count < 0)
296
	if (count < 0)
297
		return value_new_error_VALUE (ei->pos);
297
		return value_new_error_VALUE (ei->pos);
298
	icount = (int)MIN ((gnm_float)INT_MAX, count);
298
299
299
	peek = value_peek_string (argv[0]);
300
	for (newlen = 0; peek[newlen] != 0 && icount > 0; icount--)
300
	if (count >= g_utf8_strlen (peek, -1))
301
		newlen += g_utf8_skip[peek[newlen]];
301
		return value_new_string (peek);
302
302
303
	newlen = g_utf8_offset_to_pointer (peek, count) - peek;
304
	return value_new_string_nocopy (g_strndup (peek, newlen));
303
	return value_new_string_nocopy (g_strndup (peek, newlen));
305
}
304
}
306
305
Lines 346-372 static char const *help_mid = { Link Here
346
static GnmValue *
345
static GnmValue *
347
gnumeric_mid (FunctionEvalInfo *ei, GnmValue **argv)
346
gnumeric_mid (FunctionEvalInfo *ei, GnmValue **argv)
348
{
347
{
349
	char       *upos;
348
	const char *source = value_peek_string (argv[0]);
350
	char const *source;
349
	gnm_float pos = value_get_as_float (argv[1]);
351
	int         pos, len, ulen, slen;
350
	gnm_float len = value_get_as_float (argv[2]);
351
	size_t slen = g_utf8_strlen (source, -1);
352
	const char *upos;
353
	size_t ilen, ipos, ulen;
352
354
353
	pos = value_get_as_int (argv[1]);
355
	if (len < 0 || pos < 1)
354
	len = value_get_as_int (argv[2]);
355
356
	if (len < 0 || pos <= 0)
357
		return value_new_error_VALUE (ei->pos);
358
359
	source = value_peek_string (argv[0]);
360
	slen   = g_utf8_strlen (source, -1);
361
362
	if (pos > slen)
363
		return value_new_error_VALUE (ei->pos);
356
		return value_new_error_VALUE (ei->pos);
357
	if (pos >= slen + 1)
358
		return value_new_string ("");
364
359
365
	pos--;  /* Make pos zero-based.  */
360
	/* Make ipos zero-based.  */
361
	ipos = (size_t)(pos - 1);
362
	ilen  = (size_t)MIN (len, (gnm_float)(slen - ipos));
366
363
367
	len  = MIN (len, slen - pos);
364
	upos = g_utf8_offset_to_pointer (source, ipos);
368
	upos = g_utf8_offset_to_pointer (source, pos);
365
	ulen = g_utf8_offset_to_pointer (upos, ilen) - upos;
369
	ulen = g_utf8_offset_to_pointer (upos, len) - upos;
370
366
371
	return value_new_string_nocopy (g_strndup (upos, ulen));
367
	return value_new_string_nocopy (g_strndup (upos, ulen));
372
}
368
}
Lines 392-418 static char const *help_right = { Link Here
392
static GnmValue *
388
static GnmValue *
393
gnumeric_right (FunctionEvalInfo *ei, GnmValue **argv)
389
gnumeric_right (FunctionEvalInfo *ei, GnmValue **argv)
394
{
390
{
395
	int count, slen;
391
	char const *os = value_peek_string (argv[0]);
396
	char const *os;
392
	gnm_float count = argv[1] ? value_get_as_float (argv[1]) : 1.0;
397
	char *s;
393
	int icount, slen;
398
399
	count = argv[1] ? value_get_as_int (argv[1]) : 1;
400
394
401
	if (count < 0)
395
	if (count < 0)
402
		return value_new_error_VALUE (ei->pos);
396
		return value_new_error_VALUE (ei->pos);
397
	icount = (int)MIN ((gnm_float)INT_MAX, count);
403
398
404
	os   = value_peek_string (argv[0]);
405
	slen = g_utf8_strlen (os, -1);
399
	slen = g_utf8_strlen (os, -1);
406
400
407
	if (count < slen)
401
	if (icount < slen)
408
		s = g_strdup (g_utf8_offset_to_pointer (os, slen - count));
402
		return value_new_string (g_utf8_offset_to_pointer (os, slen - icount));
409
	else {
403
	else
410
		/* We could just duplicate the arg, but that would not ensure
404
		/* We could just duplicate the arg, but that would not ensure
411
		   that the result was a string.  */
405
		   that the result was a string.  */
412
		s = g_strdup (os);
406
		return value_new_string (os);
413
	}
414
415
	return value_new_string_nocopy (s);
416
}
407
}
417
408
418
/***************************************************************************/
409
/***************************************************************************/
Lines 480-511 static char const *help_rept = { Link Here
480
static GnmValue *
471
static GnmValue *
481
gnumeric_rept (FunctionEvalInfo *ei, GnmValue **argv)
472
gnumeric_rept (FunctionEvalInfo *ei, GnmValue **argv)
482
{
473
{
483
	GString    *res;
474
	char const *source = value_peek_string (argv[0]);
484
	char const *source;
475
	gnm_float num = value_get_as_float (argv[1]);
485
	int         num;
476
	size_t len = strlen (source);
486
	int         len;
477
	char *res;
487
	int         i;
478
	size_t i, inum;
488
479
489
	num = value_get_as_int (argv[1]);
490
	if (num < 0)
480
	if (num < 0)
491
		return value_new_error_VALUE (ei->pos);
481
		return value_new_error_VALUE (ei->pos);
492
482
493
	source = value_peek_string (argv[0]);
494
	len    = strlen (source);
495
496
	/* Fast special case.  =REPT ("",2^30) should not take long.  */
483
	/* Fast special case.  =REPT ("",2^30) should not take long.  */
497
	if (len == 0 || num == 0)
484
	if (len == 0 || num < 1)
498
		return value_new_string ("");
485
		return value_new_string ("");
499
486
500
	/* Check if the length would overflow.  */
487
	/* Check if the length would overflow.  */
501
	if (num >= INT_MAX / len)
488
	if (num >= INT_MAX / len)
502
		return value_new_error_VALUE (ei->pos);
489
		return value_new_error_VALUE (ei->pos);
503
490
504
	res = g_string_sized_new (len * num);
491
	inum = (size_t)num;
505
	for (i = 0; i < num; i++)
492
	res = g_try_malloc (len * inum + 1);
506
		g_string_append (res, source);
493
	if (!res)
494
		return value_new_error_VALUE (ei->pos);
507
495
508
	return value_new_string_nocopy (g_string_free (res, FALSE));
496
	for (i = 0; inum-- > 0; i += len)
497
		memcpy (res + i, source, len);
498
	res[i] = 0;
499
500
	return value_new_string_nocopy (res);
509
}
501
}
510
502
511
/***************************************************************************/
503
/***************************************************************************/
Lines 561-603 static char const *help_find = { Link Here
561
static GnmValue *
553
static GnmValue *
562
gnumeric_find (FunctionEvalInfo *ei, GnmValue **argv)
554
gnumeric_find (FunctionEvalInfo *ei, GnmValue **argv)
563
{
555
{
564
	int count, haystacksize;
556
	const char *needle   = value_peek_string (argv[0]);
565
	char const *haystack, *needle;
557
	const char *haystack = value_peek_string (argv[1]);
566
558
	gnm_float count      = argv[2] ? value_get_as_float (argv[2]) : 1.0;
567
	/*
559
	size_t haystacksize = g_utf8_strlen (haystack, -1);
568
	 * FIXME: My gut feeling is that we should return arguments
560
	size_t icount;
569
	 * invalid when g_utf8_strlen (needle, -1) is 0 (i.e. needle is "")
561
	const char *p;
570
	 * Currently we return "1" which seems nonsensical.
571
	 */
572
	needle   = value_peek_string (argv[0]);
573
	haystack = value_peek_string (argv[1]);
574
	count    = argv[2] ? value_get_as_int (argv[2]) : 1;
575
576
	haystacksize = g_utf8_strlen (haystack, -1);
577
562
578
	/*
563
	if (count < 1 || count >= haystacksize + 1)
579
	 * NOTE: It seems that the implementation of g_strstr will
580
	 * even work for UTF-8 string, even though there is no special
581
	 * UTF-8 version for it, this is why we use "strlen (haystart)"
582
	 * and not g_utf8_strlen below
583
	 */
584
	if (count <= 0 || count > haystacksize) {
585
		return value_new_error_VALUE (ei->pos);
564
		return value_new_error_VALUE (ei->pos);
586
	} else {
565
	icount = (size_t)count;
587
		char const *haystart = g_utf8_offset_to_pointer (haystack,
566
588
								 count - 1);
567
	haystack = g_utf8_offset_to_pointer (haystack, icount - 1);
589
		char const *p        = g_strstr_len (haystart,
590
						     strlen (haystart), needle);
591
568
569
	p = g_strstr_len (haystack, strlen (haystack), needle);
592
		if (p)
570
		if (p)
593
			/* One-based */
594
			return value_new_int
571
			return value_new_int
595
				(g_utf8_pointer_to_offset (haystack, p) + 1);
572
			(g_utf8_pointer_to_offset (haystack, p) + icount);
596
		else
573
		else
597
			/* Really?  */
598
			return value_new_error_VALUE (ei->pos);
574
			return value_new_error_VALUE (ei->pos);
599
	}
575
	}
600
}
601
576
602
/***************************************************************************/
577
/***************************************************************************/
603
578
Lines 619-649 static char const *help_fixed = { Link Here
619
static GnmValue *
594
static GnmValue *
620
gnumeric_fixed (FunctionEvalInfo *ei, GnmValue **argv)
595
gnumeric_fixed (FunctionEvalInfo *ei, GnmValue **argv)
621
{
596
{
622
	int decimals;
597
 	gnm_float num = value_get_as_float (argv[0]);
623
	gnm_float num;
598
 	gnm_float decimals = argv[1] ? value_get_as_float (argv[1]) : 2.0;
624
	gboolean commas = TRUE;
599
 	gboolean commas = argv[2] ? value_get_as_checked_bool (argv[2]) : TRUE;
625
	format_info_t fmt;
600
	format_info_t fmt;
626
	GString *str;
601
	GString *str;
627
602
628
	num = value_get_as_float (argv[0]);
603
 	decimals = gnumeric_fake_trunc (decimals);
629
	decimals = argv[1] ? value_get_as_int (argv[1]) : 2;
604
 	if (decimals >= 128)
630
	if (argv[2] != NULL) {
631
		gboolean err;
632
		commas = !value_get_as_bool (argv[2], &err);
633
		if (err)
634
			return value_new_error_VALUE (ei->pos);
635
	}
636
637
	if (decimals >= 127) /* else buffer overflow */
638
		return value_new_error_VALUE (ei->pos);
605
		return value_new_error_VALUE (ei->pos);
639
606
640
	if (decimals <= 0) {
607
 	if (decimals < 0) {
641
		/* no decimal point : just round and pad 0's */
608
		/* no decimal point : just round and pad 0's */
642
		gnm_float mult = gpow10 (decimals);
609
		gnm_float mult = gpow10 (decimals);
643
		num = (gnumeric_fake_round (num * mult) / mult);
610
 		if (mult == 0)
611
 			num = 0;  /* Underflow */
612
 		else
613
 			num = gnumeric_fake_round (num * mult) / mult;
644
		fmt.right_req = fmt.right_allowed = 0;
614
		fmt.right_req = fmt.right_allowed = 0;
645
	} else /* decimal point format */
615
	} else /* decimal point format */
646
		fmt.right_req = fmt.right_allowed = decimals;
616
 		fmt.right_req = fmt.right_allowed = (int)decimals;
647
617
648
	fmt.right_optional	   = 0;
618
	fmt.right_optional	   = 0;
649
	fmt.right_spaces	   = 0;
619
	fmt.right_spaces	   = 0;
Lines 735-767 static char const *help_replace = { Link Here
735
static GnmValue *
705
static GnmValue *
736
gnumeric_replace (FunctionEvalInfo *ei, GnmValue **argv)
706
gnumeric_replace (FunctionEvalInfo *ei, GnmValue **argv)
737
{
707
{
738
	GString *res;
708
	const char *old = value_peek_string (argv[0]);
739
	gint start, num, oldlen;
709
	gnm_float start = value_get_as_float (argv[1]);
740
	char const *old;
710
	gnm_float num = value_get_as_float (argv[2]);
741
	char const *new;
711
	const char *new = value_peek_string (argv[3]);
742
712
	size_t istart, inum, oldlen, precutlen, postcutlen, newlen;
743
	start  = value_get_as_int (argv[1]);
713
	const char *p, *q;
744
	num    = value_get_as_int (argv[2]);
714
	char *res;
745
	old    = value_peek_string (argv[0]);
746
	oldlen = g_utf8_strlen (old, -1);
747
715
748
	if (start <= 0 || num <= 0)
716
	if (start < 1 || num < 0)
749
		return value_new_error_VALUE (ei->pos);
717
		return value_new_error_VALUE (ei->pos);
750
	if (start > oldlen)
751
		return value_new_error (ei->pos, _ ("Arguments out of range"));
752
718
753
	start--;  /* Make this zero-based.  */
719
	oldlen = g_utf8_strlen (old, -1);
720
	/* Make istart zero-based.  */
721
	istart = (int)MIN ((gnm_float)oldlen, start - 1);
722
	inum = (int)MIN((gnm_float)(oldlen - istart), num);
754
723
755
	if (start + num > oldlen)
724
	/* |<----precut----><cut><---postcut--->| */
756
		num = oldlen - start;
725
	/*  ^old            ^p   ^q               */
757
726
758
	new = value_peek_string (argv[3]);
727
	p = g_utf8_offset_to_pointer (old, istart);
728
	q = g_utf8_offset_to_pointer (p, inum);
759
729
760
	res = g_string_new (old);
730
	precutlen = p - old;
761
	g_string_erase (res, start, num);
731
	postcutlen = strlen (q);
762
	g_string_insert (res, start, new);
732
	newlen = strlen (new);
763
733
764
	return value_new_string_nocopy (g_string_free (res, FALSE));
734
	res = g_malloc (precutlen + newlen + postcutlen + 1);
735
	memcpy (res, old, precutlen);
736
	memcpy (res + precutlen, new, newlen);
737
	memcpy (res + precutlen + newlen, q, postcutlen + 1);
738
	return value_new_string_nocopy (res);
765
}
739
}
766
740
767
/***************************************************************************/
741
/***************************************************************************/
Lines 855-861 gnumeric_trim (FunctionEvalInfo *ei, Gnm Link Here
855
	char const *s;
829
	char const *s;
856
	GString  *res   = g_string_new (NULL);
830
	GString  *res   = g_string_new (NULL);
857
	gboolean  space = TRUE;
831
	gboolean  space = TRUE;
858
	int       len;
832
	size_t    last_len = 0;
859
833
860
	s = value_peek_string (argv[0]);
834
	s = value_peek_string (argv[0]);
861
	while (*s) {
835
	while (*s) {
Lines 867-872 gnumeric_trim (FunctionEvalInfo *ei, Gnm Link Here
867
		 */
841
		 */
868
		if (g_unichar_isspace (uc)) {
842
		if (g_unichar_isspace (uc)) {
869
			if (!space) {
843
			if (!space) {
844
				last_len = res->len;
870
				g_string_append_unichar (res, uc);
845
				g_string_append_unichar (res, uc);
871
				space = TRUE;
846
				space = TRUE;
872
			}
847
			}
Lines 878-887 gnumeric_trim (FunctionEvalInfo *ei, Gnm Link Here
878
		s = g_utf8_next_char (s);
853
		s = g_utf8_next_char (s);
879
	}
854
	}
880
855
881
	g_warning ("FIXME: this looks bogus.");
856
	if (space)
882
	len = g_utf8_strlen (res->str, -1);
857
		g_string_truncate (res, last_len);
883
	if (space && len > 0)
884
		g_string_truncate (res, len - 1);
885
858
886
	return value_new_string_nocopy (g_string_free (res, FALSE));
859
	return value_new_string_nocopy (g_string_free (res, FALSE));
887
}
860
}
Lines 949-972 static char const *help_substitute = { Link Here
949
static GnmValue *
922
static GnmValue *
950
gnumeric_substitute (FunctionEvalInfo *ei, GnmValue **argv)
923
gnumeric_substitute (FunctionEvalInfo *ei, GnmValue **argv)
951
{
924
{
925
	/*
926
	 * Careful: value_peek_string handle only two live
927
	 * pointers at a time.
928
	 */
929
	char *textcopy = VALUE_IS_STRING (argv[0]) ? NULL : value_get_as_string (argv[0]);
930
	char const *text = textcopy ? textcopy : value_peek_string (argv[0]);
931
	char const *old  = value_peek_string (argv[1]);
932
	char const *new  = value_peek_string (argv[2]);
952
	char const *p;
933
	char const *p;
953
	int oldlen, newlen, len, inst;
934
	int oldlen, newlen, len, inst;
954
	GString *s;
935
	GString *s;
955
956
	char const *text = value_peek_string (argv[0]);
957
	char const *old  = value_peek_string (argv[1]);
958
	char const *new  = value_peek_string (argv[2]);
959
	int num = 0;
936
	int num = 0;
960
937
961
	if (argv[3]) {
938
	if (argv[3]) {
962
		num = value_get_as_int (argv[3]);
939
		gnm_float fnum = value_get_as_float (argv[3]);
963
		if (num <= 0)
940
		if (fnum <= 0) {
941
			g_free (textcopy);
964
			return value_new_error_VALUE (ei->pos);
942
			return value_new_error_VALUE (ei->pos);
965
	}
943
	}
944
		num = (int)MIN((gnm_float)INT_MAX, fnum);
945
	}
966
946
967
	oldlen = strlen (old);
947
	oldlen = strlen (old);
968
	if (oldlen == 0)
948
	if (oldlen == 0)
969
		return value_dup (argv[0]);
949
		return textcopy
950
			? value_new_string_nocopy (textcopy)
951
			: value_dup (argv[0]);
970
952
971
	newlen = strlen (new);
953
	newlen = strlen (new);
972
	len = strlen (text);
954
	len = strlen (text);
Lines 1019-1029 gnumeric_dollar (FunctionEvalInfo *ei, G Link Here
1019
	GnmValue *v;
1001
	GnmValue *v;
1020
	char *s, *end;
1002
	char *s, *end;
1021
        gnm_float number = value_get_as_float (argv[0]);
1003
        gnm_float number = value_get_as_float (argv[0]);
1022
        int decimals = argv[1] ? value_get_as_int (argv[1]) : 2;
1004
        gnm_float decimals = argv[1] ? value_get_as_float (argv[1]) : 2.0;
1023
1005
1024
	/* This is what Excel appears to do.  */
1006
	/* This is what Excel appears to do.  */
1025
	if (decimals >= 128)
1007
	if (decimals >= 128)
1026
		return value_new_error_VALUE (ei->pos);
1008
		return value_new_error_VALUE (ei->pos);
1009
	decimals = gnumeric_fake_trunc (decimals);
1027
1010
1028
	/* Since decimals can be negative, round the number.  */
1011
	/* Since decimals can be negative, round the number.  */
1029
	p10 = gpow10 (decimals);
1012
	p10 = gpow10 (decimals);
Lines 1033-1039 gnumeric_dollar (FunctionEvalInfo *ei, G Link Here
1033
		number = gnumeric_fake_round (number * p10) / p10;
1016
		number = gnumeric_fake_round (number * p10) / p10;
1034
1017
1035
	info = style_format_default_money ()->family_info;
1018
	info = style_format_default_money ()->family_info;
1036
	info.num_decimals = MAX (decimals, 0);
1019
 	info.num_decimals = (int)MAX (decimals, 0);
1037
	info.negative_fmt = 2;
1020
	info.negative_fmt = 2;
1038
1021
1039
	sf = style_format_build (FMT_CURRENCY, &info);
1022
	sf = style_format_build (FMT_CURRENCY, &info);
Lines 1087-1113 gnumeric_search (FunctionEvalInfo *ei, G Link Here
1087
{
1070
{
1088
	char const *needle = value_peek_string (argv[0]);
1071
	char const *needle = value_peek_string (argv[0]);
1089
	char const *haystack = value_peek_string (argv[1]);
1072
	char const *haystack = value_peek_string (argv[1]);
1090
	int start = argv[2] ? value_get_as_int (argv[2]) : 1;
1073
 	gnm_float start = argv[2] ? value_get_as_float (argv[2]) : 1.0;
1074
 	size_t i, istart;
1091
	char const *hay2;
1075
	char const *hay2;
1092
	go_regex_t r;
1076
	go_regex_t r;
1093
	regmatch_t rm;
1094
	GnmValue *res = NULL;
1077
	GnmValue *res = NULL;
1095
	int i;
1096
1078
1097
	start--;
1079
 	if (start < 1 || start >= INT_MAX)
1098
	if (start < 0)
1099
		return value_new_error_VALUE (ei->pos);
1080
		return value_new_error_VALUE (ei->pos);
1100
	for (i = start, hay2 = haystack; i > 0; i--) {
1081
 	// Make istart zero-based.  */
1082
 	istart = (int)(start - 1);
1083
1084
 	for (i = istart, hay2 = haystack; i > 0; i--) {
1101
		if (*hay2 == 0)
1085
		if (*hay2 == 0)
1102
			return value_new_error_VALUE (ei->pos);
1086
			return value_new_error_VALUE (ei->pos);
1103
		hay2 = g_utf8_next_char (hay2);
1087
		hay2 = g_utf8_next_char (hay2);
1104
	}
1088
	}
1105
1089
1106
	if (gnumeric_regcomp_XL (&r, needle, REG_ICASE) == REG_OK) {
1090
	if (gnumeric_regcomp_XL (&r, needle, REG_ICASE) == REG_OK) {
1091
		regmatch_t rm;
1092
1107
		switch (go_regexec (&r, hay2, 1, &rm, 0)) {
1093
		switch (go_regexec (&r, hay2, 1, &rm, 0)) {
1108
		case REG_NOMATCH: break;
1094
		case REG_NOMATCH:
1095
			break;
1109
		case REG_OK:
1096
		case REG_OK:
1110
			res = value_new_int (1 + start + rm.rm_so);
1097
 			res = value_new_int (1 + istart +
1098
 				 g_utf8_pointer_to_offset (hay2, hay2 + rm.rm_so));
1111
			break;
1099
			break;
1112
		default:
1100
		default:
1113
			g_warning ("Unexpected regexec result");
1101
			g_warning ("Unexpected regexec result");
(-)plugins/html/html_read.c (-3 / +5 lines)
Lines 80-89 html_append_text (GString *buf, const xm Link Here
80
	const xmlChar *p;
80
	const xmlChar *p;
81
	
81
	
82
	while (*text) {
82
	while (*text) {
83
		while (g_ascii_isspace (*text))
83
		while (g_unichar_isspace (g_utf8_get_char (text)))
84
			text++;
84
			text = g_utf8_next_char (text);
85
		if (*text) {
85
		if (*text) {
86
			for (p = text; *p && !g_ascii_isspace (*p); p++)
86
			for (p = text; 
87
			     *p && !g_unichar_isspace (g_utf8_get_char (p)); 
88
			     p =  g_utf8_next_char (p))
87
				;
89
				;
88
			if (buf->len > 0)
90
			if (buf->len > 0)
89
				g_string_append_c (buf, ' ');
91
				g_string_append_c (buf, ' ');
(-)plugins/html/latex.c (-2 / +2 lines)
Lines 525-531 latex2e_write_table_header(GsfOutput *ou Link Here
525
525
526
	gsf_output_printf (output, "%%\t\\multicolumn{%d}{c}{The First Header} \\\\ \\hline \n", num_cols);
526
	gsf_output_printf (output, "%%\t\\multicolumn{%d}{c}{The First Header} \\\\ \\hline \n", num_cols);
527
	gsf_output_printf (output, "%%\t\\multicolumn{1}{c}{colTag}\t%%Column 1\n");
527
	gsf_output_printf (output, "%%\t\\multicolumn{1}{c}{colTag}\t%%Column 1\n");
528
	for (col = 1 ; col < num_cols; col++)
528
	for (col = 2 ; col < num_cols; col++)
529
		gsf_output_printf (output, "%%\t&\\multicolumn{1}{c}{colTag}\t%%Column %d\n",col);
529
		gsf_output_printf (output, "%%\t&\\multicolumn{1}{c}{colTag}\t%%Column %d\n",col);
530
	gsf_output_printf (output, "%%\t&\\multicolumn{1}{c}{colTag}\t\\\\ \\hline %%Last column\n");
530
	gsf_output_printf (output, "%%\t&\\multicolumn{1}{c}{colTag}\t\\\\ \\hline %%Last column\n");
531
	gsf_output_printf (output, "%%\t\\endfirsthead\n\n");
531
	gsf_output_printf (output, "%%\t\\endfirsthead\n\n");
Lines 534-540 latex2e_write_table_header(GsfOutput *ou Link Here
534
	gsf_output_printf (output, "%%\t\\hline\n");
534
	gsf_output_printf (output, "%%\t\\hline\n");
535
	gsf_output_printf (output, "%%\t\\multicolumn{%d}{l}{\\ldots\\small\\slshape continued} \\\\ \\hline\n", num_cols);
535
	gsf_output_printf (output, "%%\t\\multicolumn{%d}{l}{\\ldots\\small\\slshape continued} \\\\ \\hline\n", num_cols);
536
	gsf_output_printf (output, "%%\t\\multicolumn{1}{c}{colTag}\t%%Column 1\n");
536
	gsf_output_printf (output, "%%\t\\multicolumn{1}{c}{colTag}\t%%Column 1\n");
537
	for (col = 1 ; col < num_cols; col++)
537
	for (col = 2 ; col < num_cols; col++)
538
				gsf_output_printf (output, "%%\t&\\multicolumn{1}{c}{colTag}\t%%Column %d\n",col);
538
				gsf_output_printf (output, "%%\t&\\multicolumn{1}{c}{colTag}\t%%Column %d\n",col);
539
	gsf_output_printf (output, "%%\t&\\multicolumn{1}{c}{colTag}\t\\\\ \\hline %%Last column\n");
539
	gsf_output_printf (output, "%%\t&\\multicolumn{1}{c}{colTag}\t\\\\ \\hline %%Last column\n");
540
	gsf_output_printf (output, "%%\t\\endhead\n\n");
540
	gsf_output_printf (output, "%%\t\\endhead\n\n");
(-)plugins/python-loader/py-gnumeric.c (-1 / +1 lines)
Lines 887-893 py_RangeRef_object_getattr (py_RangeRef_ Link Here
887
	if (strcmp (name, "start") == 0) {
887
	if (strcmp (name, "start") == 0) {
888
		return py_new_CellRef_object (&self->range_ref.a);
888
		return py_new_CellRef_object (&self->range_ref.a);
889
	} else if (strcmp (name, "end") == 0) {
889
	} else if (strcmp (name, "end") == 0) {
890
		return py_new_CellRef_object (&self->range_ref.a);
890
		return py_new_CellRef_object (&self->range_ref.b);
891
	} else {
891
	} else {
892
		return Py_FindMethod (py_RangeRef_object_methods,
892
		return Py_FindMethod (py_RangeRef_object_methods,
893
				      (PyObject *) self, name);
893
				      (PyObject *) self, name);
(-)plugins/qpro/plugin.xml.in (-1 / +1 lines)
Lines 10-16 Link Here
10
	<services>
10
	<services>
11
		<service type="file_opener" id="qpro" priority="100" probe="TRUE">
11
		<service type="file_opener" id="qpro" priority="100" probe="TRUE">
12
			<information>
12
			<information>
13
				<_description>Quatro Pro (*.wb1, *.wb2, *.wb3)</_description>
13
				<_description>Quattro Pro (*.wb1, *.wb2, *.wb3)</_description>
14
			</information>
14
			</information>
15
			<suffixes>
15
			<suffixes>
16
				<suffix>wb1</suffix>
16
				<suffix>wb1</suffix>
(-)plugins/xbase/boot.c (-5 / +15 lines)
Lines 82-93 xbase_field_as_value (gchar *content, XB Link Here
82
82
83
	switch (field->type) {
83
	switch (field->type) {
84
	case 'C': {
84
	case 'C': {
85
		if (file->char_map != (GIConv)-1)
85
		char *sutf8 = g_convert_with_iconv (g_strchomp (s), -1,
86
			val = value_new_string_nocopy (
86
						    file->char_map, NULL, NULL, NULL);
87
				g_convert_with_iconv (g_strchomp (s), -1,
87
		if (!sutf8) {
88
				      file->char_map, NULL, NULL, NULL));
88
			char *t;
89
			for (t = s; *t; t++)
90
				if ((guchar)*t >= 0x7f)
91
					*t = '?';
92
			sutf8 = s;
93
			s = NULL;
94
			g_warning ("Unrepresentable characters replaced by '?'");
95
		}
96
		if (sutf8)
97
			val = value_new_string_nocopy (sutf8);
89
		else
98
		else
90
			val = value_new_string_nocopy (g_strchomp (s));
99
			val = value_new_string ("???");
100
		g_free (s);
91
		return val;
101
		return val;
92
	}
102
	}
93
	case 'N':
103
	case 'N':
(-)plugins/xbase/xbase.c (-2 / +9 lines)
Lines 183-190 xbase_read_header (XBfile *x, ErrorInfo Link Here
183
				       codepages[i].name, codepages[i].codepage););
183
				       codepages[i].name, codepages[i].codepage););
184
			break;
184
			break;
185
		}
185
		}
186
	if (codepages[i].id != 0)
186
	if (x->char_map == (GIConv)-1) {
187
		fprintf (stderr, "unknown 0x%hhx\n!\n", hdr[29]);
187
#if XBASE_DEBUG > 0
188
		fprintf (stderr, "unknown 0x%x\n!\n", hdr[29]);
189
#endif
190
		g_warning ("File has unknown or missing code page information (%x)",
191
			   hdr[29]);
192
		/* Got any better idea?  */
193
		x->char_map = g_iconv_open ("UTF-8", "ISO-8859-1");
194
	}
188
}
195
}
189
196
190
static XBfield *
197
static XBfield *
(-)schemas/Makefile.am (-1 / +16 lines)
Lines 13-19 if GCONF_SCHEMAS_INSTALL Link Here
13
install-data-local:
13
install-data-local:
14
	if test -z "$(DESTDIR)" ; then \
14
	if test -z "$(DESTDIR)" ; then \
15
		for p in $(schema_DATA) ; do \
15
		for p in $(schema_DATA) ; do \
16
			GCONF_CONFIG_SOURCE=$(GCONF_SCHEMA_CONFIG_SOURCE) $(GCONFTOOL) --makefile-install-rule $(srcdir)/$$p; \
16
			GCONF_CONFIG_SOURCE=$(GCONF_SCHEMA_CONFIG_SOURCE) $(GCONFTOOL) --makefile-install-rule $$p; \
17
		done \
17
		done \
18
	fi
18
	fi
19
else
19
else
Lines 22-24 endif Link Here
22
22
23
EXTRA_DIST = $(schema_DATA) $(schema_in_files)
23
EXTRA_DIST = $(schema_DATA) $(schema_in_files)
24
CLEANFILES = $(schema_DATA)
24
CLEANFILES = $(schema_DATA)
25
26
if WITH_WIN32
27
if !CROSS_COMPILING
28
SUFFIXES = .reg .hkcu.reg
29
regdir = $(prefix)/etc/win32/reg
30
reg_DATA = $(schema_in_files:.schemas.in=.reg) $(schema_in_files:.schemas.in=.hkcu.reg)
31
CLEANFILES += $(reg_DATA)
32
33
%.reg:   %.schemas.in
34
	$(top_builddir)/tools/gconf-schemas-to-win32-reg.exe $< >$@
35
%.hkcu.reg:   %.schemas.in
36
	$(top_builddir)/tools/gconf-schemas-to-win32-reg.exe -c $< >$@
37
endif
38
endif
39
(-)src/GNOME_Gnumeric-gtk.xml.in (-2 / +2 lines)
Lines 212-218 Link Here
212
    <menu name="Help" action="MenuHelp">
212
    <menu name="Help" action="MenuHelp">
213
      <menuitem action="HelpDocs"/>
213
      <menuitem action="HelpDocs"/>
214
      <menuitem action="HelpWeb"/>
214
      <menuitem action="HelpWeb"/>
215
      <menuitem action="HelpIRC"/>
215
      <!-- <menuitem action="HelpIRC"/> -->
216
      <menuitem action="HelpBug"/>
216
      <menuitem action="HelpBug"/>
217
      <separator/>
217
      <separator/>
218
      <menuitem action="HelpAbout"/>
218
      <menuitem action="HelpAbout"/>
Lines 297-303 Link Here
297
  <accelerator name="FontStrikeThrough"  action="FontStrikeThrough"/>
297
  <accelerator name="FontStrikeThrough"  action="FontStrikeThrough"/>
298
  <accelerator name="FormatAsNumber"	 action="FormatAsNumber"/>
298
  <accelerator name="FormatAsNumber"	 action="FormatAsNumber"/>
299
  <accelerator name="FormatAsCurrency"	 action="FormatAsCurrency"/>
299
  <accelerator name="FormatAsCurrency"	 action="FormatAsCurrency"/>
300
  <accelerator name="FormatAsAccounting" action="FormatAsAccounting"/>
300
  <accelerator name="FormatAsGeneral"    action="FormatAsGeneral"/>
301
  <accelerator name="FormatAsPercentage" action="FormatAsPercentage"/>
301
  <accelerator name="FormatAsPercentage" action="FormatAsPercentage"/>
302
  <accelerator name="FormatAsScientific" action="FormatAsScientific"/>
302
  <accelerator name="FormatAsScientific" action="FormatAsScientific"/>
303
  <accelerator name="FormatAsDate"	 action="FormatAsDate"/>
303
  <accelerator name="FormatAsDate"	 action="FormatAsDate"/>
(-)src/application.c (-3 / +8 lines)
Lines 124-133 add_icon (GtkIconFactory *factory, Link Here
124
}
124
}
125
125
126
/**
126
/**
127
 * gnm_app_workbook_list_remove :
127
 * gnm_app_workbook_list_add :
128
 * @wb :
128
 * @wb :
129
 *
129
 *
130
 * Remove @wb from the application's list of workbooks.
130
 * Add @wb to the application's list of workbooks.
131
 **/
131
 **/
132
void
132
void
133
gnm_app_workbook_list_add (Workbook *wb)
133
gnm_app_workbook_list_add (Workbook *wb)
Lines 532-538 gnm_app_history_add (char const *uri) Link Here
532
	g_object_notify (G_OBJECT (app), "file-history-list");
532
	g_object_notify (G_OBJECT (app), "file-history-list");
533
	gnm_gconf_set_file_history_files (
533
	gnm_gconf_set_file_history_files (
534
		gnm_string_slist_copy (app->history_list));
534
		gnm_string_slist_copy (app->history_list));
535
	go_conf_sync ();
535
	go_conf_sync (NULL);
536
}
536
}
537
537
538
gboolean gnm_app_use_auto_complete	  (void) { return gnm_app_prefs->auto_complete; }
538
gboolean gnm_app_use_auto_complete	  (void) { return gnm_app_prefs->auto_complete; }
Lines 780-786 gnumeric_application_finalize (GObject * Link Here
780
	g_slist_foreach (application->history_list, (GFunc)g_free, NULL);
780
	g_slist_foreach (application->history_list, (GFunc)g_free, NULL);
781
	g_slist_free (application->history_list);
781
	g_slist_free (application->history_list);
782
	application->history_list = NULL;
782
	application->history_list = NULL;
783
784
	g_free (application->clipboard_cut_range);
785
	application->clipboard_cut_range = NULL;
786
783
	g_hash_table_destroy (application->named_pixbufs);
787
	g_hash_table_destroy (application->named_pixbufs);
788
784
	app = NULL;
789
	app = NULL;
785
	G_OBJECT_CLASS (parent_klass)->finalize (obj);
790
	G_OBJECT_CLASS (parent_klass)->finalize (obj);
786
}
791
}
(-)src/collect.c (-4 / +13 lines)
Lines 17-22 Link Here
17
#include "datetime.h"
17
#include "datetime.h"
18
#include "workbook.h"
18
#include "workbook.h"
19
#include "sheet.h"
19
#include "sheet.h"
20
#include "number-match.h"
20
21
21
/* ------------------------------------------------------------------------- */
22
/* ------------------------------------------------------------------------- */
22
23
Lines 74-82 callback_function_collect (GnmEvalPos co Link Here
74
		break;
75
		break;
75
76
76
	case VALUE_STRING:
77
	case VALUE_STRING:
77
	        if (cl->flags & COLLECT_DATES) {
78
	        if (cl->flags & COLLECT_COERCE_STRINGS) {
78
		        x = datetime_value_to_serial (value, cl->date_conv);
79
			GnmValue *vc = format_match_number (value_peek_string (value),
79
			if (x == 0)
80
							    NULL,
81
							    cl->date_conv);
82
			gboolean bad = !vc || VALUE_TYPE(vc) == VALUE_BOOLEAN;
83
			if (vc) {
84
				x = value_get_as_float (vc);
85
				value_release (vc);
86
			}
87
88
			if (bad)
80
			        return value_new_error_VALUE (ep);
89
			        return value_new_error_VALUE (ep);
81
		} else if (cl->flags & COLLECT_IGNORE_STRINGS)
90
		} else if (cl->flags & COLLECT_IGNORE_STRINGS)
82
			goto callback_function_collect_store_info;
91
			goto callback_function_collect_store_info;
Lines 121-129 callback_function_collect (GnmEvalPos co Link Here
121
 * exprlist:       List of expressions to evaluate.
130
 * exprlist:       List of expressions to evaluate.
122
 * cr:             Current location (for resolving relative cells).
131
 * cr:             Current location (for resolving relative cells).
123
 * flags:          COLLECT_IGNORE_STRINGS: silently ignore strings.
132
 * flags:          COLLECT_IGNORE_STRINGS: silently ignore strings.
133
 *                 COLLECT_COERCE_STRINGS: coerce string into numbers
124
 *                 COLLECT_ZERO_STRINGS: count strings as 0.
134
 *                 COLLECT_ZERO_STRINGS: count strings as 0.
125
 *                   (Alternative: return #VALUE!.)
135
 *                   (Alternative: return #VALUE!.)
126
 *                 COLLECT_DATES: count strings as dates.
127
 *                 COLLECT_IGNORE_BOOLS: silently ignore bools.
136
 *                 COLLECT_IGNORE_BOOLS: silently ignore bools.
128
 *                 COLLECT_ZEROONE_BOOLS: count FALSE as 0, TRUE as 1.
137
 *                 COLLECT_ZEROONE_BOOLS: count FALSE as 0, TRUE as 1.
129
 *                   (Alternative: return #VALUE!.)
138
 *                   (Alternative: return #VALUE!.)
(-)src/collect.h (-1 / +1 lines)
Lines 7-12 Link Here
7
typedef enum {
7
typedef enum {
8
	COLLECT_IGNORE_STRINGS	= 0x01,
8
	COLLECT_IGNORE_STRINGS	= 0x01,
9
	COLLECT_ZERO_STRINGS	= 0x02,
9
	COLLECT_ZERO_STRINGS	= 0x02,
10
	COLLECT_COERCE_STRINGS	= 0x04,
10
11
11
	COLLECT_IGNORE_BOOLS	= 0x10,
12
	COLLECT_IGNORE_BOOLS	= 0x10,
12
	COLLECT_ZEROONE_BOOLS	= 0x20,
13
	COLLECT_ZEROONE_BOOLS	= 0x20,
Lines 16-22 typedef enum { Link Here
16
17
17
	COLLECT_IGNORE_BLANKS	= 0x1000,
18
	COLLECT_IGNORE_BLANKS	= 0x1000,
18
	COLLECT_IGNORE_SUBTOTAL	= 0x2000,
19
	COLLECT_IGNORE_SUBTOTAL	= 0x2000,
19
	COLLECT_DATES		= 0x4000,
20
	COLLECT_INFO		= 0x8000,
20
	COLLECT_INFO		= 0x8000,
21
21
22
	COLLECT_NO_INFO_MASK	= 0x7777
22
	COLLECT_NO_INFO_MASK	= 0x7777
(-)src/colrow.c (+2 lines)
Lines 153-158 colrow_foreach (ColRowCollection const * Link Here
153
{
153
{
154
	int i;
154
	int i;
155
155
156
	g_return_val_if_fail (first >= 0, FALSE);
157
156
	/* TODO : Do we need to support right -> left as an option */
158
	/* TODO : Do we need to support right -> left as an option */
157
159
158
	/* clip */
160
	/* clip */
(-)src/commands.c (-35 / +37 lines)
Lines 247-261 cmd_cell_range_is_locked_effective (Shee Link Here
247
		for (i = range->start.row; i <= range->end.row; i++)
247
		for (i = range->start.row; i <= range->end.row; i++)
248
			for (j = range->start.col; j <= range->end.col; j++)
248
			for (j = range->start.col; j <= range->end.col; j++)
249
				if (mstyle_get_content_locked (sheet_style_get (sheet, j, i))) {
249
				if (mstyle_get_content_locked (sheet_style_get (sheet, j, i))) {
250
					char *text;
250
					char *r = global_range_name (sheet, range);
251
					text = g_strdup_printf (wbv->is_protected  ?
251
					char *text = g_strdup_printf (wbv->is_protected  ?
252
				 _("%s is locked. Unprotect the workbook to enable editing.") :
252
				 _("%s is locked. Unprotect the workbook to enable editing.") :
253
				 _("%s is locked. Unprotect the sheet to enable editing."),
253
				 _("%s is locked. Unprotect the sheet to enable editing."),
254
								undo_global_range_name (
254
						 r);
255
									sheet, range));
255
					gnm_cmd_context_error_invalid (GNM_CMD_CONTEXT (wbc),
256
					gnm_cmd_context_error_invalid (GNM_CMD_CONTEXT (wbc), cmd_name,
256
						cmd_name, text);
257
								text);
258
					g_free (text);
257
					g_free (text);
258
					g_free (r);
259
					return TRUE;
259
					return TRUE;
260
				}
260
				}
261
	return FALSE;
261
	return FALSE;
Lines 368-374 undo_redo_menu_labels (Workbook *wb) Link Here
368
}
368
}
369
369
370
static void
370
static void
371
update_after_action (Sheet *sheet, Workbook *wb)
371
update_after_action (Sheet *sheet, WorkbookControl *wbc)
372
{
372
{
373
	if (sheet != NULL) {
373
	if (sheet != NULL) {
374
		g_return_if_fail (IS_SHEET (sheet));
374
		g_return_if_fail (IS_SHEET (sheet));
Lines 378-392 update_after_action (Sheet *sheet, Workb Link Here
378
			workbook_recalc (sheet->workbook);
378
			workbook_recalc (sheet->workbook);
379
		sheet_update (sheet);
379
		sheet_update (sheet);
380
380
381
		WORKBOOK_FOREACH_CONTROL (sheet->workbook, view, control,
381
		if (sheet->workbook == wb_control_workbook (wbc))
382
			  wb_control_sheet_focus (control, sheet);
382
			WORKBOOK_VIEW_FOREACH_CONTROL (wb_control_view (wbc), control,
383
		);
383
				  wb_control_sheet_focus (control, sheet););
384
	} else if (wb != NULL) {
384
	} else if (wbc != NULL)
385
		WORKBOOK_FOREACH_CONTROL (wb, view, wbc, {
386
			wb_control_sheet_focus (wbc, sheet);
387
			sheet_update (wb_control_cur_sheet (wbc));
385
			sheet_update (wb_control_cur_sheet (wbc));
388
		});
389
	}
390
}
386
}
391
387
392
/*
388
/*
Lines 507-513 command_undo (WorkbookControl *wbc) Link Here
507
	/* TRUE indicates a failure to undo.  Leave the command where it is */
503
	/* TRUE indicates a failure to undo.  Leave the command where it is */
508
	if (klass->undo_cmd (cmd, wbc))
504
	if (klass->undo_cmd (cmd, wbc))
509
		return;
505
		return;
510
	update_after_action (cmd->sheet, wb);
506
	update_after_action (cmd->sheet, wbc);
511
507
512
	wb->undo_commands = g_slist_remove (wb->undo_commands,
508
	wb->undo_commands = g_slist_remove (wb->undo_commands,
513
					    wb->undo_commands->data);
509
					    wb->undo_commands->data);
Lines 546-552 command_redo (WorkbookControl *wbc) Link Here
546
	/* TRUE indicates a failure to redo.  Leave the command where it is */
542
	/* TRUE indicates a failure to redo.  Leave the command where it is */
547
	if (klass->redo_cmd (cmd, wbc))
543
	if (klass->redo_cmd (cmd, wbc))
548
		return;
544
		return;
549
	update_after_action (cmd->sheet, wb);
545
	update_after_action (cmd->sheet, wbc);
550
546
551
	/* Remove the command from the undo list */
547
	/* Remove the command from the undo list */
552
	wb->redo_commands = g_slist_remove (wb->redo_commands,
548
	wb->redo_commands = g_slist_remove (wb->redo_commands,
Lines 608-614 command_setup_combos (WorkbookControl *w Link Here
608
		undo_label = get_menu_label (ptr);
604
		undo_label = get_menu_label (ptr);
609
		wb_control_undo_redo_push (wbc, TRUE, undo_label, ptr->data);
605
		wb_control_undo_redo_push (wbc, TRUE, undo_label, ptr->data);
610
	}
606
	}
611
	g_slist_reverse (tmp);
607
	(void) g_slist_reverse (tmp);
612
608
613
	wb_control_undo_redo_truncate (wbc, 0, FALSE);
609
	wb_control_undo_redo_truncate (wbc, 0, FALSE);
614
	tmp = g_slist_reverse (wb->redo_commands);
610
	tmp = g_slist_reverse (wb->redo_commands);
Lines 616-622 command_setup_combos (WorkbookControl *w Link Here
616
		redo_label = get_menu_label (ptr);
612
		redo_label = get_menu_label (ptr);
617
		wb_control_undo_redo_push (wbc, FALSE, redo_label, ptr->data);
613
		wb_control_undo_redo_push (wbc, FALSE, redo_label, ptr->data);
618
	}
614
	}
619
	g_slist_reverse (tmp);
615
	(void) g_slist_reverse (tmp);
620
616
621
	/* update the menus too */
617
	/* update the menus too */
622
	wb_control_undo_redo_labels (wbc, undo_label, redo_label);
618
	wb_control_undo_redo_labels (wbc, undo_label, redo_label);
Lines 792-798 command_push_undo (WorkbookControl *wbc, Link Here
792
788
793
	/* TRUE indicates a failure to do the command */
789
	/* TRUE indicates a failure to do the command */
794
	trouble = klass->redo_cmd (cmd, wbc);
790
	trouble = klass->redo_cmd (cmd, wbc);
795
	update_after_action (cmd->sheet, wb);
791
	update_after_action (cmd->sheet, wbc);
796
792
797
	if (!trouble)
793
	if (!trouble)
798
		command_register_undo (wbc, obj);
794
		command_register_undo (wbc, obj);
Lines 3845-3851 typedef struct { Link Here
3845
3841
3846
3842
3847
static void
3843
static void
3848
cmd_search_replace_update_after_action (CmdSearchReplace *me)
3844
cmd_search_replace_update_after_action (CmdSearchReplace *me,
3845
					WorkbookControl *wbc)
3849
{
3846
{
3850
	GList *tmp;
3847
	GList *tmp;
3851
	Sheet *last_sheet = NULL;
3848
	Sheet *last_sheet = NULL;
Lines 3854-3860 cmd_search_replace_update_after_action ( Link Here
3854
		SearchReplaceItem *sri = tmp->data;
3851
		SearchReplaceItem *sri = tmp->data;
3855
		if (sri->pos.sheet != last_sheet) {
3852
		if (sri->pos.sheet != last_sheet) {
3856
			last_sheet = sri->pos.sheet;
3853
			last_sheet = sri->pos.sheet;
3857
			update_after_action (last_sheet, NULL);
3854
			update_after_action (last_sheet, wbc);
3858
		}
3855
		}
3859
	}
3856
	}
3860
}
3857
}
Lines 3862-3868 cmd_search_replace_update_after_action ( Link Here
3862
3859
3863
static gboolean
3860
static gboolean
3864
cmd_search_replace_undo (GnmCommand *cmd,
3861
cmd_search_replace_undo (GnmCommand *cmd,
3865
			 G_GNUC_UNUSED WorkbookControl *wbc)
3862
			 WorkbookControl *wbc)
3866
{
3863
{
3867
	CmdSearchReplace *me = CMD_SEARCH_REPLACE (cmd);
3864
	CmdSearchReplace *me = CMD_SEARCH_REPLACE (cmd);
3868
	GList *tmp;
3865
	GList *tmp;
Lines 3893-3906 cmd_search_replace_undo (GnmCommand *cmd Link Here
3893
		break;
3890
		break;
3894
		}
3891
		}
3895
	}
3892
	}
3896
	cmd_search_replace_update_after_action (me);
3893
	cmd_search_replace_update_after_action (me, wbc);
3897
3894
3898
	return FALSE;
3895
	return FALSE;
3899
}
3896
}
3900
3897
3901
static gboolean
3898
static gboolean
3902
cmd_search_replace_redo (GnmCommand *cmd,
3899
cmd_search_replace_redo (GnmCommand *cmd,
3903
			 G_GNUC_UNUSED WorkbookControl *wbc)
3900
			 WorkbookControl *wbc)
3904
{
3901
{
3905
	CmdSearchReplace *me = CMD_SEARCH_REPLACE (cmd);
3902
	CmdSearchReplace *me = CMD_SEARCH_REPLACE (cmd);
3906
	GList *tmp;
3903
	GList *tmp;
Lines 3931-3937 cmd_search_replace_redo (GnmCommand *cmd Link Here
3931
		break;
3928
		break;
3932
		}
3929
		}
3933
	}
3930
	}
3934
	cmd_search_replace_update_after_action (me);
3931
	cmd_search_replace_update_after_action (me, wbc);
3935
3932
3936
	return FALSE;
3933
	return FALSE;
3937
}
3934
}
Lines 4074-4082 cmd_search_replace_do_cell (CmdSearchRep Link Here
4074
4071
4075
4072
4076
static gboolean
4073
static gboolean
4077
cmd_search_replace_do (CmdSearchReplace *me,
4074
cmd_search_replace_do (CmdSearchReplace *me, Sheet *sheet,
4078
		       G_GNUC_UNUSED Workbook *wb, Sheet *sheet,
4075
		       gboolean test_run, WorkbookControl *wbc)
4079
		       gboolean test_run)
4080
{
4076
{
4081
	GnmSearchReplace *sr = me->sr;
4077
	GnmSearchReplace *sr = me->sr;
4082
	GPtrArray *cells;
4078
	GPtrArray *cells;
Lines 4114-4120 cmd_search_replace_do (CmdSearchReplace Link Here
4114
		/* Cells were added in the wrong order.  Correct.  */
4110
		/* Cells were added in the wrong order.  Correct.  */
4115
		me->cells = g_list_reverse (me->cells);
4111
		me->cells = g_list_reverse (me->cells);
4116
4112
4117
		cmd_search_replace_update_after_action (me);
4113
		cmd_search_replace_update_after_action (me, wbc);
4118
	}
4114
	}
4119
4115
4120
	return result;
4116
	return result;
Lines 4158-4164 cmd_search_replace (WorkbookControl *wbc Link Here
4158
{
4154
{
4159
	GObject *obj;
4155
	GObject *obj;
4160
	CmdSearchReplace *me;
4156
	CmdSearchReplace *me;
4161
	Workbook *wb = wb_control_workbook (wbc);
4162
4157
4163
	g_return_val_if_fail (sr != NULL, TRUE);
4158
	g_return_val_if_fail (sr != NULL, TRUE);
4164
4159
Lines 4172-4184 cmd_search_replace (WorkbookControl *wbc Link Here
4172
	me->cmd.size = 1;  /* Corrected below. */
4167
	me->cmd.size = 1;  /* Corrected below. */
4173
	me->cmd.cmd_descriptor = g_strdup (_("Search and Replace"));
4168
	me->cmd.cmd_descriptor = g_strdup (_("Search and Replace"));
4174
4169
4175
	if (cmd_search_replace_do (me, wb, sheet, TRUE)) {
4170
	if (cmd_search_replace_do (me, sheet, TRUE, wbc)) {
4176
		/* There was an error and nothing was done.  */
4171
		/* There was an error and nothing was done.  */
4177
		g_object_unref (obj);
4172
		g_object_unref (obj);
4178
		return TRUE;
4173
		return TRUE;
4179
	}
4174
	}
4180
4175
4181
	cmd_search_replace_do (me, wb, sheet, FALSE);
4176
	cmd_search_replace_do (me, sheet, FALSE, wbc);
4182
	me->cmd.size += g_list_length (me->cells);
4177
	me->cmd.size += g_list_length (me->cells);
4183
4178
4184
	command_register_undo (wbc, obj);
4179
	command_register_undo (wbc, obj);
Lines 6559-6575 cmd_text_to_columns (WorkbookControl *wb Link Here
6559
{
6554
{
6560
	GObject *obj;
6555
	GObject *obj;
6561
	CmdTextToColumns *me;
6556
	CmdTextToColumns *me;
6557
	char *src_range_name, *target_range_name;
6562
6558
6563
	g_return_val_if_fail (content != NULL, TRUE);
6559
	g_return_val_if_fail (content != NULL, TRUE);
6564
6560
6561
	src_range_name = undo_global_range_name (src_sheet, src);
6562
	target_range_name = undo_global_range_name (target_sheet, target);
6563
6565
	obj = g_object_new (CMD_TEXT_TO_COLUMNS_TYPE, NULL);
6564
	obj = g_object_new (CMD_TEXT_TO_COLUMNS_TYPE, NULL);
6566
	me = CMD_TEXT_TO_COLUMNS (obj);
6565
	me = CMD_TEXT_TO_COLUMNS (obj);
6567
6566
6568
	me->cmd.sheet = (src_sheet == target_sheet ? src_sheet : NULL);
6567
	me->cmd.sheet = (src_sheet == target_sheet ? src_sheet : NULL);
6569
	me->cmd.size = 1;  /* FIXME?  */
6568
	me->cmd.size = 1;  /* FIXME?  */
6570
	me->cmd.cmd_descriptor = g_strdup_printf (_("Text (%s) to Columns (%s)"),
6569
	me->cmd.cmd_descriptor = g_strdup_printf (_("Text (%s) to Columns (%s)"),
6571
						  undo_global_range_name (src_sheet, src),
6570
						  src_range_name,
6572
						  undo_global_range_name (target_sheet, target));
6571
						  target_range_name);
6573
	me->dst.range = *target;
6572
	me->dst.range = *target;
6574
	me->dst.sheet = target_sheet;
6573
	me->dst.sheet = target_sheet;
6575
	me->dst.paste_flags = PASTE_CONTENT | PASTE_FORMATS;
6574
	me->dst.paste_flags = PASTE_CONTENT | PASTE_FORMATS;
Lines 6577-6582 cmd_text_to_columns (WorkbookControl *wb Link Here
6577
	me->src_sheet = src_sheet;
6576
	me->src_sheet = src_sheet;
6578
	me->content = content;
6577
	me->content = content;
6579
	me->saved_sizes = NULL;
6578
	me->saved_sizes = NULL;
6579
6580
	g_free (src_range_name);
6581
	g_free (target_range_name);
6580
6582
6581
	/* Check array subdivision & merged regions */
6583
	/* Check array subdivision & merged regions */
6582
	if (sheet_range_splits_region (target_sheet, &me->dst.range,
6584
	if (sheet_range_splits_region (target_sheet, &me->dst.range,
(-)src/datetime.c (-10 lines)
Lines 187-202 datetime_serial_raw_to_seconds (gnm_floa Link Here
187
/* ------------------------------------------------------------------------- */
187
/* ------------------------------------------------------------------------- */
188
188
189
int
189
int
190
datetime_value_to_seconds (GnmValue const *v)
191
{
192
	/* we just want the seconds, actual date does not matter. So we can ignore
193
	 * the date convention (1900 vs 1904) */
194
	return datetime_serial_raw_to_seconds (datetime_value_to_serial_raw (v, NULL));
195
}
196
197
/* ------------------------------------------------------------------------- */
198
199
int
200
datetime_timet_to_seconds (time_t t)
190
datetime_timet_to_seconds (time_t t)
201
{
191
{
202
	/* we just want the seconds, actual date does not matter. So we can ignore
192
	/* we just want the seconds, actual date does not matter. So we can ignore
(-)src/datetime.h (-3 lines)
Lines 40-48 void datetime_serial_to_g (GDate *r Link Here
40
time_t   datetime_serial_to_timet	(int serial,		 GnmDateConventions const *conv);
40
time_t   datetime_serial_to_timet	(int serial,		 GnmDateConventions const *conv);
41
int      datetime_serial_raw_to_serial	(gnm_float raw);
41
int      datetime_serial_raw_to_serial	(gnm_float raw);
42
42
43
/* These are time-only assuming a 24h day.  It probably loses completely on */
44
/* days with summer time ("daylight savings") changes.  */
45
int datetime_value_to_seconds (GnmValue const *v);
46
int datetime_timet_to_seconds (time_t t);
43
int datetime_timet_to_seconds (time_t t);
47
int datetime_serial_raw_to_seconds (gnm_float raw);
44
int datetime_serial_raw_to_seconds (gnm_float raw);
48
45
(-)src/dependent.c (-1 / +2 lines)
Lines 1977-1988 do_deps_destroy (Sheet *sheet, GnmExprRe Link Here
1977
		}
1977
		}
1978
	}
1978
	}
1979
	g_slist_free (local_dyn_deps);
1979
	g_slist_free (local_dyn_deps);
1980
	local_dyn_deps = NULL;
1980
1981
1981
	/* Filter workbook local deps for GNM_EXPR_REWRITE_WORKBOOK */
1982
	/* Filter workbook local deps for GNM_EXPR_REWRITE_WORKBOOK */
1982
	if (rwinfo->type == GNM_EXPR_REWRITE_WORKBOOK) {
1983
	if (rwinfo->type == GNM_EXPR_REWRITE_WORKBOOK) {
1983
		Workbook const *target = rwinfo->u.workbook;
1984
		Workbook const *target = rwinfo->u.workbook;
1984
		ptr = dyn_deps;
1985
		ptr = dyn_deps;
1985
		dyn_deps = local_dyn_deps = NULL;
1986
		dyn_deps = NULL;
1986
		for (; ptr != NULL ; ptr = next) {
1987
		for (; ptr != NULL ; ptr = next) {
1987
			dep = ptr->data;
1988
			dep = ptr->data;
1988
			next = ptr->next;
1989
			next = ptr->next;
(-)src/gnumeric-canvas.c (-11 / +20 lines)
Lines 424-440 gnm_canvas_key_press (GtkWidget *widget, Link Here
424
		res = gnm_canvas_key_mode_object (gcanvas, event);
424
		res = gnm_canvas_key_mode_object (gcanvas, event);
425
	else {
425
	else {
426
		gcanvas->mask_state = event->state;
426
		gcanvas->mask_state = event->state;
427
		if (gtk_im_context_filter_keypress (gcanvas->im_context,event)) {
427
		gcanvas->insert_decimal = event->keyval == GDK_KP_Decimal ||
428
			gcanvas->need_im_reset = TRUE;
428
					  event->keyval == GDK_KP_Separator;
429
		if (gtk_im_context_filter_keypress (gcanvas->im_context,event))
429
			return TRUE;
430
			return TRUE;
430
		}
431
		switch (event->keyval) {
431
		switch (event->keyval) {
432
		case GDK_Shift_L:   case GDK_Shift_R:
432
		case GDK_Shift_L:   case GDK_Shift_R:
433
		case GDK_Alt_L:     case GDK_Alt_R:
433
		case GDK_Alt_L:     case GDK_Alt_R:
434
		case GDK_Control_L: case GDK_Control_R:
434
		case GDK_Control_L: case GDK_Control_R:
435
			break;
435
			break;
436
		default:
436
		default:
437
			gcanvas->reseting_im = TRUE;
437
			gtk_im_context_reset (gcanvas->im_context);
438
			gtk_im_context_reset (gcanvas->im_context);
439
			gcanvas->reseting_im = FALSE;
438
			break;
440
			break;
439
		}
441
		}
440
		res = gnm_canvas_key_mode_sheet (gcanvas, event);
442
		res = gnm_canvas_key_mode_sheet (gcanvas, event);
Lines 463-472 gnm_canvas_key_release (GtkWidget *widge Link Here
463
		return TRUE;
465
		return TRUE;
464
466
465
	if (gtk_im_context_filter_keypress (gcanvas->im_context,event))
467
	if (gtk_im_context_filter_keypress (gcanvas->im_context,event))
466
	{
467
		gcanvas->need_im_reset = TRUE;
468
		return TRUE;
468
		return TRUE;
469
	}
470
	/*
469
	/*
471
	 * The status_region normally displays the current edit_pos
470
	 * The status_region normally displays the current edit_pos
472
	 * When we extend the selection it changes to displaying the size of
471
	 * When we extend the selection it changes to displaying the size of
Lines 486-492 gnm_canvas_key_release (GtkWidget *widge Link Here
486
static gint
485
static gint
487
gnm_canvas_focus_in (GtkWidget *widget, GdkEventFocus *event)
486
gnm_canvas_focus_in (GtkWidget *widget, GdkEventFocus *event)
488
{
487
{
489
	GNM_CANVAS (widget)->need_im_reset = TRUE;
490
	gtk_im_context_focus_in (GNM_CANVAS (widget)->im_context);
488
	gtk_im_context_focus_in (GNM_CANVAS (widget)->im_context);
491
	return (*GTK_WIDGET_CLASS (parent_klass)->focus_in_event) (widget, event);
489
	return (*GTK_WIDGET_CLASS (parent_klass)->focus_in_event) (widget, event);
492
}
490
}
Lines 495-501 gnm_canvas_focus_in (GtkWidget *widget, Link Here
495
static gint
493
static gint
496
gnm_canvas_focus_out (GtkWidget *widget, GdkEventFocus *event)
494
gnm_canvas_focus_out (GtkWidget *widget, GdkEventFocus *event)
497
{
495
{
498
	GNM_CANVAS (widget)->need_im_reset = TRUE;
499
	gtk_im_context_focus_out (GNM_CANVAS (widget)->im_context);
496
	gtk_im_context_focus_out (GNM_CANVAS (widget)->im_context);
500
	return (*GTK_WIDGET_CLASS (parent_klass)->focus_out_event) (widget, event);
497
	return (*GTK_WIDGET_CLASS (parent_klass)->focus_out_event) (widget, event);
501
}
498
}
Lines 586-597 gnm_canvas_commit_cb (GtkIMContext *cont Link Here
586
{
583
{
587
	WorkbookControlGUI *wbcg = gcanvas->simple.scg->wbcg;
584
	WorkbookControlGUI *wbcg = gcanvas->simple.scg->wbcg;
588
	GtkEditable *editable = GTK_EDITABLE (gnm_expr_entry_get_entry (wbcg_get_entry_logical (wbcg)));
585
	GtkEditable *editable = GTK_EDITABLE (gnm_expr_entry_get_entry (wbcg_get_entry_logical (wbcg)));
589
	gint tmp_pos;
586
	gint tmp_pos, length;
590
587
591
	if (!wbcg_is_editing (wbcg) &&
588
	if (!wbcg_is_editing (wbcg) &&
592
	    !wbcg_edit_start (wbcg, TRUE, TRUE))
589
	    !wbcg_edit_start (wbcg, TRUE, TRUE))
593
		return;
590
		return;
594
591
592
	if (gcanvas->insert_decimal) {
593
		GString const *s = format_get_decimal ();
594
		str = s->str;
595
		length = s->len;
596
	} else
597
		length = strlen (str);
598
595
	if (gtk_editable_get_selection_bounds (editable, NULL, NULL))
599
	if (gtk_editable_get_selection_bounds (editable, NULL, NULL))
596
		gtk_editable_delete_selection (editable);
600
		gtk_editable_delete_selection (editable);
597
	else {
601
	else {
Lines 601-607 gnm_canvas_commit_cb (GtkIMContext *cont Link Here
601
	}
605
	}
602
606
603
	tmp_pos = gtk_editable_get_position (editable);
607
	tmp_pos = gtk_editable_get_position (editable);
604
	gtk_editable_insert_text (editable, str, strlen (str), &tmp_pos);
608
	gtk_editable_insert_text (editable, str, length, &tmp_pos);
605
	gtk_editable_set_position (editable, tmp_pos);
609
	gtk_editable_set_position (editable, tmp_pos);
606
}
610
}
607
611
Lines 619-625 gnm_canvas_preedit_changed_cb (GtkIMCont Link Here
619
		pango_attr_list_unref (gcanvas->preedit_attrs);
623
		pango_attr_list_unref (gcanvas->preedit_attrs);
620
	gtk_im_context_get_preedit_string (gcanvas->im_context, &preedit_string, &gcanvas->preedit_attrs, &cursor_pos);
624
	gtk_im_context_get_preedit_string (gcanvas->im_context, &preedit_string, &gcanvas->preedit_attrs, &cursor_pos);
621
625
622
	if (!wbcg_is_editing (wbcg) && !wbcg_edit_start (wbcg, TRUE, TRUE)) {
626
	/* in gtk-2.8 something changed.  gtk_im_context_reset started
627
	 * triggering a pre-edit-changed.  We'd end up start and finishing an
628
	 * empty edit every time the cursor moved */
629
	if (!gcanvas->reseting_im &&
630
	    !wbcg_is_editing (wbcg) && !wbcg_edit_start (wbcg, TRUE, TRUE)) {
623
		gtk_im_context_reset (gcanvas->im_context);
631
		gtk_im_context_reset (gcanvas->im_context);
624
		gcanvas->preedit_length = 0;
632
		gcanvas->preedit_length = 0;
625
		if (gcanvas->preedit_attrs)
633
		if (gcanvas->preedit_attrs)
Lines 691-696 gnm_canvas_init (GnmCanvas *gcanvas) Link Here
691
	gcanvas->im_context = gtk_im_multicontext_new ();
699
	gcanvas->im_context = gtk_im_multicontext_new ();
692
	gcanvas->preedit_length = 0;
700
	gcanvas->preedit_length = 0;
693
	gcanvas->preedit_attrs = NULL;
701
	gcanvas->preedit_attrs = NULL;
702
	gcanvas->reseting_im = FALSE;
694
703
695
	g_signal_connect (G_OBJECT (gcanvas->im_context), "commit",
704
	g_signal_connect (G_OBJECT (gcanvas->im_context), "commit",
696
		G_CALLBACK (gnm_canvas_commit_cb), gcanvas);
705
		G_CALLBACK (gnm_canvas_commit_cb), gcanvas);
(-)src/gnumeric-canvas.h (-1 / +2 lines)
Lines 36-46 struct _GnmCanvas { Link Here
36
	gboolean   sliding_adjacent_h, sliding_adjacent_v;
36
	gboolean   sliding_adjacent_h, sliding_adjacent_v;
37
37
38
	/*  IM */
38
	/*  IM */
39
	guint      need_im_reset :1;
39
	guint      reseting_im :1;	/* quick hack to keep gtk_im_context_reset from starting an edit */
40
	guint      mask_state;
40
	guint      mask_state;
41
	guint      preedit_length;
41
	guint      preedit_length;
42
	GtkIMContext  *im_context;
42
	GtkIMContext  *im_context;
43
	PangoAttrList *preedit_attrs;
43
	PangoAttrList *preedit_attrs;
44
	gboolean insert_decimal;
44
};
45
};
45
46
46
GType gnm_canvas_get_type (void);
47
GType gnm_canvas_get_type (void);
(-)src/gnumeric-gconf-priv.h (-91 / +93 lines)
Lines 8-119 Link Here
8
 *        dialogs/dialog-preferences.c
8
 *        dialogs/dialog-preferences.c
9
 */
9
 */
10
10
11
#define GNM_CONF_DIR			"gnumeric"
11
12
12
/*
13
/*
13
 *  schemas/gnumeric-dialogs.schemas
14
 *  schemas/gnumeric-dialogs.schemas
14
 */
15
 */
15
#define FUNCTION_SELECT_GCONF_RECENT "/apps/gnumeric/functionselector/recentfunctions"
16
#define FUNCTION_SELECT_GCONF_DIR		"functionselector"
16
#define FUNCTION_SELECT_GCONF_NUM_OF_RECENT "/apps/gnumeric/functionselector/num-of-recent"
17
#define FUNCTION_SELECT_GCONF_RECENT		"recentfunctions"
18
#define FUNCTION_SELECT_GCONF_NUM_OF_RECENT	"num-of-recent"
19
20
#define CONF_DEFAULT_FONT_DIR	  "core/defaultfont"
21
#define CONF_DEFAULT_FONT_NAME	  "name"
22
#define CONF_DEFAULT_FONT_SIZE	  "size"
23
#define CONF_DEFAULT_FONT_BOLD	  "bold"
24
#define CONF_DEFAULT_FONT_ITALIC  "italic"
25
26
#define PLUGIN_GCONF_DIR		"plugins"
27
#define PLUGIN_GCONF_ACTIVATE_NEW	"activate-new"
28
#define PLUGIN_GCONF_ACTIVE		"active"
29
#define PLUGIN_GCONF_FILE_STATES	"file-states"
30
#define PLUGIN_GCONF_EXTRA_DIRS		"extra-dirs"
31
32
#define AUTOFORMAT_GCONF_DIR		"autoformat"
33
#define AUTOFORMAT_GCONF_EXTRA_DIRS	"extra-dirs"
34
#define AUTOFORMAT_GCONF_SYS_DIR	"sys-dir"
35
#define AUTOFORMAT_GCONF_USR_DIR	"usr-dir"
36
37
#define PRINTSETUP_GCONF_DIR			"printsetup"
38
#define PRINTSETUP_GCONF_ALL_SHEETS		"all-sheets"
39
#define PRINTSETUP_GCONF_PRINTER_CONFIG		"printer-config"
40
#define PRINTSETUP_GCONF_HEADER			"header"
41
#define PRINTSETUP_GCONF_FOOTER			"footer"
42
#define PRINTSETUP_GCONF_HF_FONT_NAME		"hf-font-name"
43
#define PRINTSETUP_GCONF_HF_FONT_SIZE		"hf-font-size"
44
#define PRINTSETUP_GCONF_HF_FONT_BOLD		"hf-font-bold"
45
#define PRINTSETUP_GCONF_HF_FONT_ITALIC		"hf-font-italic"
46
#define PRINTSETUP_GCONF_CENTER_HORIZONTALLY	"center-horizontally"
47
#define PRINTSETUP_GCONF_CENTER_VERTICALLY	"center-vertically"
48
#define PRINTSETUP_GCONF_PRINT_GRID_LINES	"print-grid-lines"
49
#define PRINTSETUP_GCONF_EVEN_IF_ONLY_STYLES	"print-even-if-only-styles"
50
#define PRINTSETUP_GCONF_PRINT_BLACK_AND_WHITE	"print-black-n-white"
51
#define PRINTSETUP_GCONF_PRINT_TITLES		"print-titles"
52
#define PRINTSETUP_GCONF_RIGHT_THEN_DOWN	"right-then-down"
53
#define PRINTSETUP_GCONF_SCALE_PERCENTAGE	"scale-percentage"
54
#define PRINTSETUP_GCONF_SCALE_PERCENTAGE_VALUE	"scale-percentage-value"
55
#define PRINTSETUP_GCONF_SCALE_WIDTH		"scale-width"
56
#define PRINTSETUP_GCONF_SCALE_HEIGHT		"scale-height"
57
#define PRINTSETUP_GCONF_REPEAT_TOP		"repeat-top"
58
#define PRINTSETUP_GCONF_REPEAT_LEFT		"repeat-left"
59
#define PRINTSETUP_GCONF_MARGIN_TOP		"margin-top"
60
#define PRINTSETUP_GCONF_MARGIN_BOTTOM		"margin-bottom"
61
#define PRINTSETUP_GCONF_HEADER_FORMAT_LEFT	"hf-left"
62
#define PRINTSETUP_GCONF_HEADER_FORMAT_MIDDLE	"hf-middle"
63
#define PRINTSETUP_GCONF_HEADER_FORMAT_RIGHT	"hf-right"
17
64
18
#define CONF_DEFAULT_FONT_DIR	"/apps/gnumeric/core/defaultfont/"
65
#define DIALOGS_GCONF_DIR		"dialogs"
19
#define CONF_DEFAULT_FONT_NAME	  CONF_DEFAULT_FONT_DIR "name"
66
#define DIALOGS_GCONF_UNFOCUSED_RS	"rs/unfocused"
20
#define CONF_DEFAULT_FONT_SIZE	  CONF_DEFAULT_FONT_DIR "size"
21
#define CONF_DEFAULT_FONT_BOLD	  CONF_DEFAULT_FONT_DIR "bold"
22
#define CONF_DEFAULT_FONT_ITALIC  CONF_DEFAULT_FONT_DIR "italic"
23
24
#define PLUGIN_GCONF_DIRECTORY "/apps/gnumeric/plugins"
25
#define PLUGIN_GCONF_ACTIVATE_NEW PLUGIN_GCONF_DIRECTORY "/activate-new"
26
#define PLUGIN_GCONF_ACTIVE PLUGIN_GCONF_DIRECTORY "/active"
27
#define PLUGIN_GCONF_FILE_STATES PLUGIN_GCONF_DIRECTORY "/file-states"
28
#define PLUGIN_GCONF_EXTRA_DIRS PLUGIN_GCONF_DIRECTORY "/extra-dirs"
29
30
#define AUTOFORMAT_GCONF_DIRECTORY "/apps/gnumeric/autoformat"
31
#define AUTOFORMAT_GCONF_EXTRA_DIRS AUTOFORMAT_GCONF_DIRECTORY "/extra-dirs"
32
#define AUTOFORMAT_GCONF_SYS_DIR AUTOFORMAT_GCONF_DIRECTORY "/sys-dir"
33
#define AUTOFORMAT_GCONF_USR_DIR AUTOFORMAT_GCONF_DIRECTORY "/usr-dir"
34
35
#define PRINTSETUP_GCONF_DIRECTORY "/apps/gnumeric/printsetup"
36
#define PRINTSETUP_GCONF_ALL_SHEETS PRINTSETUP_GCONF_DIRECTORY "/all-sheets"
37
#define PRINTSETUP_GCONF_PRINTER_CONFIG PRINTSETUP_GCONF_DIRECTORY "/printer-config"
38
#define PRINTSETUP_GCONF_HEADER PRINTSETUP_GCONF_DIRECTORY "/header"
39
#define PRINTSETUP_GCONF_FOOTER PRINTSETUP_GCONF_DIRECTORY "/footer"
40
#define PRINTSETUP_GCONF_HF_FONT_NAME PRINTSETUP_GCONF_DIRECTORY "/hf-font-name"
41
#define PRINTSETUP_GCONF_HF_FONT_SIZE PRINTSETUP_GCONF_DIRECTORY "/hf-font-size"
42
#define PRINTSETUP_GCONF_HF_FONT_BOLD PRINTSETUP_GCONF_DIRECTORY "/hf-font-bold"
43
#define PRINTSETUP_GCONF_HF_FONT_ITALIC PRINTSETUP_GCONF_DIRECTORY "/hf-font-italic"
44
#define PRINTSETUP_GCONF_CENTER_HORIZONTALLY PRINTSETUP_GCONF_DIRECTORY "/center-horizontally"
45
#define PRINTSETUP_GCONF_CENTER_VERTICALLY PRINTSETUP_GCONF_DIRECTORY "/center-vertically"
46
#define PRINTSETUP_GCONF_PRINT_GRID_LINES PRINTSETUP_GCONF_DIRECTORY "/print-grid-lines"
47
#define PRINTSETUP_GCONF_EVEN_IF_ONLY_STYLES PRINTSETUP_GCONF_DIRECTORY "/print-even-if-only-styles"
48
#define PRINTSETUP_GCONF_PRINT_BLACK_AND_WHITE PRINTSETUP_GCONF_DIRECTORY "/print-black-n-white"
49
#define PRINTSETUP_GCONF_PRINT_TITLES PRINTSETUP_GCONF_DIRECTORY "/print-titles"
50
#define PRINTSETUP_GCONF_RIGHT_THEN_DOWN PRINTSETUP_GCONF_DIRECTORY "/right-then-down"
51
#define PRINTSETUP_GCONF_SCALE_PERCENTAGE PRINTSETUP_GCONF_DIRECTORY "/scale-percentage"
52
#define PRINTSETUP_GCONF_SCALE_PERCENTAGE_VALUE PRINTSETUP_GCONF_DIRECTORY "/scale-percentage-value"
53
#define PRINTSETUP_GCONF_SCALE_WIDTH PRINTSETUP_GCONF_DIRECTORY "/scale-width"
54
#define PRINTSETUP_GCONF_SCALE_HEIGHT PRINTSETUP_GCONF_DIRECTORY "/scale-height"
55
#define PRINTSETUP_GCONF_REPEAT_TOP PRINTSETUP_GCONF_DIRECTORY "/repeat-top"
56
#define PRINTSETUP_GCONF_REPEAT_LEFT PRINTSETUP_GCONF_DIRECTORY "/repeat-left"
57
#define PRINTSETUP_GCONF_MARGIN_TOP PRINTSETUP_GCONF_DIRECTORY "/margin-top"
58
#define PRINTSETUP_GCONF_MARGIN_BOTTOM PRINTSETUP_GCONF_DIRECTORY "/margin-bottom"
59
#define PRINTSETUP_GCONF_HEADER_FORMAT_LEFT PRINTSETUP_GCONF_DIRECTORY "/hf-left"
60
#define PRINTSETUP_GCONF_HEADER_FORMAT_MIDDLE PRINTSETUP_GCONF_DIRECTORY "/hf-middle"
61
#define PRINTSETUP_GCONF_HEADER_FORMAT_RIGHT PRINTSETUP_GCONF_DIRECTORY "/hf-right"
62
63
#define DIALOGS_GCONF_DIRECTORY "/apps/gnumeric/dialogs"
64
#define DIALOGS_GCONF_UNFOCUSED_RS DIALOGS_GCONF_DIRECTORY "/rs/unfocused"
65
67
66
/*
68
/*
67
 *  schemas/gnumeric-general.schemas
69
 *  schemas/gnumeric-general.schemas
68
 */
70
 */
69
71
70
#define GNM_CONF_UNDO_DIRECTORY "/apps/gnumeric/undo"
72
#define GNM_CONF_UNDO_DIR			"undo"
71
#define GNM_CONF_UNDO_SIZE GNM_CONF_UNDO_DIRECTORY "/size"
73
#define GNM_CONF_UNDO_SIZE			"size"
72
#define GNM_CONF_UNDO_MAXNUM GNM_CONF_UNDO_DIRECTORY "/maxnum"
74
#define GNM_CONF_UNDO_MAXNUM			"maxnum"
73
#define GNM_CONF_UNDO_SHOW_SHEET_NAME GNM_CONF_UNDO_DIRECTORY "/show_sheet_name"
75
#define GNM_CONF_UNDO_SHOW_SHEET_NAME		"show_sheet_name"
74
#define GNM_CONF_UNDO_MAX_DESCRIPTOR_WIDTH GNM_CONF_UNDO_DIRECTORY "/max_descriptor_width"
76
#define GNM_CONF_UNDO_MAX_DESCRIPTOR_WIDTH	"max_descriptor_width"
75
77
76
#define GNM_CONF_FONT_DIRECTORY "/apps/gnumeric/core/defaultfont"
78
#define GNM_CONF_FONT_DIR		"core/defaultfont"
77
#define GNM_CONF_FONT_NAME GNM_CONF_FONT_DIRECTORY "/name"
79
#define GNM_CONF_FONT_NAME		"name"
78
#define GNM_CONF_FONT_SIZE GNM_CONF_FONT_DIRECTORY "/size"
80
#define GNM_CONF_FONT_SIZE		"size"
79
#define GNM_CONF_FONT_BOLD GNM_CONF_FONT_DIRECTORY "/bold"
81
#define GNM_CONF_FONT_BOLD		"bold"
80
#define GNM_CONF_FONT_ITALIC GNM_CONF_FONT_DIRECTORY "/italic"
82
#define GNM_CONF_FONT_ITALIC		"italic"
81
83
82
#define GNM_CONF_FILE_DIRECTORY "/apps/gnumeric/core/file"
84
#define GNM_CONF_FILE_DIR		"core/file"
83
#define GNM_CONF_FILE_HISTORY_N GNM_CONF_FILE_DIRECTORY "/history/n"
85
#define GNM_CONF_FILE_HISTORY_N		"history/n"
84
#define GNM_CONF_FILE_HISTORY_FILES GNM_CONF_FILE_DIRECTORY "/history/files"
86
#define GNM_CONF_FILE_HISTORY_FILES	"history/files"
85
#define GNM_CONF_FILE_OVERWRITE_DEFAULT GNM_CONF_FILE_DIRECTORY "/save/def-overwrite"
87
#define GNM_CONF_FILE_OVERWRITE_DEFAULT	"save/def-overwrite"
86
#define GNM_CONF_FILE_SINGLE_SHEET_SAVE GNM_CONF_FILE_DIRECTORY "/save/single_sheet"
88
#define GNM_CONF_FILE_SINGLE_SHEET_SAVE	"save/single_sheet"
87
89
88
#define GNM_CONF_WORKBOOK_NSHEETS "/apps/gnumeric/core/workbook/n-sheet"
90
#define GNM_CONF_WORKBOOK_NSHEETS	"core/workbook/n-sheet"
89
91
90
#define GNM_CONF_GUI_DIRECTORY "/apps/gnumeric/core/gui"
92
#define GNM_CONF_GUI_DIR		"core/gui"
91
#define GNM_CONF_GUI_RES_H GNM_CONF_GUI_DIRECTORY "/screen/horizontaldpi"
93
#define GNM_CONF_GUI_RES_H		"screen/horizontaldpi"
92
#define GNM_CONF_GUI_RES_V GNM_CONF_GUI_DIRECTORY "/screen/verticaldpi"
94
#define GNM_CONF_GUI_RES_V		"screen/verticaldpi"
93
#define GNM_CONF_GUI_ED_AUTOCOMPLETE GNM_CONF_GUI_DIRECTORY "/editing/autocomplete"
95
#define GNM_CONF_GUI_ED_AUTOCOMPLETE	"editing/autocomplete"
94
#define GNM_CONF_GUI_ED_TRANSITION_KEYS GNM_CONF_GUI_DIRECTORY "/editing/transitionkeys"
96
#define GNM_CONF_GUI_ED_TRANSITION_KEYS	"editing/transitionkeys"
95
#define GNM_CONF_GUI_ED_LIVESCROLLING GNM_CONF_GUI_DIRECTORY "/editing/livescrolling"
97
#define GNM_CONF_GUI_ED_LIVESCROLLING	"editing/livescrolling"
96
#define GNM_CONF_GUI_ED_RECALC_LAG GNM_CONF_GUI_DIRECTORY "/editing/recalclag"
98
#define GNM_CONF_GUI_ED_RECALC_LAG	"editing/recalclag"
97
#define GNM_CONF_GUI_WINDOW_X GNM_CONF_GUI_DIRECTORY "/window/x"
99
#define GNM_CONF_GUI_WINDOW_X		"window/x"
98
#define GNM_CONF_GUI_WINDOW_Y GNM_CONF_GUI_DIRECTORY "/window/y"
100
#define GNM_CONF_GUI_WINDOW_Y		"window/y"
99
#define GNM_CONF_GUI_ZOOM GNM_CONF_GUI_DIRECTORY "/window/zoom"
101
#define GNM_CONF_GUI_ZOOM		"window/zoom"
100
102
101
#define GNM_CONF_XML_COMPRESSION "/apps/gnumeric/core/xml/compression-level"
103
#define GNM_CONF_XML_COMPRESSION	"core/xml/compression-level"
102
104
103
#define GNM_CONF_SORT_DIRECTORY "/apps/gnumeric/core/sort"
105
#define GNM_CONF_SORT_DIR			"core/sort"
104
#define GNM_CONF_SORT_DEFAULT_BY_CASE GNM_CONF_SORT_DIRECTORY "/default/by-case"
106
#define GNM_CONF_SORT_DEFAULT_BY_CASE		"default/by-case"
105
#define GNM_CONF_SORT_DEFAULT_RETAIN_FORM GNM_CONF_SORT_DIRECTORY "/default/retain-formats"
107
#define GNM_CONF_SORT_DEFAULT_RETAIN_FORM	"default/retain-formats"
106
#define GNM_CONF_SORT_DEFAULT_ASCENDING GNM_CONF_SORT_DIRECTORY "/default/ascending"
108
#define GNM_CONF_SORT_DEFAULT_ASCENDING		"default/ascending"
107
#define GNM_CONF_SORT_DIALOG_MAX_INITIAL GNM_CONF_SORT_DIRECTORY "/dialog/max-initial-clauses"
109
#define GNM_CONF_SORT_DIALOG_MAX_INITIAL	"dialog/max-initial-clauses"
108
110
109
#define GNM_CONF_CUTANDPASTE_DIRECTORY "/apps/gnumeric/cut-and-paste"
111
#define GNM_CONF_CUTANDPASTE_DIR		"cut-and-paste"
110
#define GNM_CONF_CUTANDPASTE_PREFER_CLIPBOARD GNM_CONF_CUTANDPASTE_DIRECTORY "/prefer-clipboard"
112
#define GNM_CONF_CUTANDPASTE_PREFER_CLIPBOARD	"prefer-clipboard"
111
113
112
/*
114
/*
113
 *  schemas/gnumeric-plugins.schemas
115
 *  schemas/gnumeric-plugins.schemas
114
 */
116
 */
115
117
116
#define PLUGIN_GCONF_LATEX "/apps/gnumeric/plugin/latex"
118
#define PLUGIN_GCONF_LATEX		"plugin/latex"
117
#define PLUGIN_GCONF_LATEX_USE_UTF8 PLUGIN_GCONF_LATEX "/use-utf8"
119
#define PLUGIN_GCONF_LATEX_USE_UTF8	"use-utf8"
118
120
119
#endif /* GNM_CONF_PRIV_H */
121
#endif /* GNM_CONF_PRIV_H */
(-)src/gnumeric-gconf.c (-281 / +1100 lines)
Lines 2-12 Link Here
2
/*
2
/*
3
 * gnumeric-gconf.c:
3
 * gnumeric-gconf.c:
4
 *
4
 *
5
 *
6
 * Author:
5
 * Author:
7
 * 	Andreas J. Guelzow <aguelzow@taliesin.ca>
6
 * 	Andreas J. Guelzow <aguelzow@taliesin.ca>
8
 *
7
 *
9
 * (C) Copyright 2002-2004 Andreas J. Guelzow <aguelzow@taliesin.ca>
8
 * (C) Copyright 2002-2005 Andreas J. Guelzow <aguelzow@taliesin.ca>
9
 *
10
 * Introduced the concept of "node" and implemented the win32 backend
11
 * by Ivan, Wong Yat Cheung <email@ivanwong.info>, 2005
10
 *
12
 *
11
 * This program is free software; you can redistribute it and/or modify
13
 * This program is free software; you can redistribute it and/or modify
12
 * it under the terms of the GNU General Public License as published by
14
 * it under the terms of the GNU General Public License as published by
Lines 33-38 Link Here
33
35
34
static GnmAppPrefs prefs;
36
static GnmAppPrefs prefs;
35
GnmAppPrefs const *gnm_app_prefs = &prefs;
37
GnmAppPrefs const *gnm_app_prefs = &prefs;
38
static GOConfNode *root = NULL;
36
39
37
#ifdef WITH_GNOME
40
#ifdef WITH_GNOME
38
#include <format.h>
41
#include <format.h>
Lines 40-128 GnmAppPrefs const *gnm_app_prefs = &pref Link Here
40
#include <number-match.h>
43
#include <number-match.h>
41
#include <gconf/gconf-client.h>
44
#include <gconf/gconf-client.h>
42
45
46
struct _GOConfNode {
47
	gchar *path;
48
	gboolean root;
49
};
50
43
static GConfClient *gconf_client = NULL;
51
static GConfClient *gconf_client = NULL;
44
static GConfClient *
52
45
gnm_app_get_gconf_client (void)
53
54
static void
55
go_conf_init ()
46
{
56
{
47
	if (!gconf_client) {
57
	if (!gconf_client)
48
		gconf_client = gconf_client_get_default ();
58
		gconf_client = gconf_client_get_default ();
49
		gconf_client_add_dir (gconf_client, "/apps/gnumeric",
59
}
60
61
static void
62
go_conf_shutdown ()
63
{
64
	if (gconf_client) {
65
		g_object_unref (G_OBJECT (gconf_client));
66
		gconf_client = NULL;
67
	}
68
}
69
70
static gchar *
71
go_conf_get_real_key (GOConfNode const *key, gchar const *subkey)
72
{
73
	return key ? g_strconcat ((key)->path, "/", subkey, NULL) :
74
		     g_strdup (subkey);
75
}
76
77
GOConfNode *
78
go_conf_get_node (GOConfNode *parent, gchar const *key)
79
{
80
	GOConfNode *node;
81
82
	node = g_new (GOConfNode, 1);
83
	gconf_client = gconf_client;
84
	node->root = !parent;
85
	if (node->root) {
86
		node->path = g_strconcat ("/apps/", key, NULL);
87
		gconf_client_add_dir (gconf_client, node->path,
50
				      GCONF_CLIENT_PRELOAD_RECURSIVE,
88
				      GCONF_CLIENT_PRELOAD_RECURSIVE,
51
				      NULL);
89
				      NULL);
52
	}
90
	}
53
	return gconf_client;
91
	else
92
		node->path = go_conf_get_real_key (parent, key);
93
94
	return node;
95
}
96
97
void
98
go_conf_free_node (GOConfNode *node)
99
{
100
	if (node) {
101
		if (node->root)
102
			gconf_client_remove_dir (gconf_client, node->path, NULL);
103
		g_free (node->path);
104
		g_free (node);
105
	}
54
}
106
}
107
55
void
108
void
56
go_conf_sync (void)
109
go_conf_sync (GOConfNode *node)
57
{
110
{
58
	gconf_client_suggest_sync (gnm_app_get_gconf_client (), NULL);
111
	gconf_client_suggest_sync (gconf_client, NULL);
59
}
112
}
60
113
61
void     
114
void     
62
go_conf_set_bool (char const *key, gboolean val)
115
go_conf_set_bool (GOConfNode *node, gchar const *key, gboolean val)
63
{
116
{
64
	gconf_client_set_bool (gnm_app_get_gconf_client (), key, val, NULL);
117
	gchar *real_key = go_conf_get_real_key (node, key);
118
	gconf_client_set_bool (gconf_client, real_key, val, NULL);
119
	g_free (real_key);
65
}
120
}
121
66
void     
122
void     
67
go_conf_set_int (char const *key, gint val)
123
go_conf_set_int (GOConfNode *node, gchar const *key, gint val)
68
{
124
{
69
	gconf_client_set_int (gnm_app_get_gconf_client (), key, val, NULL);
125
	gchar *real_key = go_conf_get_real_key (node, key);
126
	gconf_client_set_int (gconf_client, real_key, val, NULL);
127
	g_free (real_key);
70
}
128
}
129
71
void     
130
void     
72
go_conf_set_double (char const *key, gnm_float val)
131
go_conf_set_double (GOConfNode *node, gchar const *key, gnm_float val)
73
{
132
{
74
	gconf_client_set_float (gnm_app_get_gconf_client (), key, val, NULL);
133
	gchar *real_key = go_conf_get_real_key (node, key);
134
	gconf_client_set_float (gconf_client, real_key, val, NULL);
135
	g_free (real_key);
75
}
136
}
137
76
void     
138
void     
77
go_conf_set_string (char const *key, char const *str)
139
go_conf_set_string (GOConfNode *node, gchar const *key, gchar const *str)
78
{
140
{
79
	gconf_client_set_string (gnm_app_get_gconf_client (), key, str, NULL);
141
	gchar *real_key = go_conf_get_real_key (node, key);
142
	gconf_client_set_string (gconf_client, real_key, str, NULL);
143
	g_free (real_key);
80
}
144
}
145
81
void
146
void
82
go_conf_set_str_list (char const *key, GSList *list)
147
go_conf_set_str_list (GOConfNode *node, gchar const *key, GSList *list)
83
{
148
{
84
	gconf_client_set_list (gnm_app_get_gconf_client (),
149
	gchar *real_key = go_conf_get_real_key (node, key);
85
		key, GCONF_VALUE_STRING, list, NULL);
150
	gconf_client_set_list (gconf_client, real_key,
151
		GCONF_VALUE_STRING, list, NULL);
152
	g_free (real_key);
86
}
153
}
87
154
88
static GConfValue *
155
static GConfValue *
89
go_conf_get (char const *key, GConfValueType t)
156
go_conf_get (GOConfNode *node, gchar const *key, GConfValueType t)
90
{
157
{
91
	GError *err = NULL;
158
	GError *err = NULL;
92
	GConfValue *val = gconf_client_get (gnm_app_get_gconf_client (), key, &err);
159
	GConfValue *val;
160
	gchar *real_key;
161
162
	real_key = go_conf_get_real_key (node, key);
163
	val = gconf_client_get (gconf_client, real_key, &err);
93
164
94
	if (err != NULL) {
165
	if (err != NULL) {
95
		g_warning ("Unable to load key '%s' : because %s",
166
		g_warning ("Unable to load key '%s' : because %s",
96
			   key, err->message);
167
			      real_key, err->message);
168
		g_free (real_key);
97
		g_error_free (err);
169
		g_error_free (err);
98
		return NULL;
170
		return NULL;
99
	}
171
	}
100
	if (val == NULL) {
172
	if (val == NULL) {
101
		g_warning ("Unable to load key '%s'", key);
173
		g_warning ("Unable to load key '%s'", real_key);
174
		g_free (real_key);
102
		return NULL;
175
		return NULL;
103
	}
176
	}
104
177
105
	if (val->type != t) {
178
	if (val->type != t) {
106
#if 1 /* gconf_value_type_to_string is internal */
179
#if 1 /* gconf_value_type_to_string is internal */
107
		g_warning ("Expected `%d' got `%d' for key %s",
180
		g_warning ("Expected `%d' got `%d' for key %s",
108
			t, val->type, key);
181
			   t, val->type, real_key);
109
#else
182
#else
110
		g_warning ("Expected `%s' got `%s' for key %s",
183
		g_warning ("Expected `%s' got `%s' for key %s",
111
			gconf_value_type_to_string (t),
184
			gconf_value_type_to_string (t),
112
			gconf_value_type_to_string (val->type),
185
			gconf_value_type_to_string (val->type),
113
			key);
186
			   real_key);
114
#endif
187
#endif
188
		g_free (real_key);
115
		gconf_value_free (val);
189
		gconf_value_free (val);
116
		return NULL;
190
		return NULL;
117
	}
191
	}
192
	g_free (real_key);
118
193
119
	return val;
194
	return val;
120
}
195
}
121
gboolean
196
gboolean
122
go_conf_load_bool (char const *key, gboolean default_val)
197
go_conf_load_bool (GOConfNode *node, gchar const *key, gboolean default_val)
123
{
198
{
124
	gboolean res;
199
	gboolean res;
125
	GConfValue *val = go_conf_get (key, GCONF_VALUE_BOOL);
200
	GConfValue *val = go_conf_get (node, key, GCONF_VALUE_BOOL);
126
201
127
	if (val != NULL) {
202
	if (val != NULL) {
128
		res = gconf_value_get_bool (val);
203
		res = gconf_value_get_bool (val);
Lines 134-144 go_conf_load_bool (char const *key, gboo Link Here
134
	return res;
209
	return res;
135
}
210
}
136
211
137
int
212
gint
138
go_conf_load_int (char const *key, int minima, int maxima, int default_val)
213
go_conf_load_int (GOConfNode *node, gchar const *key, gint minima, gint maxima, gint default_val)
139
{
214
{
140
	int res = -1;
215
	gint res = -1;
141
	GConfValue *val = go_conf_get (key, GCONF_VALUE_INT);
216
	GConfValue *val = go_conf_get (node, key, GCONF_VALUE_INT);
142
217
143
	if (val != NULL) {
218
	if (val != NULL) {
144
		res = gconf_value_get_int (val);
219
		res = gconf_value_get_int (val);
Lines 156-167 go_conf_load_int (char const *key, int m Link Here
156
	return res;
231
	return res;
157
}
232
}
158
233
159
double
234
gdouble
160
go_conf_load_double (char const *key,
235
go_conf_load_double (GOConfNode *node, gchar const *key,
161
		     double minima, double maxima, double default_val)
236
		     gdouble minima, gdouble maxima, gdouble default_val)
162
{
237
{
163
	double res = -1;
238
	gdouble res = -1;
164
	GConfValue *val = go_conf_get (key, GCONF_VALUE_FLOAT);
239
	GConfValue *val = go_conf_get (node, key, GCONF_VALUE_FLOAT);
165
240
166
	if (val != NULL) {
241
	if (val != NULL) {
167
		res = gconf_value_get_float (val);
242
		res = gconf_value_get_float (val);
Lines 178-223 go_conf_load_double (char const *key, Link Here
178
	}
253
	}
179
	return res;
254
	return res;
180
}
255
}
181
char *
256
182
go_conf_load_string (char const *key)
257
gchar *
258
go_conf_load_string (GOConfNode *node, gchar const *key)
183
{
259
{
184
	return gconf_client_get_string (gnm_app_get_gconf_client (), key, NULL);
260
	gchar *val;
261
	
262
	gchar *real_key = go_conf_get_real_key (node, key);
263
	val = gconf_client_get_string (gconf_client, real_key, NULL);
264
	g_free (real_key);
265
266
	return val;
185
}
267
}
268
186
GSList *
269
GSList *
187
go_conf_load_str_list (char const *key)
270
go_conf_load_str_list (GOConfNode *node, gchar const *key)
188
{
271
{
189
	return gconf_client_get_list (gnm_app_get_gconf_client (),
272
	GSList *list;
190
		key, GCONF_VALUE_STRING, NULL);
273
	
274
	gchar *real_key = go_conf_get_real_key (node, key);
275
	list = gconf_client_get_list (gconf_client, real_key,
276
				      GCONF_VALUE_STRING, NULL);
277
	g_free (real_key);
278
	
279
	return list;
191
}
280
}
192
281
193
static GConfSchema *
282
static GConfSchema *
194
get_schema (char const *key)
283
get_schema (GOConfNode *node, gchar const *key)
195
{
284
{
196
	char *schema_key = g_strconcat ("/schemas", key, NULL);
285
	gchar *schema_key = g_strconcat (
286
		"/schemas", node->path, "/", key, NULL);
197
	GConfSchema *schema = gconf_client_get_schema (
287
	GConfSchema *schema = gconf_client_get_schema (
198
		gnm_app_get_gconf_client (), schema_key, NULL);
288
		gconf_client, schema_key, NULL);
199
	g_free (schema_key);
289
	g_free (schema_key);
200
	return schema;
290
	return schema;
201
}
291
}
202
char *
292
203
go_conf_get_short_desc (char const *key)
293
gchar *
294
go_conf_get_short_desc (GOConfNode *node, gchar const *key)
204
{
295
{
205
	GConfSchema *schema = get_schema (key);
296
	GConfSchema *schema = get_schema (node, key);
206
297
207
	if (schema != NULL) {
298
	if (schema != NULL) {
208
		char *desc = g_strdup (gconf_schema_get_short_desc (schema));
299
		gchar *desc = g_strdup (gconf_schema_get_short_desc (schema));
209
		gconf_schema_free (schema);
300
		gconf_schema_free (schema);
210
		return desc;
301
		return desc;
211
	}
302
	}
212
	return NULL;
303
	return NULL;
213
}
304
}
214
char *
305
215
go_conf_get_long_desc  (char const *key)
306
gchar *
307
go_conf_get_long_desc  (GOConfNode *node, gchar const *key)
216
{
308
{
217
	GConfSchema *schema = get_schema (key);
309
	GConfSchema *schema = get_schema (node, key);
218
310
219
	if (schema != NULL) {
311
	if (schema != NULL) {
220
		char *desc =  g_strdup (gconf_schema_get_long_desc (schema));
312
		gchar *desc =  g_strdup (gconf_schema_get_long_desc (schema));
221
		gconf_schema_free (schema);
313
		gconf_schema_free (schema);
222
		return desc;
314
		return desc;
223
	}
315
	}
Lines 225-233 go_conf_get_long_desc (char const *key) Link Here
225
}
317
}
226
318
227
GType
319
GType
228
go_conf_get_type (char const *key)
320
go_conf_get_type (GOConfNode *node, gchar const *key)
229
{
321
{
230
	GConfSchema *schema = get_schema (key);
322
	GConfSchema *schema = get_schema (node, key);
231
	GType t;
323
	GType t;
232
324
233
	switch (gconf_schema_get_type (schema)) {
325
	switch (gconf_schema_get_type (schema)) {
Lines 244-270 go_conf_get_type (char const *key) Link Here
244
	return t;
336
	return t;
245
}
337
}
246
338
247
char *
339
gchar *
248
go_conf_get_value_as_str (char const *key)
340
go_conf_get_value_as_str (GOConfNode *node, gchar const *key)
249
{
341
{
250
	char *value_string;
342
	gchar *value_string;
251
	GConfClient *gconf = gnm_app_get_gconf_client ();
343
	GConfClient *gconf = gconf_client;
252
344
253
	switch (go_conf_get_type (key)) {
345
	switch (go_conf_get_type (node, key)) {
254
	case G_TYPE_STRING:
346
	case G_TYPE_STRING:
255
		value_string = gconf_client_get_string (gconf, key, NULL);
347
		value_string = gconf_client_get_string (gconf, key, NULL);
256
348
257
		break;
349
		break;
258
	case G_TYPE_INT:
350
	case G_TYPE_INT:
259
		value_string = g_strdup_printf ("%i", gconf_client_get_int (gconf, key,
351
		value_string = g_strdup_printf ("%i", go_conf_get_int (node, key));
260
									    NULL));
261
		break;
352
		break;
262
	case G_TYPE_FLOAT:
353
	case G_TYPE_FLOAT:
263
		value_string = g_strdup_printf ("%f", gconf_client_get_float (gconf, key,
354
		value_string = g_strdup_printf ("%f", go_conf_get_double (node, key));
264
									    NULL));
265
		break;
355
		break;
266
	case G_TYPE_BOOLEAN:
356
	case G_TYPE_BOOLEAN:
267
		value_string = g_strdup (format_boolean (gconf_client_get_bool (gconf, key, NULL)));
357
		value_string = g_strdup (format_boolean (go_conf_get_bool (node, key)));
268
		break;
358
		break;
269
	default:
359
	default:
270
		value_string = g_strdup ("ERROR FIXME");
360
		value_string = g_strdup ("ERROR FIXME");
Lines 273-315 go_conf_get_value_as_str (char const *ke Link Here
273
	return value_string;
363
	return value_string;
274
}
364
}
275
365
276
int
366
gboolean
277
go_conf_get_bool (char const *key)
367
go_conf_get_bool (GOConfNode *node, gchar const *key)
278
{
368
{
279
	GConfClient *gconf = gnm_app_get_gconf_client ();
369
	gboolean val;
280
	return gconf_client_get_bool (gconf, key, NULL);
370
	gchar *real_key;
371
372
	real_key = go_conf_get_real_key (node, key);
373
	val = gconf_client_get_bool (gconf_client, real_key, NULL);
374
	g_free (real_key);
375
376
	return val;
281
}
377
}
282
378
283
int
379
gint
284
go_conf_get_int	(char const *key)
380
go_conf_get_int	(GOConfNode *node, gchar const *key)
285
{
381
{
286
	GConfClient *gconf = gnm_app_get_gconf_client ();
382
	gint val;
287
	return gconf_client_get_int (gconf, key, NULL);
383
	gchar *real_key;
384
385
	real_key = go_conf_get_real_key (node, key);
386
	val = gconf_client_get_int (gconf_client, real_key, NULL);
387
	g_free (real_key);
388
389
	return val;
288
}
390
}
289
391
290
double
392
gdouble
291
go_conf_get_double (char const *key)
393
go_conf_get_double (GOConfNode *node, gchar const *key)
292
{
394
{
293
	GConfClient *gconf = gnm_app_get_gconf_client ();
395
	gdouble val;
294
	return gconf_client_get_float (gconf, key, NULL);
396
	gchar *real_key;
295
}
296
397
398
	real_key = go_conf_get_real_key (node, key);
399
	val = gconf_client_get_float (gconf_client, real_key, NULL);
400
	g_free (real_key);
401
402
	return val;
403
}
297
404
298
gboolean
405
gboolean
299
go_conf_set_value_from_str (char const *key, char const *val_str)
406
go_conf_set_value_from_str (GOConfNode *node, gchar const *key, gchar const *val_str)
300
{
407
{
301
	GConfClient *client = gnm_app_get_gconf_client ();
408
	switch (go_conf_get_type (node, key)) {
302
303
	switch (go_conf_get_type (key)) {
304
	case G_TYPE_STRING:
409
	case G_TYPE_STRING:
305
		go_conf_set_string (key, val_str);
410
		go_conf_set_string (node, key, val_str);
306
		break;
411
		break;
307
	case G_TYPE_FLOAT: {
412
	case G_TYPE_FLOAT: {
308
		GnmDateConventions const *conv = NULL;  /* workbook_date_conv (state->wb); */
413
		GnmDateConventions const *conv = NULL;  /* workbook_date_conv (state->wb); */
309
		GnmValue *value = format_match_number (val_str, NULL, conv);
414
		GnmValue *value = format_match_number (val_str, NULL, conv);
310
		if (value != NULL) {
415
		if (value != NULL) {
311
			gnm_float the_float = value_get_as_float (value);
416
			gnm_float the_float = value_get_as_float (value);
312
			gconf_client_set_float (client, key, the_float, NULL);
417
			go_conf_set_double (node, key, the_float);
313
		}
418
		}
314
		if (value)
419
		if (value)
315
			value_release (value);
420
			value_release (value);
Lines 319-326 go_conf_set_value_from_str (char const * Link Here
319
		GnmDateConventions const *conv = NULL;  /* workbook_date_conv (state->wb); */
424
		GnmDateConventions const *conv = NULL;  /* workbook_date_conv (state->wb); */
320
		GnmValue *value = format_match_number (val_str, NULL, conv);
425
		GnmValue *value = format_match_number (val_str, NULL, conv);
321
		if (value != NULL) {
426
		if (value != NULL) {
322
			int the_int = value_get_as_int (value);
427
			gint the_int = value_get_as_int (value);
323
			go_conf_set_int (key, the_int);
428
			go_conf_set_int (node, key, the_int);
324
		}
429
		}
325
		if (value)
430
		if (value)
326
			value_release (value);
431
			value_release (value);
Lines 333-339 go_conf_set_value_from_str (char const * Link Here
333
		if (value != NULL) {
438
		if (value != NULL) {
334
			err = FALSE;
439
			err = FALSE;
335
			the_bool =  value_get_as_bool (value, &err);
440
			the_bool =  value_get_as_bool (value, &err);
336
			gconf_client_set_bool (client, key, the_bool, NULL);
441
			go_conf_set_bool (node, key, the_bool);
337
		}
442
		}
338
		if (value)
443
		if (value)
339
			value_release (value);
444
			value_release (value);
Lines 349-491 go_conf_set_value_from_str (char const * Link Here
349
void
454
void
350
go_conf_remove_monitor (guint monitor_id)
455
go_conf_remove_monitor (guint monitor_id)
351
{
456
{
352
	gconf_client_notify_remove (gnm_app_get_gconf_client (),
457
	gconf_client_notify_remove (gconf_client,
353
		GPOINTER_TO_INT (monitor_id));
458
		GPOINTER_TO_INT (monitor_id));
354
}
459
}
355
460
356
typedef struct {
461
typedef struct {
357
	void (*monitor) (char const *key, gpointer data);
462
	GOConfMonitorFunc monitor;
358
	gpointer data;
463
	gpointer data;
359
} GOConfClosure;
464
} GOConfClosure;
465
360
static void
466
static void
361
cb_key_changed (GConfClient *client, guint cnxn_id,
467
cb_key_changed (GConfClient *client, guint cnxn_id,
362
		GConfEntry *entry, GOConfClosure *close)
468
		GConfEntry *entry, GOConfClosure *close)
363
{
469
{
364
	close->monitor (gconf_entry_get_key (entry), close->data);
470
	close->monitor (NULL, gconf_entry_get_key (entry), close->data);
365
}
471
}
472
366
guint
473
guint
367
go_conf_add_monitor (char const *key,
474
go_conf_add_monitor (GOConfNode *node, gchar const *key,
368
		     GOConfMonitorFunc monitor, gpointer data)
475
		     GOConfMonitorFunc monitor, gpointer data)
369
{
476
{
477
	guint ret;
370
	GOConfClosure *close = g_new0 (GOConfClosure, 1);
478
	GOConfClosure *close = g_new0 (GOConfClosure, 1);
479
	gchar *real_key;
480
	
371
	close->monitor = monitor;
481
	close->monitor = monitor;
372
	close->data = data;
482
	close->data = data;
373
	return gconf_client_notify_add (gnm_app_get_gconf_client (), key,
483
	real_key = go_conf_get_real_key (node, key);
484
	ret = gconf_client_notify_add (gconf_client, real_key,
374
		(GConfClientNotifyFunc) cb_key_changed, close, g_free, NULL);
485
		(GConfClientNotifyFunc) cb_key_changed, close, g_free, NULL);
486
	g_free (real_key);
487
	
488
	return ret;
489
}
490
491
#elif defined G_OS_WIN32
492
493
#include <windows.h>
494
#include <format.h>
495
#include <value.h>
496
#include <number-match.h>
497
498
#ifndef ERANGE
499
/* mingw has not defined ERANGE (yet), MSVC has it though */
500
# define ERANGE 34
501
#endif
502
503
struct _GOConfNode {
504
	HKEY hKey;
505
	gchar *path;
506
};
507
508
static void
509
go_conf_init ()
510
{
511
}
512
513
static void
514
go_conf_shutdown ()
515
{
516
}
517
518
static gboolean
519
go_conf_win32_get_node (GOConfNode *node, HKEY *phKey, gchar const *key, gboolean *is_new)
520
{
521
	gchar *path, *c;
522
	LONG ret;
523
	DWORD disposition;
524
525
	path = g_strconcat (node ? "" : "Software\\", key, NULL);
526
	for (c = path; *c; ++c) {
527
		if (*c == '/')
528
			*c = '\\';
529
	}
530
	ret = RegCreateKeyEx (node ? node->hKey : HKEY_CURRENT_USER, path,
531
			      0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS,
532
			      NULL, phKey, &disposition);
533
	g_free (path);
534
	
535
	if (is_new)
536
		*is_new = disposition == REG_CREATED_NEW_KEY;
537
538
	return ret == ERROR_SUCCESS;
539
}
540
541
static gboolean
542
go_conf_win32_set (GOConfNode *node, gchar const *key,
543
		   gint type, guchar *data, gint size)
544
{
545
	gchar *last_sep, *path = NULL;
546
	HKEY hKey;
547
	gboolean ok;
548
549
	if ((last_sep = strrchr (key, '/')) != NULL) {
550
		path = g_strndup (key, last_sep - key);
551
		ok = go_conf_win32_get_node (node, &hKey, path, NULL);
552
		g_free (path);
553
		if (!ok)
554
			return FALSE;
555
		key = last_sep + 1;
556
	}
557
	else
558
		hKey = node->hKey;
559
	RegSetValueEx (hKey, key, 0, type, data, size);
560
	if (path)
561
		RegCloseKey (hKey);
562
563
	return TRUE;
564
}
565
566
static gboolean
567
go_conf_win32_get (GOConfNode *node, gchar const *key,
568
		   gulong *type, guchar **data, gulong *size,
569
		   gboolean realloc, gint *ret_code)
570
{
571
	gchar *last_sep, *path = NULL;
572
	HKEY hKey;
573
	LONG ret;
574
	gboolean ok;
575
576
	if ((last_sep = strrchr (key, '/')) != NULL) {
577
		path = g_strndup (key, last_sep - key);
578
		ok = go_conf_win32_get_node (node, &hKey, path, NULL);
579
		g_free (path);
580
		if (!ok)
581
			return FALSE;
582
		key = last_sep + 1;
583
	}
584
	else
585
		hKey = node->hKey;
586
	if (!*data && realloc) {
587
		RegQueryValueEx (hKey, key, NULL, type, NULL, size);
588
		*data = g_new (guchar, *size);
589
	}
590
	while ((ret = RegQueryValueEx (hKey, key, NULL,
591
				       type, *data, size)) == ERROR_MORE_DATA &&
592
	       realloc)
593
		*data = g_realloc (*data, *size);
594
	if (path)
595
		RegCloseKey (hKey);
596
	if (ret_code)
597
		*ret_code = ret;
598
599
	return ret == ERROR_SUCCESS;
600
}
601
602
static void
603
go_conf_win32_clone (HKEY hSrcKey, gchar *key, HKEY hDstKey, gchar *buf1, gchar *buf2, gchar *buf3)
604
{
605
#define WIN32_MAX_REG_KEYNAME_LEN 256
606
#define WIN32_MAX_REG_VALUENAME_LEN 32767
607
#define WIN32_INIT_VALUE_DATA_LEN 2048
608
	gint i;
609
	gchar *subkey, *value_name, *data;
610
	DWORD name_size, type, data_size;
611
	HKEY hSrcSK, hDstSK;
612
	FILETIME ft;
613
	LONG ret;
614
615
	if (RegOpenKeyEx (hSrcKey, key, 0, KEY_READ, &hSrcSK) != ERROR_SUCCESS)
616
		return;
617
618
	if (!buf1) {
619
		subkey = g_malloc (WIN32_MAX_REG_KEYNAME_LEN);
620
		value_name = g_malloc (WIN32_MAX_REG_VALUENAME_LEN);
621
		data = g_malloc (WIN32_INIT_VALUE_DATA_LEN);
622
	}
623
	else {
624
		subkey = buf1;
625
		value_name = buf2;
626
		data = buf3;
627
	}
628
629
	ret = ERROR_SUCCESS;
630
	for (i = 0; ret == ERROR_SUCCESS; ++i) {
631
		name_size = WIN32_MAX_REG_KEYNAME_LEN;
632
		ret = RegEnumKeyEx (hSrcSK, i, subkey, &name_size, NULL, NULL, NULL, &ft);
633
		if (ret != ERROR_SUCCESS)
634
			continue;
635
636
		if (RegCreateKeyEx (hDstKey, subkey, 0, NULL, 0, KEY_WRITE,
637
				    NULL, &hDstSK, NULL) == ERROR_SUCCESS) {
638
			go_conf_win32_clone (hSrcSK, subkey, hDstSK, subkey, value_name, data);
639
			RegCloseKey (hDstSK);
640
		}
641
	}
642
643
	ret = ERROR_SUCCESS;
644
	for (i = 0; ret == ERROR_SUCCESS; ++i) {
645
		name_size = WIN32_MAX_REG_KEYNAME_LEN;
646
		data_size = WIN32_MAX_REG_VALUENAME_LEN;
647
		while ((ret = RegEnumValue (hSrcSK, i, value_name, &name_size,
648
					    NULL, &type, data, &data_size)) ==
649
		       ERROR_MORE_DATA)
650
			data = g_realloc (data, data_size);
651
		if (ret != ERROR_SUCCESS)
652
			continue;
653
654
		RegSetValueEx (hDstKey, value_name, 0, type, data, data_size);
655
	}
656
657
	RegCloseKey (hSrcSK);
658
	if (!buf1) {
659
		g_free (subkey);
660
		g_free (value_name);
661
		g_free (data);
662
	}
663
}
664
665
GOConfNode *
666
go_conf_get_node (GOConfNode *parent, const gchar *key)
667
{
668
	HKEY hKey;
669
	GOConfNode *node = NULL;
670
	gboolean is_new;
671
672
	if (go_conf_win32_get_node (parent, &hKey, key, &is_new)) {
673
		if (!parent && is_new) {
674
			gchar *path;
675
676
			path = g_strconcat (".DEFAULT\\Software\\", key, NULL);
677
			go_conf_win32_clone (HKEY_USERS, path, hKey, NULL, NULL, NULL);
678
			g_free (path);
679
		}
680
		node = g_malloc (sizeof (GOConfNode));
681
		node->hKey = hKey;
682
		node->path = g_strdup (key);
683
	}
684
685
	return node;
686
}
687
688
void
689
go_conf_free_node (GOConfNode *node)
690
{
691
	if (node) {
692
		RegCloseKey (node->hKey);
693
		g_free (node->path);
694
		g_free (node);
695
	}
696
}
697
698
void     
699
go_conf_set_bool (GOConfNode *node, gchar const *key, gboolean val)
700
{
701
	guchar bool = val ? 1 : 0;
702
703
	go_conf_win32_set (node, key, REG_BINARY, (guchar *) &bool,
704
			   sizeof (bool));
705
}
706
707
void     
708
go_conf_set_int (GOConfNode *node, gchar const *key, gint val)
709
{
710
	go_conf_win32_set (node, key, REG_DWORD, (guchar *) &val,
711
			   sizeof (DWORD));
712
}
713
714
void     
715
go_conf_set_double (GOConfNode *node, gchar const *key, gnm_float val)
716
{
717
	gchar str[G_ASCII_DTOSTR_BUF_SIZE];
718
719
	g_ascii_dtostr (str, sizeof (str), val);
720
	go_conf_win32_set (node, key, REG_SZ, (guchar *) str,
721
			   strlen (str) + 1);
722
}
723
724
void     
725
go_conf_set_string (GOConfNode *node, gchar const *key, gchar const *str)
726
{
727
	go_conf_win32_set (node, key, REG_SZ, (guchar *) str,
728
			   strlen (str) + 1);
729
}
730
731
void
732
go_conf_set_str_list (GOConfNode *node, gchar const *key, GSList *list)
733
{
734
	GString *str_list;
735
736
	str_list = g_string_new ("");
737
	while (list) {
738
		g_string_append (str_list, g_strescape (list->data, NULL));
739
		g_string_append_c (str_list, '\n');
740
		list = list->next;
741
	}
742
	go_conf_win32_set (node, key, REG_SZ, (guchar *) str_list->str,
743
			   str_list->len + 1);
744
	g_string_free (str_list, TRUE);
745
}
746
747
gboolean
748
go_conf_get_bool (GOConfNode *node, gchar const *key)
749
{
750
	guchar val, *ptr = &val;
751
	gulong type, size = sizeof (val);
752
753
	if (go_conf_win32_get (node, key, &type, &ptr, &size, FALSE, NULL) &&
754
	    type == REG_BINARY)
755
		return val;
756
757
	return FALSE;
758
}
759
760
gint
761
go_conf_get_int	(GOConfNode *node, gchar const *key)
762
{
763
	gint val;
764
	gulong type, size = sizeof (DWORD);
765
	guchar *ptr = (guchar *) &val;
766
767
	if (go_conf_win32_get (node, key, &type, &ptr, &size, FALSE, NULL) &&
768
	    type == REG_DWORD)
769
		return val;
770
771
	return 0;
772
}
773
774
gdouble
775
go_conf_get_double (GOConfNode *node, gchar const *key)
776
{
777
	gchar *ptr = go_conf_get_string (node, key);
778
	gdouble val;
779
780
	if (ptr) {
781
		val = g_ascii_strtod (ptr, NULL);
782
		g_free (ptr);
783
		if (errno != ERANGE)
784
			return val;
785
	}
786
787
	return 0.0;
788
}
789
790
gchar *
791
go_conf_get_string (GOConfNode *node, gchar const *key)
792
{
793
	DWORD type, size = 0;
794
	guchar *ptr = NULL;
795
796
	if (go_conf_win32_get (node, key, &type, &ptr, &size, TRUE, NULL) &&
797
	    type == REG_SZ)
798
		return ptr;
799
800
	g_free (ptr);
801
802
	return NULL;
803
}
804
805
GSList *
806
go_conf_get_str_list (GOConfNode *node, gchar const *key)
807
{
808
	GSList *list = NULL;
809
	gchar *ptr;
810
	gchar **str_list;
811
	gint i;
812
813
	if ((ptr = go_conf_get_string (node, key)) != NULL) {
814
		str_list = g_strsplit ((const gchar *) ptr, "\n", 0);
815
		for (i = 0; str_list[i]; ++i)
816
			list = g_slist_prepend (list, g_strcompress (str_list[i]));
817
		g_slist_reverse (list);
818
		g_strfreev (str_list);
819
		g_free (ptr);
820
	}
821
822
	return list;
823
}
824
825
static guchar *
826
go_conf_get (GOConfNode *node, gchar const *key, gulong expected)
827
{
828
	gulong type, size = 0;
829
	guchar *ptr = NULL;
830
	gint ret_code;
831
832
	if (!go_conf_win32_get (node, key, &type, &ptr, &size, TRUE, &ret_code)) {
833
		LPTSTR msg_buf;
834
835
		FormatMessage (FORMAT_MESSAGE_ALLOCATE_BUFFER |
836
			       FORMAT_MESSAGE_FROM_SYSTEM |
837
			       FORMAT_MESSAGE_IGNORE_INSERTS,
838
			       NULL,
839
			       ret_code,
840
			       MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT),
841
			       (LPTSTR) &msg_buf,
842
			       0,
843
			       NULL);
844
		g_warning ("Unable to load key '%s' : because %s",
845
			   key, msg_buf);
846
		LocalFree (msg_buf);
847
		g_free (ptr);
848
		return NULL;
375
}
849
}
850
851
	if (type != expected) {
852
		g_warning ("Expected `%lu' got `%lu' for key %s of node %s",
853
			   expected, type, key, node->path);
854
		g_free (ptr);
855
		return NULL;
856
	}
857
858
	return ptr;
859
}
860
861
gboolean
862
go_conf_load_bool (GOConfNode *node, gchar const *key,
863
		   gboolean default_val)
864
{
865
	guchar *val = go_conf_get (node, key, REG_BINARY);
866
	gboolean res;
867
868
	if (val) {
869
		res = (gboolean) *val;
870
		g_free (val);
871
	} else {
872
		g_warning ("Using default value '%s'", default_val ? "true" : "false");
873
		return default_val;
874
	}
875
876
	return res;
877
}
878
879
gint
880
go_conf_load_int (GOConfNode *node, gchar const *key,
881
		  gint minima, gint maxima, gint default_val)
882
{
883
	guchar *val = go_conf_get (node, key, REG_DWORD);
884
	gint res;
885
886
	if (val) {
887
		res = *(gint *) val;
888
		g_free (val);
889
		if (res < minima || maxima < res) {
890
			g_warning ("Invalid value '%d' for %s. If should be >= %d and <= %d",
891
				   res, key, minima, maxima);
892
			val = NULL;
893
		}
894
	}
895
	if (!val) {
896
		g_warning ("Using default value '%d'", default_val);
897
		return default_val;
898
	}
899
900
	return res;
901
}
902
903
gdouble
904
go_conf_load_double (GOConfNode *node, gchar const *key,
905
		     gdouble minima, gdouble maxima, gdouble default_val)
906
{
907
	gdouble res = -1;
908
	gchar *val = (gchar *) go_conf_get (node, key, REG_SZ);
909
910
	if (val) {
911
		res = g_ascii_strtod (val, NULL);
912
		g_free (val);
913
		if (errno == ERANGE || res < minima || maxima < res) {
914
			g_warning ("Invalid value '%g' for %s.  If should be >= %g and <= %g",
915
				   res, key, minima, maxima);
916
			val = NULL;
917
		}
918
	}
919
	if (!val) {
920
		g_warning ("Using default value '%g'", default_val);
921
		return default_val;
922
	}
923
924
	return res;
925
}
926
927
gchar *
928
go_conf_load_string (GOConfNode *node, gchar const *key)
929
{
930
	return go_conf_get (node, key, REG_SZ);
931
}
932
933
GSList *
934
go_conf_load_str_list (GOConfNode *node, gchar const *key)
935
{
936
	return go_conf_get_str_list (node, key);
937
}
938
939
gchar *
940
go_conf_get_short_desc (GOConfNode *node, gchar const *key)
941
{
942
	return NULL;
943
}
944
945
gchar *
946
go_conf_get_long_desc  (GOConfNode *node, gchar const *key)
947
{
948
	return NULL;
949
}
950
951
GType
952
go_conf_get_type (GOConfNode *node, gchar const *key)
953
{
954
	gulong type, size;
955
	guchar *ptr = NULL;
956
	GType t = G_TYPE_NONE;
957
958
	if (go_conf_win32_get (node, key, &type, &ptr, &size, FALSE, NULL)) {
959
		switch (type) {
960
		case REG_BINARY:
961
			t = G_TYPE_BOOLEAN; break;
962
		case REG_DWORD:
963
			t = G_TYPE_INT; break;
964
		case REG_SZ:
965
			t = G_TYPE_STRING; break;
966
		}
967
	}
968
969
	return t;
970
}
971
972
gchar *
973
go_conf_get_value_as_str (GOConfNode *node, gchar const *key)
974
{
975
	gchar *value_string;
976
977
	switch (go_conf_get_type (node, key)) {
978
	case G_TYPE_STRING:
979
		value_string = go_conf_get_string (node, key);
980
		break;
981
	case G_TYPE_INT:
982
		value_string = g_strdup_printf ("%i", go_conf_get_int (node, key));
983
		break;
984
	case G_TYPE_FLOAT:
985
		value_string = go_conf_get_string (node, key);
986
		break;
987
	case G_TYPE_BOOLEAN:
988
		value_string = g_strdup (format_boolean (go_conf_get_bool (node, key)));
989
		break;
990
	default:
991
		value_string = g_strdup ("ERROR FIXME");
992
	}
993
994
	return value_string;
995
}
996
997
gboolean
998
go_conf_set_value_from_str (GOConfNode *node, gchar const *key,
999
			    gchar const *val_str)
1000
{
1001
	switch (go_conf_get_type (node, key)) {
1002
	case G_TYPE_STRING:
1003
		go_conf_set_string (node, key, val_str);
1004
		break;
1005
	case G_TYPE_INT: {
1006
		GnmDateConventions const *conv = NULL;  /* workbook_date_conv (state->wb); */
1007
		GnmValue *value = format_match_number (val_str, NULL, conv);
1008
		if (value != NULL) {
1009
			gint the_int = value_get_as_int (value);
1010
			go_conf_set_int (node, key, the_int);
1011
		}
1012
		if (value)
1013
			value_release (value);
1014
		break;
1015
	}
1016
	case G_TYPE_BOOLEAN: {
1017
		GnmDateConventions const *conv = NULL;  /* workbook_date_conv (state->wb); */
1018
		GnmValue *value = format_match_number (val_str, NULL, conv);
1019
		gboolean err, the_bool;
1020
		if (value != NULL) {
1021
			err = FALSE;
1022
			the_bool =  value_get_as_bool (value, &err);
1023
			go_conf_set_bool (node, key, the_bool);
1024
		}
1025
		if (value)
1026
			value_release (value);
1027
		break;
1028
	}
1029
	default:
1030
		g_warning ("Unsupported gconf type in preference dialog");
1031
	}
1032
1033
	return TRUE;
1034
}
1035
1036
void
1037
go_conf_sync (GOConfNode *node)
1038
{
1039
	if (node)
1040
		RegFlushKey (node->hKey);
1041
}
1042
1043
void
1044
go_conf_remove_monitor (guint monitor_id)
1045
{
1046
}
1047
1048
guint
1049
go_conf_add_monitor (GOConfNode *node, gchar const *key,
1050
		     GOConfMonitorFunc monitor, gpointer data)
1051
{
1052
	return 1;
1053
}
1054
376
#else
1055
#else
1056
377
void     
1057
void     
378
go_conf_set_bool (G_GNUC_UNUSED char const *key, G_GNUC_UNUSED gboolean val)
1058
go_conf_set_bool (GOConfNode *node, gchar const *key, gboolean val)
379
{
1059
{
380
}
1060
}
1061
381
void     
1062
void     
382
go_conf_set_int (G_GNUC_UNUSED char const *key, G_GNUC_UNUSED gint val)
1063
go_conf_set_int (GOConfNode *node, gchar const *key, gint val)
383
{
1064
{
384
}
1065
}
1066
385
void     
1067
void     
386
go_conf_set_double (G_GNUC_UNUSED char const *key, G_GNUC_UNUSED gnm_float val)
1068
go_conf_set_double (GOConfNode *node, gchar const *key, gnm_float val)
387
{
1069
{
388
}
1070
}
1071
389
void     
1072
void     
390
go_conf_set_string (G_GNUC_UNUSED char const *key, G_GNUC_UNUSED char const *str)
1073
go_conf_set_string (GOConfNode *node, gchar const *key, char const *str)
391
{
1074
{
392
}
1075
}
1076
393
void
1077
void
394
go_conf_set_str_list (G_GNUC_UNUSED char const *key, G_GNUC_UNUSED GSList *list)
1078
go_conf_set_str_list (GOConfNode *node, gchar const *key, GSList *list)
395
{
1079
{
396
}
1080
}
1081
397
gboolean
1082
gboolean
398
go_conf_get_bool (char const *key)
1083
go_conf_get_bool (GOConfNode *node, gchar const *key)
399
{
1084
{
400
	return FALSE;
1085
	return FALSE;
401
}
1086
}
402
1087
403
int
1088
gint
404
go_conf_get_int	(char const *key)
1089
go_conf_get_int	(GOConfNode *node, gchar const *key)
405
{
1090
{
406
	return 0;
1091
	return 0;
407
}
1092
}
408
1093
409
double
1094
gdouble
410
go_conf_get_double (char const *key)
1095
go_conf_get_double (GOConfNode *node, gchar const *key)
411
{
1096
{
412
	return 0.;
1097
	return 0.;
413
}
1098
}
414
1099
415
char *
1100
gchar *
416
go_conf_get_string (char const *key)
1101
go_conf_get_string (GOConfNode *node, gchar const *key)
417
{
1102
{
418
	return g_strdup ("");
1103
	return g_strdup ("");
419
}
1104
}
420
1105
421
GSList *
1106
GSList *
422
go_conf_get_str_list (char const *key)
1107
go_conf_get_str_list (GOConfNode *node, gchar const *key)
423
{
1108
{
424
	return NULL;
1109
	return NULL;
425
}
1110
}
426
1111
427
gboolean
1112
gboolean
428
go_conf_load_bool (G_GNUC_UNUSED char const *key,
1113
go_conf_load_bool (GOConfNode *node, gchar const *key,
429
		   gboolean default_val)
1114
		   gboolean default_val)
430
{
1115
{
431
	return default_val;
1116
	return default_val;
432
}
1117
}
433
int
1118
int
434
go_conf_load_int (G_GNUC_UNUSED char const *key,
1119
go_conf_load_int (GOConfNode *node, gchar const *key,
435
		  G_GNUC_UNUSED int minima, G_GNUC_UNUSED int maxima,
1120
		  gint minima, gint maxima,
436
		  int default_val)
1121
		  gint default_val)
437
{
1122
{
438
	return default_val;
1123
	return default_val;
439
}
1124
}
440
1125
441
double
1126
double
442
go_conf_load_double (G_GNUC_UNUSED char const *key,
1127
go_conf_load_double (GOConfNode *node, gchar const *key,
443
		     G_GNUC_UNUSED double minima, G_GNUC_UNUSED double maxima,
1128
		     gdouble minima, gdouble maxima,
444
		     double default_val)
1129
		     gdouble default_val)
445
{
1130
{
446
	return default_val;
1131
	gchar *real_key;
1132
	gchar *ptr;
1133
	double val;
1134
	GError *err = NULL;
1135
1136
	real_key = go_conf_get_real_key (node, key);
1137
	ptr = g_key_file_get_value (key_file, DOUBLE_GROUP, real_key, &err);
1138
1139
	if (err) {
1140
		val = default_val;
1141
		g_error_free (err);
1142
	} else {		
1143
		val = g_ascii_strtod (ptr, NULL);
1144
		if (val < minima || val > maxima) {
1145
			val = default_val;
447
}
1146
}
1147
}
1148
1149
	g_free(ptr);
1150
	g_free (real_key);
1151
	return val;
1152
}
1153
448
char *
1154
char *
449
go_conf_load_string (G_GNUC_UNUSED char const *key)
1155
go_conf_load_string (GOConfNode *node, gchar const *key)
450
{
1156
{
451
	return NULL;
1157
	gchar *real_key;
1158
	char *val = NULL;
1159
	GError *err = NULL;
1160
1161
	real_key = go_conf_get_real_key (node, key);
1162
	val = g_key_file_get_string (key_file, STRING_GROUP, real_key, &err);
1163
1164
	if (err) {
1165
#if 0
1166
		g_warning (err->message);
1167
#endif
1168
		g_error_free (err);
452
}
1169
}
1170
	
1171
	g_free (real_key);
1172
	return val;
1173
}
1174
453
GSList *
1175
GSList *
454
go_conf_load_str_list (G_GNUC_UNUSED char const *key)
1176
go_conf_load_str_list (GOConfNode *node, gchar const *key)
455
{
1177
{
456
	return NULL;
1178
	return go_conf_get_str_list (node, key);
457
}
1179
}
1180
458
char *
1181
char *
459
go_conf_get_short_desc (char const *key)
1182
go_conf_get_short_desc (GOConfNode *node, gchar const *key)
460
{
1183
{
461
	return NULL;
1184
	return NULL;
462
}
1185
}
463
char *
1186
464
go_conf_get_long_desc  (char const *key)
1187
gchar *
1188
go_conf_get_long_desc  (GOConfNode *node, gchar const *key)
465
{
1189
{
466
	return NULL;
1190
	return NULL;
467
}
1191
}
468
1192
469
GType
1193
GType
470
go_conf_get_type (char const *key)
1194
go_conf_get_type (GOConfNode *node, gchar const *key)
471
{
1195
{
472
	return G_TYPE_NONE;
1196
	gchar **groups;
1197
	gchar *real_key;
1198
	GType type = G_TYPE_NONE;
1199
	int i, ng;
1200
1201
	real_key = go_conf_get_real_key (node, key);
1202
	groups = g_key_file_get_groups (key_file, &ng);
1203
1204
	if (groups != NULL) {
1205
		for (i = 0; i < ng; i++) {
1206
			if (g_key_file_has_key (key_file, groups[i], real_key, NULL)) {
1207
				if (!g_ascii_strcasecmp (groups[i], BOOL_GROUP)) {
1208
					type = G_TYPE_BOOLEAN;
1209
				} else if (!g_ascii_strcasecmp (groups[i], INT_GROUP)) {
1210
					type = G_TYPE_INT;
1211
				} else if (!g_ascii_strcasecmp (groups[i], DOUBLE_GROUP)) {
1212
					type = G_TYPE_DOUBLE;
1213
				} else if (!g_ascii_strcasecmp (groups[i], STRING_GROUP)) {
1214
					type = G_TYPE_STRING;
1215
				} else if (!g_ascii_strcasecmp (groups[i], STRLIST_GROUP)) {
1216
					type = G_TYPE_STRING;
1217
				}
1218
				break;
1219
			}
1220
		}
1221
		g_strfreev (groups);
473
}
1222
}
474
1223
475
char *
1224
	g_free (real_key);
476
go_conf_get_value_as_str (char const *key)
1225
1226
	return type;
1227
}
1228
1229
gchar *
1230
go_conf_get_value_as_str (GOConfNode *node, gchar const *key)
477
{
1231
{
478
	return g_strdup ("");
1232
	gchar *val = NULL;
1233
	gchar *real_key = go_conf_get_real_key (node, key);
1234
	val = g_key_file_get_string (key_file, STRING_GROUP, real_key, NULL);
1235
	g_free (real_key);	
1236
	return val;
479
}
1237
}
480
1238
481
gboolean
1239
gboolean
482
go_conf_set_value_from_str (char const *key, char const *val_str)
1240
go_conf_set_value_from_str (GOConfNode *node, gchar const *key, gchar const *val_str)
483
{
1241
{
1242
	gchar *real_key = go_conf_get_real_key (node, key);
1243
	g_key_file_set_value (key_file, STRING_GROUP, real_key, val_str);
1244
	g_free (real_key);
484
	return TRUE;
1245
	return TRUE;
485
}
1246
}
486
1247
487
void
1248
void
488
go_conf_sync (void)
1249
go_conf_sync (GOConfNode *node)
489
{
1250
{
490
}
1251
}
491
1252
Lines 495-501 go_conf_remove_monitor (guint monitor_id Link Here
495
}
1256
}
496
1257
497
guint
1258
guint
498
go_conf_add_monitor (char const *key,
1259
go_conf_add_monitor (GOConfNode *node, gchar const *key,
499
		     GOConfMonitorFunc monitor, gpointer data)
1260
		     GOConfMonitorFunc monitor, gpointer data)
500
{
1261
{
501
	return 1;
1262
	return 1;
Lines 506-596 go_conf_add_monitor (char const *key, Link Here
506
static void
1267
static void
507
gnm_conf_init_printer_decoration_font (void)
1268
gnm_conf_init_printer_decoration_font (void)
508
{
1269
{
1270
	GOConfNode *node;
509
	gchar *name;
1271
	gchar *name;
510
	if (prefs.printer_decoration_font == NULL)
1272
	if (prefs.printer_decoration_font == NULL)
511
		prefs.printer_decoration_font = mstyle_new ();
1273
		prefs.printer_decoration_font = mstyle_new ();
512
1274
513
	name = go_conf_load_string (PRINTSETUP_GCONF_HF_FONT_NAME);
1275
	node = go_conf_get_node (root, PRINTSETUP_GCONF_DIR);
1276
	name = go_conf_load_string (node, PRINTSETUP_GCONF_HF_FONT_NAME);
514
	if (name) {
1277
	if (name) {
515
		mstyle_set_font_name (prefs.printer_decoration_font, name);
1278
		mstyle_set_font_name (prefs.printer_decoration_font, name);
516
		g_free (name);
1279
		g_free (name);
517
	} else
1280
	} else
518
		mstyle_set_font_name (prefs.printer_decoration_font, DEFAULT_FONT);
1281
		mstyle_set_font_name (prefs.printer_decoration_font, DEFAULT_FONT);
519
	mstyle_set_font_size (prefs.printer_decoration_font,
1282
	mstyle_set_font_size (prefs.printer_decoration_font,
520
		go_conf_load_double (PRINTSETUP_GCONF_HF_FONT_SIZE, 1., 100., DEFAULT_SIZE));
1283
		go_conf_load_double (node, PRINTSETUP_GCONF_HF_FONT_SIZE, 1., 100., DEFAULT_SIZE));
521
	mstyle_set_font_bold (prefs.printer_decoration_font,
1284
	mstyle_set_font_bold (prefs.printer_decoration_font,
522
		go_conf_load_bool (PRINTSETUP_GCONF_HF_FONT_BOLD, FALSE));
1285
		go_conf_load_bool (node, PRINTSETUP_GCONF_HF_FONT_BOLD, FALSE));
523
	mstyle_set_font_italic (prefs.printer_decoration_font,
1286
	mstyle_set_font_italic (prefs.printer_decoration_font,
524
		go_conf_load_bool (PRINTSETUP_GCONF_HF_FONT_ITALIC, FALSE));
1287
		go_conf_load_bool (node, PRINTSETUP_GCONF_HF_FONT_ITALIC, FALSE));
1288
	go_conf_free_node (node);
525
}
1289
}
526
1290
527
static void
1291
static void
528
gnm_conf_init_essential (void)
1292
gnm_conf_init_essential (void)
529
{
1293
{
530
	prefs.default_font.name = go_conf_load_string (CONF_DEFAULT_FONT_NAME);
1294
	GOConfNode *node;
1295
	
1296
	node = go_conf_get_node (root, CONF_DEFAULT_FONT_DIR);
1297
	prefs.default_font.name = go_conf_load_string (node, CONF_DEFAULT_FONT_NAME);
531
	if (prefs.default_font.name == NULL)
1298
	if (prefs.default_font.name == NULL)
532
		prefs.default_font.name = g_strdup (DEFAULT_FONT);
1299
		prefs.default_font.name = g_strdup (DEFAULT_FONT);
533
	prefs.default_font.size = go_conf_load_double (
1300
	prefs.default_font.size = go_conf_load_double (
534
		CONF_DEFAULT_FONT_SIZE, 1., 100., DEFAULT_SIZE);
1301
		node, CONF_DEFAULT_FONT_SIZE, 1., 100., DEFAULT_SIZE);
535
	prefs.default_font.is_bold = go_conf_load_bool (
1302
	prefs.default_font.is_bold = go_conf_load_bool (
536
		CONF_DEFAULT_FONT_BOLD, FALSE);
1303
		node, CONF_DEFAULT_FONT_BOLD, FALSE);
537
	prefs.default_font.is_italic = go_conf_load_bool (
1304
	prefs.default_font.is_italic = go_conf_load_bool (
538
		CONF_DEFAULT_FONT_ITALIC, FALSE);
1305
		node, CONF_DEFAULT_FONT_ITALIC, FALSE);
1306
	go_conf_free_node (node);
539
1307
1308
	node = go_conf_get_node (root, GNM_CONF_FILE_DIR);
540
	prefs.file_history_max = go_conf_load_int (
1309
	prefs.file_history_max = go_conf_load_int (
541
		GNM_CONF_FILE_HISTORY_N, 0, 20, 4);
1310
		node, GNM_CONF_FILE_HISTORY_N, 0, 20, 4);
542
	prefs.file_history_files = go_conf_load_str_list (GNM_CONF_FILE_HISTORY_FILES);
1311
	prefs.file_history_files = go_conf_load_str_list (node, GNM_CONF_FILE_HISTORY_FILES);
543
	prefs.plugin_file_states = go_conf_load_str_list (PLUGIN_GCONF_FILE_STATES);
1312
	go_conf_free_node (node);
544
	prefs.plugin_extra_dirs = go_conf_load_str_list (PLUGIN_GCONF_EXTRA_DIRS);
1313
545
	prefs.active_plugins = go_conf_load_str_list (PLUGIN_GCONF_ACTIVE);
1314
	node = go_conf_get_node (root, PLUGIN_GCONF_DIR);
1315
	prefs.plugin_file_states = go_conf_load_str_list (node, PLUGIN_GCONF_FILE_STATES);
1316
	prefs.plugin_extra_dirs = go_conf_load_str_list (node, PLUGIN_GCONF_EXTRA_DIRS);
1317
	prefs.active_plugins = go_conf_load_str_list (node, PLUGIN_GCONF_ACTIVE);
546
	prefs.activate_new_plugins = go_conf_load_bool (
1318
	prefs.activate_new_plugins = go_conf_load_bool (
547
		PLUGIN_GCONF_ACTIVATE_NEW, TRUE);
1319
		node, PLUGIN_GCONF_ACTIVATE_NEW, TRUE);
1320
	go_conf_free_node (node);
548
1321
1322
	node = go_conf_get_node (root, GNM_CONF_GUI_DIR);
549
	prefs.horizontal_dpi = go_conf_load_double (
1323
	prefs.horizontal_dpi = go_conf_load_double (
550
		GNM_CONF_GUI_RES_H, 10., 1000., 96.);
1324
		node, GNM_CONF_GUI_RES_H, 10., 1000., 96.);
551
	prefs.vertical_dpi = go_conf_load_double (
1325
	prefs.vertical_dpi = go_conf_load_double (
552
		GNM_CONF_GUI_RES_V, 10., 1000., 96.);
1326
		node, GNM_CONF_GUI_RES_V, 10., 1000., 96.);
553
	prefs.initial_sheet_number = go_conf_load_int (
1327
	prefs.initial_sheet_number = go_conf_load_int (
554
		GNM_CONF_WORKBOOK_NSHEETS, 1, 64, 3);
1328
		root, GNM_CONF_WORKBOOK_NSHEETS, 1, 64, 3);
555
	prefs.horizontal_window_fraction = go_conf_load_double (
1329
	prefs.horizontal_window_fraction = go_conf_load_double (
556
		  GNM_CONF_GUI_WINDOW_X, .1, 1., .6);
1330
		  node, GNM_CONF_GUI_WINDOW_X, .1, 1., .6);
557
	prefs.vertical_window_fraction = go_conf_load_double (
1331
	prefs.vertical_window_fraction = go_conf_load_double (
558
		  GNM_CONF_GUI_WINDOW_Y, .1, 1., .6);
1332
		  node, GNM_CONF_GUI_WINDOW_Y, .1, 1., .6);
559
	prefs.zoom = go_conf_load_double (
1333
	prefs.zoom = go_conf_load_double (
560
		  GNM_CONF_GUI_ZOOM, .1, 5., 1.);
1334
		  node, GNM_CONF_GUI_ZOOM, .1, 5., 1.);
1335
	prefs.auto_complete = go_conf_load_bool (
1336
		  node, GNM_CONF_GUI_ED_AUTOCOMPLETE, TRUE);
1337
	prefs.live_scrolling = go_conf_load_bool (
1338
		  node, GNM_CONF_GUI_ED_LIVESCROLLING, TRUE);
1339
	go_conf_free_node (node);
561
1340
562
	/* Unfortunately we need the printing stuff in essentials since the */
1341
	/* Unfortunately we need the printing stuff in essentials since the */
563
	/* first pi is created for the new sheet before the idle loop has a */
1342
	/* first pi is created for the new sheet before the idle loop has a */
564
	/* chance to run                                                    */
1343
	/* chance to run                                                    */
565
	prefs.printer_config = go_conf_load_string (PRINTSETUP_GCONF_PRINTER_CONFIG);
1344
	node = go_conf_get_node (root, PRINTSETUP_GCONF_DIR);
1345
	prefs.printer_config = go_conf_load_string (node, PRINTSETUP_GCONF_PRINTER_CONFIG);
566
	prefs.print_center_horizontally = go_conf_load_bool 
1346
	prefs.print_center_horizontally = go_conf_load_bool 
567
		(PRINTSETUP_GCONF_CENTER_HORIZONTALLY, FALSE); 
1347
		(node, PRINTSETUP_GCONF_CENTER_HORIZONTALLY, FALSE); 
568
	prefs.print_center_vertically = go_conf_load_bool 
1348
	prefs.print_center_vertically = go_conf_load_bool 
569
		(PRINTSETUP_GCONF_CENTER_VERTICALLY, FALSE);
1349
		(node, PRINTSETUP_GCONF_CENTER_VERTICALLY, FALSE);
570
	prefs.print_grid_lines = go_conf_load_bool 
1350
	prefs.print_grid_lines = go_conf_load_bool 
571
		(PRINTSETUP_GCONF_PRINT_GRID_LINES, FALSE);
1351
		(node, PRINTSETUP_GCONF_PRINT_GRID_LINES, FALSE);
572
	prefs.print_even_if_only_styles = go_conf_load_bool 
1352
	prefs.print_even_if_only_styles = go_conf_load_bool 
573
		(PRINTSETUP_GCONF_EVEN_IF_ONLY_STYLES, FALSE);
1353
		(node, PRINTSETUP_GCONF_EVEN_IF_ONLY_STYLES, FALSE);
574
	prefs.print_black_and_white = go_conf_load_bool 
1354
	prefs.print_black_and_white = go_conf_load_bool 
575
		(PRINTSETUP_GCONF_PRINT_BLACK_AND_WHITE, FALSE);
1355
		(node, PRINTSETUP_GCONF_PRINT_BLACK_AND_WHITE, FALSE);
576
	prefs.print_titles = go_conf_load_bool 
1356
	prefs.print_titles = go_conf_load_bool 
577
		(PRINTSETUP_GCONF_PRINT_TITLES, FALSE);
1357
		(node, PRINTSETUP_GCONF_PRINT_TITLES, FALSE);
578
	prefs.print_order_right_then_down = go_conf_load_bool 
1358
	prefs.print_order_right_then_down = go_conf_load_bool 
579
		(PRINTSETUP_GCONF_RIGHT_THEN_DOWN, FALSE);
1359
		(node, PRINTSETUP_GCONF_RIGHT_THEN_DOWN, FALSE);
580
	prefs.print_scale_percentage = go_conf_load_bool 
1360
	prefs.print_scale_percentage = go_conf_load_bool 
581
		(PRINTSETUP_GCONF_SCALE_PERCENTAGE, TRUE);
1361
		(node, PRINTSETUP_GCONF_SCALE_PERCENTAGE, TRUE);
582
	prefs.print_scale_percentage_value = go_conf_load_double 
1362
	prefs.print_scale_percentage_value = go_conf_load_double 
583
		(PRINTSETUP_GCONF_SCALE_PERCENTAGE_VALUE, 1, 500, 100);
1363
		(node, PRINTSETUP_GCONF_SCALE_PERCENTAGE_VALUE, 1, 500, 100);
584
	prefs.print_scale_width = go_conf_load_int 
1364
	prefs.print_scale_width = go_conf_load_int 
585
		(PRINTSETUP_GCONF_SCALE_WIDTH, 0, 100, 1);
1365
		(node, PRINTSETUP_GCONF_SCALE_WIDTH, 0, 100, 1);
586
        prefs.print_scale_height = go_conf_load_int 
1366
        prefs.print_scale_height = go_conf_load_int 
587
		(PRINTSETUP_GCONF_SCALE_HEIGHT, 0, 100, 1);
1367
		(node, PRINTSETUP_GCONF_SCALE_HEIGHT, 0, 100, 1);
588
	prefs.print_repeat_top = go_conf_load_string (PRINTSETUP_GCONF_REPEAT_TOP);
1368
	prefs.print_repeat_top = go_conf_load_string (node, PRINTSETUP_GCONF_REPEAT_TOP);
589
	prefs.print_repeat_left = go_conf_load_string (PRINTSETUP_GCONF_REPEAT_LEFT);
1369
	prefs.print_repeat_left = go_conf_load_string (node, PRINTSETUP_GCONF_REPEAT_LEFT);
590
	prefs.print_tb_margins.top.points = go_conf_load_double 
1370
	prefs.print_tb_margins.top.points = go_conf_load_double 
591
		(PRINTSETUP_GCONF_MARGIN_TOP, 0.0, 10000.0, 120.0);
1371
		(node, PRINTSETUP_GCONF_MARGIN_TOP, 0.0, 10000.0, 120.0);
592
	prefs.print_tb_margins.bottom.points = go_conf_load_double 
1372
	prefs.print_tb_margins.bottom.points = go_conf_load_double 
593
		(PRINTSETUP_GCONF_MARGIN_BOTTOM, 0.0, 10000.0, 120.0);
1373
		(node, PRINTSETUP_GCONF_MARGIN_BOTTOM, 0.0, 10000.0, 120.0);
594
	{
1374
	{
595
		/* Note: the desired display unit is stored in the  */
1375
		/* Note: the desired display unit is stored in the  */
596
		/* printer config. So we are never using this field */
1376
		/* printer config. So we are never using this field */
Lines 602-672 gnm_conf_init_essential (void) Link Here
602
			= prefs.print_tb_margins.top.desired_display;
1382
			= prefs.print_tb_margins.top.desired_display;
603
	}
1383
	}
604
	prefs.print_all_sheets = go_conf_load_bool (
1384
	prefs.print_all_sheets = go_conf_load_bool (
605
		PRINTSETUP_GCONF_ALL_SHEETS, TRUE);
1385
		node, PRINTSETUP_GCONF_ALL_SHEETS, TRUE);
606
	prefs.printer_header = go_conf_load_str_list (PRINTSETUP_GCONF_HEADER);
1386
	prefs.printer_header = go_conf_load_str_list (node, PRINTSETUP_GCONF_HEADER);
607
	prefs.printer_footer = go_conf_load_str_list (PRINTSETUP_GCONF_FOOTER);
1387
	prefs.printer_footer = go_conf_load_str_list (node, PRINTSETUP_GCONF_FOOTER);
608
	prefs.printer_header_formats_left = go_conf_load_str_list (PRINTSETUP_GCONF_HEADER_FORMAT_LEFT);
1388
	prefs.printer_header_formats_left = go_conf_load_str_list (node, PRINTSETUP_GCONF_HEADER_FORMAT_LEFT);
609
	prefs.printer_header_formats_middle = go_conf_load_str_list (PRINTSETUP_GCONF_HEADER_FORMAT_MIDDLE);
1389
	prefs.printer_header_formats_middle = go_conf_load_str_list (node, PRINTSETUP_GCONF_HEADER_FORMAT_MIDDLE);
610
	prefs.printer_header_formats_right = go_conf_load_str_list (PRINTSETUP_GCONF_HEADER_FORMAT_RIGHT);
1390
	prefs.printer_header_formats_right = go_conf_load_str_list (node, PRINTSETUP_GCONF_HEADER_FORMAT_RIGHT);
611
1391
	go_conf_free_node (node);
612
	prefs.auto_complete = go_conf_load_bool (GNM_CONF_GUI_ED_AUTOCOMPLETE, TRUE);
613
	prefs.live_scrolling = go_conf_load_bool (GNM_CONF_GUI_ED_LIVESCROLLING, TRUE);
614
}
1392
}
615
1393
616
static gboolean
1394
static gboolean
617
gnm_conf_init_extras (void)
1395
gnm_conf_init_extras (void)
618
{
1396
{
619
	char *tmp;
1397
	char *tmp;
1398
	GOConfNode *node;
620
1399
1400
	node = go_conf_get_node (root, FUNCTION_SELECT_GCONF_DIR);
621
	prefs.num_of_recent_funcs = go_conf_load_int (
1401
	prefs.num_of_recent_funcs = go_conf_load_int (
622
		FUNCTION_SELECT_GCONF_NUM_OF_RECENT, 0, 40, 10);
1402
		node, FUNCTION_SELECT_GCONF_NUM_OF_RECENT, 0, 40, 10);
623
	prefs.recent_funcs = go_conf_load_str_list (FUNCTION_SELECT_GCONF_RECENT);
1403
	prefs.recent_funcs = go_conf_load_str_list (node, FUNCTION_SELECT_GCONF_RECENT);
1404
	go_conf_free_node (node);
624
1405
1406
	node = go_conf_get_node (root, GNM_CONF_GUI_DIR);
625
	prefs.transition_keys = go_conf_load_bool (
1407
	prefs.transition_keys = go_conf_load_bool (
626
		GNM_CONF_GUI_ED_TRANSITION_KEYS, FALSE);
1408
		node, GNM_CONF_GUI_ED_TRANSITION_KEYS, FALSE);
627
	prefs.recalc_lag = go_conf_load_int (
1409
	prefs.recalc_lag = go_conf_load_int (
628
		GNM_CONF_GUI_ED_RECALC_LAG, -5000, 5000, 200);
1410
		node, GNM_CONF_GUI_ED_RECALC_LAG, -5000, 5000, 200);
1411
	go_conf_free_node (node);
1412
1413
	node = go_conf_get_node (root, GNM_CONF_UNDO_DIR);
629
	prefs.show_sheet_name = go_conf_load_bool (
1414
	prefs.show_sheet_name = go_conf_load_bool (
630
		GNM_CONF_UNDO_SHOW_SHEET_NAME, TRUE);
1415
		node, GNM_CONF_UNDO_SHOW_SHEET_NAME, TRUE);
631
	prefs.max_descriptor_width = go_conf_load_int (
1416
	prefs.max_descriptor_width = go_conf_load_int (
632
		GNM_CONF_UNDO_MAX_DESCRIPTOR_WIDTH, 5, 256, 15);
1417
		node, GNM_CONF_UNDO_MAX_DESCRIPTOR_WIDTH, 5, 256, 15);
633
	prefs.undo_size = go_conf_load_int (
1418
	prefs.undo_size = go_conf_load_int (
634
		GNM_CONF_UNDO_SIZE, 1, 1000000, 100000);
1419
		node, GNM_CONF_UNDO_SIZE, 1, 1000000, 100000);
635
	prefs.undo_max_number = go_conf_load_int (
1420
	prefs.undo_max_number = go_conf_load_int (
636
		GNM_CONF_UNDO_MAXNUM, 0, 10000, 100);
1421
		node, GNM_CONF_UNDO_MAXNUM, 0, 10000, 100);
1422
	go_conf_free_node (node);
637
1423
638
	prefs.autoformat.extra_dirs = go_conf_load_str_list (AUTOFORMAT_GCONF_EXTRA_DIRS);
1424
	node = go_conf_get_node (root, AUTOFORMAT_GCONF_DIR);
639
	tmp = go_conf_load_string (AUTOFORMAT_GCONF_SYS_DIR);
1425
	prefs.autoformat.extra_dirs = go_conf_load_str_list (node, AUTOFORMAT_GCONF_EXTRA_DIRS);
1426
	tmp = go_conf_load_string (node, AUTOFORMAT_GCONF_SYS_DIR);
640
	if (tmp == NULL)
1427
	if (tmp == NULL)
641
		tmp = g_strdup ("autoformat-templates");
1428
		tmp = g_strdup ("autoformat-templates");
642
	prefs.autoformat.sys_dir = gnm_sys_data_dir (tmp);
1429
	prefs.autoformat.sys_dir = gnm_sys_data_dir (tmp);
643
	g_free (tmp);
1430
	g_free (tmp);
644
	tmp = go_conf_load_string (AUTOFORMAT_GCONF_USR_DIR);
1431
	tmp = go_conf_load_string (node, AUTOFORMAT_GCONF_USR_DIR);
645
	if (tmp == NULL)
1432
	if (tmp == NULL)
646
		tmp = g_strdup ("autoformat-templates");
1433
		tmp = g_strdup ("autoformat-templates");
647
	prefs.autoformat.usr_dir = gnm_usr_dir (tmp);
1434
	prefs.autoformat.usr_dir = gnm_usr_dir (tmp);
648
	g_free (tmp);
1435
	g_free (tmp);
1436
	go_conf_free_node (node);
649
1437
650
	prefs.xml_compression_level = go_conf_load_int (
1438
	prefs.xml_compression_level = go_conf_load_int (
651
		GNM_CONF_XML_COMPRESSION, 0, 9, 9);
1439
		root, GNM_CONF_XML_COMPRESSION, 0, 9, 9);
1440
1441
	node = go_conf_get_node (root, GNM_CONF_FILE_DIR);
652
	prefs.file_overwrite_default_answer = go_conf_load_bool (
1442
	prefs.file_overwrite_default_answer = go_conf_load_bool (
653
		GNM_CONF_FILE_OVERWRITE_DEFAULT, FALSE);
1443
		node, GNM_CONF_FILE_OVERWRITE_DEFAULT, FALSE);
654
	prefs.file_ask_single_sheet_save = go_conf_load_bool (
1444
	prefs.file_ask_single_sheet_save = go_conf_load_bool (
655
		GNM_CONF_FILE_SINGLE_SHEET_SAVE, TRUE);
1445
		node, GNM_CONF_FILE_SINGLE_SHEET_SAVE, TRUE);
1446
	go_conf_free_node (node);
1447
1448
	node = go_conf_get_node (root, GNM_CONF_SORT_DIR);
656
	prefs.sort_default_by_case = go_conf_load_bool (
1449
	prefs.sort_default_by_case = go_conf_load_bool (
657
		GNM_CONF_SORT_DEFAULT_BY_CASE, FALSE);
1450
		node, GNM_CONF_SORT_DEFAULT_BY_CASE, FALSE);
658
	prefs.sort_default_retain_formats = go_conf_load_bool (
1451
	prefs.sort_default_retain_formats = go_conf_load_bool (
659
		GNM_CONF_SORT_DEFAULT_RETAIN_FORM, TRUE);
1452
		node, GNM_CONF_SORT_DEFAULT_RETAIN_FORM, TRUE);
660
	prefs.sort_default_ascending = go_conf_load_bool (
1453
	prefs.sort_default_ascending = go_conf_load_bool (
661
		GNM_CONF_SORT_DEFAULT_ASCENDING, TRUE);
1454
		node, GNM_CONF_SORT_DEFAULT_ASCENDING, TRUE);
662
	prefs.sort_max_initial_clauses = go_conf_load_int (
1455
	prefs.sort_max_initial_clauses = go_conf_load_int (
663
		GNM_CONF_SORT_DIALOG_MAX_INITIAL, 0, 256, 10);
1456
		node, GNM_CONF_SORT_DIALOG_MAX_INITIAL, 0, 256, 10);
1457
	go_conf_free_node (node);
1458
664
	prefs.unfocused_range_selection = go_conf_load_bool (
1459
	prefs.unfocused_range_selection = go_conf_load_bool (
665
		DIALOGS_GCONF_UNFOCUSED_RS, TRUE);
1460
		root, DIALOGS_GCONF_DIR "/" DIALOGS_GCONF_UNFOCUSED_RS, TRUE);
666
	prefs.prefer_clipboard_selection = go_conf_load_bool (
1461
	prefs.prefer_clipboard_selection = go_conf_load_bool (
667
		GNM_CONF_CUTANDPASTE_PREFER_CLIPBOARD, TRUE);
1462
		root, GNM_CONF_CUTANDPASTE_DIR "/" GNM_CONF_CUTANDPASTE_PREFER_CLIPBOARD, TRUE);
668
	prefs.latex_use_utf8 = go_conf_load_bool (
1463
	prefs.latex_use_utf8 = go_conf_load_bool (
669
		PLUGIN_GCONF_LATEX_USE_UTF8, TRUE); 
1464
		root, PLUGIN_GCONF_LATEX "/" PLUGIN_GCONF_LATEX_USE_UTF8, TRUE); 
670
1465
671
	gnm_conf_init_printer_decoration_font ();
1466
	gnm_conf_init_printer_decoration_font ();
672
1467
Lines 681-686 gnm_conf_init_extras (void) Link Here
681
void
1476
void
682
gnm_conf_init (gboolean fast)
1477
gnm_conf_init (gboolean fast)
683
{
1478
{
1479
	go_conf_init ();
1480
	root = go_conf_get_node (NULL, GNM_CONF_DIR);
684
	gnm_conf_init_essential ();
1481
	gnm_conf_init_essential ();
685
	if (fast)
1482
	if (fast)
686
		g_timeout_add (1000, (GSourceFunc) gnm_conf_init_extras, NULL);
1483
		g_timeout_add (1000, (GSourceFunc) gnm_conf_init_extras, NULL);
Lines 691-705 gnm_conf_init (gboolean fast) Link Here
691
void     
1488
void     
692
gnm_conf_shutdown (void)
1489
gnm_conf_shutdown (void)
693
{
1490
{
1491
	if (prefs.printer_decoration_font) {
694
	mstyle_unref (prefs.printer_decoration_font);
1492
	mstyle_unref (prefs.printer_decoration_font);
695
	prefs.printer_decoration_font = NULL;
1493
	prefs.printer_decoration_font = NULL;
696
#ifdef WITH_GNOME
697
	if (gconf_client) {
698
		gconf_client_remove_dir (gconf_client, "/apps/gnumeric", NULL);
699
		g_object_unref (G_OBJECT (gconf_client));
700
		gconf_client = NULL;
701
	}
1494
	}
702
#endif
1495
	go_conf_free_node (root);
1496
	go_conf_shutdown ();
1497
}
1498
1499
GOConfNode *
1500
gnm_conf_get_root (void)
1501
{
1502
	return root;
703
}
1503
}
704
1504
705
void
1505
void
Lines 713-719 gnm_gconf_set_plugin_file_states (GSList Link Here
713
	g_slist_free ((GSList *)prefs.plugin_file_states);
1513
	g_slist_free ((GSList *)prefs.plugin_file_states);
714
	prefs.plugin_file_states = list;
1514
	prefs.plugin_file_states = list;
715
1515
716
	go_conf_set_str_list (PLUGIN_GCONF_FILE_STATES, list);
1516
	go_conf_set_str_list (root, PLUGIN_GCONF_DIR "/" PLUGIN_GCONF_FILE_STATES, list);
717
}
1517
}
718
1518
719
void
1519
void
Lines 727-751 gnm_gconf_set_plugin_extra_dirs (GSList Link Here
727
	g_slist_free ((GSList *)prefs.plugin_extra_dirs);
1527
	g_slist_free ((GSList *)prefs.plugin_extra_dirs);
728
	prefs.plugin_extra_dirs = list;
1528
	prefs.plugin_extra_dirs = list;
729
1529
730
	go_conf_set_str_list (PLUGIN_GCONF_EXTRA_DIRS, list);
1530
	go_conf_set_str_list (root, PLUGIN_GCONF_DIR "/" PLUGIN_GCONF_EXTRA_DIRS, list);
731
}
1531
}
732
1532
733
void
1533
void
734
gnm_gconf_set_active_plugins (GSList *list)
1534
gnm_gconf_set_active_plugins (GSList *list)
735
{
1535
{
736
	go_conf_set_str_list (PLUGIN_GCONF_ACTIVE, list);
1536
	go_conf_set_str_list (root, PLUGIN_GCONF_DIR "/" PLUGIN_GCONF_ACTIVE, list);
737
}
1537
}
738
1538
739
void
1539
void
740
gnm_gconf_set_activate_new_plugins (gboolean val)
1540
gnm_gconf_set_activate_new_plugins (gboolean val)
741
{
1541
{
742
	go_conf_set_bool (PLUGIN_GCONF_ACTIVATE_NEW, val);
1542
	go_conf_set_bool (root, PLUGIN_GCONF_DIR "/" PLUGIN_GCONF_ACTIVATE_NEW, val);
743
}
1543
}
744
1544
745
void
1545
void
746
gnm_gconf_set_recent_funcs (GSList *list)
1546
gnm_gconf_set_recent_funcs (GSList *list)
747
{
1547
{
748
	go_conf_set_str_list (FUNCTION_SELECT_GCONF_RECENT, list);
1548
	go_conf_set_str_list (root, FUNCTION_SELECT_GCONF_DIR "/" FUNCTION_SELECT_GCONF_RECENT, list);
749
1549
750
	/* the const_casts are ok, the const in the header is just to keep
1550
	/* the const_casts are ok, the const in the header is just to keep
751
	 * people for doing stupid things */
1551
	 * people for doing stupid things */
Lines 761-767 gnm_gconf_set_num_recent_functions (gint Link Here
761
	if (val < 0)
1561
	if (val < 0)
762
		val = 0;
1562
		val = 0;
763
	prefs.num_of_recent_funcs = val;
1563
	prefs.num_of_recent_funcs = val;
764
	go_conf_set_int ( FUNCTION_SELECT_GCONF_NUM_OF_RECENT, val);
1564
	go_conf_set_int (root, FUNCTION_SELECT_GCONF_DIR "/" FUNCTION_SELECT_GCONF_NUM_OF_RECENT, val);
765
}
1565
}
766
1566
767
void
1567
void
Lines 774-780 gnm_gconf_set_file_history_files (GSList Link Here
774
	g_slist_foreach ((GSList *)prefs.file_history_files, (GFunc)g_free, NULL);
1574
	g_slist_foreach ((GSList *)prefs.file_history_files, (GFunc)g_free, NULL);
775
	g_slist_free ((GSList *)prefs.file_history_files);
1575
	g_slist_free ((GSList *)prefs.file_history_files);
776
	prefs.file_history_files = list;
1576
	prefs.file_history_files = list;
777
	go_conf_set_str_list (GNM_CONF_FILE_HISTORY_FILES, list);
1577
	go_conf_set_str_list (root, GNM_CONF_FILE_DIR "/" GNM_CONF_FILE_HISTORY_FILES, list);
778
}
1578
}
779
1579
780
void
1580
void
Lines 783-789 gnm_gconf_set_file_history_number (gint Link Here
783
	if (val < 0)
1583
	if (val < 0)
784
		val = 0;
1584
		val = 0;
785
	prefs.file_history_max = val; 
1585
	prefs.file_history_max = val; 
786
	go_conf_set_int (GNM_CONF_FILE_HISTORY_N, val);
1586
	go_conf_set_int (root, GNM_CONF_FILE_DIR "/" GNM_CONF_FILE_HISTORY_N, val);
787
}
1587
}
788
1588
789
1589
Lines 793-799 gnm_gconf_set_undo_size (gint val) Link Here
793
	if (val < 1)
1593
	if (val < 1)
794
		val = 1;
1594
		val = 1;
795
	prefs.undo_size = val; 
1595
	prefs.undo_size = val; 
796
	go_conf_set_int (GNM_CONF_UNDO_SIZE, val);
1596
	go_conf_set_int (root, GNM_CONF_UNDO_DIR "/" GNM_CONF_UNDO_SIZE, val);
797
}
1597
}
798
1598
799
1599
Lines 803-835 gnm_gconf_set_undo_max_number (gint val) Link Here
803
	if (val < 1)
1603
	if (val < 1)
804
		val = 1;
1604
		val = 1;
805
	prefs.undo_max_number = val;
1605
	prefs.undo_max_number = val;
806
	go_conf_set_int (GNM_CONF_UNDO_MAXNUM, val);
1606
	go_conf_set_int (root, GNM_CONF_UNDO_DIR "/" GNM_CONF_UNDO_MAXNUM, val);
807
}
1607
}
808
1608
809
void
1609
void
810
gnm_gconf_set_autoformat_sys_dirs (char const * string)
1610
gnm_gconf_set_autoformat_sys_dirs (char const * string)
811
{
1611
{
812
	go_conf_set_string (AUTOFORMAT_GCONF_SYS_DIR, string);
1612
	go_conf_set_string (root, AUTOFORMAT_GCONF_DIR "/" AUTOFORMAT_GCONF_SYS_DIR, string);
813
}
1613
}
814
1614
815
void
1615
void
816
gnm_gconf_set_autoformat_usr_dirs (char const * string)
1616
gnm_gconf_set_autoformat_usr_dirs (char const * string)
817
{
1617
{
818
	go_conf_set_string (AUTOFORMAT_GCONF_USR_DIR, string);
1618
	go_conf_set_string (root, AUTOFORMAT_GCONF_DIR "/" AUTOFORMAT_GCONF_USR_DIR, string);
819
}
1619
}
820
1620
821
void
1621
void
822
gnm_gconf_set_all_sheets (gboolean val)
1622
gnm_gconf_set_all_sheets (gboolean val)
823
{
1623
{
824
	go_conf_set_bool (PRINTSETUP_GCONF_ALL_SHEETS, val);
1624
	go_conf_set_bool (root, PRINTSETUP_GCONF_DIR "/" PRINTSETUP_GCONF_ALL_SHEETS, val);
825
}
1625
}
826
1626
827
void
1627
void
828
gnm_gconf_set_printer_config (gchar *str)
1628
gnm_gconf_set_printer_config (gchar const *str)
829
{
1629
{
830
	go_conf_set_string  (PRINTSETUP_GCONF_PRINTER_CONFIG, str);
1630
	go_conf_set_string (root, PRINTSETUP_GCONF_DIR "/" PRINTSETUP_GCONF_PRINTER_CONFIG, str);
1631
	if (prefs.printer_config != str) {
831
	g_free (prefs.printer_config);
1632
	g_free (prefs.printer_config);
832
	prefs.printer_config = str;
1633
		prefs.printer_config = g_strdup (str);
1634
	}
833
}
1635
}
834
1636
835
void
1637
void
Lines 840-846 gnm_gconf_set_printer_header (gchar cons Link Here
840
	list = g_slist_prepend (list, g_strdup (right));
1642
	list = g_slist_prepend (list, g_strdup (right));
841
	list = g_slist_prepend (list, g_strdup (middle));
1643
	list = g_slist_prepend (list, g_strdup (middle));
842
	list = g_slist_prepend (list, g_strdup (left));
1644
	list = g_slist_prepend (list, g_strdup (left));
843
	go_conf_set_str_list (PRINTSETUP_GCONF_HEADER, list);
1645
	go_conf_set_str_list (root, PRINTSETUP_GCONF_DIR "/" PRINTSETUP_GCONF_HEADER, list);
844
	gnm_slist_free_custom ((GSList *)prefs.printer_header, g_free);
1646
	gnm_slist_free_custom ((GSList *)prefs.printer_header, g_free);
845
	prefs.printer_header = list;
1647
	prefs.printer_header = list;
846
}
1648
}
Lines 853-859 gnm_gconf_set_printer_footer (gchar cons Link Here
853
	list = g_slist_prepend (list, g_strdup (right));
1655
	list = g_slist_prepend (list, g_strdup (right));
854
	list = g_slist_prepend (list, g_strdup (middle));
1656
	list = g_slist_prepend (list, g_strdup (middle));
855
	list = g_slist_prepend (list, g_strdup (left));
1657
	list = g_slist_prepend (list, g_strdup (left));
856
	go_conf_set_str_list (PRINTSETUP_GCONF_FOOTER, list);
1658
	go_conf_set_str_list (root, PRINTSETUP_GCONF_DIR "/" PRINTSETUP_GCONF_FOOTER, list);
857
	gnm_slist_free_custom ((GSList *)prefs.printer_footer, g_free);
1659
	gnm_slist_free_custom ((GSList *)prefs.printer_footer, g_free);
858
	prefs.printer_footer = list;
1660
	prefs.printer_footer = list;
859
}
1661
}
Lines 861-915 gnm_gconf_set_printer_footer (gchar cons Link Here
861
void     
1663
void     
862
gnm_gconf_set_print_center_horizontally (gboolean val)
1664
gnm_gconf_set_print_center_horizontally (gboolean val)
863
{
1665
{
864
	go_conf_set_bool (PRINTSETUP_GCONF_CENTER_HORIZONTALLY, val);
1666
	go_conf_set_bool (root, PRINTSETUP_GCONF_DIR "/" PRINTSETUP_GCONF_CENTER_HORIZONTALLY, val);
865
}
1667
}
866
1668
867
void     
1669
void     
868
gnm_gconf_set_print_center_vertically (gboolean val)
1670
gnm_gconf_set_print_center_vertically (gboolean val)
869
{
1671
{
870
	go_conf_set_bool (PRINTSETUP_GCONF_CENTER_VERTICALLY, val);
1672
	go_conf_set_bool (root, PRINTSETUP_GCONF_DIR "/" PRINTSETUP_GCONF_CENTER_VERTICALLY, val);
871
}
1673
}
872
1674
873
void     
1675
void     
874
gnm_gconf_set_print_grid_lines (gboolean val)
1676
gnm_gconf_set_print_grid_lines (gboolean val)
875
{
1677
{
876
	go_conf_set_bool (PRINTSETUP_GCONF_PRINT_GRID_LINES, val);
1678
	go_conf_set_bool (root, PRINTSETUP_GCONF_DIR "/" PRINTSETUP_GCONF_PRINT_GRID_LINES, val);
877
}
1679
}
878
1680
879
void     
1681
void     
880
gnm_gconf_set_print_even_if_only_styles (gboolean val)
1682
gnm_gconf_set_print_even_if_only_styles (gboolean val)
881
{
1683
{
882
	go_conf_set_bool (PRINTSETUP_GCONF_EVEN_IF_ONLY_STYLES, val);
1684
	go_conf_set_bool (root, PRINTSETUP_GCONF_DIR "/" PRINTSETUP_GCONF_EVEN_IF_ONLY_STYLES, val);
883
}
1685
}
884
1686
885
void     
1687
void     
886
gnm_gconf_set_print_black_and_white (gboolean val)
1688
gnm_gconf_set_print_black_and_white (gboolean val)
887
{
1689
{
888
	go_conf_set_bool (PRINTSETUP_GCONF_PRINT_BLACK_AND_WHITE, val);
1690
	go_conf_set_bool (root, PRINTSETUP_GCONF_DIR "/" PRINTSETUP_GCONF_PRINT_BLACK_AND_WHITE, val);
889
}
1691
}
890
1692
891
void     
1693
void     
892
gnm_gconf_set_print_titles (gboolean val)
1694
gnm_gconf_set_print_titles (gboolean val)
893
{
1695
{
894
	go_conf_set_bool (PRINTSETUP_GCONF_PRINT_TITLES, val);
1696
	go_conf_set_bool (root, PRINTSETUP_GCONF_DIR "/" PRINTSETUP_GCONF_PRINT_TITLES, val);
895
}
1697
}
896
1698
897
void     
1699
void     
898
gnm_gconf_set_print_order_right_then_down (gboolean val)
1700
gnm_gconf_set_print_order_right_then_down (gboolean val)
899
{
1701
{
900
	go_conf_set_bool (PRINTSETUP_GCONF_RIGHT_THEN_DOWN, val);
1702
	go_conf_set_bool (root, PRINTSETUP_GCONF_DIR "/" PRINTSETUP_GCONF_RIGHT_THEN_DOWN, val);
901
}
1703
}
902
1704
903
void     
1705
void     
904
gnm_gconf_set_print_scale_percentage (gboolean val)
1706
gnm_gconf_set_print_scale_percentage (gboolean val)
905
{
1707
{
906
	go_conf_set_bool (PRINTSETUP_GCONF_SCALE_PERCENTAGE, val);
1708
	go_conf_set_bool (
1709
		root, PRINTSETUP_GCONF_DIR "/" PRINTSETUP_GCONF_SCALE_PERCENTAGE, val);
907
}
1710
}
908
1711
909
void     
1712
void     
910
gnm_gconf_set_print_scale_percentage_value (gnm_float val)
1713
gnm_gconf_set_print_scale_percentage_value (gnm_float val)
911
{
1714
{
912
	go_conf_set_double (PRINTSETUP_GCONF_SCALE_PERCENTAGE_VALUE, val);
1715
	go_conf_set_double (
1716
		root, PRINTSETUP_GCONF_DIR "/" PRINTSETUP_GCONF_SCALE_PERCENTAGE_VALUE, val);
913
}
1717
}
914
1718
915
void     
1719
void     
Lines 917-935 gnm_gconf_set_print_tb_margins (PrintMar Link Here
917
{
1721
{
918
	/* We are not saving the GnomePrintUnits since they are */
1722
	/* We are not saving the GnomePrintUnits since they are */
919
	/* duplicated in the gnomeprintconfig                   */
1723
	/* duplicated in the gnomeprintconfig                   */
920
	go_conf_set_double (PRINTSETUP_GCONF_MARGIN_TOP, pm->top.points);
1724
	go_conf_set_double (
921
	go_conf_set_double (PRINTSETUP_GCONF_MARGIN_BOTTOM, pm->bottom.points);
1725
		root, PRINTSETUP_GCONF_DIR "/" PRINTSETUP_GCONF_MARGIN_TOP, pm->top.points);
1726
	go_conf_set_double (
1727
		root, PRINTSETUP_GCONF_DIR "/" PRINTSETUP_GCONF_MARGIN_BOTTOM, pm->bottom.points);
922
}
1728
}
923
1729
924
void     
1730
void     
925
gnm_gconf_set_print_header_formats (GSList *left, GSList *middle, 
1731
gnm_gconf_set_print_header_formats (GSList *left, GSList *middle, 
926
				    GSList *right)
1732
				    GSList *right)
927
{
1733
{
928
	go_conf_set_str_list (PRINTSETUP_GCONF_HEADER_FORMAT_LEFT, left);
1734
	go_conf_set_str_list (
1735
		root, PRINTSETUP_GCONF_DIR "/" PRINTSETUP_GCONF_HEADER_FORMAT_LEFT, left);
929
	gnm_slist_free_custom (left, g_free);
1736
	gnm_slist_free_custom (left, g_free);
930
	go_conf_set_str_list (PRINTSETUP_GCONF_HEADER_FORMAT_MIDDLE, middle);
1737
	go_conf_set_str_list (
1738
		root, PRINTSETUP_GCONF_DIR "/" PRINTSETUP_GCONF_HEADER_FORMAT_MIDDLE, middle);
931
	gnm_slist_free_custom (middle, g_free);
1739
	gnm_slist_free_custom (middle, g_free);
932
	go_conf_set_str_list (PRINTSETUP_GCONF_HEADER_FORMAT_RIGHT, right);
1740
	go_conf_set_str_list (
1741
		root, PRINTSETUP_GCONF_DIR "/" PRINTSETUP_GCONF_HEADER_FORMAT_RIGHT, right);
933
	gnm_slist_free_custom (right, g_free);
1742
	gnm_slist_free_custom (right, g_free);
934
}
1743
}
935
1744
Lines 937-996 void Link Here
937
gnm_gconf_set_gui_window_x (gnm_float val)
1746
gnm_gconf_set_gui_window_x (gnm_float val)
938
{
1747
{
939
	prefs.horizontal_window_fraction = val;
1748
	prefs.horizontal_window_fraction = val;
940
	go_conf_set_double (GNM_CONF_GUI_WINDOW_X, val);
1749
	go_conf_set_double (
1750
		root, GNM_CONF_GUI_DIR "/" GNM_CONF_GUI_WINDOW_X, val);
941
}
1751
}
942
1752
943
void     
1753
void     
944
gnm_gconf_set_gui_window_y (gnm_float val)
1754
gnm_gconf_set_gui_window_y (gnm_float val)
945
{
1755
{
946
	prefs.vertical_window_fraction = val;
1756
	prefs.vertical_window_fraction = val;
947
	go_conf_set_double (GNM_CONF_GUI_WINDOW_Y, val);
1757
	go_conf_set_double (
1758
		root, GNM_CONF_GUI_DIR "/" GNM_CONF_GUI_WINDOW_Y, val);
948
}
1759
}
949
1760
950
void     
1761
void     
951
gnm_gconf_set_gui_zoom (gnm_float val)
1762
gnm_gconf_set_gui_zoom (gnm_float val)
952
{
1763
{
953
	prefs.zoom = val;
1764
	prefs.zoom = val;
954
	go_conf_set_double (GNM_CONF_GUI_WINDOW_Y, val);
1765
	go_conf_set_double (
1766
		root, GNM_CONF_GUI_DIR "/" GNM_CONF_GUI_WINDOW_Y, val);
955
}
1767
}
956
1768
957
void     
1769
void     
958
gnm_gconf_set_default_font_size (gnm_float val)
1770
gnm_gconf_set_default_font_size (gnm_float val)
959
{
1771
{
960
	prefs.default_font.size = val;
1772
	prefs.default_font.size = val;
961
	go_conf_set_double (GNM_CONF_FONT_SIZE, val);
1773
	go_conf_set_double (
1774
		root, GNM_CONF_FONT_DIR "/" GNM_CONF_FONT_SIZE, val);
962
}
1775
}
963
1776
964
void     
1777
void     
965
gnm_gconf_set_default_font_name (char const *str)
1778
gnm_gconf_set_default_font_name (char const *str)
966
{
1779
{
967
	g_return_if_fail (str != NULL);
1780
	go_conf_set_string (root, GNM_CONF_FONT_DIR "/" GNM_CONF_FONT_NAME, str);
968
1781
	if (prefs.default_font.name != str) {
969
	/* the const_casts are ok, the const in the header is just to keep
1782
		/* the const in the header is just a safety net */
970
	 * people for doing stupid things */
971
	if (prefs.default_font.name != NULL)
972
		g_free ((char *) prefs.default_font.name);
1783
		g_free ((char *) prefs.default_font.name);
973
	prefs.default_font.name = g_strdup (str);
1784
	prefs.default_font.name = g_strdup (str);
974
	go_conf_set_string (GNM_CONF_FONT_NAME, str);
1785
	}
975
}
1786
}
976
1787
977
void     
1788
void     
978
gnm_gconf_set_default_font_bold (gboolean val)
1789
gnm_gconf_set_default_font_bold (gboolean val)
979
{
1790
{
980
	prefs.default_font.is_bold = val;
1791
	prefs.default_font.is_bold = val;
981
	go_conf_set_bool (GNM_CONF_FONT_BOLD, val);
1792
	go_conf_set_bool (
1793
		root, GNM_CONF_FONT_DIR "/" GNM_CONF_FONT_BOLD, val);
982
}
1794
}
983
1795
984
void     
1796
void     
985
gnm_gconf_set_default_font_italic (gboolean val)
1797
gnm_gconf_set_default_font_italic (gboolean val)
986
{
1798
{
987
	prefs.default_font.is_italic = val;
1799
	prefs.default_font.is_italic = val;
988
	go_conf_set_bool (GNM_CONF_FONT_ITALIC, val);
1800
	go_conf_set_bool (
1801
		root, GNM_CONF_FONT_DIR "/" GNM_CONF_FONT_ITALIC, val);
989
}
1802
}
990
1803
991
void
1804
void
992
gnm_gconf_set_hf_font (GnmStyle const *mstyle)
1805
gnm_gconf_set_hf_font (GnmStyle const *mstyle)
993
{
1806
{
1807
	GOConfNode *node;
994
	GnmStyle *old_style = (prefs.printer_decoration_font != NULL) ?
1808
	GnmStyle *old_style = (prefs.printer_decoration_font != NULL) ?
995
		prefs.printer_decoration_font :
1809
		prefs.printer_decoration_font :
996
		mstyle_new_default ();
1810
		mstyle_new_default ();
Lines 998-1015 gnm_gconf_set_hf_font (GnmStyle const *m Link Here
998
	prefs.printer_decoration_font = mstyle_copy_merge (old_style, mstyle);
1812
	prefs.printer_decoration_font = mstyle_copy_merge (old_style, mstyle);
999
	mstyle_unref (old_style);
1813
	mstyle_unref (old_style);
1000
	
1814
	
1815
	node = go_conf_get_node (root, PRINTSETUP_GCONF_DIR);
1001
	if (mstyle_is_element_set (mstyle, MSTYLE_FONT_SIZE))
1816
	if (mstyle_is_element_set (mstyle, MSTYLE_FONT_SIZE))
1002
		go_conf_set_double (PRINTSETUP_GCONF_HF_FONT_SIZE,
1817
		go_conf_set_double (node, PRINTSETUP_GCONF_HF_FONT_SIZE,
1003
			mstyle_get_font_size (mstyle));
1818
			mstyle_get_font_size (mstyle));
1004
	if (mstyle_is_element_set (mstyle, MSTYLE_FONT_NAME))
1819
	if (mstyle_is_element_set (mstyle, MSTYLE_FONT_NAME))
1005
		go_conf_set_string (PRINTSETUP_GCONF_HF_FONT_NAME,
1820
		go_conf_set_string (node, PRINTSETUP_GCONF_HF_FONT_NAME,
1006
			mstyle_get_font_name (mstyle));
1821
			mstyle_get_font_name (mstyle));
1007
	if (mstyle_is_element_set (mstyle, MSTYLE_FONT_BOLD))
1822
	if (mstyle_is_element_set (mstyle, MSTYLE_FONT_BOLD))
1008
		go_conf_set_bool (PRINTSETUP_GCONF_HF_FONT_BOLD,
1823
		go_conf_set_bool (node, PRINTSETUP_GCONF_HF_FONT_BOLD,
1009
			mstyle_get_font_bold (mstyle));
1824
			mstyle_get_font_bold (mstyle));
1010
	if (mstyle_is_element_set (mstyle, MSTYLE_FONT_ITALIC))
1825
	if (mstyle_is_element_set (mstyle, MSTYLE_FONT_ITALIC))
1011
		go_conf_set_bool (PRINTSETUP_GCONF_HF_FONT_ITALIC,
1826
		go_conf_set_bool (node, PRINTSETUP_GCONF_HF_FONT_ITALIC,
1012
			mstyle_get_font_italic (mstyle));
1827
			mstyle_get_font_italic (mstyle));
1828
	go_conf_free_node (node);
1013
}
1829
}
1014
1830
1015
1831
Lines 1019-1025 gnm_gconf_set_max_descriptor_width (gint Link Here
1019
	if (val < 1)
1835
	if (val < 1)
1020
		val = 1;
1836
		val = 1;
1021
	prefs.max_descriptor_width = val;
1837
	prefs.max_descriptor_width = val;
1022
	go_conf_set_int (GNM_CONF_UNDO_MAX_DESCRIPTOR_WIDTH, val);
1838
	go_conf_set_int (
1839
		root, GNM_CONF_UNDO_DIR "/" GNM_CONF_UNDO_MAX_DESCRIPTOR_WIDTH, val);
1023
}
1840
}
1024
1841
1025
void
1842
void
Lines 1028-1034 gnm_gconf_set_sort_dialog_max_initial (g Link Here
1028
	if (val < 1)
1845
	if (val < 1)
1029
		val = 1;
1846
		val = 1;
1030
	prefs.sort_max_initial_clauses = val;
1847
	prefs.sort_max_initial_clauses = val;
1031
	go_conf_set_int (GNM_CONF_SORT_DIALOG_MAX_INITIAL, val);
1848
	go_conf_set_int (
1849
		root, GNM_CONF_SORT_DIR "/" GNM_CONF_SORT_DIALOG_MAX_INITIAL, val);
1032
}
1850
}
1033
1851
1034
void
1852
void
Lines 1037-1043 gnm_gconf_set_workbook_nsheets (gint val Link Here
1037
	if (val < 1)
1855
	if (val < 1)
1038
		val = 1;
1856
		val = 1;
1039
	prefs.initial_sheet_number = val;
1857
	prefs.initial_sheet_number = val;
1040
	go_conf_set_int (GNM_CONF_WORKBOOK_NSHEETS, val);
1858
	go_conf_set_int (root, GNM_CONF_WORKBOOK_NSHEETS, val);
1041
}
1859
}
1042
1860
1043
void
1861
void
Lines 1046-1124 gnm_gconf_set_xml_compression (gint val) Link Here
1046
	if (val < 0)
1864
	if (val < 0)
1047
		val = 0;
1865
		val = 0;
1048
	prefs.xml_compression_level = val;
1866
	prefs.xml_compression_level = val;
1049
	go_conf_set_int (GNM_CONF_XML_COMPRESSION, val);
1867
	go_conf_set_int (root, GNM_CONF_XML_COMPRESSION, val);
1050
}
1868
}
1051
1869
1052
void     
1870
void     
1053
gnm_gconf_set_show_sheet_name (gboolean val)
1871
gnm_gconf_set_show_sheet_name (gboolean val)
1054
{
1872
{
1055
	prefs.show_sheet_name = val;
1873
	prefs.show_sheet_name = val;
1056
	go_conf_set_bool( GNM_CONF_UNDO_SHOW_SHEET_NAME, 
1874
	go_conf_set_bool (
1057
			  val != FALSE);
1875
		root, GNM_CONF_UNDO_DIR "/" GNM_CONF_UNDO_SHOW_SHEET_NAME,val != FALSE);
1058
}
1876
}
1059
1877
1060
void     
1878
void     
1061
gnm_gconf_set_latex_use_utf8 (gboolean val)
1879
gnm_gconf_set_latex_use_utf8 (gboolean val)
1062
{
1880
{
1063
	prefs.latex_use_utf8 = val;
1881
	prefs.latex_use_utf8 = val;
1064
	go_conf_set_bool( PLUGIN_GCONF_LATEX_USE_UTF8, 
1882
	go_conf_set_bool (
1065
			  val != FALSE);
1883
		root, PLUGIN_GCONF_LATEX "/" PLUGIN_GCONF_LATEX_USE_UTF8, val != FALSE);
1066
}
1884
}
1067
1885
1068
void     
1886
void     
1069
gnm_gconf_set_sort_retain_form (gboolean val)
1887
gnm_gconf_set_sort_retain_form (gboolean val)
1070
{
1888
{
1071
	prefs.sort_default_retain_formats = val;
1889
	prefs.sort_default_retain_formats = val;
1072
	go_conf_set_bool( GNM_CONF_SORT_DEFAULT_RETAIN_FORM, 
1890
	go_conf_set_bool (
1073
			  val != FALSE);
1891
		root, GNM_CONF_SORT_DIR "/" GNM_CONF_SORT_DEFAULT_RETAIN_FORM, val != FALSE);
1074
}
1892
}
1075
1893
1076
void     
1894
void     
1077
gnm_gconf_set_sort_by_case (gboolean val)
1895
gnm_gconf_set_sort_by_case (gboolean val)
1078
{
1896
{
1079
	prefs.sort_default_by_case = val;
1897
	prefs.sort_default_by_case = val;
1080
	go_conf_set_bool( GNM_CONF_SORT_DEFAULT_BY_CASE, 
1898
	go_conf_set_bool (
1081
			  val != FALSE);
1899
		root, GNM_CONF_SORT_DIR "/" GNM_CONF_SORT_DEFAULT_BY_CASE, val != FALSE);
1082
}
1900
}
1083
1901
1084
void     
1902
void     
1085
gnm_gconf_set_sort_ascending (gboolean val)
1903
gnm_gconf_set_sort_ascending (gboolean val)
1086
{
1904
{
1087
	prefs.sort_default_ascending = val;
1905
	prefs.sort_default_ascending = val;
1088
	go_conf_set_bool( GNM_CONF_SORT_DEFAULT_ASCENDING, 
1906
	go_conf_set_bool (
1089
			  val != FALSE);
1907
		root, GNM_CONF_SORT_DIR "/" GNM_CONF_SORT_DEFAULT_ASCENDING, val != FALSE);
1090
}
1908
}
1091
1909
1092
void     
1910
void     
1093
gnm_gconf_set_gui_transition_keys (gboolean val)
1911
gnm_gconf_set_gui_transition_keys (gboolean val)
1094
{
1912
{
1095
	prefs.transition_keys = val;
1913
	prefs.transition_keys = val;
1096
	go_conf_set_bool( GNM_CONF_GUI_ED_TRANSITION_KEYS, 
1914
	go_conf_set_bool (
1097
			  val != FALSE);
1915
		root, GNM_CONF_GUI_DIR "/" GNM_CONF_GUI_ED_TRANSITION_KEYS, val != FALSE);
1098
}
1916
}
1099
1917
1100
void     
1918
void     
1101
gnm_gconf_set_gui_livescrolling (gboolean val)
1919
gnm_gconf_set_gui_livescrolling (gboolean val)
1102
{
1920
{
1103
	prefs.live_scrolling = val;
1921
	prefs.live_scrolling = val;
1104
	go_conf_set_bool( GNM_CONF_GUI_ED_LIVESCROLLING, 
1922
	go_conf_set_bool (
1105
			  val != FALSE);
1923
		root, GNM_CONF_GUI_DIR "/" GNM_CONF_GUI_ED_LIVESCROLLING, val != FALSE);
1106
}
1924
}
1107
1925
1108
void     
1926
void     
1109
gnm_gconf_set_file_overwrite (gboolean val)
1927
gnm_gconf_set_file_overwrite (gboolean val)
1110
{
1928
{
1111
	prefs.file_overwrite_default_answer = val;
1929
	prefs.file_overwrite_default_answer = val;
1112
	go_conf_set_bool( GNM_CONF_FILE_OVERWRITE_DEFAULT, 
1930
	go_conf_set_bool (
1113
			  val != FALSE);
1931
		root, GNM_CONF_FILE_DIR "/" GNM_CONF_FILE_OVERWRITE_DEFAULT, val != FALSE);
1114
}
1932
}
1115
1933
1116
void     
1934
void     
1117
gnm_gconf_set_file_single_sheet_save (gboolean val)
1935
gnm_gconf_set_file_single_sheet_save (gboolean val)
1118
{
1936
{
1119
	prefs.file_ask_single_sheet_save = val;
1937
	prefs.file_ask_single_sheet_save = val;
1120
	go_conf_set_bool( GNM_CONF_FILE_SINGLE_SHEET_SAVE, 
1938
	go_conf_set_bool (
1121
			  val != FALSE);
1939
		root, GNM_CONF_FILE_DIR "/" GNM_CONF_FILE_SINGLE_SHEET_SAVE, val != FALSE);
1122
}
1940
}
1123
1941
1124
void    
1942
void    
Lines 1129-1135 gnm_gconf_set_gui_resolution_h (gnm_floa Link Here
1129
	if (val > 250)
1947
	if (val > 250)
1130
		val = 250;
1948
		val = 250;
1131
	prefs.horizontal_dpi = val;
1949
	prefs.horizontal_dpi = val;
1132
	go_conf_set_double (GNM_CONF_GUI_RES_H, val);
1950
	go_conf_set_double (
1951
		root, GNM_CONF_GUI_DIR "/" GNM_CONF_GUI_RES_H, val);
1133
}
1952
}
1134
1953
1135
void     
1954
void     
Lines 1140-1169 gnm_gconf_set_gui_resolution_v (gnm_floa Link Here
1140
	if (val > 250)
1959
	if (val > 250)
1141
		val = 250;
1960
		val = 250;
1142
	prefs.vertical_dpi = val;
1961
	prefs.vertical_dpi = val;
1143
	go_conf_set_double (GNM_CONF_GUI_RES_V, val);
1962
	go_conf_set_double (
1963
		root, GNM_CONF_GUI_DIR "/" GNM_CONF_GUI_RES_V, val);
1144
}
1964
}
1145
1965
1146
void     
1966
void     
1147
gnm_gconf_set_unfocused_rs (gboolean val)
1967
gnm_gconf_set_unfocused_rs (gboolean val)
1148
{
1968
{
1149
	prefs.unfocused_range_selection = val;
1969
	prefs.unfocused_range_selection = val;
1150
	go_conf_set_bool( DIALOGS_GCONF_UNFOCUSED_RS, 
1970
	go_conf_set_bool (
1151
			  val != FALSE);
1971
		root, DIALOGS_GCONF_DIR "/" DIALOGS_GCONF_UNFOCUSED_RS, val != FALSE);
1152
}
1972
}
1153
1973
1154
void     
1974
void     
1155
gnm_gconf_set_autocomplete (gboolean val)
1975
gnm_gconf_set_autocomplete (gboolean val)
1156
{
1976
{
1157
	prefs.auto_complete = val;
1977
	prefs.auto_complete = val;
1158
	go_conf_set_bool( GNM_CONF_GUI_ED_AUTOCOMPLETE, 
1978
	go_conf_set_bool (
1159
			  val != FALSE);
1979
		root, GNM_CONF_GUI_DIR "/" GNM_CONF_GUI_ED_AUTOCOMPLETE, val != FALSE);
1160
}
1980
}
1161
1981
1162
void     
1982
void     
1163
gnm_gconf_set_prefer_clipboard  (gboolean val)
1983
gnm_gconf_set_prefer_clipboard  (gboolean val)
1164
{
1984
{
1165
	prefs.prefer_clipboard_selection = val;
1985
	prefs.prefer_clipboard_selection = val;
1166
	go_conf_set_bool( GNM_CONF_CUTANDPASTE_PREFER_CLIPBOARD, 
1986
	go_conf_set_bool (
1167
			  val != FALSE);
1987
		root, GNM_CONF_CUTANDPASTE_DIR "/" GNM_CONF_CUTANDPASTE_PREFER_CLIPBOARD, val != FALSE);
1168
}
1988
}
1169
(-)src/gnumeric-gconf.h (-27 / +33 lines)
Lines 82-90 typedef struct { Link Here
82
} GnmAppPrefs;
82
} GnmAppPrefs;
83
extern GnmAppPrefs const *gnm_app_prefs;
83
extern GnmAppPrefs const *gnm_app_prefs;
84
84
85
typedef struct _GOConfNode GOConfNode;
86
85
void     gnm_conf_init (gboolean fast);
87
void     gnm_conf_init (gboolean fast);
86
void     gnm_conf_shutdown (void);
88
void     gnm_conf_shutdown (void);
87
void     gnm_conf_sync (void);
89
void     gnm_conf_sync (void);
90
GOConfNode *gnm_conf_get_root (void);
88
91
89
/* autocorrect */
92
/* autocorrect */
90
void     gnm_gconf_set_autocorrect_init_caps (gboolean val);
93
void     gnm_gconf_set_autocorrect_init_caps (gboolean val);
Lines 123-129 void gnm_gconf_set_file_single_sheet Link Here
123
126
124
/* print-setup & printing */
127
/* print-setup & printing */
125
void     gnm_gconf_set_all_sheets (gboolean val);
128
void     gnm_gconf_set_all_sheets (gboolean val);
126
void     gnm_gconf_set_printer_config (gchar *str);
129
void     gnm_gconf_set_printer_config (gchar const *str);
127
void     gnm_gconf_set_printer_header (gchar const *left, gchar const *middle, 
130
void     gnm_gconf_set_printer_header (gchar const *left, gchar const *middle, 
128
				       gchar const *right);
131
				       gchar const *right);
129
void     gnm_gconf_set_printer_footer (gchar const *left, gchar const *middle, 
132
void     gnm_gconf_set_printer_footer (gchar const *left, gchar const *middle, 
Lines 180-214 void gnm_gconf_set_prefer_clipboard Link Here
180
183
181
/**************************************************************/
184
/**************************************************************/
182
185
183
char	*go_conf_get_short_desc     (char const *key);
186
GOConfNode * go_conf_get_node       (GOConfNode *parent, const gchar *key);
184
char	*go_conf_get_long_desc      (char const *key);
187
void	 go_conf_free_node	    (GOConfNode *node);
185
GType	 go_conf_get_type	    (char const *key);
188
186
char	*go_conf_get_value_as_str   (char const *key);
189
gchar	*go_conf_get_short_desc     (GOConfNode *node, gchar const *key);
187
gboolean go_conf_set_value_from_str (char const *key, char const *val_str);
190
gchar	*go_conf_get_long_desc      (GOConfNode *node, gchar const *key);
188
191
GType	 go_conf_get_type	    (GOConfNode *node, gchar const *key);
189
gboolean go_conf_get_bool	(char const *key);
192
gchar	*go_conf_get_value_as_str   (GOConfNode *node, gchar const *key);
190
int	 go_conf_get_int	(char const *key);
193
gboolean go_conf_set_value_from_str (GOConfNode *node, gchar const *key, gchar const *val_str);
191
double	 go_conf_get_double	(char const *key);
194
192
char	*go_conf_get_string	(char const *key);
195
gboolean go_conf_get_bool	(GOConfNode *node, gchar const *key);
193
GSList	*go_conf_get_str_list	(char const *key);
196
gint	 go_conf_get_int	(GOConfNode *node, gchar const *key);
194
197
gdouble	 go_conf_get_double	(GOConfNode *node, gchar const *key);
195
gboolean go_conf_load_bool	(char const *key, gboolean default_val);
198
gchar	*go_conf_get_string	(GOConfNode *node, gchar const *key);
196
int	 go_conf_load_int	(char const *key, int minima, int maxima, int default_val);
199
GSList	*go_conf_get_str_list	(GOConfNode *node, gchar const *key);
197
double	 go_conf_load_double	(char const *key, double minima, double maxima, double default_val);
200
198
char	*go_conf_load_string	(char const *key);
201
gboolean go_conf_load_bool	(GOConfNode *node, gchar const *key, gboolean default_val);
199
GSList	*go_conf_load_str_list	(char const *key);
202
gint	 go_conf_load_int	(GOConfNode *node, gchar const *key, gint minima, gint maxima, gint default_val);
200
203
gdouble	 go_conf_load_double	(GOConfNode *node, gchar const *key, gdouble minima, gdouble maxima, gdouble default_val);
201
void	 go_conf_set_bool	(char const *key, gboolean val);
204
gchar	*go_conf_load_string	(GOConfNode *node, gchar const *key);
202
void	 go_conf_set_int	(char const *key, gint val);
205
GSList	*go_conf_load_str_list	(GOConfNode *node, gchar const *key);
203
void	 go_conf_set_double	(char const *key, gnm_float val);
206
204
void	 go_conf_set_string	(char const *key, char const *str);
207
void	 go_conf_set_bool	(GOConfNode *node, gchar const *key, gboolean val);
205
void	 go_conf_set_str_list	(char const *key, GSList *list);
208
void	 go_conf_set_int	(GOConfNode *node, gchar const *key, gint val);
209
void	 go_conf_set_double	(GOConfNode *node, gchar const *key, gnm_float val);
210
void	 go_conf_set_string	(GOConfNode *node, gchar const *key, gchar const *str);
211
void	 go_conf_set_str_list	(GOConfNode *node, gchar const *key, GSList *list);
206
212
207
void	 go_conf_sync		(void);
213
void	 go_conf_sync		(GOConfNode *node);
208
214
209
typedef void (*GOConfMonitorFunc) (char const *key, gpointer data);
215
typedef void (*GOConfMonitorFunc) (GOConfNode *node, gchar const *key, gpointer data);
210
void	 go_conf_remove_monitor	(guint monitor_id);
216
void	 go_conf_remove_monitor	(guint monitor_id);
211
guint	 go_conf_add_monitor	(char const *key,
217
guint	 go_conf_add_monitor	(GOConfNode *node, gchar const *key,
212
				 GOConfMonitorFunc monitor, gpointer data);
218
				 GOConfMonitorFunc monitor, gpointer data);
213
219
214
#endif /* GNM_CONF_H */
220
#endif /* GNM_CONF_H */
(-)src/gui-clipboard.c (-1 / +2 lines)
Lines 237-243 complex_content_received (GtkClipboard * Link Here
237
		 * if the conversion from the X selection -> a cellregion
237
		 * if the conversion from the X selection -> a cellregion
238
		 * was canceled this may have content sized -1,-1
238
		 * was canceled this may have content sized -1,-1
239
		 */
239
		 */
240
		if (content->cols > 0 && content->rows > 0)
240
		if ((content->cols > 0 && content->rows > 0) ||
241
		    content->objects != NULL)
241
			cmd_paste_copy (wbc, pt, content);
242
			cmd_paste_copy (wbc, pt, content);
242
243
243
		/* Release the resources we used */
244
		/* Release the resources we used */
(-)src/gui-file.c (-1 / +2 lines)
Lines 660-665 gui_file_save_as (WorkbookControlGUI *wb Link Here
660
	fsel = GTK_FILE_CHOOSER
660
	fsel = GTK_FILE_CHOOSER
661
		(g_object_new (GTK_TYPE_FILE_CHOOSER_DIALOG,
661
		(g_object_new (GTK_TYPE_FILE_CHOOSER_DIALOG,
662
			       "action", GTK_FILE_CHOOSER_ACTION_SAVE,
662
			       "action", GTK_FILE_CHOOSER_ACTION_SAVE,
663
			       "local-only", FALSE,
663
			       "title", _("Select a file"),
664
			       "title", _("Select a file"),
664
			       NULL));
665
			       NULL));
665
	gtk_dialog_add_buttons (GTK_DIALOG (fsel),
666
	gtk_dialog_add_buttons (GTK_DIALOG (fsel),
Lines 727-733 gui_file_save_as (WorkbookControlGUI *wb Link Here
727
	wb_uri = workbook_get_uri (wb_view_workbook (wb_view));
728
	wb_uri = workbook_get_uri (wb_view_workbook (wb_view));
728
	if (wb_uri != NULL) {
729
	if (wb_uri != NULL) {
729
		char *basename = go_basename_from_uri (wb_uri);
730
		char *basename = go_basename_from_uri (wb_uri);
730
		char *dot = strrchr (basename, '.');
731
		char *dot = basename ? strrchr (basename, '.') : NULL;
731
732
732
		gtk_file_chooser_set_uri (fsel, wb_uri);
733
		gtk_file_chooser_set_uri (fsel, wb_uri);
733
		gtk_file_chooser_unselect_all (fsel);
734
		gtk_file_chooser_unselect_all (fsel);
(-)src/libgnumeric.c (-5 / +12 lines)
Lines 56-65 int immediate_exit_flag = 0; Link Here
56
int print_debugging = 0;
56
int print_debugging = 0;
57
gboolean initial_workbook_open_complete = FALSE;
57
gboolean initial_workbook_open_complete = FALSE;
58
char	   *x_geometry;
58
char	   *x_geometry;
59
char const *gnumeric_lib_dir = GNUMERIC_LIBDIR;
59
char *gnumeric_lib_dir = (char *)GNUMERIC_LIBDIR;
60
char const *gnumeric_data_dir = GNUMERIC_DATADIR;
60
char *gnumeric_data_dir = (char *)GNUMERIC_DATADIR;
61
char const *gnumeric_icon_dir = GNUMERIC_ICONDIR;
61
char *gnumeric_icon_dir = (char *)GNUMERIC_ICONDIR;
62
char const *gnumeric_locale_dir = GNUMERIC_LOCALEDIR;
62
char *gnumeric_locale_dir = (char *)GNUMERIC_LOCALEDIR;
63
63
64
/**
64
/**
65
 * gnm_pre_parse_init :
65
 * gnm_pre_parse_init :
Lines 77-83 gnm_pre_parse_init (char const* gnumeric Link Here
77
77
78
#ifdef G_OS_WIN32
78
#ifdef G_OS_WIN32
79
{
79
{
80
	char *dir;
80
	gchar *dir;
81
	dir = g_win32_get_package_installation_directory (NULL, NULL);
81
	dir = g_win32_get_package_installation_directory (NULL, NULL);
82
	gnumeric_data_dir = g_build_filename (dir,
82
	gnumeric_data_dir = g_build_filename (dir,
83
		"share", "gnumeric", GNUMERIC_VERSION, NULL);
83
		"share", "gnumeric", GNUMERIC_VERSION, NULL);
Lines 87-92 gnm_pre_parse_init (char const* gnumeric Link Here
87
		"share", "locale", NULL);
87
		"share", "locale", NULL);
88
	gnumeric_lib_dir = g_build_filename (dir,
88
	gnumeric_lib_dir = g_build_filename (dir,
89
		"lib", "gnumeric", GNUMERIC_VERSION, NULL);
89
		"lib", "gnumeric", GNUMERIC_VERSION, NULL);
90
	g_free (dir);
90
}
91
}
91
#endif
92
#endif
92
93
Lines 197-200 gnm_shutdown (void) Link Here
197
	libgoffice_shutdown ();
198
	libgoffice_shutdown ();
198
	plugin_services_shutdown ();
199
	plugin_services_shutdown ();
199
	g_object_unref (gnm_app_get_app ());
200
	g_object_unref (gnm_app_get_app ());
201
#ifdef G_OS_WIN32
202
	g_free (gnumeric_lib_dir);
203
	g_free (gnumeric_data_dir);
204
	g_free (gnumeric_icon_dir);
205
	g_free (gnumeric_locale_dir);
206
#endif
200
}
207
}
(-)src/libgnumeric.h (-4 / +4 lines)
Lines 13-22 extern int immediate_exit_flag; Link Here
13
extern int	 print_debugging;
13
extern int	 print_debugging;
14
extern gboolean	 initial_workbook_open_complete;
14
extern gboolean	 initial_workbook_open_complete;
15
extern char	*x_geometry;
15
extern char	*x_geometry;
16
extern char const *gnumeric_lib_dir;
16
extern char	*gnumeric_lib_dir;
17
extern char const *gnumeric_data_dir;
17
extern char	*gnumeric_data_dir;
18
extern char const *gnumeric_icon_dir;
18
extern char	*gnumeric_icon_dir;
19
extern char const *gnumeric_locale_dir;
19
extern char	*gnumeric_locale_dir;
20
20
21
void gnm_pre_parse_init (char const* gnumeric_binary);
21
void gnm_pre_parse_init (char const* gnumeric_binary);
22
void gnm_common_init	(gboolean fast);
22
void gnm_common_init	(gboolean fast);
(-)src/number-match.c (-4 / +4 lines)
Lines 155-162 format_create_regexp (unsigned char cons Link Here
155
			if (format[1] == '$') {
155
			if (format[1] == '$') {
156
				for (format += 2; *format && *format != ']' ; ++format)
156
				for (format += 2; *format && *format != ']' ; ++format)
157
					g_string_append_c (regexp, *format);
157
					g_string_append_c (regexp, *format);
158
				if (*format == ']')
158
				if (*format != ']')
159
					++format;
159
					format--;
160
				break;
160
				break;
161
			} else if (format[1] == 'h' && format[2] == ']') {
161
			} else if (format[1] == 'h' && format[2] == ']') {
162
				g_string_append (regexp, "([-+]?[0-9]+)");
162
				g_string_append (regexp, "([-+]?[0-9]+)");
Lines 843-849 compute_value (char const *s, const regm Link Here
843
				number = 0.;
843
				number = 0.;
844
				/* FIXME: this loop is bogus.  */
844
				/* FIXME: this loop is bogus.  */
845
				while (1) {
845
				while (1) {
846
					int thisnumber;
846
					unsigned long thisnumber;
847
					if (number > DBL_MAX / 1000.0) {
847
					if (number > DBL_MAX / 1000.0) {
848
						g_free (str);
848
						g_free (str);
849
						return NULL;
849
						return NULL;
Lines 896-902 compute_value (char const *s, const regm Link Here
896
			}
896
			}
897
			if (exppart) {
897
			if (exppart) {
898
				char *end;
898
				char *end;
899
				int exponent;
899
				long exponent;
900
900
901
				errno = 0; /* strtol sets errno, but does not clear it.  */
901
				errno = 0; /* strtol sets errno, but does not clear it.  */
902
				exponent = strtol (exppart, &end, 10);
902
				exponent = strtol (exppart, &end, 10);
(-)src/parser.y (-4 / +9 lines)
Lines 378-383 build_set (GnmExprList *list) Link Here
378
			return NULL;
378
			return NULL;
379
		}
379
		}
380
380
381
	unregister_allocation (list);
381
	return register_expr_allocation (gnm_expr_new_set (list));
382
	return register_expr_allocation (gnm_expr_new_set (list));
382
}
383
}
383
384
Lines 562-569 exp: CONSTANT { $$ = $1; } Link Here
562
				state->ptr-2, 2);
563
				state->ptr-2, 2);
563
			YYERROR;
564
			YYERROR;
564
		} else {
565
		} else {
565
			unregister_allocation ($2);
566
			if ($2->next == NULL) {
566
			if ($2->next == NULL) {
567
				unregister_allocation ($2);
567
				$$ = register_expr_allocation ($2->data);
568
				$$ = register_expr_allocation ($2->data);
568
				/* NOTE : free list not content */
569
				/* NOTE : free list not content */
569
				gnm_expr_list_free ($2);
570
				gnm_expr_list_free ($2);
Lines 716-726 cellref: RANGEREF { $$ = $1; } Link Here
716
		$$ = build_range_ctor ($1, $3, $3);
717
		$$ = build_range_ctor ($1, $3, $3);
717
		if ($$ == NULL) { YYERROR; }
718
		if ($$ == NULL) { YYERROR; }
718
	}
719
	}
720
	| RANGEREF RANGE_SEP RANGEREF {
721
		$$ = build_binop ($1, GNM_EXPR_OP_RANGE_CTOR, $3);
722
	}
719
	;
723
	;
720
724
721
arg_list: exp {
725
arg_list: exp {
722
		unregister_allocation ($1);
726
		unregister_allocation ($1);
723
		$$ = g_slist_prepend (NULL, $1);
727
		$$ = gnm_expr_list_prepend (NULL, $1);
724
		register_expr_list_allocation ($$);
728
		register_expr_list_allocation ($$);
725
        }
729
        }
726
	| exp SEPARATOR arg_list {
730
	| exp SEPARATOR arg_list {
Lines 731-737 arg_list: exp { Link Here
731
		if (tmp == NULL)
735
		if (tmp == NULL)
732
			tmp = gnm_expr_list_prepend (NULL, gnm_expr_new_constant (value_new_empty ()));
736
			tmp = gnm_expr_list_prepend (NULL, gnm_expr_new_constant (value_new_empty ()));
733
737
734
		$$ = g_slist_prepend (tmp, $1);
738
		$$ = gnm_expr_list_prepend (tmp, $1);
735
		register_expr_list_allocation ($$);
739
		register_expr_list_allocation ($$);
736
	}
740
	}
737
	| SEPARATOR arg_list {
741
	| SEPARATOR arg_list {
Lines 1192-1198 yylex (void) Link Here
1192
			while ((tmp = g_utf8_get_char (state->ptr)) != 0 &&
1196
			while ((tmp = g_utf8_get_char (state->ptr)) != 0 &&
1193
			       !g_unichar_isspace (tmp)) {
1197
			       !g_unichar_isspace (tmp)) {
1194
				state->ptr = g_utf8_next_char (state->ptr);
1198
				state->ptr = g_utf8_next_char (state->ptr);
1195
				if (tmp == '!' || tmp == '?') {
1199
				if (tmp == '!' || tmp == '?' ||
1200
				((state->ptr - start) == 4 && 0 == strncmp (start, "#N/A", 4))) {
1196
					GnmString *name = gnm_string_get_nocopy (g_strndup (start, state->ptr - start));
1201
					GnmString *name = gnm_string_get_nocopy (g_strndup (start, state->ptr - start));
1197
					yylval.expr = register_expr_allocation
1202
					yylval.expr = register_expr_allocation
1198
						(gnm_expr_new_constant (
1203
						(gnm_expr_new_constant (
(-)src/plugin.c (-1 / +1 lines)
Lines 1837-1843 plugins_shutdown (void) Link Here
1837
	g_hash_table_destroy (available_plugins_id_hash);
1837
	g_hash_table_destroy (available_plugins_id_hash);
1838
	gnm_slist_free_custom (available_plugins, gnm_plugin_try_unref);
1838
	gnm_slist_free_custom (available_plugins, gnm_plugin_try_unref);
1839
1839
1840
	go_conf_sync ();
1840
	go_conf_sync (NULL);
1841
}
1841
}
1842
1842
1843
void
1843
void
(-)src/print-info.c (-4 / +7 lines)
Lines 323-332 destroy_formats (void) Link Here
323
void
323
void
324
print_info_save (PrintInformation const *pi)
324
print_info_save (PrintInformation const *pi)
325
{
325
{
326
	GOConfNode *node = go_conf_get_node (gnm_conf_get_root (), PRINTSETUP_GCONF_DIR);
327
326
	gnm_gconf_set_print_scale_percentage (pi->scaling.type == PERCENTAGE);
328
	gnm_gconf_set_print_scale_percentage (pi->scaling.type == PERCENTAGE);
327
	gnm_gconf_set_print_scale_percentage_value (pi->scaling.percentage.x);
329
	gnm_gconf_set_print_scale_percentage_value (pi->scaling.percentage.x);
328
	go_conf_set_int (PRINTSETUP_GCONF_SCALE_WIDTH,  pi->scaling.dim.cols);
330
	go_conf_set_int (node, PRINTSETUP_GCONF_SCALE_WIDTH,  pi->scaling.dim.cols);
329
	go_conf_set_int (PRINTSETUP_GCONF_SCALE_HEIGHT, pi->scaling.dim.rows);
331
	go_conf_set_int (node, PRINTSETUP_GCONF_SCALE_HEIGHT, pi->scaling.dim.rows);
330
332
331
	gnm_gconf_set_print_tb_margins (&pi->margins);
333
	gnm_gconf_set_print_tb_margins (&pi->margins);
332
334
Lines 338-346 print_info_save (PrintInformation const Link Here
338
	gnm_gconf_set_print_titles (pi->print_titles);
340
	gnm_gconf_set_print_titles (pi->print_titles);
339
	gnm_gconf_set_print_order_right_then_down (pi->print_order);
341
	gnm_gconf_set_print_order_right_then_down (pi->print_order);
340
	
342
	
341
	go_conf_set_string (PRINTSETUP_GCONF_REPEAT_TOP,
343
	go_conf_set_string (node, PRINTSETUP_GCONF_REPEAT_TOP,
342
		pi->repeat_top.use ? range_name (&pi->repeat_top.range) : "");
344
		pi->repeat_top.use ? range_name (&pi->repeat_top.range) : "");
343
	go_conf_set_string (PRINTSETUP_GCONF_REPEAT_LEFT,
345
	go_conf_set_string (node, PRINTSETUP_GCONF_REPEAT_LEFT,
344
		pi->repeat_left.use ? range_name (&pi->repeat_left.range) : "");
346
		pi->repeat_left.use ? range_name (&pi->repeat_left.range) : "");
345
347
346
	save_formats ();
348
	save_formats ();
Lines 354-359 print_info_save (PrintInformation const Link Here
354
				      pi->footer->middle_format,
356
				      pi->footer->middle_format,
355
				      pi->footer->right_format);
357
				      pi->footer->right_format);
356
358
359
	go_conf_free_node (node);
357
}
360
}
358
361
359
const GnomePrintUnit *
362
const GnomePrintUnit *
(-)src/sheet-autofill.c (-25 / +30 lines)
Lines 114-120 typedef struct _FillItem { Link Here
114
		struct {
114
		struct {
115
			AutoFillList const *list;
115
			AutoFillList const *list;
116
			int           num;
116
			int           num;
117
			int           was_i18n;
118
		} list;
117
		} list;
119
		struct {
118
		struct {
120
			GnmString *str;
119
			GnmString *str;
Lines 153-159 autofill_register_list (char const *cons Link Here
153
}
152
}
154
153
155
static gboolean
154
static gboolean
156
in_list (AutoFillList const *afl, char const *s, int *n, int *is_i18n)
155
in_list (AutoFillList const *afl, char const *s, int *n)
157
{
156
{
158
	int i;
157
	int i;
159
158
Lines 162-168 in_list (AutoFillList const *afl, char c Link Here
162
		if (*translated_text == '*')
161
		if (*translated_text == '*')
163
			translated_text++;
162
			translated_text++;
164
		if (g_ascii_strcasecmp (translated_text, s) == 0) {
163
		if (g_ascii_strcasecmp (translated_text, s) == 0) {
165
			*is_i18n = TRUE;
166
			*n = i;
164
			*n = i;
167
			return TRUE;
165
			return TRUE;
168
		}
166
		}
Lines 172-183 in_list (AutoFillList const *afl, char c Link Here
172
}
170
}
173
171
174
static AutoFillList const *
172
static AutoFillList const *
175
matches_list (char const *s, int *n, int *is_i18n)
173
matches_list (char const *s, int *n)
176
{
174
{
177
	GList *l;
175
	GList *l;
178
	for (l = autofill_lists; l != NULL; l = l->next) {
176
	for (l = autofill_lists; l != NULL; l = l->next) {
179
		AutoFillList const *afl = l->data;
177
		AutoFillList const *afl = l->data;
180
		if (in_list (afl, s, n, is_i18n))
178
		if (in_list (afl, s, n))
181
			return afl;
179
			return afl;
182
	}
180
	}
183
	return NULL;
181
	return NULL;
Lines 316-329 fill_item_new (Sheet *sheet, int col, in Link Here
316
314
317
	if (value_type == VALUE_STRING) {
315
	if (value_type == VALUE_STRING) {
318
		AutoFillList const *list;
316
		AutoFillList const *list;
319
		int  num, pos, endpos, i18;
317
		int  num, pos, endpos;
320
318
321
		list = matches_list (value->v_str.val->str, &num, &i18);
319
		list = matches_list (value->v_str.val->str, &num);
322
		if (list) {
320
		if (list) {
323
			fi->type = FILL_STRING_LIST;
321
			fi->type = FILL_STRING_LIST;
324
			fi->v.list.list = list;
322
			fi->v.list.list = list;
325
			fi->v.list.num  = num;
323
			fi->v.list.num  = num;
326
			fi->v.list.was_i18n = i18;
327
			return fi;
324
			return fi;
328
		}
325
		}
329
326
Lines 472-494 type_is_compatible (FillItem *last, Fill Link Here
472
		return FALSE;
469
		return FALSE;
473
470
474
	if (last->type == FILL_STRING_LIST) {
471
	if (last->type == FILL_STRING_LIST) {
475
		/* It is possible the item is in multiple lists.  If things
472
		int num;
476
		 * disagree see if we are in the previous list, and convert
473
		char const *str;
477
		 * eg May
474
			
478
		 */
475
		if (last->v.list.list == current->v.list.list)
479
		if (last->v.list.list != current->v.list.list) {
476
			return TRUE;
480
			int num, is_i18n;
477
481
			if (in_list (last->v.list.list,
478
		/* This item may be in multiple lists.  Is it in the
482
				     current->v.list.list->items [current->v.list.num],
479
		 * same list as the previous element ? */
483
				     &num, &is_i18n)) {
480
		str = current->v.list.list->items [current->v.list.num];
481
		if (*str == '*')
482
			str++;
483
		if (in_list (last->v.list.list, str, &num)) {
484
				current->v.list.list = last->v.list.list;
484
				current->v.list.list = last->v.list.list;
485
				current->v.list.num = num;
485
				current->v.list.num = num;
486
				current->v.list.was_i18n = is_i18n;
486
			return TRUE;
487
			} else
487
		}
488
				return FALSE;
488
489
		/* The previous element may be in multple lists.  Is it
490
		 * in the current list ? */
491
		str = last->v.list.list->items [last->v.list.num];
492
		if (*str == '*')
493
			str++;
494
		if (in_list (current->v.list.list, str, &num)) {
495
			last->v.list.list = current->v.list.list;
496
			last->v.list.num = num;
497
			return TRUE;
489
		}
498
		}
490
499
491
		if (last->v.list.was_i18n != current->v.list.was_i18n)
492
			return FALSE;
500
			return FALSE;
493
	}
501
	}
494
502
Lines 709-718 autofill_cell (FillItem *fi, GnmCell *ce Link Here
709
		if (n < 0)
717
		if (n < 0)
710
			n += delta->v.list.list->count;
718
			n += delta->v.list.list->count;
711
719
712
		text = delta->v.list.list->items [n];
720
		text = _(delta->v.list.list->items [n]);
713
		if (delta->v.list.was_i18n)
714
			text = _(text);
715
716
		if (*text == '*')
721
		if (*text == '*')
717
			text++;
722
			text++;
718
723
(-)src/sheet-control-gui.c (-4 / +4 lines)
Lines 571-578 static void Link Here
571
cb_hscrollbar_adjust_bounds (GtkRange *range, gdouble new_value)
571
cb_hscrollbar_adjust_bounds (GtkRange *range, gdouble new_value)
572
{
572
{
573
	gdouble limit = range->adjustment->upper - range->adjustment->page_size;
573
	gdouble limit = range->adjustment->upper - range->adjustment->page_size;
574
	if (range->adjustment->upper < SHEET_MAX_COLS && new_value > limit) {
574
	if (range->adjustment->upper < SHEET_MAX_COLS && new_value >= limit) {
575
		range->adjustment->upper = new_value + range->adjustment->page_size;
575
		range->adjustment->upper = new_value + range->adjustment->page_size + 1;
576
		if (range->adjustment->upper > SHEET_MAX_COLS)
576
		if (range->adjustment->upper > SHEET_MAX_COLS)
577
			range->adjustment->upper = SHEET_MAX_COLS;
577
			range->adjustment->upper = SHEET_MAX_COLS;
578
		gtk_adjustment_changed (range->adjustment);
578
		gtk_adjustment_changed (range->adjustment);
Lines 582-589 static void Link Here
582
cb_vscrollbar_adjust_bounds (GtkRange *range, gdouble new_value)
582
cb_vscrollbar_adjust_bounds (GtkRange *range, gdouble new_value)
583
{
583
{
584
	gdouble limit = range->adjustment->upper - range->adjustment->page_size;
584
	gdouble limit = range->adjustment->upper - range->adjustment->page_size;
585
	if (range->adjustment->upper < SHEET_MAX_ROWS && new_value > limit) {
585
	if (range->adjustment->upper < SHEET_MAX_ROWS && new_value >= limit) {
586
		range->adjustment->upper = new_value + range->adjustment->page_size;
586
		range->adjustment->upper = new_value + range->adjustment->page_size + 1;
587
		if (range->adjustment->upper > SHEET_MAX_ROWS)
587
		if (range->adjustment->upper > SHEET_MAX_ROWS)
588
			range->adjustment->upper = SHEET_MAX_ROWS;
588
			range->adjustment->upper = SHEET_MAX_ROWS;
589
		gtk_adjustment_changed (range->adjustment);
589
		gtk_adjustment_changed (range->adjustment);
(-)src/sheet-filter.c (-2 / +8 lines)
Lines 46-51 Link Here
46
#include <gdk/gdkkeysyms.h>
46
#include <gdk/gdkkeysyms.h>
47
#include <gsf/gsf-impl-utils.h>
47
#include <gsf/gsf-impl-utils.h>
48
#include <glib/gi18n.h>
48
#include <glib/gi18n.h>
49
#include <string.h>
49
50
50
typedef struct {
51
typedef struct {
51
	SheetObject parent;
52
	SheetObject parent;
Lines 673-680 filter_expr_eval (GnmFilterOp op, GnmVal Link Here
673
		regmatch_t rm;
674
		regmatch_t rm;
674
675
675
		switch (go_regexec (regexp, str, 1, &rm, 0)) {
676
		switch (go_regexec (regexp, str, 1, &rm, 0)) {
676
		case REG_NOMATCH: return op == GNM_FILTER_OP_NOT_EQUAL;
677
		case REG_OK:
677
		case REG_OK: return op == GNM_FILTER_OP_EQUAL;
678
			if (rm.rm_so == 0 && strlen (str) == (size_t)rm.rm_eo)
679
				return op == GNM_FILTER_OP_EQUAL;
680
			/* fall through */
681
682
		case REG_NOMATCH:
683
			return op == GNM_FILTER_OP_NOT_EQUAL;
678
684
679
		default:
685
		default:
680
			g_warning ("Unexpected regexec result");
686
			g_warning ("Unexpected regexec result");
(-)src/sheet-view.c (-2 / +4 lines)
Lines 635-641 sv_is_region_empty_or_selected (SheetVie Link Here
635
 * @unfrozen : top left corner of the unfrozen region
635
 * @unfrozen : top left corner of the unfrozen region
636
 *
636
 *
637
 * By definition the unfrozen region must be below the frozen.
637
 * By definition the unfrozen region must be below the frozen.
638
 */
638
 * If @frozen == @unfrozen or @frozen == NULL unfreeze
639
 **/
639
void
640
void
640
sv_freeze_panes (SheetView *sv,
641
sv_freeze_panes (SheetView *sv,
641
		 GnmCellPos const *frozen,
642
		 GnmCellPos const *frozen,
Lines 650-656 sv_freeze_panes (SheetView *sv, Link Here
650
651
651
		/* Just in case */
652
		/* Just in case */
652
		if (unfrozen->col != (SHEET_MAX_COLS-1) &&
653
		if (unfrozen->col != (SHEET_MAX_COLS-1) &&
653
		    unfrozen->row != (SHEET_MAX_ROWS-1)) {
654
		    unfrozen->row != (SHEET_MAX_ROWS-1) &&
655
		    !cellpos_equal (frozen, unfrozen)) {
654
			sv->frozen_top_left = *frozen;
656
			sv->frozen_top_left = *frozen;
655
			sv->unfrozen_top_left = *unfrozen;
657
			sv->unfrozen_top_left = *unfrozen;
656
			if (sv->frozen_top_left.col == sv->unfrozen_top_left.col)
658
			if (sv->frozen_top_left.col == sv->unfrozen_top_left.col)
(-)src/sheet.c (+14 lines)
Lines 4060-4065 sheet_dup (Sheet const *src) Link Here
4060
					     TRUE, TRUE);
4060
					     TRUE, TRUE);
4061
	dst = sheet_new (wb, name);
4061
	dst = sheet_new (wb, name);
4062
	g_free (name);
4062
	g_free (name);
4063
4064
	dst->r1c1_addresses		= src->r1c1_addresses;
4065
	dst->display_formulas		= src->display_formulas;
4066
	dst->hide_zero			= src->hide_zero;
4067
	dst->hide_grid			= src->hide_grid;
4068
	dst->hide_col_header		= src->hide_col_header;
4069
	dst->hide_row_header		= src->hide_row_header;
4070
	dst->is_protected		= src->is_protected;
4071
	dst->is_visible			= src->is_visible;
4072
	dst->display_outlines		= src->display_outlines;
4073
	dst->outline_symbols_below	= src->outline_symbols_below;
4074
	dst->outline_symbols_right	= src->outline_symbols_right;
4075
	dst->has_filtered_rows		= src->has_filtered_rows;
4076
4063
	sheet_set_zoom_factor (dst, src->last_zoom_factor_used, FALSE, FALSE);
4077
	sheet_set_zoom_factor (dst, src->last_zoom_factor_used, FALSE, FALSE);
4064
4078
4065
        /* Copy the print info */
4079
        /* Copy the print info */
(-)src/solver.h (-6 / +8 lines)
Lines 258-265 GnmCell *solver_get_target_cell (Sheet Link Here
258
/* Returns a pointer to a input variable cell. */
258
/* Returns a pointer to a input variable cell. */
259
GnmCell		*solver_get_input_var (SolverResults *res, int n);
259
GnmCell		*solver_get_input_var (SolverResults *res, int n);
260
260
261
/* Retruns a pointer to a constraint. */
261
/* Returns a pointer to a constraint. */
262
SolverConstraint* solver_get_constraint (SolverResults *res, int n);
262
SolverConstraint* solver_get_constraint (SolverResults *res, int n);
263
void              solver_constraint_destroy (SolverConstraint *c);
263
264
264
void              solver_insert_cols    (Sheet *sheet, int col, int count);
265
void              solver_insert_cols    (Sheet *sheet, int col, int count);
265
void              solver_insert_rows    (Sheet *sheet, int row, int count);
266
void              solver_insert_rows    (Sheet *sheet, int row, int count);
Lines 270-280 void solver_delete_cols Link Here
270
271
271
#define solver_param_new() NULL
272
#define solver_param_new() NULL
272
#define solver_lp_copy(src_param, new_sheet) NULL
273
#define solver_lp_copy(src_param, new_sheet) NULL
273
#define solver_param_destroy(param)
274
#define solver_param_destroy(param)		do {} while(0)
274
#define solver_insert_cols(sheet, col, count)
275
#define solver_insert_cols(sheet, col, count)	do {} while(0)
275
#define solver_insert_rows(sheet, row, count)
276
#define solver_insert_rows(sheet, row, count)	do {} while(0)
276
#define solver_delete_cols(sheet, col, count)
277
#define solver_delete_cols(sheet, col, count)	do {} while(0)
277
#define solver_delete_rows(sheet, row, count)
278
#define solver_delete_rows(sheet, row, count)	do {} while(0)
279
#define solver_constraint_destroy(c)		do {} while(0)
278
280
279
#endif
281
#endif
280
282
(-)src/stf-parse.c (-14 / +4 lines)
Lines 55-62 gnm_setlocale(LC_ALL, parseoptions->loca Link Here
55
gnm_setlocale(LC_ALL, oldlocale);\
55
gnm_setlocale(LC_ALL, oldlocale);\
56
g_free (oldlocale);}
56
g_free (oldlocale);}
57
57
58
#define WARN_TOO_MANY_ROWS _("Too many rows in data to parse: %d")
59
60
/* Source_t struct, used for interchanging parsing information between the low level parse functions */
58
/* Source_t struct, used for interchanging parsing information between the low level parse functions */
61
typedef struct {
59
typedef struct {
62
	GStringChunk *chunk;
60
	GStringChunk *chunk;
Lines 774-781 stf_parse_general_free (GPtrArray *lines Link Here
774
GPtrArray *
772
GPtrArray *
775
stf_parse_general (StfParseOptions_t *parseoptions,
773
stf_parse_general (StfParseOptions_t *parseoptions,
776
		   GStringChunk *lines_chunk,
774
		   GStringChunk *lines_chunk,
777
		   char const *data, char const *data_end,
775
		   char const *data, char const *data_end)
778
		   int maxlines)
779
{
776
{
780
	GPtrArray *lines;
777
	GPtrArray *lines;
781
	Source_t src;
778
	Source_t src;
Lines 795-805 stf_parse_general (StfParseOptions_t *pa Link Here
795
	while (*src.position != '\0' && src.position < data_end) {
792
	while (*src.position != '\0' && src.position < data_end) {
796
		GPtrArray *line;
793
		GPtrArray *line;
797
794
798
		if (++row >= SHEET_MAX_ROWS) {
799
			g_warning (WARN_TOO_MANY_ROWS, row);
800
			break;
801
		}
802
803
		line = parseoptions->parsetype == PARSE_TYPE_CSV
795
		line = parseoptions->parsetype == PARSE_TYPE_CSV
804
			? stf_parse_csv_line (&src, parseoptions)
796
			? stf_parse_csv_line (&src, parseoptions)
805
			: stf_parse_fixed_line (&src, parseoptions);
797
			: stf_parse_fixed_line (&src, parseoptions);
Lines 807-813 stf_parse_general (StfParseOptions_t *pa Link Here
807
		g_ptr_array_add (lines, line);
799
		g_ptr_array_add (lines, line);
808
		src.position += compare_terminator (src.position, parseoptions);
800
		src.position += compare_terminator (src.position, parseoptions);
809
801
810
		if (row >= maxlines)
802
		if (++row == SHEET_MAX_ROWS)
811
			break;
803
			break;
812
	}
804
	}
813
805
Lines 1160-1167 stf_parse_sheet (StfParseOptions_t *pars Link Here
1160
	if (!data_end)
1152
	if (!data_end)
1161
		data_end = data + strlen (data);
1153
		data_end = data + strlen (data);
1162
	lines_chunk = g_string_chunk_new (100 * 1024);
1154
	lines_chunk = g_string_chunk_new (100 * 1024);
1163
	lines = stf_parse_general (parseoptions, lines_chunk, data, data_end,
1155
	lines = stf_parse_general (parseoptions, lines_chunk, data, data_end);
1164
				   SHEET_MAX_ROWS);
1165
	for (row = start_row, lrow = 0; lrow < lines->len ; row++, lrow++) {
1156
	for (row = start_row, lrow = 0; lrow < lines->len ; row++, lrow++) {
1166
		col = start_col;
1157
		col = start_col;
1167
		line = g_ptr_array_index (lines, lrow);
1158
		line = g_ptr_array_index (lines, lrow);
Lines 1212-1219 stf_parse_region (StfParseOptions_t *par Link Here
1212
	if (!data_end)
1203
	if (!data_end)
1213
		data_end = data + strlen (data);
1204
		data_end = data + strlen (data);
1214
	lines_chunk = g_string_chunk_new (100 * 1024);
1205
	lines_chunk = g_string_chunk_new (100 * 1024);
1215
	lines = stf_parse_general (parseoptions, lines_chunk, data, data_end,
1206
	lines = stf_parse_general (parseoptions, lines_chunk, data, data_end);
1216
				   SHEET_MAX_ROWS);
1217
	for (row = 0; row < lines->len; row++) {
1207
	for (row = 0; row < lines->len; row++) {
1218
		GPtrArray *line = g_ptr_array_index (lines, row);
1208
		GPtrArray *line = g_ptr_array_index (lines, row);
1219
		unsigned int col, targetcol = 0;
1209
		unsigned int col, targetcol = 0;
(-)src/stf-parse.h (-2 / +1 lines)
Lines 102-109 int stf_parse_options_fixed_splitpositio Link Here
102
GPtrArray          *stf_parse_general                                 (StfParseOptions_t *parseoptions,
102
GPtrArray          *stf_parse_general                                 (StfParseOptions_t *parseoptions,
103
								       GStringChunk *lines_chunk,
103
								       GStringChunk *lines_chunk,
104
								       char const *data,
104
								       char const *data,
105
								       char const *data_end,
105
								       char const *data_end);
106
								       int maxlines);
107
void                stf_parse_general_free                            (GPtrArray *lines);
106
void                stf_parse_general_free                            (GPtrArray *lines);
108
GPtrArray          *stf_parse_lines                                   (StfParseOptions_t *parseoptions,
107
GPtrArray          *stf_parse_lines                                   (StfParseOptions_t *parseoptions,
109
								       GStringChunk *lines_chunk,
108
								       GStringChunk *lines_chunk,
(-)src/stf.c (-8 / +42 lines)
Lines 452-474 stf_write_csv (GnmFileSaver const *fs, I Link Here
452
static gboolean
452
static gboolean
453
csv_tsv_probe (GnmFileOpener const *fo, GsfInput *input, FileProbeLevel pl)
453
csv_tsv_probe (GnmFileOpener const *fo, GsfInput *input, FileProbeLevel pl)
454
{
454
{
455
	/* Rough and ready heuristic.  If the first N bytes have no
456
	 * unprintable characters this may be text */
457
	gsf_off_t const N = 512;
458
455
	if (pl == FILE_PROBE_CONTENT) {
459
	if (pl == FILE_PROBE_CONTENT) {
456
		/* Rough and ready heuristic.  If the first 80 bytes have no
457
		 * nuls this may be text */
458
		guint8 const *header;
460
		guint8 const *header;
459
		int i;
461
		gsf_off_t i;
462
		const char *enc = NULL;
463
		char *header_utf8;
464
		const char *p;
465
		int try;
466
		gboolean ok = TRUE;
460
467
461
		if (gsf_input_seek (input, 0, G_SEEK_SET))
468
		if (gsf_input_seek (input, 0, G_SEEK_SET))
462
			return FALSE;
469
			return FALSE;
463
		i = gsf_input_remaining (input);
470
		i = gsf_input_remaining (input);
464
		if (i > 80)
471
465
			i = 80;
472
		/* If someone ships us an empty file, accept it only if
473
		   it has a proper name.  */
474
		if (i == 0)
475
			return csv_tsv_probe (fo, input, FILE_PROBE_FILE_NAME);
476
477
		if (i > N) i = N;
466
		if (NULL == (header = gsf_input_read (input, i, NULL)))
478
		if (NULL == (header = gsf_input_read (input, i, NULL)))
467
			return FALSE;
479
			return FALSE;
468
		while (i-- > 0)
480
469
			if (*header++ == 0)
481
		/*
482
		 * It is conceivable that encoding guessing could fail
483
		 * if our truncated buffer had partial characters.  We
484
		 * really need go_guess_encoding_truncated, but for now
485
		 * let's just try cutting a byte away at a time.
486
		 */
487
		for (try = 0; !enc && try < MIN (i, 6); try++)
488
			enc = gnm_guess_encoding (header, i - try, NULL, &header_utf8);
489
490
		if (!enc)
470
				return FALSE;
491
				return FALSE;
471
		return TRUE;
492
493
		for (p = header_utf8; *p; p = g_utf8_next_char (p)) {
494
			gunichar uc = g_utf8_get_char (p);
495
			/* isprint might not be true for these: */
496
			if (uc == '\n' || uc == '\t' || uc == '\r')
497
				continue;
498
			if (!g_unichar_isprint (uc)) {
499
				ok = FALSE;
500
  				break;
501
  			}
502
  		}
503
  
504
  		g_free (header_utf8);
505
		return ok;
472
	} else {
506
	} else {
473
		char const *name = gsf_input_name (input);
507
		char const *name = gsf_input_name (input);
474
		if (name == NULL)
508
		if (name == NULL)
(-)src/style-border.h (-2 / +3 lines)
Lines 34-41 typedef enum { Link Here
34
} StyleBorderType;
34
} StyleBorderType;
35
35
36
/* The order corresponds to the border_buttons name list
36
/* The order corresponds to the border_buttons name list
37
 * in dialog_cell_format_impl */
37
 * in dialog_cell_format_impl
38
typedef enum _StyleBorderLocation {
38
 * STYLE_BORDER_TOP must be 0 */
39
typedef enum {
39
	STYLE_BORDER_TOP,	STYLE_BORDER_BOTTOM,
40
	STYLE_BORDER_TOP,	STYLE_BORDER_BOTTOM,
40
	STYLE_BORDER_LEFT,	STYLE_BORDER_RIGHT,
41
	STYLE_BORDER_LEFT,	STYLE_BORDER_RIGHT,
41
	STYLE_BORDER_REV_DIAG,	STYLE_BORDER_DIAG,
42
	STYLE_BORDER_REV_DIAG,	STYLE_BORDER_DIAG,
(-)src/wbc-gtk.c (-2 / +6 lines)
Lines 630-635 wbc_gtk_init_font_name (WBCgtk *gtk) Link Here
630
630
631
	gtk->font_name = g_object_new (go_action_combo_text_get_type (),
631
	gtk->font_name = g_object_new (go_action_combo_text_get_type (),
632
		"name",     "FontName",
632
		"name",     "FontName",
633
		"case-sensitive", FALSE,
633
		NULL);
634
		NULL);
634
	for (ptr = gnumeric_font_family_list; ptr != NULL; ptr = ptr->next)
635
	for (ptr = gnumeric_font_family_list; ptr != NULL; ptr = ptr->next)
635
		if (ptr->data) 
636
		if (ptr->data) 
Lines 1016-1031 regenerate_window_menu (WBCgtk *gtk, Wor Link Here
1016
1017
1017
	k = 1;
1018
	k = 1;
1018
	WORKBOOK_FOREACH_CONTROL (wb, wbv, wbc, {
1019
	WORKBOOK_FOREACH_CONTROL (wb, wbv, wbc, {
1020
		char *basename;
1019
		if (i >= 10)
1021
		if (i >= 10)
1020
			return i;
1022
			return i;
1021
		if (IS_WORKBOOK_CONTROL_GUI (wbc)) {
1023
		if (IS_WORKBOOK_CONTROL_GUI (wbc) &&
1024
			(basename = go_basename_from_uri (wb->uri)) != NULL) {
1022
			GString *label = g_string_new (NULL);
1025
			GString *label = g_string_new (NULL);
1023
			char *name;
1026
			char *name;
1024
			const char *s;
1027
			const char *s;
1025
			GtkActionEntry entry;
1028
			GtkActionEntry entry;
1026
1029
1027
			g_string_append_printf (label, "_%d ", i);
1030
			g_string_append_printf (label, "_%d ", i);
1028
			s = wb->basename;
1031
			s = basename;
1029
			while (*s) {
1032
			while (*s) {
1030
				if (*s == '_')
1033
				if (*s == '_')
1031
					g_string_append_c (label, '_');
1034
					g_string_append_c (label, '_');
Lines 1050-1055 regenerate_window_menu (WBCgtk *gtk, Wor Link Here
1050
1053
1051
			g_string_free (label, TRUE);
1054
			g_string_free (label, TRUE);
1052
			g_free (name);
1055
			g_free (name);
1056
			g_free (basename);
1053
			i++;
1057
			i++;
1054
		}});
1058
		}});
1055
	return i;
1059
	return i;
(-)src/wbcg-actions.c (-5 / +13 lines)
Lines 490-496 static GNM_ACTION_DEF (cb_repeat) { comm Link Here
490
490
491
/****************************************************************************/
491
/****************************************************************************/
492
492
493
static GNM_ACTION_DEF (cb_view_zoom_out)
493
static GNM_ACTION_DEF (cb_view_zoom_in)
494
{
494
{
495
	Sheet *sheet = wb_control_cur_sheet (WORKBOOK_CONTROL (wbcg));
495
	Sheet *sheet = wb_control_cur_sheet (WORKBOOK_CONTROL (wbcg));
496
	int zoom = (int)(sheet->last_zoom_factor_used * 100. + .5) - 10;
496
	int zoom = (int)(sheet->last_zoom_factor_used * 100. + .5) - 10;
Lines 501-507 static GNM_ACTION_DEF (cb_view_zoom_out) Link Here
501
		cmd_zoom (WORKBOOK_CONTROL (wbcg), g_slist_append (NULL, sheet),
501
		cmd_zoom (WORKBOOK_CONTROL (wbcg), g_slist_append (NULL, sheet),
502
			  (double) (zoom + 10) / 100);
502
			  (double) (zoom + 10) / 100);
503
}
503
}
504
static GNM_ACTION_DEF (cb_view_zoom_in)
504
static GNM_ACTION_DEF (cb_view_zoom_out)
505
{
505
{
506
	Sheet *sheet = wb_control_cur_sheet (WORKBOOK_CONTROL (wbcg));
506
	Sheet *sheet = wb_control_cur_sheet (WORKBOOK_CONTROL (wbcg));
507
	int zoom = (int)(sheet->last_zoom_factor_used * 100. + .5) - 10;
507
	int zoom = (int)(sheet->last_zoom_factor_used * 100. + .5) - 10;
Lines 855-861 static GNM_ACTION_DEF (cb_help_docs) Link Here
855
855
856
static GNM_ACTION_DEF (cb_help_web)
856
static GNM_ACTION_DEF (cb_help_web)
857
{
857
{
858
	GError *err = go_url_show ("http://www.gnumeric.org/");
858
	GError *err = go_url_show ("http://www.gnome.org/projects/gnumeric/");
859
	if (err != NULL) {
859
	if (err != NULL) {
860
		gnm_cmd_context_error (GNM_CMD_CONTEXT (wbcg), err);
860
		gnm_cmd_context_error (GNM_CMD_CONTEXT (wbcg), err);
861
		g_error_free (err);
861
		g_error_free (err);
Lines 1214-1219 apply_number_format (WorkbookControlGUI Link Here
1214
	cmd_selection_format (WORKBOOK_CONTROL (wbcg), mstyle, NULL, descriptor);
1214
	cmd_selection_format (WORKBOOK_CONTROL (wbcg), mstyle, NULL, descriptor);
1215
}
1215
}
1216
1216
1217
static GNM_ACTION_DEF (cb_format_as_general)
1218
{
1219
	apply_number_format (wbcg,
1220
		cell_formats [FMT_GENERAL][0], _("Format as General"));
1221
}
1217
static GNM_ACTION_DEF (cb_format_as_number)
1222
static GNM_ACTION_DEF (cb_format_as_number)
1218
{
1223
{
1219
	apply_number_format (wbcg,
1224
	apply_number_format (wbcg,
Lines 1945-1958 static /* const 142334 */ GtkActionEntry Link Here
1945
		NULL, N_("Split merged ranges of cells"),
1950
		NULL, N_("Split merged ranges of cells"),
1946
		G_CALLBACK (cb_unmerge_cells) },
1951
		G_CALLBACK (cb_unmerge_cells) },
1947
1952
1953
	{ "FormatAsGeneral", NULL, N_("General"),
1954
		"<control>asciitilde", N_("Format the selection as General"),
1955
		G_CALLBACK (cb_format_as_general) },
1948
	{ "FormatAsNumber", NULL, N_("Number"),
1956
	{ "FormatAsNumber", NULL, N_("Number"),
1949
		"<control>asciitilde", N_("Format the selection as numbers"),
1957
		"<control>exclam", N_("Format the selection as numbers"),
1950
		G_CALLBACK (cb_format_as_number) },
1958
		G_CALLBACK (cb_format_as_number) },
1951
	{ "FormatAsCurrency", NULL, N_("Currency"),
1959
	{ "FormatAsCurrency", NULL, N_("Currency"),
1952
		"<control>dollar", N_("Format the selection as currency"),
1960
		"<control>dollar", N_("Format the selection as currency"),
1953
		G_CALLBACK (cb_format_as_currency) },
1961
		G_CALLBACK (cb_format_as_currency) },
1954
	{ "FormatAsAccounting", "Gnumeric_FormatAsAccounting", N_("Accounting"),
1962
	{ "FormatAsAccounting", "Gnumeric_FormatAsAccounting", N_("Accounting"),
1955
		"<control>exclam", N_("Format the selection as accounting"),
1963
		NULL, N_("Format the selection as accounting"),
1956
		G_CALLBACK (cb_format_as_accounting) },
1964
		G_CALLBACK (cb_format_as_accounting) },
1957
	{ "FormatAsPercentage", "Gnumeric_FormatAsPercentage", N_("Percentage"),
1965
	{ "FormatAsPercentage", "Gnumeric_FormatAsPercentage", N_("Percentage"),
1958
		"<control>percent", N_("Format the selection as percentage"),
1966
		"<control>percent", N_("Format the selection as percentage"),
(-)src/workbook-control.c (-7 / +9 lines)
Lines 35-41 Link Here
35
#include "ranges.h"
35
#include "ranges.h"
36
#include "expr-name.h"
36
#include "expr-name.h"
37
#include "command-context.h"
37
#include "command-context.h"
38
38
#include <goffice/utils/go-file.h>
39
#include <gsf/gsf-impl-utils.h>
39
#include <gsf/gsf-impl-utils.h>
40
40
41
#define WBC_CLASS(o) WORKBOOK_CONTROL_CLASS (G_OBJECT_GET_CLASS (o))
41
#define WBC_CLASS(o) WORKBOOK_CONTROL_CLASS (G_OBJECT_GET_CLASS (o))
Lines 80-91 wb_control_update_title (WorkbookControl Link Here
80
80
81
	if (wbc_class != NULL && wbc_class->set_title != NULL) {
81
	if (wbc_class != NULL && wbc_class->set_title != NULL) {
82
		Workbook const *wb = wb_control_workbook (wbc);
82
		Workbook const *wb = wb_control_workbook (wbc);
83
		if (workbook_is_dirty (wb)) {
83
		char *basename = go_basename_from_uri (wb->uri);
84
			char *tmp = g_strconcat ("*", wb->basename, NULL);
84
		char *title = g_strconcat
85
			wbc_class->set_title (wbc, tmp);
85
			(workbook_is_dirty (wb) ? "*" : "",
86
			g_free (tmp);
86
			 basename ? basename : wb->uri,
87
		} else
87
			 NULL);
88
			wbc_class->set_title (wbc, wb->basename);
88
		wbc_class->set_title (wbc, title);
89
		g_free (title);
90
		g_free (basename);
89
	}
91
	}
90
}
92
}
91
93
(-)src/workbook-view.c (-1 / +1 lines)
Lines 748-754 cb_cleanup_sendto (gpointer path) Link Here
748
gboolean
748
gboolean
749
wb_view_sendto (WorkbookView *wbv, GnmCmdContext *context)
749
wb_view_sendto (WorkbookView *wbv, GnmCmdContext *context)
750
{
750
{
751
	gboolean problem;
751
	gboolean problem = FALSE;
752
	IOContext	*io_context;
752
	IOContext	*io_context;
753
	Workbook	*wb;
753
	Workbook	*wb;
754
	GnmFileSaver	*fs;
754
	GnmFileSaver	*fs;
(-)src/cut-n-paste-code/foocanvas/libfoocanvas/Makefile.am (-22 / +17 lines)
Lines 1-4 Link Here
1
INCLUDES = \
1
AM_CPPFLAGS = \
2
	-I$(top_srcdir) 				\
2
	-I$(top_srcdir) 				\
3
	-I$(top_builddir)				\
3
	-I$(top_builddir)				\
4
	$(WARN_CFLAGS) 					\
4
	$(WARN_CFLAGS) 					\
Lines 23-34 libfoocanvas_a_LIBADD = \ Link Here
23
libfoocanvasincludedir = $(includedir)/libfoocanvas-1.0/libfoocanvas
23
libfoocanvasincludedir = $(includedir)/libfoocanvas-1.0/libfoocanvas
24
24
25
25
26
BUILT_SOURCES =					\
27
	foo-canvas-marshal.c			\
28
	foo-canvas-marshal.h
29
30
libfoocanvas_a_SOURCES =			\
26
libfoocanvas_a_SOURCES =			\
31
	$(BUILT_SOURCES)			\
27
	foo-canvas-marshal.list			\
32
	foo-canvas-i18n.h			\
28
	foo-canvas-i18n.h			\
33
	foo-canvas-line.c			\
29
	foo-canvas-line.c			\
34
	foo-canvas-pixbuf.c			\
30
	foo-canvas-pixbuf.c			\
Lines 40-67 libfoocanvas_a_SOURCES = \ Link Here
40
	foo-canvas.c				\
36
	foo-canvas.c				\
41
	libfoocanvastypes.c
37
	libfoocanvastypes.c
42
38
43
foo-canvas-marshal.h: foo-canvas-marshal.list $(GLIB_GENMARSHAL)
39
GENMARSHAL_COMMAND = $(GLIB_GENMARSHAL) --prefix=foo_canvas_marshal
44
	$(GLIB_GENMARSHAL) $< --header --prefix=foo_canvas_marshal > $@
40
SUFFIXES = .list
45
foo-canvas-marshal.c: foo-canvas-marshal.list $(GLIB_GENMARSHAL) foo-canvas-marshal.h
46
	$(GLIB_GENMARSHAL) $< --body --prefix=foo_canvas_marshal > $@.tmp
47
	echo '/* This file has been automatically generated.  Do not edit.  */' >$@
48
	echo '#include "'$*.h'"' >>$@
49
	cat $@.tmp >>$@
50
	rm -f $@.tmp
51
41
52
EXTRA_DIST = \
42
.list.h:
53
	foo-canvas-marshal.list	\
43
	$(GENMARSHAL_COMMAND) --header $< >$@
54
	libfoocanvas.pc.in
44
45
.list.c:
46
	(echo '/* This file has been automatically generated.  Do not edit. */' && \
47
	echo '#include "$*.h"' && \
48
	$(GENMARSHAL_COMMAND) --body $< ) >$@
49
50
# A hint is needed to build the header first:
51
BUILT_SOURCES = foo-canvas-marshal.h
55
52
53
# Another hint, see bugs #172211 and #172212:
54
non-intermediate: foo-canvas-marshal.c
56
55
57
CLEANFILES = foo-canvas-marshal.h foo-canvas-marshal.c
56
CLEANFILES = foo-canvas-marshal.h foo-canvas-marshal.c
58
57
59
DONT_DIST_SOURCE = $(BUILT_SOURCES)
58
EXTRA_DIST = libfoocanvas.pc.in
60
59
61
dist-hook:
62
	for file in $(DONT_DIST_SOURCE) ; do \
63
	    rm -f $(distdir)/$$file ; \
64
	done
65
60
66
noinst_HEADERS = \
61
noinst_HEADERS = \
67
	foo-canvas-marshal.h \
62
	foo-canvas-marshal.h \
(-)src/cut-n-paste-code/foocanvas/libfoocanvas/foo-canvas-line.c (-32 / +32 lines)
Lines 160-265 foo_canvas_line_class_init (FooCanvasLin Link Here
160
                 PROP_POINTS,
160
                 PROP_POINTS,
161
                 g_param_spec_boxed ("points", NULL, NULL,
161
                 g_param_spec_boxed ("points", NULL, NULL,
162
				     FOO_TYPE_CANVAS_POINTS,
162
				     FOO_TYPE_CANVAS_POINTS,
163
				     (G_PARAM_READABLE | G_PARAM_WRITABLE)));
163
				     G_PARAM_READWRITE));
164
        g_object_class_install_property
164
        g_object_class_install_property
165
                (gobject_class,
165
                (gobject_class,
166
                 PROP_FILL_COLOR,
166
                 PROP_FILL_COLOR,
167
                 g_param_spec_string ("fill_color", NULL, NULL,
167
                 g_param_spec_string ("fill-color", NULL, NULL,
168
                                      NULL,
168
                                      NULL,
169
                                      (G_PARAM_READABLE | G_PARAM_WRITABLE)));
169
                                      G_PARAM_READWRITE));
170
        g_object_class_install_property
170
        g_object_class_install_property
171
                (gobject_class,
171
                (gobject_class,
172
                 PROP_FILL_COLOR_GDK,
172
                 PROP_FILL_COLOR_GDK,
173
                 g_param_spec_boxed ("fill_color_gdk", NULL, NULL,
173
                 g_param_spec_boxed ("fill-color-gdk", NULL, NULL,
174
				     GDK_TYPE_COLOR,
174
				     GDK_TYPE_COLOR,
175
				     (G_PARAM_READABLE | G_PARAM_WRITABLE)));
175
				     G_PARAM_READWRITE));
176
        g_object_class_install_property
176
        g_object_class_install_property
177
                (gobject_class,
177
                (gobject_class,
178
                 PROP_FILL_COLOR_RGBA,
178
                 PROP_FILL_COLOR_RGBA,
179
                 g_param_spec_uint ("fill_color_rgba", NULL, NULL,
179
                 g_param_spec_uint ("fill-color-rgba", NULL, NULL,
180
				    0, G_MAXUINT, 0,
180
				    0, G_MAXUINT, 0,
181
				    (G_PARAM_READABLE | G_PARAM_WRITABLE)));
181
				    G_PARAM_READWRITE));
182
        g_object_class_install_property
182
        g_object_class_install_property
183
                (gobject_class,
183
                (gobject_class,
184
                 PROP_FILL_STIPPLE,
184
                 PROP_FILL_STIPPLE,
185
                 g_param_spec_object ("fill_stipple", NULL, NULL,
185
                 g_param_spec_object ("fill-stipple", NULL, NULL,
186
                                      GDK_TYPE_DRAWABLE,
186
                                      GDK_TYPE_DRAWABLE,
187
                                      (G_PARAM_READABLE | G_PARAM_WRITABLE)));
187
                                      G_PARAM_READWRITE));
188
        g_object_class_install_property
188
        g_object_class_install_property
189
                (gobject_class,
189
                (gobject_class,
190
                 PROP_WIDTH_PIXELS,
190
                 PROP_WIDTH_PIXELS,
191
                 g_param_spec_uint ("width_pixels", NULL, NULL,
191
                 g_param_spec_uint ("width-pixels", NULL, NULL,
192
				    0, G_MAXUINT, 0,
192
				    0, G_MAXUINT, 0,
193
				    (G_PARAM_READABLE | G_PARAM_WRITABLE)));
193
				    G_PARAM_READWRITE));
194
        g_object_class_install_property
194
        g_object_class_install_property
195
                (gobject_class,
195
                (gobject_class,
196
                 PROP_WIDTH_UNITS,
196
                 PROP_WIDTH_UNITS,
197
                 g_param_spec_double ("width_units", NULL, NULL,
197
                 g_param_spec_double ("width-units", NULL, NULL,
198
				      0.0, G_MAXDOUBLE, 0.0,
198
				      0.0, G_MAXDOUBLE, 0.0,
199
				      (G_PARAM_READABLE | G_PARAM_WRITABLE)));
199
				      G_PARAM_READWRITE));
200
        g_object_class_install_property
200
        g_object_class_install_property
201
                (gobject_class,
201
                (gobject_class,
202
                 PROP_CAP_STYLE,
202
                 PROP_CAP_STYLE,
203
                 g_param_spec_enum ("cap_style", NULL, NULL,
203
                 g_param_spec_enum ("cap-style", NULL, NULL,
204
                                    GDK_TYPE_CAP_STYLE,
204
                                    GDK_TYPE_CAP_STYLE,
205
                                    GDK_CAP_BUTT,
205
                                    GDK_CAP_BUTT,
206
                                    (G_PARAM_READABLE | G_PARAM_WRITABLE)));
206
                                    G_PARAM_READWRITE));
207
        g_object_class_install_property
207
        g_object_class_install_property
208
                (gobject_class,
208
                (gobject_class,
209
                 PROP_JOIN_STYLE,
209
                 PROP_JOIN_STYLE,
210
                 g_param_spec_enum ("join_style", NULL, NULL,
210
                 g_param_spec_enum ("join-style", NULL, NULL,
211
                                    GDK_TYPE_JOIN_STYLE,
211
                                    GDK_TYPE_JOIN_STYLE,
212
                                    GDK_JOIN_MITER,
212
                                    GDK_JOIN_MITER,
213
                                    (G_PARAM_READABLE | G_PARAM_WRITABLE)));
213
                                    G_PARAM_READWRITE));
214
        g_object_class_install_property
214
        g_object_class_install_property
215
                (gobject_class,
215
                (gobject_class,
216
                 PROP_LINE_STYLE,
216
                 PROP_LINE_STYLE,
217
                 g_param_spec_enum ("line_style", NULL, NULL,
217
                 g_param_spec_enum ("line-style", NULL, NULL,
218
                                    GDK_TYPE_LINE_STYLE,
218
                                    GDK_TYPE_LINE_STYLE,
219
                                    GDK_LINE_SOLID,
219
                                    GDK_LINE_SOLID,
220
                                    (G_PARAM_READABLE | G_PARAM_WRITABLE)));
220
                                    G_PARAM_READWRITE));
221
        g_object_class_install_property
221
        g_object_class_install_property
222
                (gobject_class,
222
                (gobject_class,
223
                 PROP_FIRST_ARROWHEAD,
223
                 PROP_FIRST_ARROWHEAD,
224
                 g_param_spec_boolean ("first_arrowhead", NULL, NULL,
224
                 g_param_spec_boolean ("first-arrowhead", NULL, NULL,
225
				       FALSE,
225
				       FALSE,
226
				       (G_PARAM_READABLE | G_PARAM_WRITABLE)));
226
				       G_PARAM_READWRITE));
227
        g_object_class_install_property
227
        g_object_class_install_property
228
                (gobject_class,
228
                (gobject_class,
229
                 PROP_LAST_ARROWHEAD,
229
                 PROP_LAST_ARROWHEAD,
230
                 g_param_spec_boolean ("last_arrowhead", NULL, NULL,
230
                 g_param_spec_boolean ("last-arrowhead", NULL, NULL,
231
				       FALSE,
231
				       FALSE,
232
				       (G_PARAM_READABLE | G_PARAM_WRITABLE)));
232
				       G_PARAM_READWRITE));
233
        g_object_class_install_property
233
        g_object_class_install_property
234
                (gobject_class,
234
                (gobject_class,
235
                 PROP_SMOOTH,
235
                 PROP_SMOOTH,
236
                 g_param_spec_boolean ("smooth", NULL, NULL,
236
                 g_param_spec_boolean ("smooth", NULL, NULL,
237
				       FALSE,
237
				       FALSE,
238
				       (G_PARAM_READABLE | G_PARAM_WRITABLE)));
238
				       G_PARAM_READWRITE));
239
        g_object_class_install_property
239
        g_object_class_install_property
240
                (gobject_class,
240
                (gobject_class,
241
                 PROP_SPLINE_STEPS,
241
                 PROP_SPLINE_STEPS,
242
                 g_param_spec_uint ("spline_steps", NULL, NULL,
242
                 g_param_spec_uint ("spline-steps", NULL, NULL,
243
				    0, G_MAXUINT, DEFAULT_SPLINE_STEPS,
243
				    0, G_MAXUINT, DEFAULT_SPLINE_STEPS,
244
				    (G_PARAM_READABLE | G_PARAM_WRITABLE)));
244
				    G_PARAM_READWRITE));
245
        g_object_class_install_property
245
        g_object_class_install_property
246
                (gobject_class,
246
                (gobject_class,
247
                 PROP_ARROW_SHAPE_A,
247
                 PROP_ARROW_SHAPE_A,
248
                 g_param_spec_double ("arrow_shape_a", NULL, NULL,
248
                 g_param_spec_double ("arrow-shape-a", NULL, NULL,
249
				      -G_MAXDOUBLE, G_MAXDOUBLE, 0,
249
				      -G_MAXDOUBLE, G_MAXDOUBLE, 0,
250
				      (G_PARAM_READABLE | G_PARAM_WRITABLE)));
250
				      G_PARAM_READWRITE));
251
        g_object_class_install_property
251
        g_object_class_install_property
252
                (gobject_class,
252
                (gobject_class,
253
                 PROP_ARROW_SHAPE_B,
253
                 PROP_ARROW_SHAPE_B,
254
                 g_param_spec_double ("arrow_shape_b", NULL, NULL,
254
                 g_param_spec_double ("arrow-shape-b", NULL, NULL,
255
				      -G_MAXDOUBLE, G_MAXDOUBLE, 0,
255
				      -G_MAXDOUBLE, G_MAXDOUBLE, 0,
256
				      (G_PARAM_READABLE | G_PARAM_WRITABLE)));
256
				      G_PARAM_READWRITE));
257
        g_object_class_install_property
257
        g_object_class_install_property
258
                (gobject_class,
258
                (gobject_class,
259
                 PROP_ARROW_SHAPE_C,
259
                 PROP_ARROW_SHAPE_C,
260
                 g_param_spec_double ("arrow_shape_c", NULL, NULL,
260
                 g_param_spec_double ("arrow-shape-c", NULL, NULL,
261
				      -G_MAXDOUBLE, G_MAXDOUBLE, 0,
261
				      -G_MAXDOUBLE, G_MAXDOUBLE, 0,
262
				      (G_PARAM_READABLE | G_PARAM_WRITABLE)));
262
				      G_PARAM_READWRITE));
263
263
264
	object_class->destroy = foo_canvas_line_destroy;
264
	object_class->destroy = foo_canvas_line_destroy;
265
265
(-)src/cut-n-paste-code/foocanvas/libfoocanvas/foo-canvas-pixbuf.c (-22 / +22 lines)
Lines 177-263 foo_canvas_pixbuf_class_init (FooCanvasP Link Here
177
                 PROP_PIXBUF,
177
                 PROP_PIXBUF,
178
                 g_param_spec_object ("pixbuf", NULL, NULL,
178
                 g_param_spec_object ("pixbuf", NULL, NULL,
179
                                      GDK_TYPE_PIXBUF,
179
                                      GDK_TYPE_PIXBUF,
180
                                      (G_PARAM_READABLE | G_PARAM_WRITABLE)));
180
                                      G_PARAM_READWRITE));
181
        g_object_class_install_property
181
        g_object_class_install_property
182
                (gobject_class,
182
                (gobject_class,
183
                 PROP_WIDTH,
183
                 PROP_WIDTH,
184
                 g_param_spec_double ("width", NULL, NULL,
184
                 g_param_spec_double ("width", NULL, NULL,
185
				      -G_MAXDOUBLE, G_MAXDOUBLE, 0,
185
				      -G_MAXDOUBLE, G_MAXDOUBLE, 0,
186
				      (G_PARAM_READABLE | G_PARAM_WRITABLE)));
186
				      G_PARAM_READWRITE));
187
        g_object_class_install_property
187
        g_object_class_install_property
188
                (gobject_class,
188
                (gobject_class,
189
                 PROP_WIDTH_SET,
189
                 PROP_WIDTH_SET,
190
                 g_param_spec_boolean ("width_set", NULL, NULL,
190
                 g_param_spec_boolean ("width-set", NULL, NULL,
191
				       FALSE,
191
				       FALSE,
192
				       (G_PARAM_READABLE | G_PARAM_WRITABLE)));
192
				       G_PARAM_READWRITE));
193
        g_object_class_install_property
193
        g_object_class_install_property
194
                (gobject_class,
194
                (gobject_class,
195
                 PROP_WIDTH_IN_PIXELS,
195
                 PROP_WIDTH_IN_PIXELS,
196
                 g_param_spec_boolean ("width_in_pixels", NULL, NULL,
196
                 g_param_spec_boolean ("width-in-pixels", NULL, NULL,
197
				       FALSE,
197
				       FALSE,
198
				       (G_PARAM_READABLE | G_PARAM_WRITABLE)));
198
				       G_PARAM_READWRITE));
199
        g_object_class_install_property
199
        g_object_class_install_property
200
                (gobject_class,
200
                (gobject_class,
201
                 PROP_HEIGHT,
201
                 PROP_HEIGHT,
202
                 g_param_spec_double ("height", NULL, NULL,
202
                 g_param_spec_double ("height", NULL, NULL,
203
				      -G_MAXDOUBLE, G_MAXDOUBLE, 0,
203
				      -G_MAXDOUBLE, G_MAXDOUBLE, 0,
204
				      (G_PARAM_READABLE | G_PARAM_WRITABLE)));
204
				      G_PARAM_READWRITE));
205
        g_object_class_install_property
205
        g_object_class_install_property
206
                (gobject_class,
206
                (gobject_class,
207
                 PROP_HEIGHT_SET,
207
                 PROP_HEIGHT_SET,
208
                 g_param_spec_boolean ("height_set", NULL, NULL,
208
                 g_param_spec_boolean ("height-set", NULL, NULL,
209
				       FALSE,
209
				       FALSE,
210
				       (G_PARAM_READABLE | G_PARAM_WRITABLE)));
210
				       G_PARAM_READWRITE));
211
        g_object_class_install_property
211
        g_object_class_install_property
212
                (gobject_class,
212
                (gobject_class,
213
                 PROP_HEIGHT_IN_PIXELS,
213
                 PROP_HEIGHT_IN_PIXELS,
214
                 g_param_spec_boolean ("height_in_pixels", NULL, NULL,
214
                 g_param_spec_boolean ("height-in-pixels", NULL, NULL,
215
				       FALSE,
215
				       FALSE,
216
				       (G_PARAM_READABLE | G_PARAM_WRITABLE)));
216
				       G_PARAM_READWRITE));
217
        g_object_class_install_property
217
        g_object_class_install_property
218
                (gobject_class,
218
                (gobject_class,
219
                 PROP_X,
219
                 PROP_X,
220
                 g_param_spec_double ("x", NULL, NULL,
220
                 g_param_spec_double ("x", NULL, NULL,
221
				      -G_MAXDOUBLE, G_MAXDOUBLE, 0,
221
				      -G_MAXDOUBLE, G_MAXDOUBLE, 0,
222
                                    (G_PARAM_READABLE | G_PARAM_WRITABLE)));
222
                                    G_PARAM_READWRITE));
223
        g_object_class_install_property
223
        g_object_class_install_property
224
                (gobject_class,
224
                (gobject_class,
225
                 PROP_X_IN_PIXELS,
225
                 PROP_X_IN_PIXELS,
226
                 g_param_spec_boolean ("x_in_pixels", NULL, NULL,
226
                 g_param_spec_boolean ("x-in-pixels", NULL, NULL,
227
				       FALSE,
227
				       FALSE,
228
				       (G_PARAM_READABLE | G_PARAM_WRITABLE)));
228
				       G_PARAM_READWRITE));
229
        g_object_class_install_property
229
        g_object_class_install_property
230
                (gobject_class,
230
                (gobject_class,
231
                 PROP_Y,
231
                 PROP_Y,
232
                 g_param_spec_double ("y", NULL, NULL,
232
                 g_param_spec_double ("y", NULL, NULL,
233
				      -G_MAXDOUBLE, G_MAXDOUBLE, 0,
233
				      -G_MAXDOUBLE, G_MAXDOUBLE, 0,
234
				      (G_PARAM_READABLE | G_PARAM_WRITABLE)));
234
				      G_PARAM_READWRITE));
235
        g_object_class_install_property
235
        g_object_class_install_property
236
                (gobject_class,
236
                (gobject_class,
237
                 PROP_Y_IN_PIXELS,
237
                 PROP_Y_IN_PIXELS,
238
                 g_param_spec_boolean ("y_in_pixels", NULL, NULL,
238
                 g_param_spec_boolean ("y-in-pixels", NULL, NULL,
239
				       FALSE,
239
				       FALSE,
240
				       (G_PARAM_READABLE | G_PARAM_WRITABLE)));
240
				       G_PARAM_READWRITE));
241
        g_object_class_install_property
241
        g_object_class_install_property
242
                (gobject_class,
242
                (gobject_class,
243
                 PROP_ANCHOR,
243
                 PROP_ANCHOR,
244
                 g_param_spec_enum ("anchor", NULL, NULL,
244
                 g_param_spec_enum ("anchor", NULL, NULL,
245
                                    GTK_TYPE_ANCHOR_TYPE,
245
                                    GTK_TYPE_ANCHOR_TYPE,
246
                                    GTK_ANCHOR_NW,
246
                                    GTK_ANCHOR_NW,
247
                                    (G_PARAM_READABLE | G_PARAM_WRITABLE)));
247
                                    G_PARAM_READWRITE));
248
        g_object_class_install_property
248
        g_object_class_install_property
249
                (gobject_class,
249
                (gobject_class,
250
                 PROP_INTERP_TYPE,
250
                 PROP_INTERP_TYPE,
251
                 g_param_spec_enum ("interp_type", NULL, NULL,
251
                 g_param_spec_enum ("interp-type", NULL, NULL,
252
                                    GDK_TYPE_INTERP_TYPE,
252
                                    GDK_TYPE_INTERP_TYPE,
253
                                    GDK_INTERP_BILINEAR,
253
                                    GDK_INTERP_BILINEAR,
254
                                    (G_PARAM_READABLE | G_PARAM_WRITABLE)));
254
                                    G_PARAM_READWRITE));
255
        g_object_class_install_property
255
        g_object_class_install_property
256
                (gobject_class,
256
                (gobject_class,
257
		 PROP_POINT_IGNORES_ALPHA,
257
		 PROP_POINT_IGNORES_ALPHA,
258
                 g_param_spec_boolean ("point_ignores_alpha", NULL, NULL,
258
                 g_param_spec_boolean ("point-ignores-alpha", NULL, NULL,
259
				       FALSE,
259
				       FALSE,
260
				       (G_PARAM_READABLE | G_PARAM_WRITABLE)));
260
				       G_PARAM_READWRITE));
261
261
262
	object_class->destroy = foo_canvas_pixbuf_destroy;
262
	object_class->destroy = foo_canvas_pixbuf_destroy;
263
263
(-)src/cut-n-paste-code/foocanvas/libfoocanvas/foo-canvas-polygon.c (-21 / +21 lines)
Lines 149-215 foo_canvas_polygon_class_init (FooCanvas Link Here
149
                 PROP_POINTS,
149
                 PROP_POINTS,
150
                 g_param_spec_boxed ("points", NULL, NULL,
150
                 g_param_spec_boxed ("points", NULL, NULL,
151
				     FOO_TYPE_CANVAS_POINTS,
151
				     FOO_TYPE_CANVAS_POINTS,
152
				     (G_PARAM_READABLE | G_PARAM_WRITABLE)));
152
				     G_PARAM_READWRITE));
153
        g_object_class_install_property
153
        g_object_class_install_property
154
                (gobject_class,
154
                (gobject_class,
155
                 PROP_FILL_COLOR,
155
                 PROP_FILL_COLOR,
156
                 g_param_spec_string ("fill_color", NULL, NULL,
156
                 g_param_spec_string ("fill-color", NULL, NULL,
157
                                      NULL,
157
                                      NULL,
158
                                      (G_PARAM_READABLE | G_PARAM_WRITABLE)));
158
                                      G_PARAM_READWRITE));
159
        g_object_class_install_property
159
        g_object_class_install_property
160
                (gobject_class,
160
                (gobject_class,
161
                 PROP_FILL_COLOR_GDK,
161
                 PROP_FILL_COLOR_GDK,
162
                 g_param_spec_boxed ("fill_color_gdk", NULL, NULL,
162
                 g_param_spec_boxed ("fill-color-gdk", NULL, NULL,
163
				     GDK_TYPE_COLOR,
163
				     GDK_TYPE_COLOR,
164
				     (G_PARAM_READABLE | G_PARAM_WRITABLE)));
164
				     G_PARAM_READWRITE));
165
        g_object_class_install_property
165
        g_object_class_install_property
166
                (gobject_class,
166
                (gobject_class,
167
                 PROP_FILL_COLOR_RGBA,
167
                 PROP_FILL_COLOR_RGBA,
168
                 g_param_spec_uint ("fill_color_rgba", NULL, NULL,
168
                 g_param_spec_uint ("fill-color-rgba", NULL, NULL,
169
				    0, G_MAXUINT, 0,
169
				    0, G_MAXUINT, 0,
170
				    (G_PARAM_READABLE | G_PARAM_WRITABLE)));
170
				    G_PARAM_READWRITE));
171
        g_object_class_install_property
171
        g_object_class_install_property
172
                (gobject_class,
172
                (gobject_class,
173
                 PROP_OUTLINE_COLOR,
173
                 PROP_OUTLINE_COLOR,
174
                 g_param_spec_string ("outline_color", NULL, NULL,
174
                 g_param_spec_string ("outline-color", NULL, NULL,
175
                                      NULL,
175
                                      NULL,
176
                                      (G_PARAM_READABLE | G_PARAM_WRITABLE)));
176
                                      G_PARAM_READWRITE));
177
        g_object_class_install_property
177
        g_object_class_install_property
178
                (gobject_class,
178
                (gobject_class,
179
                 PROP_OUTLINE_COLOR_GDK,
179
                 PROP_OUTLINE_COLOR_GDK,
180
                 g_param_spec_boxed ("outline_color_gdk", NULL, NULL,
180
                 g_param_spec_boxed ("outline-color-gdk", NULL, NULL,
181
				     GDK_TYPE_COLOR,
181
				     GDK_TYPE_COLOR,
182
				     (G_PARAM_READABLE | G_PARAM_WRITABLE)));
182
				     G_PARAM_READWRITE));
183
        g_object_class_install_property
183
        g_object_class_install_property
184
                (gobject_class,
184
                (gobject_class,
185
                 PROP_OUTLINE_COLOR_RGBA,
185
                 PROP_OUTLINE_COLOR_RGBA,
186
                 g_param_spec_uint ("outline_color_rgba", NULL, NULL,
186
                 g_param_spec_uint ("outline-color-rgba", NULL, NULL,
187
				    0, G_MAXUINT, 0,
187
				    0, G_MAXUINT, 0,
188
				    (G_PARAM_READABLE | G_PARAM_WRITABLE)));
188
				    G_PARAM_READWRITE));
189
        g_object_class_install_property
189
        g_object_class_install_property
190
                (gobject_class,
190
                (gobject_class,
191
                 PROP_FILL_STIPPLE,
191
                 PROP_FILL_STIPPLE,
192
                 g_param_spec_object ("fill_stipple", NULL, NULL,
192
                 g_param_spec_object ("fill-stipple", NULL, NULL,
193
                                      GDK_TYPE_DRAWABLE,
193
                                      GDK_TYPE_DRAWABLE,
194
                                      (G_PARAM_READABLE | G_PARAM_WRITABLE)));
194
                                      G_PARAM_READWRITE));
195
        g_object_class_install_property
195
        g_object_class_install_property
196
                (gobject_class,
196
                (gobject_class,
197
                 PROP_OUTLINE_STIPPLE,
197
                 PROP_OUTLINE_STIPPLE,
198
                 g_param_spec_object ("outline_stipple", NULL, NULL,
198
                 g_param_spec_object ("outline-stipple", NULL, NULL,
199
                                      GDK_TYPE_DRAWABLE,
199
                                      GDK_TYPE_DRAWABLE,
200
                                      (G_PARAM_READABLE | G_PARAM_WRITABLE)));
200
                                      G_PARAM_READWRITE));
201
        g_object_class_install_property
201
        g_object_class_install_property
202
                (gobject_class,
202
                (gobject_class,
203
                 PROP_WIDTH_PIXELS,
203
                 PROP_WIDTH_PIXELS,
204
                 g_param_spec_uint ("width_pixels", NULL, NULL,
204
                 g_param_spec_uint ("width-pixels", NULL, NULL,
205
				    0, G_MAXUINT, 0,
205
				    0, G_MAXUINT, 0,
206
				    (G_PARAM_READABLE | G_PARAM_WRITABLE)));
206
				    G_PARAM_READWRITE));
207
        g_object_class_install_property
207
        g_object_class_install_property
208
                (gobject_class,
208
                (gobject_class,
209
                 PROP_WIDTH_UNITS,
209
                 PROP_WIDTH_UNITS,
210
                 g_param_spec_double ("width_units", NULL, NULL,
210
                 g_param_spec_double ("width-units", NULL, NULL,
211
				      0.0, G_MAXDOUBLE, 0.0,
211
				      0.0, G_MAXDOUBLE, 0.0,
212
				      (G_PARAM_READABLE | G_PARAM_WRITABLE)));
212
				      G_PARAM_READWRITE));
213
213
214
	object_class->destroy = foo_canvas_polygon_destroy;
214
	object_class->destroy = foo_canvas_polygon_destroy;
215
215
(-)src/cut-n-paste-code/foocanvas/libfoocanvas/foo-canvas-rect-ellipse.c (-27 / +27 lines)
Lines 152-236 foo_canvas_re_class_init (FooCanvasRECla Link Here
152
                 PROP_X1,
152
                 PROP_X1,
153
                 g_param_spec_double ("x1", NULL, NULL,
153
                 g_param_spec_double ("x1", NULL, NULL,
154
				      -G_MAXDOUBLE, G_MAXDOUBLE, 0,
154
				      -G_MAXDOUBLE, G_MAXDOUBLE, 0,
155
				      (G_PARAM_READABLE | G_PARAM_WRITABLE)));
155
				      G_PARAM_READWRITE));
156
        g_object_class_install_property
156
        g_object_class_install_property
157
                (gobject_class,
157
                (gobject_class,
158
                 PROP_Y1,
158
                 PROP_Y1,
159
                 g_param_spec_double ("y1", NULL, NULL,
159
                 g_param_spec_double ("y1", NULL, NULL,
160
				      -G_MAXDOUBLE, G_MAXDOUBLE, 0,
160
				      -G_MAXDOUBLE, G_MAXDOUBLE, 0,
161
				      (G_PARAM_READABLE | G_PARAM_WRITABLE)));
161
				      G_PARAM_READWRITE));
162
        g_object_class_install_property
162
        g_object_class_install_property
163
                (gobject_class,
163
                (gobject_class,
164
                 PROP_X2,
164
                 PROP_X2,
165
                 g_param_spec_double ("x2", NULL, NULL,
165
                 g_param_spec_double ("x2", NULL, NULL,
166
				      -G_MAXDOUBLE, G_MAXDOUBLE, 0,
166
				      -G_MAXDOUBLE, G_MAXDOUBLE, 0,
167
				      (G_PARAM_READABLE | G_PARAM_WRITABLE)));
167
				      G_PARAM_READWRITE));
168
        g_object_class_install_property
168
        g_object_class_install_property
169
                (gobject_class,
169
                (gobject_class,
170
                 PROP_Y2,
170
                 PROP_Y2,
171
                 g_param_spec_double ("y2", NULL, NULL,
171
                 g_param_spec_double ("y2", NULL, NULL,
172
				      -G_MAXDOUBLE, G_MAXDOUBLE, 0,
172
				      -G_MAXDOUBLE, G_MAXDOUBLE, 0,
173
				      (G_PARAM_READABLE | G_PARAM_WRITABLE)));
173
				      G_PARAM_READWRITE));
174
        g_object_class_install_property
174
        g_object_class_install_property
175
                (gobject_class,
175
                (gobject_class,
176
                 PROP_FILL_COLOR,
176
                 PROP_FILL_COLOR,
177
                 g_param_spec_string ("fill_color", NULL, NULL,
177
                 g_param_spec_string ("fill-color", NULL, NULL,
178
                                      NULL,
178
                                      NULL,
179
                                      (G_PARAM_READABLE | G_PARAM_WRITABLE)));
179
                                      G_PARAM_READWRITE));
180
        g_object_class_install_property
180
        g_object_class_install_property
181
                (gobject_class,
181
                (gobject_class,
182
                 PROP_FILL_COLOR_GDK,
182
                 PROP_FILL_COLOR_GDK,
183
                 g_param_spec_boxed ("fill_color_gdk", NULL, NULL,
183
                 g_param_spec_boxed ("fill-color-gdk", NULL, NULL,
184
				     GDK_TYPE_COLOR,
184
				     GDK_TYPE_COLOR,
185
				     (G_PARAM_READABLE | G_PARAM_WRITABLE)));
185
				     G_PARAM_READWRITE));
186
        g_object_class_install_property
186
        g_object_class_install_property
187
                (gobject_class,
187
                (gobject_class,
188
                 PROP_FILL_COLOR_RGBA,
188
                 PROP_FILL_COLOR_RGBA,
189
                 g_param_spec_uint ("fill_color_rgba", NULL, NULL,
189
                 g_param_spec_uint ("fill-color-rgba", NULL, NULL,
190
				    0, G_MAXUINT, 0,
190
				    0, G_MAXUINT, 0,
191
				    (G_PARAM_READABLE | G_PARAM_WRITABLE)));
191
				    G_PARAM_READWRITE));
192
        g_object_class_install_property
192
        g_object_class_install_property
193
                (gobject_class,
193
                (gobject_class,
194
                 PROP_FILL_STIPPLE,
194
                 PROP_FILL_STIPPLE,
195
                 g_param_spec_object ("fill_stipple", NULL, NULL,
195
                 g_param_spec_object ("fill-stipple", NULL, NULL,
196
                                      GDK_TYPE_DRAWABLE,
196
                                      GDK_TYPE_DRAWABLE,
197
                                      (G_PARAM_READABLE | G_PARAM_WRITABLE)));
197
                                      G_PARAM_READWRITE));
198
        g_object_class_install_property
198
        g_object_class_install_property
199
                (gobject_class,
199
                (gobject_class,
200
                 PROP_OUTLINE_COLOR,
200
                 PROP_OUTLINE_COLOR,
201
                 g_param_spec_string ("outline_color", NULL, NULL,
201
                 g_param_spec_string ("outline-color", NULL, NULL,
202
                                      NULL,
202
                                      NULL,
203
                                      (G_PARAM_READABLE | G_PARAM_WRITABLE)));
203
                                      G_PARAM_READWRITE));
204
        g_object_class_install_property
204
        g_object_class_install_property
205
                (gobject_class,
205
                (gobject_class,
206
                 PROP_OUTLINE_COLOR_GDK,
206
                 PROP_OUTLINE_COLOR_GDK,
207
                 g_param_spec_boxed ("outline_color_gdk", NULL, NULL,
207
                 g_param_spec_boxed ("outline-color-gdk", NULL, NULL,
208
				     GDK_TYPE_COLOR,
208
				     GDK_TYPE_COLOR,
209
				     (G_PARAM_READABLE | G_PARAM_WRITABLE)));
209
				     G_PARAM_READWRITE));
210
        g_object_class_install_property
210
        g_object_class_install_property
211
                (gobject_class,
211
                (gobject_class,
212
                 PROP_OUTLINE_COLOR_RGBA,
212
                 PROP_OUTLINE_COLOR_RGBA,
213
                 g_param_spec_uint ("outline_color_rgba", NULL, NULL,
213
                 g_param_spec_uint ("outline-color-rgba", NULL, NULL,
214
				    0, G_MAXUINT, 0,
214
				    0, G_MAXUINT, 0,
215
				    (G_PARAM_READABLE | G_PARAM_WRITABLE)));
215
				    G_PARAM_READWRITE));
216
        g_object_class_install_property
216
        g_object_class_install_property
217
                (gobject_class,
217
                (gobject_class,
218
                 PROP_OUTLINE_STIPPLE,
218
                 PROP_OUTLINE_STIPPLE,
219
                 g_param_spec_object ("outline_stipple", NULL, NULL,
219
                 g_param_spec_object ("outline-stipple", NULL, NULL,
220
                                      GDK_TYPE_DRAWABLE,
220
                                      GDK_TYPE_DRAWABLE,
221
                                      (G_PARAM_READABLE | G_PARAM_WRITABLE)));
221
                                      G_PARAM_READWRITE));
222
        g_object_class_install_property
222
        g_object_class_install_property
223
                (gobject_class,
223
                (gobject_class,
224
                 PROP_WIDTH_PIXELS,
224
                 PROP_WIDTH_PIXELS,
225
                 g_param_spec_uint ("width_pixels", NULL, NULL,
225
                 g_param_spec_uint ("width-pixels", NULL, NULL,
226
				    0, G_MAXUINT, 0,
226
				    0, G_MAXUINT, 0,
227
				    (G_PARAM_READABLE | G_PARAM_WRITABLE)));
227
				    G_PARAM_READWRITE));
228
        g_object_class_install_property
228
        g_object_class_install_property
229
                (gobject_class,
229
                (gobject_class,
230
                 PROP_WIDTH_UNITS,
230
                 PROP_WIDTH_UNITS,
231
                 g_param_spec_double ("width_units", NULL, NULL,
231
                 g_param_spec_double ("width-units", NULL, NULL,
232
				      0.0, G_MAXDOUBLE, 0.0,
232
				      0.0, G_MAXDOUBLE, 0.0,
233
				      (G_PARAM_READABLE | G_PARAM_WRITABLE)));
233
				      G_PARAM_READWRITE));
234
234
235
	object_class->destroy = foo_canvas_re_destroy;
235
	object_class->destroy = foo_canvas_re_destroy;
236
236
Lines 842-858 foo_canvas_rect_realize (FooCanvasItem Link Here
842
#ifdef HAVE_RENDER
842
#ifdef HAVE_RENDER
843
	FooCanvasRectPrivate *priv;
843
	FooCanvasRectPrivate *priv;
844
	int event_base, error_base;
844
	int event_base, error_base;
845
	Display *dpy;
845
846
846
	priv = FOO_CANVAS_RECT (item)->priv;
847
	priv = FOO_CANVAS_RECT (item)->priv;
847
848
848
	priv->use_render = XRenderQueryExtension (gdk_display, &event_base, &error_base);
849
	dpy = gdk_x11_drawable_get_xdisplay (GTK_WIDGET (item->canvas)->window);
850
	priv->use_render = XRenderQueryExtension (dpy, &event_base, &error_base);
849
851
850
	if (priv->use_render) {
852
	if (priv->use_render) {
851
		Display *dpy;
852
		GdkVisual *gdk_visual;
853
		GdkVisual *gdk_visual;
853
		Visual *visual;
854
		Visual *visual;
854
855
855
		dpy = gdk_x11_drawable_get_xdisplay (GTK_WIDGET (item->canvas)->window);
856
		gdk_visual = gtk_widget_get_visual (GTK_WIDGET (item->canvas));
856
		gdk_visual = gtk_widget_get_visual (GTK_WIDGET (item->canvas));
857
		visual = gdk_x11_visual_get_xvisual (gdk_visual);
857
		visual = gdk_x11_visual_get_xvisual (gdk_visual);
858
858
(-)src/cut-n-paste-code/foocanvas/libfoocanvas/foo-canvas-text.c (-44 / +44 lines)
Lines 215-221 foo_canvas_text_class_init (FooCanvasTex Link Here
215
				      _("Text"),
215
				      _("Text"),
216
				      _("Text to render"),
216
				      _("Text to render"),
217
                                      NULL,
217
                                      NULL,
218
                                      (G_PARAM_READABLE | G_PARAM_WRITABLE)));
218
                                      G_PARAM_READWRITE));
219
219
220
        g_object_class_install_property
220
        g_object_class_install_property
221
                (gobject_class,
221
                (gobject_class,
Lines 232-245 foo_canvas_text_class_init (FooCanvasTex Link Here
232
                 PROP_X,
232
                 PROP_X,
233
                 g_param_spec_double ("x", NULL, NULL,
233
                 g_param_spec_double ("x", NULL, NULL,
234
				      -G_MAXDOUBLE, G_MAXDOUBLE, 0.0,
234
				      -G_MAXDOUBLE, G_MAXDOUBLE, 0.0,
235
				      (G_PARAM_READABLE | G_PARAM_WRITABLE)));
235
				      G_PARAM_READWRITE));
236
236
237
        g_object_class_install_property
237
        g_object_class_install_property
238
                (gobject_class,
238
                (gobject_class,
239
                 PROP_Y,
239
                 PROP_Y,
240
                 g_param_spec_double ("y", NULL, NULL,
240
                 g_param_spec_double ("y", NULL, NULL,
241
				      -G_MAXDOUBLE, G_MAXDOUBLE, 0.0,
241
				      -G_MAXDOUBLE, G_MAXDOUBLE, 0.0,
242
				      (G_PARAM_READABLE | G_PARAM_WRITABLE)));
242
				      G_PARAM_READWRITE));
243
243
244
244
245
	/* Font */
245
	/* Font */
Lines 250-265 foo_canvas_text_class_init (FooCanvasTex Link Here
250
				      _("Font"),
250
				      _("Font"),
251
				      _("Font description as a string"),
251
				      _("Font description as a string"),
252
                                      NULL,
252
                                      NULL,
253
                                      (G_PARAM_READABLE | G_PARAM_WRITABLE)));
253
                                      G_PARAM_READWRITE));
254
254
255
        g_object_class_install_property
255
        g_object_class_install_property
256
		(gobject_class,
256
		(gobject_class,
257
		 PROP_FONT_DESC,
257
		 PROP_FONT_DESC,
258
		 g_param_spec_boxed ("font_desc",
258
		 g_param_spec_boxed ("font-desc",
259
				     _("Font description"),
259
				     _("Font description"),
260
				     _("Font description as a PangoFontDescription struct"),
260
				     _("Font description as a PangoFontDescription struct"),
261
				     PANGO_TYPE_FONT_DESCRIPTION,
261
				     PANGO_TYPE_FONT_DESCRIPTION,
262
				     (G_PARAM_READABLE | G_PARAM_WRITABLE)));
262
				     G_PARAM_READWRITE));
263
263
264
	g_object_class_install_property
264
	g_object_class_install_property
265
		(gobject_class,
265
		(gobject_class,
Lines 268-274 foo_canvas_text_class_init (FooCanvasTex Link Here
268
				      _("Font family"),
268
				      _("Font family"),
269
				      _("Name of the font family, e.g. Sans, Helvetica, Times, Monospace"),
269
				      _("Name of the font family, e.g. Sans, Helvetica, Times, Monospace"),
270
				      NULL,
270
				      NULL,
271
				      (G_PARAM_READABLE | G_PARAM_WRITABLE)));
271
				      G_PARAM_READWRITE));
272
272
273
	/* Style */
273
	/* Style */
274
        g_object_class_install_property
274
        g_object_class_install_property
Lines 276-282 foo_canvas_text_class_init (FooCanvasTex Link Here
276
                 PROP_ATTRIBUTES,
276
                 PROP_ATTRIBUTES,
277
                 g_param_spec_boxed ("attributes", NULL, NULL,
277
                 g_param_spec_boxed ("attributes", NULL, NULL,
278
				     PANGO_TYPE_ATTR_LIST,
278
				     PANGO_TYPE_ATTR_LIST,
279
				     (G_PARAM_READABLE | G_PARAM_WRITABLE)));
279
				     G_PARAM_READWRITE));
280
280
281
	g_object_class_install_property
281
	g_object_class_install_property
282
		(gobject_class,
282
		(gobject_class,
Lines 334-340 foo_canvas_text_class_init (FooCanvasTex Link Here
334
	g_object_class_install_property
334
	g_object_class_install_property
335
		(gobject_class,
335
		(gobject_class,
336
		PROP_SIZE_POINTS,
336
		PROP_SIZE_POINTS,
337
		g_param_spec_double ("size_points",
337
		g_param_spec_double ("size-points",
338
				     _("Font points"),
338
				     _("Font points"),
339
				     _("Font size in points"),
339
				     _("Font size in points"),
340
				     0.0,
340
				     0.0,
Lines 389-525 foo_canvas_text_class_init (FooCanvasTex Link Here
389
                 g_param_spec_enum ("anchor", NULL, NULL,
389
                 g_param_spec_enum ("anchor", NULL, NULL,
390
                                    GTK_TYPE_ANCHOR_TYPE,
390
                                    GTK_TYPE_ANCHOR_TYPE,
391
                                    GTK_ANCHOR_CENTER,
391
                                    GTK_ANCHOR_CENTER,
392
                                    (G_PARAM_READABLE | G_PARAM_WRITABLE)));
392
                                    G_PARAM_READWRITE));
393
        g_object_class_install_property
393
        g_object_class_install_property
394
                (gobject_class,
394
                (gobject_class,
395
                 PROP_JUSTIFICATION,
395
                 PROP_JUSTIFICATION,
396
                 g_param_spec_enum ("justification", NULL, NULL,
396
                 g_param_spec_enum ("justification", NULL, NULL,
397
                                    GTK_TYPE_JUSTIFICATION,
397
                                    GTK_TYPE_JUSTIFICATION,
398
                                    GTK_JUSTIFY_LEFT,
398
                                    GTK_JUSTIFY_LEFT,
399
                                    (G_PARAM_READABLE | G_PARAM_WRITABLE)));
399
                                    G_PARAM_READWRITE));
400
        g_object_class_install_property
400
        g_object_class_install_property
401
                (gobject_class,
401
                (gobject_class,
402
                 PROP_CLIP_WIDTH,
402
                 PROP_CLIP_WIDTH,
403
                 g_param_spec_double ("clip_width", NULL, NULL,
403
                 g_param_spec_double ("clip-width", NULL, NULL,
404
				      -G_MAXDOUBLE, G_MAXDOUBLE, 0.0,
404
				      -G_MAXDOUBLE, G_MAXDOUBLE, 0.0,
405
				      (G_PARAM_READABLE | G_PARAM_WRITABLE)));
405
				      G_PARAM_READWRITE));
406
        g_object_class_install_property
406
        g_object_class_install_property
407
                (gobject_class,
407
                (gobject_class,
408
                 PROP_CLIP_HEIGHT,
408
                 PROP_CLIP_HEIGHT,
409
                 g_param_spec_double ("clip_height", NULL, NULL,
409
                 g_param_spec_double ("clip-height", NULL, NULL,
410
				      -G_MAXDOUBLE, G_MAXDOUBLE, 0.0,
410
				      -G_MAXDOUBLE, G_MAXDOUBLE, 0.0,
411
				      (G_PARAM_READABLE | G_PARAM_WRITABLE)));
411
				      G_PARAM_READWRITE));
412
        g_object_class_install_property
412
        g_object_class_install_property
413
                (gobject_class,
413
                (gobject_class,
414
                 PROP_CLIP,
414
                 PROP_CLIP,
415
                 g_param_spec_boolean ("clip", NULL, NULL,
415
                 g_param_spec_boolean ("clip", NULL, NULL,
416
				       FALSE,
416
				       FALSE,
417
				       (G_PARAM_READABLE | G_PARAM_WRITABLE)));
417
				       G_PARAM_READWRITE));
418
        g_object_class_install_property
418
        g_object_class_install_property
419
                (gobject_class,
419
                (gobject_class,
420
                 PROP_WRAP_WIDTH,
420
                 PROP_WRAP_WIDTH,
421
                 g_param_spec_double ("wrap_width", NULL, NULL,
421
                 g_param_spec_double ("wrap-width", NULL, NULL,
422
				      -G_MAXDOUBLE, G_MAXDOUBLE, 0.0,
422
				      -G_MAXDOUBLE, G_MAXDOUBLE, 0.0,
423
				      (G_PARAM_READABLE | G_PARAM_WRITABLE)));
423
				      G_PARAM_READWRITE));
424
        g_object_class_install_property
424
        g_object_class_install_property
425
                (gobject_class,
425
                (gobject_class,
426
                 PROP_X_OFFSET,
426
                 PROP_X_OFFSET,
427
                 g_param_spec_double ("x_offset", NULL, NULL,
427
                 g_param_spec_double ("x-offset", NULL, NULL,
428
				      -G_MAXDOUBLE, G_MAXDOUBLE, 0.0,
428
				      -G_MAXDOUBLE, G_MAXDOUBLE, 0.0,
429
				      (G_PARAM_READABLE | G_PARAM_WRITABLE)));
429
				      G_PARAM_READWRITE));
430
        g_object_class_install_property
430
        g_object_class_install_property
431
                (gobject_class,
431
                (gobject_class,
432
                 PROP_Y_OFFSET,
432
                 PROP_Y_OFFSET,
433
                 g_param_spec_double ("y_offset", NULL, NULL,
433
                 g_param_spec_double ("y-offset", NULL, NULL,
434
				      -G_MAXDOUBLE, G_MAXDOUBLE, 0.0,
434
				      -G_MAXDOUBLE, G_MAXDOUBLE, 0.0,
435
				      (G_PARAM_READABLE | G_PARAM_WRITABLE)));
435
				      G_PARAM_READWRITE));
436
        g_object_class_install_property
436
        g_object_class_install_property
437
                (gobject_class,
437
                (gobject_class,
438
                 PROP_FILL_COLOR,
438
                 PROP_FILL_COLOR,
439
                 g_param_spec_string ("fill_color",
439
                 g_param_spec_string ("fill-color",
440
				      _("Color"),
440
				      _("Color"),
441
				      _("Text color, as string"),
441
				      _("Text color, as string"),
442
                                      NULL,
442
                                      NULL,
443
                                      (G_PARAM_READABLE | G_PARAM_WRITABLE)));
443
                                      G_PARAM_READWRITE));
444
        g_object_class_install_property
444
        g_object_class_install_property
445
                (gobject_class,
445
                (gobject_class,
446
                 PROP_FILL_COLOR_GDK,
446
                 PROP_FILL_COLOR_GDK,
447
                 g_param_spec_boxed ("fill_color_gdk",
447
                 g_param_spec_boxed ("fill-color-gdk",
448
				     _("Color"),
448
				     _("Color"),
449
				     _("Text color, as a GdkColor"),
449
				     _("Text color, as a GdkColor"),
450
				     GDK_TYPE_COLOR,
450
				     GDK_TYPE_COLOR,
451
				     (G_PARAM_READABLE | G_PARAM_WRITABLE)));
451
				     G_PARAM_READWRITE));
452
        g_object_class_install_property
452
        g_object_class_install_property
453
                (gobject_class,
453
                (gobject_class,
454
                 PROP_FILL_COLOR_RGBA,
454
                 PROP_FILL_COLOR_RGBA,
455
                 g_param_spec_uint ("fill_color_rgba",
455
                 g_param_spec_uint ("fill-color-rgba",
456
				    _("Color"),
456
				    _("Color"),
457
				    _("Text color, as an R/G/B/A combined integer"),
457
				    _("Text color, as an R/G/B/A combined integer"),
458
				    0, G_MAXUINT, 0,
458
				    0, G_MAXUINT, 0,
459
				    (G_PARAM_READABLE | G_PARAM_WRITABLE)));
459
				    G_PARAM_READWRITE));
460
        g_object_class_install_property
460
        g_object_class_install_property
461
                (gobject_class,
461
                (gobject_class,
462
                 PROP_FILL_STIPPLE,
462
                 PROP_FILL_STIPPLE,
463
                 g_param_spec_object ("fill_stipple", NULL, NULL,
463
                 g_param_spec_object ("fill-stipple", NULL, NULL,
464
                                      GDK_TYPE_DRAWABLE,
464
                                      GDK_TYPE_DRAWABLE,
465
                                      (G_PARAM_READABLE | G_PARAM_WRITABLE)));
465
                                      G_PARAM_READWRITE));
466
        g_object_class_install_property
466
        g_object_class_install_property
467
                (gobject_class,
467
                (gobject_class,
468
                 PROP_TEXT_WIDTH,
468
                 PROP_TEXT_WIDTH,
469
                 g_param_spec_double ("text_width",
469
                 g_param_spec_double ("text-width",
470
				      _("Text width"),
470
				      _("Text width"),
471
				      _("Width of the rendered text"),
471
				      _("Width of the rendered text"),
472
				      0.0, G_MAXDOUBLE, 0.0,
472
				      0.0, G_MAXDOUBLE, 0.0,
473
				      (G_PARAM_READABLE | G_PARAM_WRITABLE)));
473
				      G_PARAM_READWRITE));
474
        g_object_class_install_property
474
        g_object_class_install_property
475
                (gobject_class,
475
                (gobject_class,
476
                 PROP_TEXT_HEIGHT,
476
                 PROP_TEXT_HEIGHT,
477
                 g_param_spec_double ("text_height",
477
                 g_param_spec_double ("text-height",
478
				      _("Text height"),
478
				      _("Text height"),
479
				      _("Height of the rendered text"),
479
				      _("Height of the rendered text"),
480
				      0.0, G_MAXDOUBLE, 0.0,
480
				      0.0, G_MAXDOUBLE, 0.0,
481
				      (G_PARAM_READABLE | G_PARAM_WRITABLE)));
481
				      G_PARAM_READWRITE));
482
482
483
	/* Style props are set (explicitly applied) or not */
483
	/* Style props are set (explicitly applied) or not */
484
#define ADD_SET_PROP(propname, propval, nick, blurb) g_object_class_install_property (gobject_class, propval, g_param_spec_boolean (propname, nick, blurb, FALSE, G_PARAM_READABLE | G_PARAM_WRITABLE))
484
#define ADD_SET_PROP(propname, propval, nick, blurb) g_object_class_install_property (gobject_class, propval, g_param_spec_boolean (propname, nick, blurb, FALSE, G_PARAM_READABLE | G_PARAM_WRITABLE))
485
485
486
	ADD_SET_PROP ("family_set", PROP_FAMILY_SET,
486
	ADD_SET_PROP ("family-set", PROP_FAMILY_SET,
487
		      _("Font family set"),
487
		      _("Font family set"),
488
		      _("Whether this tag affects the font family"));
488
		      _("Whether this tag affects the font family"));
489
489
490
	ADD_SET_PROP ("style_set", PROP_STYLE_SET,
490
	ADD_SET_PROP ("style-set", PROP_STYLE_SET,
491
		      _("Font style set"),
491
		      _("Font style set"),
492
		      _("Whether this tag affects the font style"));
492
		      _("Whether this tag affects the font style"));
493
493
494
	ADD_SET_PROP ("variant_set", PROP_VARIANT_SET,
494
	ADD_SET_PROP ("variant-set", PROP_VARIANT_SET,
495
		      _("Font variant set"),
495
		      _("Font variant set"),
496
		      _("Whether this tag affects the font variant"));
496
		      _("Whether this tag affects the font variant"));
497
497
498
	ADD_SET_PROP ("weight_set", PROP_WEIGHT_SET,
498
	ADD_SET_PROP ("weight-set", PROP_WEIGHT_SET,
499
		      _("Font weight set"),
499
		      _("Font weight set"),
500
		      _("Whether this tag affects the font weight"));
500
		      _("Whether this tag affects the font weight"));
501
501
502
	ADD_SET_PROP ("stretch_set", PROP_STRETCH_SET,
502
	ADD_SET_PROP ("stretch-set", PROP_STRETCH_SET,
503
		      _("Font stretch set"),
503
		      _("Font stretch set"),
504
		      _("Whether this tag affects the font stretch"));
504
		      _("Whether this tag affects the font stretch"));
505
505
506
	ADD_SET_PROP ("size_set", PROP_SIZE_SET,
506
	ADD_SET_PROP ("size-set", PROP_SIZE_SET,
507
		      _("Font size set"),
507
		      _("Font size set"),
508
		      _("Whether this tag affects the font size"));
508
		      _("Whether this tag affects the font size"));
509
509
510
	ADD_SET_PROP ("rise_set", PROP_RISE_SET,
510
	ADD_SET_PROP ("rise-set", PROP_RISE_SET,
511
		      _("Rise set"),
511
		      _("Rise set"),
512
		      _("Whether this tag affects the rise"));
512
		      _("Whether this tag affects the rise"));
513
513
514
	ADD_SET_PROP ("strikethrough_set", PROP_STRIKETHROUGH_SET,
514
	ADD_SET_PROP ("strikethrough-set", PROP_STRIKETHROUGH_SET,
515
		      _("Strikethrough set"),
515
		      _("Strikethrough set"),
516
		      _("Whether this tag affects strikethrough"));
516
		      _("Whether this tag affects strikethrough"));
517
517
518
	ADD_SET_PROP ("underline_set", PROP_UNDERLINE_SET,
518
	ADD_SET_PROP ("underline-set", PROP_UNDERLINE_SET,
519
		      _("Underline set"),
519
		      _("Underline set"),
520
		      _("Whether this tag affects underlining"));
520
		      _("Whether this tag affects underlining"));
521
521
522
	ADD_SET_PROP ("scale_set", PROP_SCALE_SET,
522
	ADD_SET_PROP ("scale-set", PROP_SCALE_SET,
523
		      _("Scale set"),
523
		      _("Scale set"),
524
		      _("Whether this tag affects font scaling"));
524
		      _("Whether this tag affects font scaling"));
525
#undef ADD_SET_PROP
525
#undef ADD_SET_PROP
(-)src/cut-n-paste-code/foocanvas/libfoocanvas/foo-canvas-widget.c (-8 / +30 lines)
Lines 75-80 static void foo_canvas_widget_bounds Link Here
75
static void foo_canvas_widget_draw (FooCanvasItem *item,
75
static void foo_canvas_widget_draw (FooCanvasItem *item,
76
				      GdkDrawable *drawable,
76
				      GdkDrawable *drawable,
77
				      GdkEventExpose   *event);
77
				      GdkEventExpose   *event);
78
static void foo_canvas_widget_map   (FooCanvasItem *item);
79
static void foo_canvas_widget_unmap (FooCanvasItem *item);
78
80
79
static FooCanvasItemClass *parent_class;
81
static FooCanvasItemClass *parent_class;
80
82
Lines 124-167 foo_canvas_widget_class_init (FooCanvasW Link Here
124
                 PROP_WIDGET,
126
                 PROP_WIDGET,
125
                 g_param_spec_object ("widget", NULL, NULL,
127
                 g_param_spec_object ("widget", NULL, NULL,
126
                                      GTK_TYPE_WIDGET,
128
                                      GTK_TYPE_WIDGET,
127
                                      (G_PARAM_READABLE | G_PARAM_WRITABLE)));
129
                                      G_PARAM_READWRITE));
128
        g_object_class_install_property
130
        g_object_class_install_property
129
                (gobject_class,
131
                (gobject_class,
130
                 PROP_X,
132
                 PROP_X,
131
                 g_param_spec_double ("x", NULL, NULL,
133
                 g_param_spec_double ("x", NULL, NULL,
132
				      -G_MAXDOUBLE, G_MAXDOUBLE, 0.0,
134
				      -G_MAXDOUBLE, G_MAXDOUBLE, 0.0,
133
				      (G_PARAM_READABLE | G_PARAM_WRITABLE)));
135
				      G_PARAM_READWRITE));
134
        g_object_class_install_property
136
        g_object_class_install_property
135
                (gobject_class,
137
                (gobject_class,
136
                 PROP_Y,
138
                 PROP_Y,
137
                 g_param_spec_double ("y", NULL, NULL,
139
                 g_param_spec_double ("y", NULL, NULL,
138
				      -G_MAXDOUBLE, G_MAXDOUBLE, 0.0,
140
				      -G_MAXDOUBLE, G_MAXDOUBLE, 0.0,
139
				      (G_PARAM_READABLE | G_PARAM_WRITABLE)));
141
				      G_PARAM_READWRITE));
140
        g_object_class_install_property
142
        g_object_class_install_property
141
                (gobject_class,
143
                (gobject_class,
142
                 PROP_WIDTH,
144
                 PROP_WIDTH,
143
                 g_param_spec_double ("width", NULL, NULL,
145
                 g_param_spec_double ("width", NULL, NULL,
144
				      -G_MAXDOUBLE, G_MAXDOUBLE, 0.0,
146
				      -G_MAXDOUBLE, G_MAXDOUBLE, 0.0,
145
				      (G_PARAM_READABLE | G_PARAM_WRITABLE)));
147
				      G_PARAM_READWRITE));
146
        g_object_class_install_property
148
        g_object_class_install_property
147
                (gobject_class,
149
                (gobject_class,
148
                 PROP_HEIGHT,
150
                 PROP_HEIGHT,
149
                 g_param_spec_double ("height", NULL, NULL,
151
                 g_param_spec_double ("height", NULL, NULL,
150
				      -G_MAXDOUBLE, G_MAXDOUBLE, 0.0,
152
				      -G_MAXDOUBLE, G_MAXDOUBLE, 0.0,
151
				      (G_PARAM_READABLE | G_PARAM_WRITABLE)));
153
				      G_PARAM_READWRITE));
152
        g_object_class_install_property
154
        g_object_class_install_property
153
                (gobject_class,
155
                (gobject_class,
154
                 PROP_ANCHOR,
156
                 PROP_ANCHOR,
155
                 g_param_spec_enum ("anchor", NULL, NULL,
157
                 g_param_spec_enum ("anchor", NULL, NULL,
156
                                    GTK_TYPE_ANCHOR_TYPE,
158
                                    GTK_TYPE_ANCHOR_TYPE,
157
                                    GTK_ANCHOR_NW,
159
                                    GTK_ANCHOR_NW,
158
                                    (G_PARAM_READABLE | G_PARAM_WRITABLE)));
160
                                    G_PARAM_READWRITE));
159
        g_object_class_install_property
161
        g_object_class_install_property
160
                (gobject_class,
162
                (gobject_class,
161
                 PROP_SIZE_PIXELS,
163
                 PROP_SIZE_PIXELS,
162
                 g_param_spec_boolean ("size_pixels", NULL, NULL,
164
                 g_param_spec_boolean ("size-pixels", NULL, NULL,
163
				       FALSE,
165
				       FALSE,
164
				       (G_PARAM_READABLE | G_PARAM_WRITABLE)));
166
				       G_PARAM_READWRITE));
165
167
166
	object_class->destroy = foo_canvas_widget_destroy;
168
	object_class->destroy = foo_canvas_widget_destroy;
167
169
Lines 170-175 foo_canvas_widget_class_init (FooCanvasW Link Here
170
	item_class->translate = foo_canvas_widget_translate;
172
	item_class->translate = foo_canvas_widget_translate;
171
	item_class->bounds = foo_canvas_widget_bounds;
173
	item_class->bounds = foo_canvas_widget_bounds;
172
	item_class->draw = foo_canvas_widget_draw;
174
	item_class->draw = foo_canvas_widget_draw;
175
	item_class->map   = foo_canvas_widget_map;
176
	item_class->unmap = foo_canvas_widget_unmap;
173
}
177
}
174
178
175
static void
179
static void
Lines 484-489 foo_canvas_widget_draw (FooCanvasItem *i Link Here
484
	if (witem->widget)
488
	if (witem->widget)
485
		gtk_widget_queue_draw (witem->widget);
489
		gtk_widget_queue_draw (witem->widget);
486
#endif
490
#endif
491
}
492
static void
493
foo_canvas_widget_map (FooCanvasItem *item)
494
{
495
	FooCanvasWidget *witem = FOO_CANVAS_WIDGET (item);
496
	if (parent_class->map)
497
		(* parent_class->map) (item);
498
	if (witem->widget && GTK_WIDGET_VISIBLE (witem->widget))
499
		gtk_widget_map (witem->widget);
500
}
501
502
static void
503
foo_canvas_widget_unmap (FooCanvasItem *item)
504
{
505
	FooCanvasWidget *witem = FOO_CANVAS_WIDGET (item);
506
	if (parent_class->unmap)
507
		(* parent_class->unmap) (item);
508
	gtk_widget_unmap (witem->widget);
487
}
509
}
488
510
489
static double
511
static double
(-)src/cut-n-paste-code/foocanvas/libfoocanvas/foo-canvas.c (-4 / +4 lines)
Lines 1232-1245 foo_canvas_group_class_init (FooCanvasGr Link Here
1232
				      _("X"),
1232
				      _("X"),
1233
				      _("X"),
1233
				      _("X"),
1234
				      -G_MAXDOUBLE, G_MAXDOUBLE, 0.0,
1234
				      -G_MAXDOUBLE, G_MAXDOUBLE, 0.0,
1235
				      (G_PARAM_READABLE | G_PARAM_WRITABLE)));
1235
				      G_PARAM_READWRITE));
1236
	g_object_class_install_property
1236
	g_object_class_install_property
1237
		(gobject_class, GROUP_PROP_Y,
1237
		(gobject_class, GROUP_PROP_Y,
1238
		 g_param_spec_double ("y",
1238
		 g_param_spec_double ("y",
1239
				      _("Y"),
1239
				      _("Y"),
1240
				      _("Y"),
1240
				      _("Y"),
1241
				      -G_MAXDOUBLE, G_MAXDOUBLE, 0.0,
1241
				      -G_MAXDOUBLE, G_MAXDOUBLE, 0.0,
1242
				      (G_PARAM_READABLE | G_PARAM_WRITABLE)));
1242
				      G_PARAM_READWRITE));
1243
1243
1244
	object_class->destroy = foo_canvas_group_destroy;
1244
	object_class->destroy = foo_canvas_group_destroy;
1245
1245
Lines 3965-3977 foo_canvas_item_class_init (FooCanvasIte Link Here
3965
		(gobject_class, ITEM_PROP_PARENT,
3965
		(gobject_class, ITEM_PROP_PARENT,
3966
		 g_param_spec_object ("parent", NULL, NULL,
3966
		 g_param_spec_object ("parent", NULL, NULL,
3967
				      FOO_TYPE_CANVAS_ITEM,
3967
				      FOO_TYPE_CANVAS_ITEM,
3968
				      (G_PARAM_READABLE | G_PARAM_WRITABLE)));
3968
				      G_PARAM_READWRITE));
3969
3969
3970
	g_object_class_install_property
3970
	g_object_class_install_property
3971
		(gobject_class, ITEM_PROP_VISIBLE,
3971
		(gobject_class, ITEM_PROP_VISIBLE,
3972
		 g_param_spec_boolean ("visible", NULL, NULL,
3972
		 g_param_spec_boolean ("visible", NULL, NULL,
3973
				      TRUE,
3973
				      TRUE,
3974
				      (G_PARAM_READABLE | G_PARAM_WRITABLE)));
3974
				      G_PARAM_READWRITE));
3975
3975
3976
	item_signals[ITEM_EVENT] =
3976
	item_signals[ITEM_EVENT] =
3977
		g_signal_new ("event",
3977
		g_signal_new ("event",
(-)src/cut-n-paste-code/goffice/graph/gog-object-xml.c (+1 lines)
Lines 497-502 gog_object_new_from_xml (GogObject *pare Link Here
497
			res = g_object_new (type, NULL);
497
			res = g_object_new (type, NULL);
498
		xmlFree (type_name);
498
		xmlFree (type_name);
499
		explicitly_typed_role = TRUE;
499
		explicitly_typed_role = TRUE;
500
		g_return_val_if_fail (res != NULL, NULL);
500
	}
501
	}
501
	role = xmlGetProp (node, (xmlChar const *) "role");
502
	role = xmlGetProp (node, (xmlChar const *) "role");
502
	if (role == NULL) {
503
	if (role == NULL) {
(-)src/cut-n-paste-code/goffice/graph/plugins/plot_barcol/gog-1.5d.c (-1 / +2 lines)
Lines 91-96 gog_plot1_5d_set_property (GObject *obj, Link Here
91
		if ((gog_1_5d->in_3d != 0) == (tmp != 0))
91
		if ((gog_1_5d->in_3d != 0) == (tmp != 0))
92
			return;
92
			return;
93
		gog_1_5d->in_3d = tmp;
93
		gog_1_5d->in_3d = tmp;
94
		break;
94
	}
95
	}
95
96
96
	default: G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, param_id, pspec);
97
	default: G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, param_id, pspec);
Lines 324-330 gog_plot1_5d_class_init (GogPlotClass *p Link Here
324
			"How to group multiple series, normal, stacked, as_percentage",
325
			"How to group multiple series, normal, stacked, as_percentage",
325
			"normal", G_PARAM_READWRITE | GOG_PARAM_PERSISTENT));
326
			"normal", G_PARAM_READWRITE | GOG_PARAM_PERSISTENT));
326
	g_object_class_install_property (gobject_klass, GOG_1_5D_PROP_IN_3D,
327
	g_object_class_install_property (gobject_klass, GOG_1_5D_PROP_IN_3D,
327
		g_param_spec_boolean ("in_3d", "in_3d",
328
		g_param_spec_boolean ("in-3d", "in-3d",
328
			"Place holder to all us to round trip pseudo 3d state",
329
			"Place holder to all us to round trip pseudo 3d state",
329
			FALSE, G_PARAM_READWRITE | GOG_PARAM_PERSISTENT));
330
			FALSE, G_PARAM_READWRITE | GOG_PARAM_PERSISTENT));
330
331
(-)src/cut-n-paste-code/goffice/gui-utils/go-action-combo-text.c (-1 / +63 lines)
Lines 78-88 struct _GOActionComboText { Link Here
78
	GSList		*elements;
78
	GSList		*elements;
79
	char const 	*largest_elem;
79
	char const 	*largest_elem;
80
	char *entry_val;
80
	char *entry_val;
81
	gboolean	 case_sensitive;
81
};
82
};
82
typedef struct {
83
typedef struct {
83
	GtkActionClass	base;
84
	GtkActionClass	base;
84
} GOActionComboTextClass;
85
} GOActionComboTextClass;
85
86
87
enum {
88
	PROP_0,
89
	PROP_CASE_SENSITIVE
90
};
91
86
static GObjectClass *combo_text_parent;
92
static GObjectClass *combo_text_parent;
87
93
88
static void
94
static void
Lines 107-112 go_action_combo_disconnect_proxy (GtkAct Link Here
107
}
113
}
108
#endif
114
#endif
109
115
116
static gint
117
g_strcase_equal (gconstpointer s1, gconstpointer s2)
118
{
119
	gchar *a2 = g_utf8_casefold ((const gchar*) s1, -1);
120
	gchar *b2 = g_utf8_casefold ((const gchar*) s2, -1);
121
	gint res = g_utf8_collate (a2, b2);
122
	g_free (a2);
123
	g_free (b2);
124
	return !res;
125
}
126
110
static gboolean
127
static gboolean
111
cb_entry_changed (GoComboText *ct, char const *text, GOActionComboText *taction)
128
cb_entry_changed (GoComboText *ct, char const *text, GOActionComboText *taction)
112
{
129
{
Lines 123-129 go_action_combo_create_tool_item (GtkAct Link Here
123
	GSList *ptr;
140
	GSList *ptr;
124
	int tmp, w = -1;
141
	int tmp, w = -1;
125
142
126
	tool->combo = (GoComboText *)go_combo_text_new (NULL);
143
	tool->combo = (GoComboText *)go_combo_text_new (taction->case_sensitive ? NULL : g_strcase_equal);
127
	if (taction->largest_elem != NULL)
144
	if (taction->largest_elem != NULL)
128
		w = gnm_measure_string (
145
		w = gnm_measure_string (
129
			gtk_widget_get_pango_context (GTK_WIDGET (tool->combo)),
146
			gtk_widget_get_pango_context (GTK_WIDGET (tool->combo)),
Lines 163-168 go_action_combo_text_finalize (GObject * Link Here
163
{
180
{
164
	combo_text_parent->finalize (obj);
181
	combo_text_parent->finalize (obj);
165
}
182
}
183
184
static void
185
go_action_combo_text_set_property (GObject      *object,
186
				   guint         prop_id,
187
				   GValue const *value,
188
				   GParamSpec   *pspec)
189
{
190
	GOActionComboText *taction = GO_ACTION_COMBO_TEXT (object);
191
192
	switch (prop_id) {
193
	case PROP_CASE_SENSITIVE:
194
		taction->case_sensitive = g_value_get_boolean (value);
195
		break;
196
	default:
197
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
198
	}
199
}
200
201
static void
202
go_action_combo_text_get_property (GObject      *object,
203
		  guint         prop_id,
204
		  GValue       *value,
205
		  GParamSpec   *pspec)
206
{
207
	GOActionComboText *taction = GO_ACTION_COMBO_TEXT (object);
208
209
	switch (prop_id) {
210
	case PROP_CASE_SENSITIVE:
211
		g_value_set_boolean (value, taction->case_sensitive);
212
		break;
213
	default:
214
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
215
	}
216
}
217
166
static void
218
static void
167
go_action_combo_text_class_init (GtkActionClass *gtk_act_klass)
219
go_action_combo_text_class_init (GtkActionClass *gtk_act_klass)
168
{
220
{
Lines 177-182 go_action_combo_text_class_init (GtkActi Link Here
177
	gtk_act_klass->connect_proxy	= go_action_combo_stack_connect_proxy;
229
	gtk_act_klass->connect_proxy	= go_action_combo_stack_connect_proxy;
178
	gtk_act_klass->disconnect_proxy = go_action_combo_stack_disconnect_proxy;
230
	gtk_act_klass->disconnect_proxy = go_action_combo_stack_disconnect_proxy;
179
#endif
231
#endif
232
233
	gobject_klass->set_property	= go_action_combo_text_set_property;
234
	gobject_klass->get_property	= go_action_combo_text_get_property;
235
236
	g_object_class_install_property (gobject_klass,
237
		PROP_CASE_SENSITIVE,
238
		g_param_spec_boolean ("case-sensitive", _("Case Sensitive"),
239
			_("Should the text comparasion be case sensitive"),
240
			TRUE,
241
			G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
180
}
242
}
181
243
182
GSF_CLASS (GOActionComboText, go_action_combo_text,
244
GSF_CLASS (GOActionComboText, go_action_combo_text,
(-)src/cut-n-paste-code/goffice/gui-utils/go-combo-text.c (-1 lines)
Lines 187-193 go_combo_text_init (GoComboText *ct) Link Here
187
	ct->rows = 0;
187
	ct->rows = 0;
188
	ct->entry = gtk_entry_new ();
188
	ct->entry = gtk_entry_new ();
189
	ct->list = gtk_tree_view_new ();
189
	ct->list = gtk_tree_view_new ();
190
	g_object_set (G_OBJECT (ct->list), NULL);
191
	gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (ct->list), FALSE);
190
	gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (ct->list), FALSE);
192
	store = gtk_list_store_new (1, G_TYPE_STRING);
191
	store = gtk_list_store_new (1, G_TYPE_STRING);
193
	gtk_tree_view_set_model (GTK_TREE_VIEW (ct->list), GTK_TREE_MODEL (store));
192
	gtk_tree_view_set_model (GTK_TREE_VIEW (ct->list), GTK_TREE_MODEL (store));
(-)src/dialogs/dialog-autofilter.c (-8 / +14 lines)
Lines 92-103 map_op (AutoFilterState *state, GnmFilte Link Here
92
92
93
	case 7:
93
	case 7:
94
	case 8: *op = (i == 8) ? GNM_FILTER_OP_NOT_EQUAL : GNM_FILTER_OP_EQUAL;
94
	case 8: *op = (i == 8) ? GNM_FILTER_OP_NOT_EQUAL : GNM_FILTER_OP_EQUAL;
95
		v = value_new_string_nocopy (g_strconcat ("*", txt, NULL));
95
		v = value_new_string_nocopy (g_strconcat (txt, "*", NULL));
96
		break;
96
		break;
97
97
98
	case 9:
98
	case 9:
99
	case 10: *op = (i == 10) ? GNM_FILTER_OP_NOT_EQUAL : GNM_FILTER_OP_EQUAL;
99
	case 10: *op = (i == 10) ? GNM_FILTER_OP_NOT_EQUAL : GNM_FILTER_OP_EQUAL;
100
		v = value_new_string_nocopy (g_strconcat (txt, "*", NULL));
100
		v = value_new_string_nocopy (g_strconcat ("*", txt, NULL));
101
		break;
101
		break;
102
102
103
	case 11:
103
	case 11:
Lines 187-192 init_operator (AutoFilterState *state, G Link Here
187
	       char const *op_widget, char const *val_widget)
187
	       char const *op_widget, char const *val_widget)
188
{
188
{
189
	GtkWidget *w = glade_xml_get_widget (state->gui, op_widget);
189
	GtkWidget *w = glade_xml_get_widget (state->gui, op_widget);
190
	char const *str = v ? value_peek_string (v) : NULL;
191
	char *content = NULL;
190
	int i;
192
	int i;
191
193
192
	switch (op) {
194
	switch (op) {
Lines 201-223 init_operator (AutoFilterState *state, G Link Here
201
	};
203
	};
202
204
203
	if (v != NULL && v->type == VALUE_STRING && (i == 1 || i == 2)) {
205
	if (v != NULL && v->type == VALUE_STRING && (i == 1 || i == 2)) {
204
		char const *str = v->v_str.val->str;
205
		unsigned const len = strlen (str);
206
		unsigned const len = strlen (str);
207
206
		/* there needs to be at least 1 letter */
208
		/* there needs to be at least 1 letter */
207
		gboolean starts = (len > 1 && str[0] == '*');
209
		int ends = (len > 1 && str[0] == '*') ? 1 : 0; /* as a bool and offset */
208
		gboolean ends   = (len > 1 && str[len-1] == '*' && str[len-2] != '~');
209
210
210
		if (starts)
211
		if (len > 1 && str[len-1] == '*' && str[len-2] != '~') {
212
			content = g_strdup (str + ends);
213
			content[len - ends - 1] = '\0';
211
			i += (ends ? 10 : 6);
214
			i += (ends ? 10 : 6);
212
		else if (ends)
215
		} else if (ends) {
216
			str += 1;
213
			i += 8;
217
			i += 8;
214
	}
218
	}
219
	}
215
	gtk_combo_box_set_active (GTK_COMBO_BOX (w), i);
220
	gtk_combo_box_set_active (GTK_COMBO_BOX (w), i);
216
221
217
	if (v != NULL) {
222
	if (v != NULL) {
218
		w = glade_xml_get_widget (state->gui, val_widget);
223
		w = glade_xml_get_widget (state->gui, val_widget);
219
		gtk_entry_set_text (GTK_ENTRY (w), value_peek_string (v));
224
		gtk_entry_set_text (GTK_ENTRY (w), content ? content : str);
220
	}
225
	}
226
	g_free (content);
221
}
227
}
222
228
223
void
229
void
(-)src/dialogs/dialog-function-select.c (-1 / +1 lines)
Lines 116-122 dialog_function_write_recent_func (Funct Link Here
116
			(gconf_value_list, g_strdup (gnm_func_get_name (rec_funcs->data)));
116
			(gconf_value_list, g_strdup (gnm_func_get_name (rec_funcs->data)));
117
	}
117
	}
118
	gnm_gconf_set_recent_funcs (gconf_value_list);
118
	gnm_gconf_set_recent_funcs (gconf_value_list);
119
	go_conf_sync ();
119
	go_conf_sync (NULL);
120
}
120
}
121
121
122
122
(-)src/dialogs/dialog-paste-special.c (-1 / +1 lines)
Lines 193-199 dialog_paste_special (WorkbookControlGUI Link Here
193
	state = g_new0 (PasteSpecialState, 1);
193
	state = g_new0 (PasteSpecialState, 1);
194
	state->wbcg   = wbcg;
194
	state->wbcg   = wbcg;
195
	state->dialog = GTK_DIALOG (tmp);
195
	state->dialog = GTK_DIALOG (tmp);
196
	gtk_dialog_set_default_response (state->dialog, GTK_RESPONSE_CANCEL);
196
	gtk_dialog_set_default_response (state->dialog, GTK_RESPONSE_OK);
197
197
198
	f1  = gtk_frame_new (_("Paste type"));
198
	f1  = gtk_frame_new (_("Paste type"));
199
	f1v = gtk_vbox_new (TRUE, 0);
199
	f1v = gtk_vbox_new (TRUE, 0);
(-)src/dialogs/dialog-preferences.c (-76 / +104 lines)
Lines 74-79 typedef struct { Link Here
74
	GtkTreeStore    *store;
74
	GtkTreeStore    *store;
75
	GtkTreeView     *view;
75
	GtkTreeView     *view;
76
	Workbook	*wb;
76
	Workbook	*wb;
77
	GOConfNode	*root;
77
} PrefState;
78
} PrefState;
78
79
79
typedef void (* double_conf_setter_t) (gnm_float value);
80
typedef void (* double_conf_setter_t) (gnm_float value);
Lines 125-131 dialog_pref_load_description (PrefState Link Here
125
static void
126
static void
126
dialog_pref_load_description_from_key (PrefState *state, char const *key)
127
dialog_pref_load_description_from_key (PrefState *state, char const *key)
127
{
128
{
128
	char *long_desc = go_conf_get_long_desc (key);
129
	char *long_desc = go_conf_get_long_desc (state->root, key);
129
130
130
	if (long_desc == NULL)
131
	if (long_desc == NULL)
131
		dialog_pref_load_description (state, "");
132
		dialog_pref_load_description (state, "");
Lines 136-144 dialog_pref_load_description_from_key (P Link Here
136
}
137
}
137
138
138
static void
139
static void
139
set_tip (char const *key, GtkWidget *item)
140
set_tip (GOConfNode *node, char const *key, GtkWidget *item)
140
{
141
{
141
	char *desc = go_conf_get_long_desc (key);
142
	char *desc = go_conf_get_long_desc (node, key);
142
	if (desc != NULL) {
143
	if (desc != NULL) {
143
		GtkTooltips *the_tip = gtk_tooltips_new ();
144
		GtkTooltips *the_tip = gtk_tooltips_new ();
144
		gtk_tooltips_set_tip (the_tip, item, desc, NULL);
145
		gtk_tooltips_set_tip (the_tip, item, desc, NULL);
Lines 153-162 cb_pref_notification_destroy (gpointer h Link Here
153
}
154
}
154
155
155
static void
156
static void
156
connect_notification (char const *key, GOConfMonitorFunc func,
157
connect_notification (GOConfNode *node, char const *key, GOConfMonitorFunc func,
157
		      gpointer data, GtkWidget *container)
158
		      gpointer data, GtkWidget *container)
158
{
159
{
159
	guint handle = go_conf_add_monitor (key, func, data);
160
	guint handle = go_conf_add_monitor (node, key, func, data);
160
	g_signal_connect_swapped (G_OBJECT (container), "destroy",
161
	g_signal_connect_swapped (G_OBJECT (container), "destroy",
161
		G_CALLBACK (cb_pref_notification_destroy),
162
		G_CALLBACK (cb_pref_notification_destroy),
162
		GUINT_TO_POINTER (handle));
163
		GUINT_TO_POINTER (handle));
Lines 172-197 bool_pref_widget_to_conf (GtkToggleButto Link Here
172
	setter (gtk_toggle_button_get_active (button));
173
	setter (gtk_toggle_button_get_active (button));
173
}
174
}
174
static void
175
static void
175
bool_pref_conf_to_widget (char const *key, GtkToggleButton *button)
176
bool_pref_conf_to_widget (GOConfNode *node, char const *key, GtkToggleButton *button)
176
{
177
{
177
	gboolean val_in_button = gtk_toggle_button_get_active (button);
178
	gboolean val_in_button = gtk_toggle_button_get_active (button);
178
	gboolean val_in_conf = go_conf_get_bool (key);
179
	gboolean val_in_conf = go_conf_get_bool (node, key);
179
	if ((val_in_button != FALSE) != (val_in_conf != FALSE))
180
	if ((val_in_button != FALSE) != (val_in_conf != FALSE))
180
		gtk_toggle_button_set_active (button, val_in_conf);
181
		gtk_toggle_button_set_active (button, val_in_conf);
181
}
182
}
182
static void
183
static void
183
bool_pref_create_widget (char const *key, GtkWidget *table, gint row, 
184
bool_pref_create_widget (GOConfNode *node, char const *key, GtkWidget *table,
184
			 gboolean_conf_setter_t setter, 
185
			 gint row, gboolean_conf_setter_t setter, 
185
			 char const *default_text)
186
			 char const *default_text)
186
{
187
{
187
	char *desc = go_conf_get_short_desc (key);
188
	char *desc = go_conf_get_short_desc (node, key);
188
	GtkWidget *item = gtk_check_button_new_with_label (
189
	GtkWidget *item = gtk_check_button_new_with_label (
189
		(desc != NULL) ? desc : default_text);
190
		(desc != NULL) ? desc : default_text);
190
191
191
	if (desc != NULL)
192
	if (desc != NULL)
192
		g_free (desc);
193
		g_free (desc);
193
194
194
	bool_pref_conf_to_widget (key, GTK_TOGGLE_BUTTON (item));
195
	bool_pref_conf_to_widget (node, key, GTK_TOGGLE_BUTTON (item));
195
	g_signal_connect (G_OBJECT (item),
196
	g_signal_connect (G_OBJECT (item),
196
		"toggled",
197
		"toggled",
197
		G_CALLBACK (bool_pref_widget_to_conf), (gpointer) setter);
198
		G_CALLBACK (bool_pref_widget_to_conf), (gpointer) setter);
Lines 199-207 bool_pref_create_widget (char const *key Link Here
199
		0, 2, row, row + 1,
200
		0, 2, row, row + 1,
200
		GTK_FILL | GTK_SHRINK, GTK_FILL | GTK_SHRINK, 5, 5);
201
		GTK_FILL | GTK_SHRINK, GTK_FILL | GTK_SHRINK, 5, 5);
201
202
202
	connect_notification (key, (GOConfMonitorFunc)bool_pref_conf_to_widget,
203
	connect_notification (node, key, (GOConfMonitorFunc)bool_pref_conf_to_widget,
203
			      item, table);
204
			      item, table);
204
	set_tip (key, item);
205
	set_tip (node, key, item);
205
}
206
}
206
207
207
/*************************************************************************/
208
/*************************************************************************/
Lines 215-233 int_pref_widget_to_conf (GtkSpinButton * Link Here
215
}
216
}
216
217
217
static void
218
static void
218
int_pref_conf_to_widget (char const *key, GtkSpinButton *button)
219
int_pref_conf_to_widget (GOConfNode *node, char const *key, GtkSpinButton *button)
219
{
220
{
220
	gint val_in_button = gtk_spin_button_get_value_as_int (button);
221
	gint val_in_button = gtk_spin_button_get_value_as_int (button);
221
	gint val_in_conf = go_conf_get_int (key);
222
	gint val_in_conf = go_conf_get_int (node, key);
222
	if (val_in_conf != val_in_button)
223
	if (val_in_conf != val_in_button)
223
		gtk_spin_button_set_value (button, (gdouble) val_in_conf);
224
		gtk_spin_button_set_value (button, (gdouble) val_in_conf);
224
}
225
}
225
static void
226
static void
226
int_pref_create_widget (char const *key, GtkWidget *table, gint row,
227
int_pref_create_widget (GOConfNode *node, char const *key, GtkWidget *table,
227
			gint val, gint from, gint to, gint step, 
228
			gint row, gint val, gint from, gint to, gint step, 
228
			gint_conf_setter_t setter, char const *default_text)
229
			gint_conf_setter_t setter, char const *default_text)
229
{
230
{
230
	char *desc = go_conf_get_short_desc (key);
231
	char *desc = go_conf_get_short_desc (node, key);
231
	GtkWidget *item = gtk_label_new 
232
	GtkWidget *item = gtk_label_new 
232
		((desc != NULL) ? desc : default_text);
233
		((desc != NULL) ? desc : default_text);
233
234
Lines 243-249 int_pref_create_widget (char const *key, Link Here
243
				    gtk_adjustment_new (val, from, to, step, 
244
				    gtk_adjustment_new (val, from, to, step, 
244
							step, step)),
245
							step, step)),
245
				    1, 0);
246
				    1, 0);
246
	int_pref_conf_to_widget (key, GTK_SPIN_BUTTON (item));
247
	int_pref_conf_to_widget (node, key, GTK_SPIN_BUTTON (item));
247
	g_signal_connect (G_OBJECT (item),
248
	g_signal_connect (G_OBJECT (item),
248
			  "value-changed",
249
			  "value-changed",
249
			  G_CALLBACK (int_pref_widget_to_conf), (gpointer) setter);
250
			  G_CALLBACK (int_pref_widget_to_conf), (gpointer) setter);
Lines 251-259 int_pref_create_widget (char const *key, Link Here
251
		1, 2, row, row + 1,
252
		1, 2, row, row + 1,
252
		GTK_FILL | GTK_EXPAND, GTK_FILL | GTK_SHRINK, 5, 2);
253
		GTK_FILL | GTK_EXPAND, GTK_FILL | GTK_SHRINK, 5, 2);
253
254
254
	connect_notification (key, (GOConfMonitorFunc)int_pref_conf_to_widget,
255
	connect_notification (node, key, (GOConfMonitorFunc)int_pref_conf_to_widget,
255
			      item, table);
256
			      item, table);
256
	set_tip (key, item);
257
	set_tip (node, key, item);
257
}
258
}
258
259
259
/*************************************************************************/
260
/*************************************************************************/
Lines 267-288 double_pref_widget_to_conf (GtkSpinButto Link Here
267
}
268
}
268
269
269
static void
270
static void
270
double_pref_conf_to_widget (char const *key, GtkSpinButton *button)
271
double_pref_conf_to_widget (GOConfNode *node, char const *key, GtkSpinButton *button)
271
{
272
{
272
	double val_in_button = gtk_spin_button_get_value (button);
273
	double val_in_button = gtk_spin_button_get_value (button);
273
	double val_in_conf = go_conf_get_double (key);
274
	double val_in_conf = go_conf_get_double (node, key);
274
275
275
	if (fabs (val_in_conf - val_in_button) > 1e-10) /* dead simple */
276
	if (fabs (val_in_conf - val_in_button) > 1e-10) /* dead simple */
276
		gtk_spin_button_set_value (button, val_in_conf);
277
		gtk_spin_button_set_value (button, val_in_conf);
277
}
278
}
278
static void
279
static void
279
double_pref_create_widget (char const *key, GtkWidget *table, gint row,
280
double_pref_create_widget (GOConfNode *node, char const *key, GtkWidget *table,
280
			   gnm_float val, gnm_float from, gnm_float to, 
281
			   gint row, gnm_float val, gnm_float from,gnm_float to, 
281
			   gnm_float step,
282
			   gnm_float step,
282
			   gint digits, double_conf_setter_t setter,
283
			   gint digits, double_conf_setter_t setter,
283
			   char const *default_text)
284
			   char const *default_text)
284
{
285
{
285
	char *desc = go_conf_get_short_desc (key);
286
	char *desc = go_conf_get_short_desc (node, key);
286
	GtkWidget *item = gtk_label_new (desc ? desc : default_text);
287
	GtkWidget *item = gtk_label_new (desc ? desc : default_text);
287
	
288
	
288
	if (desc != NULL)
289
	if (desc != NULL)
Lines 296-302 double_pref_create_widget (char const *k Link Here
296
	item =  gtk_spin_button_new (GTK_ADJUSTMENT (
297
	item =  gtk_spin_button_new (GTK_ADJUSTMENT (
297
				     gtk_adjustment_new (val, from, to, step, step, step)),
298
				     gtk_adjustment_new (val, from, to, step, step, step)),
298
				     1, digits);
299
				     1, digits);
299
	double_pref_conf_to_widget (key, GTK_SPIN_BUTTON (item));
300
	double_pref_conf_to_widget (node, key, GTK_SPIN_BUTTON (item));
300
	g_signal_connect (G_OBJECT (item),
301
	g_signal_connect (G_OBJECT (item),
301
			  "value-changed",
302
			  "value-changed",
302
			  G_CALLBACK (double_pref_widget_to_conf), 
303
			  G_CALLBACK (double_pref_widget_to_conf), 
Lines 305-313 double_pref_create_widget (char const *k Link Here
305
		1, 2, row, row + 1,
306
		1, 2, row, row + 1,
306
		GTK_FILL | GTK_EXPAND, GTK_FILL | GTK_SHRINK, 5, 2);
307
		GTK_FILL | GTK_EXPAND, GTK_FILL | GTK_SHRINK, 5, 2);
307
308
308
	connect_notification (key, (GOConfMonitorFunc)double_pref_conf_to_widget,
309
	connect_notification (node, key, (GOConfMonitorFunc)double_pref_conf_to_widget,
309
			      item, table);
310
			      item, table);
310
	set_tip (key, item);
311
	set_tip (node, key, item);
311
}
312
}
312
313
313
314
Lines 324-340 pref_font_page_open (PrefState *state, G Link Here
324
}
325
}
325
326
326
static void
327
static void
327
cb_pref_font_set_fonts (char const *key, GtkWidget *page)
328
cb_pref_font_set_fonts (GOConfNode *node, char const *key, GtkWidget *page)
328
{
329
{
329
	if (key == NULL || 0 == strcmp (key, GNM_CONF_FONT_NAME))
330
	if (!key || g_str_has_suffix (key, GNM_CONF_FONT_NAME))
330
		font_selector_set_name (FONT_SELECTOR (page),
331
		font_selector_set_name (FONT_SELECTOR (page),
331
			gnm_app_prefs->default_font.name);
332
			gnm_app_prefs->default_font.name);
332
	if (key == NULL || 0 == strcmp (key, GNM_CONF_FONT_SIZE))
333
	if (!key || g_str_has_suffix (key, GNM_CONF_FONT_SIZE))
333
		font_selector_set_points (FONT_SELECTOR (page),
334
		font_selector_set_points (FONT_SELECTOR (page),
334
			gnm_app_prefs->default_font.size);
335
			gnm_app_prefs->default_font.size);
335
	if (key == NULL ||
336
	if (!key ||
336
	    0 == strcmp (key, GNM_CONF_FONT_BOLD) ||
337
	    g_str_has_suffix (key, GNM_CONF_FONT_BOLD) ||
337
	    0 == strcmp (key, GNM_CONF_FONT_ITALIC))
338
	    g_str_has_suffix (key, GNM_CONF_FONT_ITALIC))
338
		font_selector_set_style (FONT_SELECTOR (page),
339
		font_selector_set_style (FONT_SELECTOR (page),
339
			gnm_app_prefs->default_font.is_bold,
340
			gnm_app_prefs->default_font.is_bold,
340
			gnm_app_prefs->default_font.is_italic);
341
			gnm_app_prefs->default_font.is_italic);
Lines 367-375 pref_font_initializer (PrefState *state, Link Here
367
{
368
{
368
	GtkWidget *page = font_selector_new ();
369
	GtkWidget *page = font_selector_new ();
369
370
370
	cb_pref_font_set_fonts (NULL, page);
371
	cb_pref_font_set_fonts (NULL, NULL, page);
371
372
372
	connect_notification (GNM_CONF_FONT_DIRECTORY,
373
	connect_notification (state->root, GNM_CONF_FONT_DIR,
373
		(GOConfMonitorFunc) cb_pref_font_set_fonts,
374
		(GOConfMonitorFunc) cb_pref_font_set_fonts,
374
		page, page);
375
		page, page);
375
	g_signal_connect (G_OBJECT (page),
376
	g_signal_connect (G_OBJECT (page),
Lines 394-416 pref_font_hf_page_open (PrefState *state Link Here
394
}
395
}
395
396
396
static void
397
static void
397
cb_pref_font_hf_set_fonts (char const *key, GtkWidget *page)
398
cb_pref_font_hf_set_fonts (GOConfNode *node, char const *key, GtkWidget *page)
398
{
399
{
399
	if (key == NULL || 0 == strcmp (key, PRINTSETUP_GCONF_HF_FONT_NAME)) {
400
	node = gnm_conf_get_root ();
400
		char *name = go_conf_load_string (PRINTSETUP_GCONF_HF_FONT_NAME);
401
	if (!key ||
402
	    g_str_has_suffix (key, PRINTSETUP_GCONF_HF_FONT_NAME)) {
403
		gchar *name = go_conf_load_string (
404
			node, PRINTSETUP_GCONF_DIR "/" PRINTSETUP_GCONF_HF_FONT_NAME);
401
		font_selector_set_name (FONT_SELECTOR (page), name);
405
		font_selector_set_name (FONT_SELECTOR (page), name);
402
		g_free (name);
406
		g_free (name);
403
	}
407
	}
404
	if (key == NULL || 0 == strcmp (key, PRINTSETUP_GCONF_HF_FONT_SIZE))
408
	if (!key ||
409
	    g_str_has_suffix (key, PRINTSETUP_GCONF_HF_FONT_SIZE))
405
		font_selector_set_points (FONT_SELECTOR (page),
410
		font_selector_set_points (FONT_SELECTOR (page),
406
			go_conf_get_double (PRINTSETUP_GCONF_HF_FONT_SIZE));
411
			go_conf_get_double (
407
412
				node, PRINTSETUP_GCONF_DIR "/" PRINTSETUP_GCONF_HF_FONT_SIZE));
408
	if (key == NULL ||
413
	if (!key ||
409
	    0 == strcmp (key, PRINTSETUP_GCONF_HF_FONT_BOLD) ||
414
	    g_str_has_suffix (key, PRINTSETUP_GCONF_HF_FONT_BOLD) ||
410
	    0 == strcmp (key, PRINTSETUP_GCONF_HF_FONT_ITALIC))
415
	    g_str_has_suffix (key, PRINTSETUP_GCONF_HF_FONT_ITALIC))
411
		font_selector_set_style (FONT_SELECTOR (page),
416
		font_selector_set_style (FONT_SELECTOR (page),
412
			go_conf_get_bool (PRINTSETUP_GCONF_HF_FONT_BOLD),
417
			go_conf_get_bool (
413
			go_conf_get_bool (PRINTSETUP_GCONF_HF_FONT_ITALIC));
418
				node, PRINTSETUP_GCONF_DIR "/" PRINTSETUP_GCONF_HF_FONT_BOLD),
419
			go_conf_get_bool (
420
				node, PRINTSETUP_GCONF_DIR "/" PRINTSETUP_GCONF_HF_FONT_ITALIC));
414
}
421
}
415
422
416
static gboolean
423
static gboolean
Lines 429-436 pref_font_hf_initializer (PrefState *sta Link Here
429
{
436
{
430
	GtkWidget *page = font_selector_new ();
437
	GtkWidget *page = font_selector_new ();
431
438
432
	cb_pref_font_hf_set_fonts (NULL, page);
439
	cb_pref_font_hf_set_fonts (state->root, NULL, page);
433
	connect_notification (PRINTSETUP_GCONF_DIRECTORY,
440
	connect_notification (state->root, PRINTSETUP_GCONF_DIR,
434
		(GOConfMonitorFunc) cb_pref_font_hf_set_fonts,
441
		(GOConfMonitorFunc) cb_pref_font_hf_set_fonts,
435
		page, page);
442
		page, page);
436
	g_signal_connect (G_OBJECT (page),
443
	g_signal_connect (G_OBJECT (page),
Lines 463-485 pref_undo_page_initializer (PrefState *s Link Here
463
{
470
{
464
	GtkWidget *page = gtk_table_new (4, 2, FALSE);
471
	GtkWidget *page = gtk_table_new (4, 2, FALSE);
465
	gint row = 0;
472
	gint row = 0;
473
	GOConfNode *node;
466
474
467
	int_pref_create_widget (GNM_CONF_UNDO_MAX_DESCRIPTOR_WIDTH,
475
	node = go_conf_get_node (state->root, GNM_CONF_UNDO_DIR);
476
	int_pref_create_widget (node, GNM_CONF_UNDO_MAX_DESCRIPTOR_WIDTH,
468
				page, row++, 5, 5, 200, 1, 
477
				page, row++, 5, 5, 200, 1, 
469
				gnm_gconf_set_max_descriptor_width,
478
				gnm_gconf_set_max_descriptor_width,
470
				_("Length of Undo Descriptors"));
479
				_("Length of Undo Descriptors"));
471
	int_pref_create_widget (GNM_CONF_UNDO_SIZE,
480
	int_pref_create_widget (node, GNM_CONF_UNDO_SIZE,
472
				page, row++, 1000, 0, 30000, 100, 
481
				page, row++, 1000, 0, 30000, 100, 
473
				gnm_gconf_set_undo_size,
482
				gnm_gconf_set_undo_size,
474
				_("Maximal Undo Size"));
483
				_("Maximal Undo Size"));
475
	int_pref_create_widget (GNM_CONF_UNDO_MAXNUM,
484
	int_pref_create_widget (node, GNM_CONF_UNDO_MAXNUM,
476
				page, row++, 20, 1, 200, 1, 
485
				page, row++, 20, 1, 200, 1, 
477
				gnm_gconf_set_undo_max_number,
486
				gnm_gconf_set_undo_max_number,
478
				_("Number of Undo Items"));
487
				_("Number of Undo Items"));
479
	bool_pref_create_widget (GNM_CONF_UNDO_SHOW_SHEET_NAME,
488
	bool_pref_create_widget (node, GNM_CONF_UNDO_SHOW_SHEET_NAME,
480
				 page, row++, 
489
				 page, row++, 
481
				 gnm_gconf_set_show_sheet_name,
490
				 gnm_gconf_set_show_sheet_name,
482
				_("Show Sheet Name in Undo List"));
491
				_("Show Sheet Name in Undo List"));
492
	go_conf_free_node (node);
483
493
484
	gtk_widget_show_all (page);
494
	gtk_widget_show_all (page);
485
	return page;
495
	return page;
Lines 508-530 pref_sort_page_initializer (PrefState *s Link Here
508
{
518
{
509
	GtkWidget *page = gtk_table_new (3, 2, FALSE);
519
	GtkWidget *page = gtk_table_new (3, 2, FALSE);
510
	gint row = 0;
520
	gint row = 0;
521
	GOConfNode *node;
511
522
512
	int_pref_create_widget (GNM_CONF_SORT_DIALOG_MAX_INITIAL,
523
	node = go_conf_get_node (state->root, GNM_CONF_SORT_DIR);
524
	int_pref_create_widget (node, GNM_CONF_SORT_DIALOG_MAX_INITIAL,
513
				page, row++, 10, 0, 50, 1, 
525
				page, row++, 10, 0, 50, 1, 
514
				gnm_gconf_set_sort_dialog_max_initial,
526
				gnm_gconf_set_sort_dialog_max_initial,
515
				_("Number of Automatic Clauses"));
527
				_("Number of Automatic Clauses"));
516
	bool_pref_create_widget (GNM_CONF_SORT_DEFAULT_RETAIN_FORM,
528
	bool_pref_create_widget (node, GNM_CONF_SORT_DEFAULT_RETAIN_FORM,
517
				 page, row++, 
529
				 page, row++, 
518
				 gnm_gconf_set_sort_retain_form,
530
				 gnm_gconf_set_sort_retain_form,
519
				 _("Sorting Preserves Formats"));
531
				 _("Sorting Preserves Formats"));
520
	bool_pref_create_widget (GNM_CONF_SORT_DEFAULT_BY_CASE,
532
	bool_pref_create_widget (node, GNM_CONF_SORT_DEFAULT_BY_CASE,
521
				 page, row++, 
533
				 page, row++, 
522
				 gnm_gconf_set_sort_by_case,
534
				 gnm_gconf_set_sort_by_case,
523
				 _("Sorting is Case-Sensitive"));
535
				 _("Sorting is Case-Sensitive"));
524
	bool_pref_create_widget (GNM_CONF_SORT_DEFAULT_ASCENDING,
536
	bool_pref_create_widget (node, GNM_CONF_SORT_DEFAULT_ASCENDING,
525
				 page, row++, 
537
				 page, row++, 
526
				 gnm_gconf_set_sort_ascending,
538
				 gnm_gconf_set_sort_ascending,
527
				 _("Sort Ascending"));
539
				 _("Sort Ascending"));
540
	go_conf_free_node (node);
528
541
529
	gtk_widget_show_all (page);
542
	gtk_widget_show_all (page);
530
	return page;
543
	return page;
Lines 553-583 pref_window_page_initializer (PrefState Link Here
553
{
566
{
554
	GtkWidget *page = gtk_table_new (4, 2, FALSE);
567
	GtkWidget *page = gtk_table_new (4, 2, FALSE);
555
	gint row = 0;
568
	gint row = 0;
569
	GOConfNode *node;
556
570
557
	double_pref_create_widget (GNM_CONF_GUI_WINDOW_Y,
571
	node = go_conf_get_node (state->root, GNM_CONF_GUI_DIR);
572
	double_pref_create_widget (node, GNM_CONF_GUI_WINDOW_Y,
558
				   page, row++, 0.75, 0.25, 1, 0.05, 2, 
573
				   page, row++, 0.75, 0.25, 1, 0.05, 2, 
559
				   gnm_gconf_set_gui_window_y,
574
				   gnm_gconf_set_gui_window_y,
560
				   _("Default Vertical Window Size"));
575
				   _("Default Vertical Window Size"));
561
	double_pref_create_widget (GNM_CONF_GUI_WINDOW_X,
576
	double_pref_create_widget (node, GNM_CONF_GUI_WINDOW_X,
562
				   page, row++, 0.75, 0.25, 1, 0.05, 2, 
577
				   page, row++, 0.75, 0.25, 1, 0.05, 2, 
563
				   gnm_gconf_set_gui_window_x,
578
				   gnm_gconf_set_gui_window_x,
564
				   _("Default Horizontal Window Size"));
579
				   _("Default Horizontal Window Size"));
565
	double_pref_create_widget (GNM_CONF_GUI_ZOOM,
580
	double_pref_create_widget (node, GNM_CONF_GUI_ZOOM,
566
				   page, row++, 1.00, 0.10, 5.00, 0.05, 2, 
581
				   page, row++, 1.00, 0.10, 5.00, 0.05, 2, 
567
				   gnm_gconf_set_gui_zoom,
582
				   gnm_gconf_set_gui_zoom,
568
				   _("Default Zoom Factor"));
583
				   _("Default Zoom Factor"));
569
	int_pref_create_widget (GNM_CONF_WORKBOOK_NSHEETS,
584
	int_pref_create_widget (state->root, GNM_CONF_WORKBOOK_NSHEETS,
570
				page, row++, 1, 1, 64, 1, 
585
				page, row++, 1, 1, 64, 1, 
571
				gnm_gconf_set_workbook_nsheets,
586
				gnm_gconf_set_workbook_nsheets,
572
				_("Default Number of Sheets"));
587
				_("Default Number of Sheets"));
573
	bool_pref_create_widget (GNM_CONF_GUI_ED_TRANSITION_KEYS,
588
	bool_pref_create_widget (node, GNM_CONF_GUI_ED_TRANSITION_KEYS,
574
				 page, row++, 
589
				 page, row++, 
575
				 gnm_gconf_set_gui_transition_keys,
590
				 gnm_gconf_set_gui_transition_keys,
576
				 _("Transition Keys"));
591
				 _("Transition Keys"));
577
	bool_pref_create_widget (GNM_CONF_GUI_ED_LIVESCROLLING,
592
	bool_pref_create_widget (node, GNM_CONF_GUI_ED_LIVESCROLLING,
578
				 page, row++, 
593
				 page, row++, 
579
				 gnm_gconf_set_gui_livescrolling,
594
				 gnm_gconf_set_gui_livescrolling,
580
				 _("Live Scrolling"));
595
				 _("Live Scrolling"));
596
	go_conf_free_node (node);
581
597
582
	gtk_widget_show_all (page);
598
	gtk_widget_show_all (page);
583
	return page;
599
	return page;
Lines 605-633 pref_file_page_initializer (PrefState *s Link Here
605
{
621
{
606
	GtkWidget *page = gtk_table_new (2, 2, FALSE);
622
	GtkWidget *page = gtk_table_new (2, 2, FALSE);
607
	gint row = 0;
623
	gint row = 0;
624
	GOConfNode *node;
608
625
609
	int_pref_create_widget (GNM_CONF_FILE_HISTORY_N,
626
	node = go_conf_get_node (state->root, GNM_CONF_FILE_DIR);
627
	int_pref_create_widget (node, GNM_CONF_FILE_HISTORY_N,
610
				page, row++, 4, 0, 40, 1, 
628
				page, row++, 4, 0, 40, 1, 
611
				gnm_gconf_set_file_history_number,
629
				gnm_gconf_set_file_history_number,
612
				_("Length of File History"));
630
				_("Length of File History"));
613
	int_pref_create_widget (GNM_CONF_XML_COMPRESSION,
631
	int_pref_create_widget (state->root, GNM_CONF_XML_COMPRESSION,
614
				page, row++, 9, 0, 9, 1, 
632
				page, row++, 9, 0, 9, 1, 
615
				gnm_gconf_set_xml_compression,
633
				gnm_gconf_set_xml_compression,
616
				_("Default Compression Level For "
634
				_("Default Compression Level For "
617
				  "Gnumeric Files"));
635
				  "Gnumeric Files"));
618
	bool_pref_create_widget (GNM_CONF_FILE_OVERWRITE_DEFAULT,
636
	bool_pref_create_widget (node, GNM_CONF_FILE_OVERWRITE_DEFAULT,
619
				 page, row++, 
637
				 page, row++, 
620
				 gnm_gconf_set_file_overwrite,
638
				 gnm_gconf_set_file_overwrite,
621
				 _("Default To Overwriting Files"));
639
				 _("Default To Overwriting Files"));
622
	bool_pref_create_widget (GNM_CONF_FILE_SINGLE_SHEET_SAVE,
640
	bool_pref_create_widget (node, GNM_CONF_FILE_SINGLE_SHEET_SAVE,
623
				 page, row++, 
641
				 page, row++, 
624
				 gnm_gconf_set_file_single_sheet_save,
642
				 gnm_gconf_set_file_single_sheet_save,
625
				 _("Warn When Exporting Into Single "
643
				 _("Warn When Exporting Into Single "
626
				   "Sheet Format"));
644
				   "Sheet Format"));
627
	bool_pref_create_widget (PLUGIN_GCONF_LATEX_USE_UTF8,
645
	bool_pref_create_widget (state->root,
646
				 PLUGIN_GCONF_LATEX "/" PLUGIN_GCONF_LATEX_USE_UTF8,
628
				 page, row++, 
647
				 page, row++, 
629
				 gnm_gconf_set_latex_use_utf8,
648
				 gnm_gconf_set_latex_use_utf8,
630
				 _("Use UTF-8 in LaTeX Export"));
649
				 _("Use UTF-8 in LaTeX Export"));
650
	go_conf_free_node (node);
631
651
632
	gtk_widget_show_all (page);
652
	gtk_widget_show_all (page);
633
	return page;
653
	return page;
Lines 655-669 pref_screen_page_initializer (PrefState Link Here
655
{
675
{
656
	GtkWidget *page = gtk_table_new (2, 2, FALSE);
676
	GtkWidget *page = gtk_table_new (2, 2, FALSE);
657
	gint row = 0;
677
	gint row = 0;
678
	GOConfNode *node;
658
679
659
	double_pref_create_widget (GNM_CONF_GUI_RES_H, page, row++,
680
	node = go_conf_get_node (state->root, GNM_CONF_GUI_DIR);
681
	double_pref_create_widget (node, GNM_CONF_GUI_RES_H, page, row++,
660
				   96, 50, 250, 1, 1, 
682
				   96, 50, 250, 1, 1, 
661
				   gnm_gconf_set_gui_resolution_h,
683
				   gnm_gconf_set_gui_resolution_h,
662
				   _("Horizontal DPI"));
684
				   _("Horizontal DPI"));
663
	double_pref_create_widget (GNM_CONF_GUI_RES_V, page, row++,
685
	double_pref_create_widget (node, GNM_CONF_GUI_RES_V, page, row++,
664
				   96, 50, 250, 1, 1, 
686
				   96, 50, 250, 1, 1, 
665
				   gnm_gconf_set_gui_resolution_v,
687
				   gnm_gconf_set_gui_resolution_v,
666
				   _("Vertical DPI"));
688
				   _("Vertical DPI"));
689
	go_conf_free_node (node);
667
690
668
	gtk_widget_show_all (page);
691
	gtk_widget_show_all (page);
669
	return page;
692
	return page;
Lines 693-708 pref_tool_page_initializer (PrefState *s Link Here
693
	GtkWidget *page = gtk_table_new (2, 2, FALSE);
716
	GtkWidget *page = gtk_table_new (2, 2, FALSE);
694
	gint row = 0;
717
	gint row = 0;
695
718
696
	int_pref_create_widget (FUNCTION_SELECT_GCONF_NUM_OF_RECENT,
719
	int_pref_create_widget (state->root,
720
				FUNCTION_SELECT_GCONF_DIR "/" FUNCTION_SELECT_GCONF_NUM_OF_RECENT,
697
				page, row++, 10, 0, 40, 1, 
721
				page, row++, 10, 0, 40, 1, 
698
				gnm_gconf_set_num_recent_functions,
722
				gnm_gconf_set_num_recent_functions,
699
				_("Maximum Length of Recently "
723
				_("Maximum Length of Recently "
700
				  "Used Functions List"));
724
				  "Used Functions List"));
701
	bool_pref_create_widget (GNM_CONF_GUI_ED_AUTOCOMPLETE,
725
	bool_pref_create_widget (state->root,
726
				 GNM_CONF_GUI_DIR "/" GNM_CONF_GUI_ED_AUTOCOMPLETE,
702
				 page, row++, 
727
				 page, row++, 
703
				 gnm_gconf_set_autocomplete,
728
				 gnm_gconf_set_autocomplete,
704
				_("Autocomplete"));
729
				_("Autocomplete"));
705
	bool_pref_create_widget (DIALOGS_GCONF_UNFOCUSED_RS,
730
	bool_pref_create_widget (state->root,
731
				 DIALOGS_GCONF_DIR "/" DIALOGS_GCONF_UNFOCUSED_RS,
706
				 page, row++, 
732
				 page, row++, 
707
				 gnm_gconf_set_unfocused_rs,
733
				 gnm_gconf_set_unfocused_rs,
708
				_("Allow Unfocused Range Selections"));
734
				_("Allow Unfocused Range Selections"));
Lines 735-741 pref_copypaste_page_initializer (PrefSta Link Here
735
	GtkWidget *page = gtk_table_new (2, 2, FALSE);
761
	GtkWidget *page = gtk_table_new (2, 2, FALSE);
736
	gint row = 0;
762
	gint row = 0;
737
763
738
	bool_pref_create_widget (GNM_CONF_CUTANDPASTE_PREFER_CLIPBOARD,
764
	bool_pref_create_widget (state->root,
765
				 GNM_CONF_CUTANDPASTE_DIR "/" GNM_CONF_CUTANDPASTE_PREFER_CLIPBOARD,
739
				 page, row++, 
766
				 page, row++, 
740
				 gnm_gconf_set_prefer_clipboard,
767
				 gnm_gconf_set_prefer_clipboard,
741
				 _("Prefer CLIPBOARD over PRIMARY selection"));
768
				 _("Prefer CLIPBOARD over PRIMARY selection"));
Lines 811-817 cb_dialog_pref_selection_changed (GtkTre Link Here
811
static gboolean
838
static gboolean
812
cb_preferences_destroy (PrefState *state)
839
cb_preferences_destroy (PrefState *state)
813
{
840
{
814
	go_conf_sync ();
841
	go_conf_sync (state->root);
815
842
816
	if (state->gui != NULL) {
843
	if (state->gui != NULL) {
817
		g_object_unref (G_OBJECT (state->gui));
844
		g_object_unref (G_OBJECT (state->gui));
Lines 870-875 dialog_preferences (WorkbookControlGUI * Link Here
870
		return;
897
		return;
871
898
872
	state = g_new0 (PrefState, 1);
899
	state = g_new0 (PrefState, 1);
900
	state->root = gnm_conf_get_root ();
873
	state->gui = gui;
901
	state->gui = gui;
874
	state->dialog     = glade_xml_get_widget (gui, "preferences");
902
	state->dialog     = glade_xml_get_widget (gui, "preferences");
875
	state->notebook   = glade_xml_get_widget (gui, "notebook");
903
	state->notebook   = glade_xml_get_widget (gui, "notebook");
(-)src/dialogs/dialog-solver.c (-36 / +41 lines)
Lines 178-184 is_hom_row_or_col_ref (GnmExprEntry *ent Link Here
178
	return res;
178
	return res;
179
}
179
}
180
180
181
static void
181
static gboolean
182
dialog_set_sec_button_sensitivity (G_GNUC_UNUSED GtkWidget *dummy,
182
dialog_set_sec_button_sensitivity (G_GNUC_UNUSED GtkWidget *dummy,
183
				   SolverState *state)
183
				   SolverState *state)
184
{
184
{
Lines 198-203 dialog_set_sec_button_sensitivity (G_GNU Link Here
198
	gtk_widget_set_sensitive (state->add_button, ready);
198
	gtk_widget_set_sensitive (state->add_button, ready);
199
	gtk_widget_set_sensitive (state->change_button, select_ready && ready);
199
	gtk_widget_set_sensitive (state->change_button, select_ready && ready);
200
	gtk_widget_set_sensitive (state->delete_button, select_ready);
200
	gtk_widget_set_sensitive (state->delete_button, select_ready);
201
202
	/* Return TRUE iff the current constraint is valid.  */
203
	return ready;
201
}
204
}
202
205
203
static void
206
static void
Lines 258-275 release_constraint (constraint_t * data) Link Here
258
static void
261
static void
259
cb_dialog_delete_clicked (G_GNUC_UNUSED GtkWidget *button, SolverState *state)
262
cb_dialog_delete_clicked (G_GNUC_UNUSED GtkWidget *button, SolverState *state)
260
{
263
{
264
	if (state->constr != NULL) {
261
	GtkTreeIter iter;
265
	GtkTreeIter iter;
262
	GtkTreeModel *store;
266
	GtkTreeModel *store;
263
	if (state->constr != NULL) {
267
264
		release_constraint (state->constr);
268
		release_constraint (state->constr);
265
		state->constr = NULL;
269
		state->constr = NULL;
266
	} else
270
267
		return;
271
		if (gtk_tree_selection_get_selected (
268
	gtk_tree_selection_get_selected (
269
		gtk_tree_view_get_selection (state->constraint_list),
272
		gtk_tree_view_get_selection (state->constraint_list),
270
		&store, &iter);
273
			    &store, &iter))
271
	gtk_list_store_remove ((GtkListStore*)store, &iter);
274
	gtk_list_store_remove ((GtkListStore*)store, &iter);
272
}
275
}
276
}
273
277
274
static  constraint_t*
278
static  constraint_t*
275
constraint_fill_row (SolverState *state, GtkListStore *store, GtkTreeIter *iter)
279
constraint_fill_row (SolverState *state, GtkListStore *store, GtkTreeIter *iter)
Lines 319-345 constraint_fill_row (SolverState *state, Link Here
319
static void
323
static void
320
cb_dialog_add_clicked (SolverState *state)
324
cb_dialog_add_clicked (SolverState *state)
321
{
325
{
326
	if (dialog_set_sec_button_sensitivity (NULL, state)) {
322
	GtkTreeIter   iter;
327
	GtkTreeIter   iter;
323
	GtkListStore *store = GTK_LIST_STORE (gtk_tree_view_get_model (state->constraint_list));
328
	GtkListStore *store = GTK_LIST_STORE (gtk_tree_view_get_model (state->constraint_list));
329
324
	gtk_list_store_append (store, &iter);
330
	gtk_list_store_append (store, &iter);
325
	constraint_fill_row (state, store, &iter);
331
	constraint_fill_row (state, store, &iter);
326
}
332
}
333
}
327
334
328
static void
335
static void
329
cb_dialog_change_clicked (GtkWidget *button, SolverState *state)
336
cb_dialog_change_clicked (GtkWidget *button, SolverState *state)
330
{
337
{
338
	if (state->constr != NULL) {
331
	GtkTreeIter iter;
339
	GtkTreeIter iter;
332
	GtkTreeModel *store;
340
	GtkTreeModel *store;
333
	if (state->constr != NULL) {
341
334
		release_constraint (state->constr);
342
		release_constraint (state->constr);
335
		state->constr = NULL;
343
		state->constr = NULL;
336
	} else
344
337
		return;
345
		if (gtk_tree_selection_get_selected (
338
	gtk_tree_selection_get_selected (
339
		gtk_tree_view_get_selection (state->constraint_list),
346
		gtk_tree_view_get_selection (state->constraint_list),
340
		&store, &iter);
347
			    &store, &iter))
341
	state->constr = constraint_fill_row (state, (GtkListStore *)store, &iter);
348
	state->constr = constraint_fill_row (state, (GtkListStore *)store, &iter);
342
}
349
}
350
}
343
351
344
static void
352
static void
345
dialog_set_main_button_sensitivity (G_GNUC_UNUSED GtkWidget *dummy,
353
dialog_set_main_button_sensitivity (G_GNUC_UNUSED GtkWidget *dummy,
Lines 528-547 check_int_constraints (GnmValue *input_r Link Here
528
{
536
{
529
	GtkTreeModel *store;
537
	GtkTreeModel *store;
530
	GtkTreeIter iter;
538
	GtkTreeIter iter;
531
	const constraint_t *a_constraint;
532
	const gchar *text;
533
539
534
	store = gtk_tree_view_get_model (state->constraint_list);
540
	store = gtk_tree_view_get_model (state->constraint_list);
535
	if (gtk_tree_model_get_iter_first (store, &iter))
541
	if (gtk_tree_model_get_iter_first (store, &iter))
536
		do {
542
		do {
543
			const constraint_t *a_constraint;
544
			gchar *text;
545
537
			gtk_tree_model_get (store, &iter, 0, &text, 1, &a_constraint, -1);
546
			gtk_tree_model_get (store, &iter, 0, &text, 1, &a_constraint, -1);
538
			if (a_constraint == NULL)
547
			if (a_constraint == NULL) {
548
				g_free (text);
539
				break;
549
				break;
550
			}
551
540
			if ((a_constraint->type != SolverINT) &&
552
			if ((a_constraint->type != SolverINT) &&
541
				(a_constraint->type != SolverBOOL))
553
			    (a_constraint->type != SolverBOOL)) {
554
				g_free (text);
542
				continue;
555
				continue;
543
			if (!global_range_contained (state->sheet, a_constraint->lhs_value, input_range))
556
			}
557
558
			if (!global_range_contained (state->sheet,
559
						     a_constraint->lhs_value,
560
						     input_range))
544
				return text;
561
				return text;
562
563
			g_free (text);
545
		} while (gtk_tree_model_iter_next (store, &iter));
564
		} while (gtk_tree_model_iter_next (store, &iter));
546
	return NULL;
565
	return NULL;
547
}
566
}
Lines 666-684 save_original_values (GSList *input_cell Link Here
666
	return ov;
685
	return ov;
667
}
686
}
668
687
669
/**
670
 * cb_destroy:
671
 * @data:
672
 * @user_data:
673
 *
674
 *
675
 **/
676
static void
677
cb_destroy (gpointer data, G_GNUC_UNUSED gpointer user_data)
678
{
679
	g_free (data);
680
}
681
682
688
683
/* Returns FALSE if the reports deleted the current sheet
689
/* Returns FALSE if the reports deleted the current sheet
684
 * and forced the dialog to die */
690
 * and forced the dialog to die */
Lines 791-797 solver_reporting (SolverState *state, So Link Here
791
}
797
}
792
798
793
static void
799
static void
794
solver_add_scenario (SolverState *state, SolverResults *res, gchar *name)
800
solver_add_scenario (SolverState *state, SolverResults *res, const gchar *name)
795
{
801
{
796
	SolverParameters *param = res->param;
802
	SolverParameters *param = res->param;
797
	GnmValue            *input_range;
803
	GnmValue            *input_range;
Lines 801-808 solver_add_scenario (SolverState *state, Link Here
801
	input_range = gnm_expr_entry_parse_as_value (state->change_cell_entry,
807
	input_range = gnm_expr_entry_parse_as_value (state->change_cell_entry,
802
						     state->sheet);
808
						     state->sheet);
803
809
804
	scenario_add_new (name, input_range, g_strdup (param->input_entry_str),
810
	scenario_add_new (name, input_range, param->input_entry_str,
805
			  g_strdup (comment), state->sheet, &scenario);
811
			  comment, state->sheet, &scenario);
806
	scenario_add (state->sheet, scenario);
812
	scenario_add (state->sheet, scenario);
807
	if (input_range != NULL)
813
	if (input_range != NULL)
808
		value_release (input_range);
814
		value_release (input_range);
Lines 957-967 cb_dialog_solve_clicked (G_GNUC_UNUSED G Link Here
957
	conv.sheet     = state->sheet;
963
	conv.sheet     = state->sheet;
958
	conv.c_listing = state->constraint_list;
964
	conv.c_listing = state->constraint_list;
959
	convert_constraint_format (&conv);
965
	convert_constraint_format (&conv);
960
	if (param->constraints != NULL) {
966
	g_slist_foreach	(param->constraints,
961
		g_slist_foreach	(param->constraints, cb_destroy, NULL);
967
			 (GFunc)solver_constraint_destroy,
968
			 NULL);
962
		g_slist_free (param->constraints);
969
		g_slist_free (param->constraints);
963
		param->constraints = NULL;
964
	}
965
	param->constraints = conv.c_list;
970
	param->constraints = conv.c_list;
966
	if (param->constraints == NULL) {
971
	if (param->constraints == NULL) {
967
		gnumeric_notice_nonmodal
972
		gnumeric_notice_nonmodal
(-)src/dialogs/dialog-stf-csv-page.c (-2 / +1 lines)
Lines 94-101 csv_page_global_change (G_GNUC_UNUSED Gt Link Here
94
	trim = parseoptions->trim_spaces;	
94
	trim = parseoptions->trim_spaces;	
95
	stf_parse_options_set_trim_spaces (parseoptions, TRIM_TYPE_NEVER);
95
	stf_parse_options_set_trim_spaces (parseoptions, TRIM_TYPE_NEVER);
96
	lines = stf_parse_general (parseoptions, lines_chunk,
96
	lines = stf_parse_general (parseoptions, lines_chunk,
97
				   pagedata->cur, pagedata->cur_end,
97
				   pagedata->cur, pagedata->cur_end);
98
				   LINE_DISPLAY_LIMIT);
99
	stf_parse_options_set_trim_spaces (parseoptions, trim);
98
	stf_parse_options_set_trim_spaces (parseoptions, trim);
100
99
101
	stf_preview_set_lines (renderdata, lines_chunk, lines);
100
	stf_preview_set_lines (renderdata, lines_chunk, lines);
(-)src/dialogs/dialog-stf-export.c (+3 lines)
Lines 162-167 cb_collect_exported_sheets (GtkTreeModel Link Here
162
		-1);
162
		-1);
163
	if (exported)
163
	if (exported)
164
		stf_export_options_sheet_list_add (state->result, sheet);
164
		stf_export_options_sheet_list_add (state->result, sheet);
165
	g_object_unref (sheet);
165
	return FALSE;
166
	return FALSE;
166
}
167
}
167
static void
168
static void
Lines 569-574 stf_export_dialog (WorkbookControlGUI *w Link Here
569
	stf_export_dialog_sheet_page_init (&state);
570
	stf_export_dialog_sheet_page_init (&state);
570
	stf_export_dialog_format_page_init (&state);
571
	stf_export_dialog_format_page_init (&state);
571
	if (state.sheets.non_empty == 0) {
572
	if (state.sheets.non_empty == 0) {
573
		gtk_widget_destroy (GTK_WIDGET (state.window));
572
		gnumeric_notice (wbcg_toplevel (wbcg),  GTK_MESSAGE_ERROR, 
574
		gnumeric_notice (wbcg_toplevel (wbcg),  GTK_MESSAGE_ERROR, 
573
				 _("This workbook does not contain any "
575
				 _("This workbook does not contain any "
574
				   "exportable content."));
576
				   "exportable content."));
Lines 589-594 stf_export_dialog (WorkbookControlGUI *w Link Here
589
				     GTK_DIALOG (state.window));
591
				     GTK_DIALOG (state.window));
590
	}
592
	}
591
	g_object_unref (G_OBJECT (state.gui));
593
	g_object_unref (G_OBJECT (state.gui));
594
	g_object_unref (state.sheets.model);
592
595
593
	return state.result;
596
	return state.result;
594
}
597
}
(-)src/dialogs/dialog-stf-fixed-page.c (-2 / +1 lines)
Lines 390-397 fixed_page_update_preview (StfDialogData Link Here
390
	trim = parseoptions->trim_spaces;
390
	trim = parseoptions->trim_spaces;
391
	stf_parse_options_set_trim_spaces (parseoptions, TRIM_TYPE_NEVER);
391
	stf_parse_options_set_trim_spaces (parseoptions, TRIM_TYPE_NEVER);
392
	lines = stf_parse_general (parseoptions, lines_chunk,
392
	lines = stf_parse_general (parseoptions, lines_chunk,
393
				   pagedata->cur, pagedata->cur_end,
393
				   pagedata->cur, pagedata->cur_end);
394
				   LINE_DISPLAY_LIMIT);
395
	stf_parse_options_set_trim_spaces (parseoptions, trim);
394
	stf_parse_options_set_trim_spaces (parseoptions, trim);
396
395
397
	stf_preview_set_lines (renderdata, lines_chunk, lines);
396
	stf_preview_set_lines (renderdata, lines_chunk, lines);
(-)src/dialogs/dialog-stf-format-page.c (-5 / +6 lines)
Lines 381-388 format_page_update_preview (StfDialogDat Link Here
381
			       stf_parse_general (pagedata->parseoptions,
381
			       stf_parse_general (pagedata->parseoptions,
382
						  lines_chunk,
382
						  lines_chunk,
383
						  pagedata->cur,
383
						  pagedata->cur,
384
						  pagedata->cur_end,
384
						  pagedata->cur_end));
385
						  LINE_DISPLAY_LIMIT));
386
385
387
	col_import_array_len_old = pagedata->format.col_import_array_len;
386
	col_import_array_len_old = pagedata->format.col_import_array_len;
388
	pagedata->format.col_import_array_len = renderdata->colcount;
387
	pagedata->format.col_import_array_len = renderdata->colcount;
Lines 628-633 stf_dialog_format_page_init (GladeXML *g Link Here
628
	pagedata->format.index         = -1;
627
	pagedata->format.index         = -1;
629
	pagedata->format.manual_change = FALSE;
628
	pagedata->format.manual_change = FALSE;
630
629
630
	/* Update widgets before connecting signals, see #333407.  */
631
	gtk_combo_box_set_active (GTK_COMBO_BOX (pagedata->format.format_trim),
632
				  0);
633
	format_page_update_column_selection (pagedata);
634
631
	/* Connect signals */
635
	/* Connect signals */
632
	pagedata->format.format_changed_handler_id = 
636
	pagedata->format.format_changed_handler_id = 
633
	     g_signal_connect (G_OBJECT (pagedata->format.format_selector),
637
	     g_signal_connect (G_OBJECT (pagedata->format.format_selector),
Lines 641-647 stf_dialog_format_page_init (GladeXML *g Link Here
641
        g_signal_connect (G_OBJECT (pagedata->format.format_trim),
645
        g_signal_connect (G_OBJECT (pagedata->format.format_trim),
642
			  "changed",
646
			  "changed",
643
			  G_CALLBACK (format_page_trim_menu_changed), pagedata);
647
			  G_CALLBACK (format_page_trim_menu_changed), pagedata);
644
	gtk_combo_box_set_active (GTK_COMBO_BOX (pagedata->format.format_trim), 0);
645
646
	format_page_update_column_selection (pagedata);
647
}
648
}
(-)src/dialogs/sheet-order.glade (-5 / +5 lines)
Lines 111-117 Link Here
111
		</widget>
111
		</widget>
112
		<packing>
112
		<packing>
113
		  <property name="padding">0</property>
113
		  <property name="padding">0</property>
114
		  <property name="expand">True</property>
114
		  <property name="expand">False</property>
115
		  <property name="fill">True</property>
115
		  <property name="fill">True</property>
116
		</packing>
116
		</packing>
117
	      </child>
117
	      </child>
Lines 126-132 Link Here
126
		</widget>
126
		</widget>
127
		<packing>
127
		<packing>
128
		  <property name="padding">0</property>
128
		  <property name="padding">0</property>
129
		  <property name="expand">True</property>
129
		  <property name="expand">False</property>
130
		  <property name="fill">True</property>
130
		  <property name="fill">True</property>
131
		</packing>
131
		</packing>
132
	      </child>
132
	      </child>
Lines 141-147 Link Here
141
		</widget>
141
		</widget>
142
		<packing>
142
		<packing>
143
		  <property name="padding">0</property>
143
		  <property name="padding">0</property>
144
		  <property name="expand">True</property>
144
		  <property name="expand">False</property>
145
		  <property name="fill">True</property>
145
		  <property name="fill">True</property>
146
		</packing>
146
		</packing>
147
	      </child>
147
	      </child>
Lines 157-163 Link Here
157
		</widget>
157
		</widget>
158
		<packing>
158
		<packing>
159
		  <property name="padding">0</property>
159
		  <property name="padding">0</property>
160
		  <property name="expand">True</property>
160
		  <property name="expand">False</property>
161
		  <property name="fill">True</property>
161
		  <property name="fill">True</property>
162
		</packing>
162
		</packing>
163
	      </child>
163
	      </child>
Lines 173-179 Link Here
173
		</widget>
173
		</widget>
174
		<packing>
174
		<packing>
175
		  <property name="padding">0</property>
175
		  <property name="padding">0</property>
176
		  <property name="expand">True</property>
176
		  <property name="expand">False</property>
177
		  <property name="fill">True</property>
177
		  <property name="fill">True</property>
178
		</packing>
178
		</packing>
179
	      </child>
179
	      </child>
(-)src/tools/Makefile.am (-1 lines)
Lines 41-44 libtools_a_SOURCES = \ Link Here
41
	tabulate.c					\
41
	tabulate.c					\
42
	tabulate.h					\
42
	tabulate.h					\
43
	tools.h
43
	tools.h
44
(-)src/tools/analysis-tools.c (+1 lines)
Lines 51-56 Link Here
51
#include "command-context.h"
51
#include "command-context.h"
52
52
53
#include <string.h>
53
#include <string.h>
54
#include <stdlib.h>
54
#include <math.h>
55
#include <math.h>
55
56
56
#undef DEBUG_ANALYSIS_TOOLS
57
#undef DEBUG_ANALYSIS_TOOLS
(-)src/tools/auto-correct.c (-22 / +32 lines)
Lines 50-62 static struct { Link Here
50
	guint notification_id;
50
	guint notification_id;
51
} autocorrect;
51
} autocorrect;
52
52
53
#define AUTOCORRECT_DIRECTORY "/apps/gnumeric/autocorrect"
53
#define AUTOCORRECT_DIRECTORY		"autocorrect"
54
#define AUTOCORRECT_INIT_CAPS		AUTOCORRECT_DIRECTORY "/init-caps"
54
#define AUTOCORRECT_INIT_CAPS		"init-caps"
55
#define AUTOCORRECT_INIT_CAPS_LIST	AUTOCORRECT_DIRECTORY "/init-caps-list"
55
#define AUTOCORRECT_INIT_CAPS_LIST	"init-caps-list"
56
#define AUTOCORRECT_FIRST_LETTER	AUTOCORRECT_DIRECTORY "/first-letter"
56
#define AUTOCORRECT_FIRST_LETTER	"first-letter"
57
#define AUTOCORRECT_FIRST_LETTER_LIST	AUTOCORRECT_DIRECTORY "/first-letter-list"
57
#define AUTOCORRECT_FIRST_LETTER_LIST	"first-letter-list"
58
#define AUTOCORRECT_NAMES_OF_DAYS	AUTOCORRECT_DIRECTORY "/names-of-days"
58
#define AUTOCORRECT_NAMES_OF_DAYS	"names-of-days"
59
#define AUTOCORRECT_REPLACE		AUTOCORRECT_DIRECTORY "/replace"
59
#define AUTOCORRECT_REPLACE		"replace"
60
60
61
static void
61
static void
62
autocorrect_clear (void)
62
autocorrect_clear (void)
Lines 68-85 autocorrect_clear (void) Link Here
68
static void
68
static void
69
autocorrect_load (void)
69
autocorrect_load (void)
70
{
70
{
71
	autocorrect.init_caps = go_conf_load_bool (AUTOCORRECT_INIT_CAPS, TRUE);
71
	GOConfNode *node = go_conf_get_node (gnm_conf_get_root (), AUTOCORRECT_DIRECTORY);
72
73
	autocorrect.init_caps = go_conf_load_bool (node, AUTOCORRECT_INIT_CAPS, TRUE);
72
	autocorrect_set_exceptions (AC_INIT_CAPS,
74
	autocorrect_set_exceptions (AC_INIT_CAPS,
73
		go_conf_load_str_list (AUTOCORRECT_INIT_CAPS_LIST));
75
		go_conf_load_str_list (node, AUTOCORRECT_INIT_CAPS_LIST));
74
	autocorrect.first_letter = go_conf_load_bool (AUTOCORRECT_FIRST_LETTER, TRUE);
76
	autocorrect.first_letter = go_conf_load_bool (node, AUTOCORRECT_FIRST_LETTER, TRUE);
75
	autocorrect_set_exceptions (AC_FIRST_LETTER,
77
	autocorrect_set_exceptions (AC_FIRST_LETTER,
76
		go_conf_load_str_list (AUTOCORRECT_FIRST_LETTER_LIST));
78
		go_conf_load_str_list (node, AUTOCORRECT_FIRST_LETTER_LIST));
77
	autocorrect.names_of_days = go_conf_load_bool (AUTOCORRECT_NAMES_OF_DAYS, TRUE);
79
	autocorrect.names_of_days = go_conf_load_bool (node, AUTOCORRECT_NAMES_OF_DAYS, TRUE);
78
	autocorrect.replace = go_conf_load_bool (AUTOCORRECT_REPLACE, TRUE);
80
	autocorrect.replace = go_conf_load_bool (node, AUTOCORRECT_REPLACE, TRUE);
81
	go_conf_free_node (node);
79
}
82
}
80
83
81
static void
84
static void
82
cb_autocorrect_update (char const *key, gpointer data)
85
cb_autocorrect_update (GOConfNode *node, gchar const *key, gpointer data)
83
{
86
{
84
	autocorrect_clear ();
87
	autocorrect_clear ();
85
	autocorrect_load ();
88
	autocorrect_load ();
Lines 88-99 cb_autocorrect_update (char const *key, Link Here
88
static void
91
static void
89
autocorrect_init (void)
92
autocorrect_init (void)
90
{
93
{
94
	GOConfNode *node;
95
91
	if (autocorrect.notification_id != 0)
96
	if (autocorrect.notification_id != 0)
92
		return;
97
		return;
93
98
94
	autocorrect_load ();
99
	autocorrect_load ();
100
	node = go_conf_get_node (gnm_conf_get_root (), AUTOCORRECT_DIRECTORY);
95
	autocorrect.notification_id = go_conf_add_monitor (
101
	autocorrect.notification_id = go_conf_add_monitor (
96
		AUTOCORRECT_DIRECTORY, &cb_autocorrect_update, NULL);
102
		node, AUTOCORRECT_DIRECTORY, &cb_autocorrect_update, NULL);
103
	go_conf_free_node (node);
97
	g_object_set_data_full (gnm_app_get_app (),
104
	g_object_set_data_full (gnm_app_get_app (),
98
		"ToolsAutoCorrect", GINT_TO_POINTER (1),
105
		"ToolsAutoCorrect", GINT_TO_POINTER (1),
99
		(GDestroyNotify) autocorrect_clear);
106
		(GDestroyNotify) autocorrect_clear);
Lines 102-120 autocorrect_init (void) Link Here
102
void
109
void
103
autocorrect_store_config (void)
110
autocorrect_store_config (void)
104
{
111
{
105
	go_conf_set_bool (AUTOCORRECT_INIT_CAPS,
112
	GOConfNode *node = go_conf_get_node (gnm_conf_get_root (), AUTOCORRECT_DIRECTORY);
113
114
	go_conf_set_bool (node, AUTOCORRECT_INIT_CAPS,
106
		autocorrect.init_caps);
115
		autocorrect.init_caps);
107
	go_conf_set_str_list (AUTOCORRECT_INIT_CAPS_LIST,
116
	go_conf_set_str_list (node, AUTOCORRECT_INIT_CAPS_LIST,
108
		autocorrect.exceptions.init_caps);
117
		autocorrect.exceptions.init_caps);
109
	go_conf_set_bool (AUTOCORRECT_FIRST_LETTER,
118
	go_conf_set_bool (node, AUTOCORRECT_FIRST_LETTER,
110
		autocorrect.first_letter);
119
		autocorrect.first_letter);
111
	go_conf_set_str_list (AUTOCORRECT_FIRST_LETTER_LIST,
120
	go_conf_set_str_list (node, AUTOCORRECT_FIRST_LETTER_LIST,
112
	       autocorrect.exceptions.first_letter);
121
	       autocorrect.exceptions.first_letter);
113
	go_conf_set_bool (AUTOCORRECT_NAMES_OF_DAYS,
122
	go_conf_set_bool (node, AUTOCORRECT_NAMES_OF_DAYS,
114
		autocorrect.names_of_days);
123
		autocorrect.names_of_days);
115
	go_conf_set_bool (AUTOCORRECT_REPLACE,
124
	go_conf_set_bool (node, AUTOCORRECT_REPLACE,
116
		autocorrect.replace);
125
		autocorrect.replace);
117
	go_conf_sync ();
126
	go_conf_sync (node);
127
	go_conf_free_node (node);
118
}
128
}
119
129
120
gboolean
130
gboolean
(-)src/tools/goal-seek.c (-8 / +23 lines)
Lines 47-53 update_data (gnm_float x, gnm_float y, G Link Here
47
		} else {
47
		} else {
48
			data->xpos = x;
48
			data->xpos = x;
49
			data->ypos = y;
49
			data->ypos = y;
50
			data->havexpos = 1;
50
			data->havexpos = TRUE;
51
		}
51
		}
52
		return FALSE;
52
		return FALSE;
53
	} else if (y < 0) {
53
	} else if (y < 0) {
Lines 70-80 update_data (gnm_float x, gnm_float y, G Link Here
70
		} else {
70
		} else {
71
			data->xneg = x;
71
			data->xneg = x;
72
			data->yneg = y;
72
			data->yneg = y;
73
			data->havexneg = 1;
73
			data->havexneg = TRUE;
74
		}
74
		}
75
		return FALSE;
75
		return FALSE;
76
	} else {
76
	} else {
77
		/* Lucky guess...  */
77
		/* Lucky guess...  */
78
		data->have_root = TRUE;
78
		data->root = x;
79
		data->root = x;
79
		return TRUE;
80
		return TRUE;
80
	}
81
	}
Lines 146-152 fake_df (GoalSeekFunction f, gnm_float x Link Here
146
void
147
void
147
goal_seek_initialize (GoalSeekData *data)
148
goal_seek_initialize (GoalSeekData *data)
148
{
149
{
149
	data->havexpos = data->havexneg = FALSE;
150
	data->havexpos = data->havexneg = data->have_root = FALSE;
151
	data->xpos = data->xneg = data->root = gnm_nan;
152
	data->ypos = data->yneg = gnm_nan;
150
	data->xmin = -1e10;
153
	data->xmin = -1e10;
151
	data->xmax = +1e10;
154
	data->xmax = +1e10;
152
	data->precision = 1e-10;
155
	data->precision = 1e-10;
Lines 163-168 goal_seek_point (GoalSeekFunction f, Goa Link Here
163
	GoalSeekStatus status;
166
	GoalSeekStatus status;
164
	gnm_float y0;
167
	gnm_float y0;
165
168
169
	if (data->have_root)
170
		return GOAL_SEEK_OK;
171
166
	if (x0 < data->xmin || x0 > data->xmax)
172
	if (x0 < data->xmin || x0 > data->xmax)
167
		return GOAL_SEEK_ERROR;
173
		return GOAL_SEEK_ERROR;
168
174
Lines 196-201 goal_seek_newton (GoalSeekFunction f, Go Link Here
196
	int iterations;
202
	int iterations;
197
	gnm_float precision = data->precision / 2;
203
	gnm_float precision = data->precision / 2;
198
204
205
	if (data->have_root)
206
		return GOAL_SEEK_OK;
207
199
#ifdef DEBUG_GOAL_SEEK
208
#ifdef DEBUG_GOAL_SEEK
200
	printf ("goal_seek_newton\n");
209
	printf ("goal_seek_newton\n");
201
#endif
210
#endif
Lines 247-257 goal_seek_newton (GoalSeekFunction f, Go Link Here
247
		 * just one side of the root.
256
		 * just one side of the root.
248
		 */
257
		 */
249
		x1 = x0 - 1.000001 * y0 / df0;
258
		x1 = x0 - 1.000001 * y0 / df0;
250
		if (x1 == x0) {
251
			data->root = x0;
252
			return GOAL_SEEK_OK;
253
		}
254
255
		stepsize = gnumabs (x1 - x0) / (gnumabs (x0) + gnumabs (x1));
259
		stepsize = gnumabs (x1 - x0) / (gnumabs (x0) + gnumabs (x1));
256
260
257
#ifdef DEBUG_GOAL_SEEK
261
#ifdef DEBUG_GOAL_SEEK
Lines 263-268 goal_seek_newton (GoalSeekFunction f, Go Link Here
263
267
264
		if (stepsize < precision) {
268
		if (stepsize < precision) {
265
			data->root = x0;
269
			data->root = x0;
270
			data->have_root = TRUE;
266
			return GOAL_SEEK_OK;
271
			return GOAL_SEEK_OK;
267
		}
272
		}
268
	}
273
	}
Lines 293-298 goal_seek_bisection (GoalSeekFunction f, Link Here
293
	gnm_float stepsize;
298
	gnm_float stepsize;
294
	int newton_submethod = 0;
299
	int newton_submethod = 0;
295
300
301
	if (data->have_root)
302
		return GOAL_SEEK_OK;
303
296
#ifdef DEBUG_GOAL_SEEK
304
#ifdef DEBUG_GOAL_SEEK
297
	printf ("goal_seek_bisection\n");
305
	printf ("goal_seek_bisection\n");
298
#endif
306
#endif
Lines 431-436 goal_seek_bisection (GoalSeekFunction f, Link Here
431
			if (data->ypos < ymid)
439
			if (data->ypos < ymid)
432
				ymid = data->ypos, xmid = data->xpos;
440
				ymid = data->ypos, xmid = data->xpos;
433
441
442
			data->have_root = TRUE;
434
			data->root = xmid;
443
			data->root = xmid;
435
			return GOAL_SEEK_OK;
444
			return GOAL_SEEK_OK;
436
		}
445
		}
Lines 449-454 goal_seek_trawl_uniformly (GoalSeekFunct Link Here
449
{
458
{
450
	int i;
459
	int i;
451
460
461
	if (data->have_root)
462
		return GOAL_SEEK_OK;
463
452
	if (xmin > xmax || xmin < data->xmin || xmax > data->xmax)
464
	if (xmin > xmax || xmin < data->xmin || xmax > data->xmax)
453
		return GOAL_SEEK_ERROR;
465
		return GOAL_SEEK_ERROR;
454
466
Lines 486-491 goal_seek_trawl_normally (GoalSeekFuncti Link Here
486
			  int points)
498
			  int points)
487
{
499
{
488
	int i;
500
	int i;
501
502
	if (data->have_root)
503
		return GOAL_SEEK_OK;
489
504
490
	if (sigma <= 0 || mu < data->xmin || mu > data->xmax)
505
	if (sigma <= 0 || mu < data->xmin || mu > data->xmax)
491
		return GOAL_SEEK_ERROR;
506
		return GOAL_SEEK_ERROR;
(-)src/tools/goal-seek.h (+1 lines)
Lines 17-22 typedef struct { Link Here
17
	gnm_float xneg;           /* Value for which f(xneg) < 0.  */
17
	gnm_float xneg;           /* Value for which f(xneg) < 0.  */
18
	gnm_float yneg;           /* f(xneg).  */
18
	gnm_float yneg;           /* f(xneg).  */
19
19
20
	gboolean have_root;       /* Do we have a valid root?  */
20
	gnm_float root;           /* Value for which f(root) == 0.  */
21
	gnm_float root;           /* Value for which f(root) == 0.  */
21
} GoalSeekData;
22
} GoalSeekData;
22
23
(-)src/tools/scenarios.c (-4 / +4 lines)
Lines 166-172 collect_values (Sheet *sheet, scenario_t Link Here
166
166
167
	rows = s->range.end.row - s->range.start.row + 1;
167
	rows = s->range.end.row - s->range.start.row + 1;
168
	cols = s->range.end.col - s->range.start.col + 1;
168
	cols = s->range.end.col - s->range.start.col + 1;
169
	s->changing_cells = g_new (GnmValue *, rows * cols);
169
	s->changing_cells = g_new0 (GnmValue *, rows * cols);
170
170
171
	cb.expr_flag = FALSE;
171
	cb.expr_flag = FALSE;
172
	cb.sheet     = sheet;
172
	cb.sheet     = sheet;
Lines 177-186 collect_values (Sheet *sheet, scenario_t Link Here
177
177
178
/* Doesn't actually add the new scenario into the sheet's scenario list. */
178
/* Doesn't actually add the new scenario into the sheet's scenario list. */
179
gboolean
179
gboolean
180
scenario_add_new (gchar *name,
180
scenario_add_new (const gchar *name,
181
		  GnmValue *changing_cells,
181
		  GnmValue *changing_cells,
182
		  gchar *cell_sel_str,
182
		  const gchar *cell_sel_str,
183
		  gchar *comment,
183
		  const gchar *comment,
184
		  Sheet *sheet,
184
		  Sheet *sheet,
185
		  scenario_t **new_scenario)
185
		  scenario_t **new_scenario)
186
{
186
{
(-)src/tools/scenarios.h (-3 / +3 lines)
Lines 41-50 scenario_t *scenario_show (Workb Link Here
41
				   scenario_t             *scenario,
41
				   scenario_t             *scenario,
42
				   scenario_t             *old_values,
42
				   scenario_t             *old_values,
43
				   data_analysis_output_t *dao);
43
				   data_analysis_output_t *dao);
44
gboolean    scenario_add_new      (gchar *name,
44
gboolean    scenario_add_new      (const gchar *name,
45
				   GnmValue *changing_cells,
45
				   GnmValue *changing_cells,
46
				   gchar *cell_sel_str,
46
				   const gchar *cell_sel_str,
47
				   gchar *comment,
47
				   const gchar *comment,
48
				   Sheet *sheet, scenario_t **new_scenario);
48
				   Sheet *sheet, scenario_t **new_scenario);
49
void        scenario_add          (Sheet *sheet, scenario_t *scenario);
49
void        scenario_add          (Sheet *sheet, scenario_t *scenario);
50
gboolean    scenario_mark_deleted (GList *scenarios, gchar *name);
50
gboolean    scenario_mark_deleted (GList *scenarios, gchar *name);
(-)src/tools/solver/solver.c (-4 / +14 lines)
Lines 75-80 solver_param_new (void) Link Here
75
void
75
void
76
solver_param_destroy (SolverParameters *sp)
76
solver_param_destroy (SolverParameters *sp)
77
{
77
{
78
	g_slist_foreach	(sp->constraints,
79
			 (GFunc)solver_constraint_destroy,
80
			 NULL);
81
	g_slist_free (sp->constraints);
82
	g_slist_free (sp->input_cells);
78
	g_free (sp->input_entry_str);
83
	g_free (sp->input_entry_str);
79
	g_free (sp->options.scenario_name);
84
	g_free (sp->options.scenario_name);
80
	g_free (sp);
85
	g_free (sp);
Lines 170-175 solver_get_constraint (SolverResults *re Link Here
170
        return res->constraints_array[n];
175
        return res->constraints_array[n];
171
}
176
}
172
177
178
void
179
solver_constraint_destroy (SolverConstraint *c)
180
{
181
	g_free (c->str);
182
	g_free (c);
183
}
184
173
/* ------------------------------------------------------------------------- */
185
/* ------------------------------------------------------------------------- */
174
186
175
static SolverConstraint*
187
static SolverConstraint*
Lines 551-557 check_program_definition_failures (Sheet Link Here
551
	param->n_bool_constraints = 0;
563
	param->n_bool_constraints = 0;
552
	i = 0;
564
	i = 0;
553
 	for (c = param->constraints; c ; c = c->next) {
565
 	for (c = param->constraints; c ; c = c->next) {
554
	        SolverConstraint *sc = (SolverConstraint *) c->data;
566
	        SolverConstraint *sc = c->data;
555
567
556
		if (sc->type == SolverINT)
568
		if (sc->type == SolverINT)
557
		        param->n_int_constraints +=
569
		        param->n_int_constraints +=
Lines 568-574 check_program_definition_failures (Sheet Link Here
568
				   param->n_total_constraints);
580
				   param->n_total_constraints);
569
	i = 0;
581
	i = 0;
570
 	for (c = param->constraints; c ; c = c->next) {
582
 	for (c = param->constraints; c ; c = c->next) {
571
	        SolverConstraint *sc = (SolverConstraint *) c->data;
583
	        SolverConstraint *sc = c->data;
572
584
573
		if (sc->rows == 1 && sc->cols == 1)
585
		if (sc->rows == 1 && sc->cols == 1)
574
		        constraints_array[i++] = sc;
586
		        constraints_array[i++] = sc;
Lines 935-939 solver_delete_cols (Sheet *sheet, int co Link Here
935
					       c->type, c->cols, c->rows);
947
					       c->type, c->cols, c->rows);
936
	}
948
	}
937
}
949
}
938
939
(-)src/widgets/gnumeric-expr-entry.c (+15 lines)
Lines 338-343 cb_gee_key_press_event (GtkEntry *entr Link Here
338
		}
338
		}
339
		return TRUE;
339
		return TRUE;
340
	}
340
	}
341
342
	case GDK_KP_Separator:
343
	case GDK_KP_Decimal: {
344
		GtkEditable *editable = GTK_EDITABLE (entry);
345
		gint start, end, l;
346
		GString const* s = format_get_decimal ();
347
		gchar const* decimal = s->str;
348
		l = s->len;
349
		gtk_editable_get_selection_bounds (editable, &start, &end);
350
		gtk_editable_delete_text (editable, start, end);
351
		gtk_editable_insert_text (editable, decimal, l, &start);
352
		gtk_editable_set_position (editable, start);
353
		return TRUE;
354
	}
355
341
	default:
356
	default:
342
		break;
357
		break;
343
	}
358
	}
(-)src/widgets/widget-font-selector.c (-14 / +15 lines)
Lines 162-181 static void Link Here
162
font_selected (GtkTreeSelection *selection,
162
font_selected (GtkTreeSelection *selection,
163
	       FontSelector *fs)
163
	       FontSelector *fs)
164
{
164
{
165
	gchar *text;
166
	GnmStyle *change;
167
	GtkTreeModel *model;
165
	GtkTreeModel *model;
168
	GtkTreeIter iter;
166
	GtkTreeIter iter;
169
167
170
	gtk_tree_selection_get_selected (selection, &model, &iter);
168
	if (gtk_tree_selection_get_selected (selection, &model, &iter)) {
169
		GnmStyle *change = mstyle_new ();
170
		gchar *text;
171
171
	gtk_tree_model_get (model, &iter, 0, &text, -1);
172
	gtk_tree_model_get (model, &iter, 0, &text, -1);
172
	gtk_entry_set_text (GTK_ENTRY (fs->font_name_entry), text);
173
	gtk_entry_set_text (GTK_ENTRY (fs->font_name_entry), text);
173
174
174
	change = mstyle_new ();
175
	mstyle_set_font_name (change, text);
175
	mstyle_set_font_name (change, text);
176
	g_free (text);
176
	g_free (text);
177
	fs_modify_style (fs, change);
177
	fs_modify_style (fs, change);
178
}
178
}
179
}
179
180
180
static void
181
static void
181
fs_fill_font_name_list (FontSelector *fs)
182
fs_fill_font_name_list (FontSelector *fs)
Lines 208-222 static void Link Here
208
style_selected (GtkTreeSelection *selection,
209
style_selected (GtkTreeSelection *selection,
209
		FontSelector *fs)
210
		FontSelector *fs)
210
{
211
{
211
	GnmStyle *change = mstyle_new ();
212
	GtkTreeModel *model;
212
	GtkTreeModel *model;
213
	GtkTreeIter iter;
213
	GtkTreeIter iter;
214
	GtkTreePath *path;
215
	int row;
216
214
217
	gtk_tree_selection_get_selected (selection, &model, &iter);
215
	if (gtk_tree_selection_get_selected (selection, &model, &iter)) {
218
	path = gtk_tree_model_get_path (model, &iter);
216
		GnmStyle *change = mstyle_new ();
219
	row = *gtk_tree_path_get_indices (path);
217
		GtkTreePath *path = gtk_tree_model_get_path (model, &iter);
218
		int row = *gtk_tree_path_get_indices (path);
220
	gtk_tree_path_free (path);
219
	gtk_tree_path_free (path);
221
220
222
	switch (row) {
221
	switch (row) {
Lines 228-234 style_selected (GtkTreeSelection *select Link Here
228
		mstyle_set_font_bold (change, TRUE);
227
		mstyle_set_font_bold (change, TRUE);
229
		mstyle_set_font_italic (change, FALSE);
228
		mstyle_set_font_italic (change, FALSE);
230
		break;
229
		break;
231
232
	case 2:
230
	case 2:
233
		mstyle_set_font_bold (change, TRUE);
231
		mstyle_set_font_bold (change, TRUE);
234
		mstyle_set_font_italic (change, TRUE);
232
		mstyle_set_font_italic (change, TRUE);
Lines 242-247 style_selected (GtkTreeSelection *select Link Here
242
	gtk_entry_set_text (GTK_ENTRY (fs->font_style_entry), _(styles[row]));
240
	gtk_entry_set_text (GTK_ENTRY (fs->font_style_entry), _(styles[row]));
243
	fs_modify_style (fs, change);
241
	fs_modify_style (fs, change);
244
}
242
}
243
}
245
244
246
static void
245
static void
247
fs_fill_font_style_list (FontSelector *fs)
246
fs_fill_font_style_list (FontSelector *fs)
Lines 282-298 static void Link Here
282
size_selected (GtkTreeSelection *selection,
281
size_selected (GtkTreeSelection *selection,
283
	       FontSelector *fs)
282
	       FontSelector *fs)
284
{
283
{
285
	GnmStyle *change = mstyle_new ();
286
	gchar *text;
287
	GtkTreeModel *model;
284
	GtkTreeModel *model;
288
	GtkTreeIter iter;
285
	GtkTreeIter iter;
289
286
290
	gtk_tree_selection_get_selected (selection, &model, &iter);
287
	if (gtk_tree_selection_get_selected (selection, &model, &iter)) {
288
		GnmStyle *change = mstyle_new ();
289
		gchar *text;
290
291
	gtk_tree_model_get (model, &iter, 0, &text, -1);
291
	gtk_tree_model_get (model, &iter, 0, &text, -1);
292
	gtk_entry_set_text (GTK_ENTRY (fs->font_size_entry), text);
292
	gtk_entry_set_text (GTK_ENTRY (fs->font_size_entry), text);
293
	mstyle_set_font_size (change, atof (text));
293
	mstyle_set_font_size (change, atof (text));
294
	g_free (text);
294
	g_free (text);
295
	fs_modify_style (fs, change);
295
	fs_modify_style (fs, change);
296
	}
296
}
297
}
297
298
298
static void
299
static void

Return to bug 139466