gnumeric r17066 - in trunk: . plugins/excel src src/widgets



Author: mortenw
Date: Mon Jan 12 16:40:22 2009
New Revision: 17066
URL: http://svn.gnome.org/viewvc/gnumeric?rev=17066&view=rev

Log:
2009-01-12  Morten Welinder  <terra gnome org>

	* src/expr.c (gnm_expr_eval): Set value format properly.

	* src/value.h (VALUE_FMT): Make result const and an r-value.  All
	users changed as needed.
	* src/number-match.h (format_match, format_match_number): Make the
	cur_fmt argument const.
	* src/mstyle.c (gnm_style_set_format): Make the format argument
	const.
	* src/parse-util.c (parse_text_value_or_expr): Make the cur_fmt
	argument const.
	* src/cell.c (gnm_cell_get_format): Make the result const.  All
	callers changed as needed.



Modified:
   trunk/ChangeLog
   trunk/NEWS
   trunk/plugins/excel/ms-excel-write.c
   trunk/src/auto-format.c
   trunk/src/cell.c
   trunk/src/cell.h
   trunk/src/expr.c
   trunk/src/mstyle.c
   trunk/src/mstyle.h
   trunk/src/number-match.c
   trunk/src/number-match.h
   trunk/src/parse-util.c
   trunk/src/parse-util.h
   trunk/src/rendered-value.c
   trunk/src/sheet-autofill.c
   trunk/src/stf-export.c
   trunk/src/value.c
   trunk/src/value.h
   trunk/src/wbc-gtk-edit.c
   trunk/src/widgets/gnm-format-sel.c
   trunk/src/workbook-view.c

Modified: trunk/NEWS
==============================================================================
--- trunk/NEWS	(original)
+++ trunk/NEWS	Mon Jan 12 16:40:22 2009
@@ -64,6 +64,8 @@
 	* Fix column-split problem with fixed-width stf import.
 	* Fix problem with deprecated gtk+ stuff in glade files.
 	* Fix xls export problem generating extra ()s.  [#567380]
+	* Constify usage of GOFormats.
+	* Fix inconsistentcy in searching with respect to formats.
 
 --------------------------------------------------------------------------
 Gnumeric 1.9.3

Modified: trunk/plugins/excel/ms-excel-write.c
==============================================================================
--- trunk/plugins/excel/ms-excel-write.c	(original)
+++ trunk/plugins/excel/ms-excel-write.c	Mon Jan 12 16:40:22 2009
@@ -2452,7 +2452,7 @@
 cb_cell_pre_pass (gpointer ignored, GnmCell const *cell, ExcelWriteState *ewb)
 {
 	GnmStyle const *style;
-	GOFormat *fmt;
+	GOFormat const *fmt;
 	gboolean use_sst;
 
 	if (gnm_cell_has_expr (cell) || cell->value == NULL)

Modified: trunk/src/auto-format.c
==============================================================================
--- trunk/src/auto-format.c	(original)
+++ trunk/src/auto-format.c	Mon Jan 12 16:40:22 2009
@@ -71,7 +71,7 @@
 {
 	struct cb_af_suggest *data = user;
 
-	*(data->explicit) = gnm_cell_get_format (iter->cell);
+	*(data->explicit) = (GOFormat *)gnm_cell_get_format (iter->cell);
 	if (*(data->explicit)) {
 		data->typ = AF_EXPLICIT;
 		return VALUE_TERMINATE;
@@ -211,7 +211,7 @@
 		if (cell == NULL)
 			return GNM_FUNC_AUTO_UNKNOWN;
 
-		*explicit = gnm_cell_get_format (cell);
+		*explicit = (GOFormat *)gnm_cell_get_format (cell);
 		return *explicit ? AF_EXPLICIT : GNM_FUNC_AUTO_UNKNOWN;
 	}
 

Modified: trunk/src/cell.c
==============================================================================
--- trunk/src/cell.c	(original)
+++ trunk/src/cell.c	Mon Jan 12 16:40:22 2009
@@ -565,7 +565,7 @@
 			}
 			return g_strconcat ("\'", tmp, NULL);
 		} else {
-			GOFormat *fmt = gnm_cell_get_format (cell);
+			GOFormat const *fmt = gnm_cell_get_format (cell);
 			return format_value (fmt, v, NULL, -1,	date_conv);
 		}
 	}
@@ -635,10 +635,10 @@
  * Get the display format.  If the assigned format is General,
  * the format of the value will be used.
  **/
-GOFormat *
+GOFormat const *
 gnm_cell_get_format (GnmCell const *cell)
 {
-	GOFormat *fmt;
+	GOFormat const *fmt;
 
 	g_return_val_if_fail (cell != NULL, go_format_general ());
 

Modified: trunk/src/cell.h
==============================================================================
--- trunk/src/cell.h	(original)
+++ trunk/src/cell.h	Mon Jan 12 16:40:22 2009
@@ -79,7 +79,7 @@
  * Manipulate GnmCell attributes
  */
 GnmStyle const *gnm_cell_get_style	(GnmCell const *cell);
-GOFormat *gnm_cell_get_format		(GnmCell const *cell);
+GOFormat const *gnm_cell_get_format	(GnmCell const *cell);
 void	gnm_cell_set_format		(GnmCell *cell, char const *format);
 
 void	gnm_cell_render_value		(GnmCell *cell, gboolean allow_variable_width);

Modified: trunk/src/expr.c
==============================================================================
--- trunk/src/expr.c	(original)
+++ trunk/src/expr.c	Mon Jan 12 16:40:22 2009
@@ -1283,8 +1283,7 @@
 			res = negate_value (a);
 		else {
 			res = value_new_float (value_get_as_float (a) / 100);
-			VALUE_FMT (res) = go_format_default_percentage ();
-			go_format_ref (VALUE_FMT (res));
+			value_set_fmt (res, go_format_default_percentage ());
 		}
 		value_release (a);
 		return res;

Modified: trunk/src/mstyle.c
==============================================================================
--- trunk/src/mstyle.c	(original)
+++ trunk/src/mstyle.c	Mon Jan 12 16:40:22 2009
@@ -1186,16 +1186,16 @@
 }
 
 void
-gnm_style_set_format (GnmStyle *style, GOFormat *format)
+gnm_style_set_format (GnmStyle *style, GOFormat const *format)
 {
 	g_return_if_fail (style != NULL);
 	g_return_if_fail (format != NULL);
 
 	elem_changed (style, MSTYLE_FORMAT);
-	go_format_ref (format);
+	go_format_ref ((GOFormat *)format);
 	elem_clear_contents (style, MSTYLE_FORMAT);
 	elem_set (style, MSTYLE_FORMAT);
-	style->format = format;
+	style->format = (GOFormat *)format;
 }
 
 /*

Modified: trunk/src/mstyle.h
==============================================================================
--- trunk/src/mstyle.h	(original)
+++ trunk/src/mstyle.h	Mon Jan 12 16:40:22 2009
@@ -117,7 +117,7 @@
 GnmFont     *gnm_style_get_font		   (GnmStyle const *style,
 					    PangoContext *context,
 					    float zoom);
-void         gnm_style_set_format	   (GnmStyle *style, GOFormat *fmt);
+void         gnm_style_set_format	   (GnmStyle *style, GOFormat const *fmt);
 void         gnm_style_set_format_text	   (GnmStyle *style, char const *fmt);
 GOFormat    *gnm_style_get_format	   (GnmStyle const *style);
 void         gnm_style_set_align_h	   (GnmStyle *style, GnmHAlign a);

Modified: trunk/src/number-match.c
==============================================================================
--- trunk/src/number-match.c	(original)
+++ trunk/src/number-match.c	Mon Jan 12 16:40:22 2009
@@ -744,7 +744,7 @@
 	if (*text) {
 		GnmValue *v = format_match_time (text, FALSE,
 						 TRUE, add_format);
-		GOFormat *fmt;
+		GOFormat const *fmt;
 		if (!v)
 			return NULL;
 		time_val = value_get_as_float (v);
@@ -1061,7 +1061,7 @@
  * format.  The caller is responsible for releasing the resulting value.
  **/
 GnmValue *
-format_match (char const *text, GOFormat *cur_fmt,
+format_match (char const *text, GOFormat const *cur_fmt,
 	      GODateConventions const *date_conv)
 {
 	GOFormatFamily fam;
@@ -1217,7 +1217,7 @@
  * resulting value.  Will ONLY return numbers.
  */
 GnmValue *
-format_match_number (char const *text, GOFormat *cur_fmt,
+format_match_number (char const *text, GOFormat const *cur_fmt,
 		     GODateConventions const *date_conv)
 {
 	GnmValue *res = format_match (text, cur_fmt, date_conv);

Modified: trunk/src/number-match.h
==============================================================================
--- trunk/src/number-match.h	(original)
+++ trunk/src/number-match.h	Mon Jan 12 16:40:22 2009
@@ -7,9 +7,9 @@
 G_BEGIN_DECLS
 
 GnmValue   *format_match_simple (char const *s);
-GnmValue   *format_match        (char const *s, GOFormat *cur_fmt,
+GnmValue   *format_match        (char const *s, GOFormat const *cur_fmt,
 				 GODateConventions const *date_conv);
-GnmValue   *format_match_number (char const *s, GOFormat *cur_fmt,
+GnmValue   *format_match_number (char const *s, GOFormat const *cur_fmt,
 				 GODateConventions const *date_conv);
 
 G_END_DECLS

Modified: trunk/src/parse-util.c
==============================================================================
--- trunk/src/parse-util.c	(original)
+++ trunk/src/parse-util.c	Mon Jan 12 16:40:22 2009
@@ -752,7 +752,7 @@
 void
 parse_text_value_or_expr (GnmParsePos const *pos, char const *text,
 			  GnmValue **val, GnmExprTop const **texpr,
-			  GOFormat *cur_fmt,
+			  GOFormat const *cur_fmt,
 			  GODateConventions const *date_conv)
 {
 	char const *expr_start;

Modified: trunk/src/parse-util.h
==============================================================================
--- trunk/src/parse-util.h	(original)
+++ trunk/src/parse-util.h	Mon Jan 12 16:40:22 2009
@@ -203,7 +203,7 @@
 				      char const *text,
 				      GnmValue **val,
 				      GnmExprTop const **texpr,
-				      GOFormat *current_format,
+				      GOFormat const *current_format,
 				      GODateConventions const *date_conv);
 
 GString	*gnm_expr_conv_quote (GnmConventions const *conv, char const *str);

Modified: trunk/src/rendered-value.c
==============================================================================
--- trunk/src/rendered-value.c	(original)
+++ trunk/src/rendered-value.c	Mon Jan 12 16:40:22 2009
@@ -363,7 +363,7 @@
 		res->might_overflow = FALSE;
 	} else {
 		int col_width = -1;
-		GOFormat *format = gnm_style_get_format (mstyle);
+		GOFormat const *format = gnm_style_get_format (mstyle);
 		GODateConventions const *date_conv = sheet->workbook
 			? workbook_date_conv (sheet->workbook)
 			: NULL;

Modified: trunk/src/sheet-autofill.c
==============================================================================
--- trunk/src/sheet-autofill.c	(original)
+++ trunk/src/sheet-autofill.c	Mon Jan 12 16:40:22 2009
@@ -175,7 +175,7 @@
 			af->status = AFS_READY;
 		}
 		if (VALUE_FMT (value))
-			afa->format = go_format_ref (VALUE_FMT (value));
+			afa->format = go_format_ref ((GOFormat *)VALUE_FMT (value));
 		break;
 	case 1:
 		afa->step = f - afa->base;
@@ -559,7 +559,7 @@
 
 	if (n == 0) {
 		if (VALUE_FMT (value))
-			afm->format = go_format_ref (VALUE_FMT (value));
+			afm->format = go_format_ref ((GOFormat *)VALUE_FMT (value));
 		afm->base = d;
 	} else {
 		int year = g_date_get_year (&d);

Modified: trunk/src/stf-export.c
==============================================================================
--- trunk/src/stf-export.c	(original)
+++ trunk/src/stf-export.c	Mon Jan 12 16:40:22 2009
@@ -212,7 +212,7 @@
 			if (cell->value) {
 				GODateConventions const *date_conv =
 					workbook_date_conv (cell->base.sheet->workbook);
-				GOFormat *format = gnm_cell_get_format (cell);
+				GOFormat const *format = gnm_cell_get_format (cell);
 				text = tmp = try_auto_date (cell->value, format, date_conv);
 				if (!text)
 					text = value_peek_string (cell->value);

Modified: trunk/src/value.c
==============================================================================
--- trunk/src/value.c	(original)
+++ trunk/src/value.c	Mon Jan 12 16:40:22 2009
@@ -533,7 +533,7 @@
 	g_return_if_fail (value != NULL);
 
 	if (VALUE_FMT (value) != NULL)
-		go_format_unref (VALUE_FMT (value));
+		go_format_unref ((GOFormat *)VALUE_FMT (value));
 
 	switch (value->type) {
 	case VALUE_EMPTY:
@@ -1330,8 +1330,8 @@
 	if (fmt != NULL)
 		go_format_ref ((GOFormat *)fmt);
 	if (VALUE_FMT (v) != NULL)
-		go_format_unref (VALUE_FMT (v));
-	VALUE_FMT (v) = (GOFormat *)fmt;
+		go_format_unref ((GOFormat *)VALUE_FMT (v));
+	v->v_any.fmt = (GOFormat *)fmt;
 }
 
 /****************************************************************************/

Modified: trunk/src/value.h
==============================================================================
--- trunk/src/value.h	(original)
+++ trunk/src/value.h	Mon Jan 12 16:40:22 2009
@@ -78,7 +78,7 @@
 	GnmValueArray	v_array;
 };
 
-#define	VALUE_FMT(v)			((v)->v_any.fmt)
+#define	VALUE_FMT(v)			((GOFormat const *)(v)->v_any.fmt)
 #define VALUE_IS_EMPTY(v)		(((v) == NULL) || ((v)->type == VALUE_EMPTY))
 #define VALUE_IS_EMPTY_OR_ERROR(v)	(VALUE_IS_EMPTY(v) || (v)->type == VALUE_ERROR)
 #define VALUE_IS_STRING(v)		((v)->type == VALUE_STRING)

Modified: trunk/src/wbc-gtk-edit.c
==============================================================================
--- trunk/src/wbc-gtk-edit.c	(original)
+++ trunk/src/wbc-gtk-edit.c	Mon Jan 12 16:40:22 2009
@@ -134,7 +134,8 @@
 		char const *txt = wbcg_edit_get_display_text (wbcg);
 		GnmStyle const *mstyle = sheet_style_get (sheet, sv->edit_pos.col, sv->edit_pos.row);
 		char const *expr_txt = NULL;
-		GOFormat *fmt = gnm_cell_get_format (sheet_cell_fetch (sheet, sv->edit_pos.col, sv->edit_pos.row));
+		GOFormat const *fmt =
+			gnm_cell_get_format (sheet_cell_fetch (sheet, sv->edit_pos.col, sv->edit_pos.row));
 
 		GnmValue *value = format_match (txt, fmt,
 						workbook_date_conv (sheet->workbook));
@@ -901,7 +902,7 @@
 			gtk_entry_set_text (wbcg_get_entry (wbcg), text);
 
 		if (cell->value != NULL) {
-			GOFormat *fmt = VALUE_FMT (cell->value);
+			GOFormat const *fmt = VALUE_FMT (cell->value);
 			if (fmt != NULL && go_format_is_markup (fmt)) {
 				PangoAttrList *markup =
 					pango_attr_list_copy ((PangoAttrList *)go_format_get_markup (fmt));

Modified: trunk/src/widgets/gnm-format-sel.c
==============================================================================
--- trunk/src/widgets/gnm-format-sel.c	(original)
+++ trunk/src/widgets/gnm-format-sel.c	Mon Jan 12 16:40:22 2009
@@ -26,7 +26,7 @@
 cb_generate_preview (GOFormatSel *gfs, GOColor *c)
 {
 	GnmValue const *v = g_object_get_data (G_OBJECT (gfs), "value");
-	GOFormat *fmt = go_format_sel_get_fmt (gfs);
+	GOFormat const *fmt = go_format_sel_get_fmt (gfs);
 
 	if (NULL == v)
 		return NULL;

Modified: trunk/src/workbook-view.c
==============================================================================
--- trunk/src/workbook-view.c	(original)
+++ trunk/src/workbook-view.c	Mon Jan 12 16:40:22 2009
@@ -239,7 +239,7 @@
 	SheetView *sv;
 	GnmStyle const *style;
 	GnmValidation const *val;
-	GOFormat *fmt_style, *fmt_cell;
+	GOFormat const *fmt_style, *fmt_cell;
 	GnmCell *cell;
 	gboolean update_controls = TRUE;
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]