gnumeric r16883 - in trunk: . plugins/excel src



Author: mortenw
Date: Tue Oct 14 15:44:44 2008
New Revision: 16883
URL: http://svn.gnome.org/viewvc/gnumeric?rev=16883&view=rev

Log:
2008-10-01  Morten Welinder  <terra gnome org>

	* src/sheet.c (gnm_sheet_foreach_name): New function.

	* src/workbook.c (workbook_foreach_name): New function.

	* src/expr-name.c (gnm_named_expr_collection_foreach): New
	function.

2008-10-02  Morten Welinder  <terra gnome org>

	* ms-excel-write.c (excel_write_NAME): Don't write a formula for
	place-holders.

2008-10-01  Morten Welinder  <terra gnome org>

	* ms-excel-write.c (excel_foreach_name): Use new
	workbook_foreach_name.



Modified:
   trunk/ChangeLog
   trunk/NEWS
   trunk/plugins/excel/ChangeLog
   trunk/plugins/excel/ms-excel-write.c
   trunk/src/expr-name.c
   trunk/src/expr-name.h
   trunk/src/sheet.c
   trunk/src/sheet.h
   trunk/src/workbook.c
   trunk/src/workbook.h

Modified: trunk/NEWS
==============================================================================
--- trunk/NEWS	(original)
+++ trunk/NEWS	Tue Oct 14 15:44:44 2008
@@ -56,6 +56,7 @@
 	* Bring SUMX2MY2, SUMX2PY2, and SUMXMY2 into 21st century.  [#554040]
 	* Fix XIRR problem with missing data.  [#554732]
 	* Switch to LINGUAS file.  [#554348]
+	* Fix problems with saving undefined names.  [#554325]
 
 Nakai:
 	* Enable Perl plugin again. [#553939]

Modified: trunk/plugins/excel/ms-excel-write.c
==============================================================================
--- trunk/plugins/excel/ms-excel-write.c	(original)
+++ trunk/plugins/excel/ms-excel-write.c	Tue Oct 14 15:44:44 2008
@@ -1571,8 +1571,12 @@
 		excel_write_string (ewb->bp, STR_NO_LENGTH, name);
 	}
 
-	expr_len = excel_write_formula (ewb, nexpr->texpr,
-		nexpr->pos.sheet, 0, 0, EXCEL_CALLED_FROM_NAME);
+	if (expr_name_is_placeholder (nexpr))
+		expr_len = 0;
+	else
+		expr_len = excel_write_formula (ewb, nexpr->texpr,
+						nexpr->pos.sheet, 0, 0,
+						EXCEL_CALLED_FROM_NAME);
 	ms_biff_put_var_seekto (ewb->bp, 4);
 	GSF_LE_SET_GUINT16 (data, expr_len);
 	ms_biff_put_var_write (ewb->bp, data, 2);
@@ -5225,20 +5229,7 @@
 static void
 excel_foreach_name (ExcelWriteState *ewb, GHFunc func)
 {
-	Workbook const *wb = ewb->base.wb;
-	Sheet const *sheet;
-	unsigned i, num_sheets = workbook_sheet_count (wb);
-
-	if (wb->names != NULL) {
-		g_hash_table_foreach (wb->names->names, func, ewb);
-	}
-	for (i = 0; i < num_sheets; i++) {
-		sheet = workbook_sheet_by_index (wb, i);
-		if (sheet->names != NULL) {
-			g_hash_table_foreach (sheet->names->names,
-				func, ewb);
-		}
-	}
+	workbook_foreach_name (ewb->base.wb, func, ewb);
 }
 
 static void

Modified: trunk/src/expr-name.c
==============================================================================
--- trunk/src/expr-name.c	(original)
+++ trunk/src/expr-name.c	Tue Oct 14 15:44:44 2008
@@ -297,6 +297,16 @@
 	return user.res;
 }
 
+/* Iterate over all names, including placeholders.  */
+void
+gnm_named_expr_collection_foreach (GnmNamedExprCollection *names,
+				   GHFunc func,
+				   gpointer data)
+{
+	g_hash_table_foreach (names->names, func, data);
+	g_hash_table_foreach (names->placeholders, func, data);
+}
+
 /******************************************************************************/
 
 /**

Modified: trunk/src/expr-name.h
==============================================================================
--- trunk/src/expr-name.h	(original)
+++ trunk/src/expr-name.h	Tue Oct 14 15:44:44 2008
@@ -72,6 +72,9 @@
 void gnm_named_expr_collection_free (GnmNamedExprCollection *names);
 void gnm_named_expr_collection_unlink (GnmNamedExprCollection *names);
 void gnm_named_expr_collection_relink (GnmNamedExprCollection *names);
+void gnm_named_expr_collection_foreach (GnmNamedExprCollection *names,
+					GHFunc func,
+					gpointer data);
 
 GnmNamedExpr *gnm_named_expr_collection_lookup (GnmNamedExprCollection const *scope,
 						char const *name);

Modified: trunk/src/sheet.c
==============================================================================
--- trunk/src/sheet.c	(original)
+++ trunk/src/sheet.c	Tue Oct 14 15:44:44 2008
@@ -5269,3 +5269,12 @@
 
 	return FALSE;
 }
+
+void
+gnm_sheet_foreach_name (Sheet const *sheet, GHFunc func, gpointer data)
+{
+	g_return_if_fail (IS_SHEET (sheet));
+
+	if (sheet->names)
+		gnm_named_expr_collection_foreach (sheet->names, func, data);
+}

Modified: trunk/src/sheet.h
==============================================================================
--- trunk/src/sheet.h	(original)
+++ trunk/src/sheet.h	Tue Oct 14 15:44:44 2008
@@ -254,6 +254,9 @@
 				      gboolean top, gboolean ignore_styles);
 
 
+void gnm_sheet_foreach_name (Sheet const *sheet, GHFunc func, gpointer data);
+
+
 /* Redraw */
 #define sheet_is_visible(_sheet) ((_sheet)->visibility == GNM_SHEET_VISIBILITY_VISIBLE)
 void     sheet_redraw_all       (Sheet const *sheet, gboolean header);

Modified: trunk/src/workbook.c
==============================================================================
--- trunk/src/workbook.c	(original)
+++ trunk/src/workbook.c	Tue Oct 14 15:44:44 2008
@@ -551,6 +551,20 @@
 	return NULL;
 }
 
+void
+workbook_foreach_name (Workbook const *wb, GHFunc func, gpointer data)
+{
+	g_return_if_fail (IS_WORKBOOK (wb));
+
+	if (wb->names)
+		gnm_named_expr_collection_foreach (wb->names, func, data);
+
+	WORKBOOK_FOREACH_SHEET (wb, sheet, {
+		gnm_sheet_foreach_name (sheet, func, data);
+	});
+}
+
+
 gboolean
 workbook_enable_recursive_dirty (Workbook *wb, gboolean enable)
 {

Modified: trunk/src/workbook.h
==============================================================================
--- trunk/src/workbook.h	(original)
+++ trunk/src/workbook.h	Tue Oct 14 15:44:44 2008
@@ -58,6 +58,9 @@
 					  GnmSheetVisibility vis);
 GSList     *workbook_local_functions	 (Workbook const *wb);
 
+void workbook_foreach_name (Workbook const *wb, GHFunc func, gpointer data);
+
+
 /* Calculation */
 void     workbook_recalc                 (Workbook *wb);	/* in eval.c */
 void     workbook_recalc_all             (Workbook *wb);	/* in eval.c */



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