gnumeric r16877 - in trunk/src: dialogs tools



Author: guelzow
Date: Mon Oct 13 03:20:12 2008
New Revision: 16877
URL: http://svn.gnome.org/viewvc/gnumeric?rev=16877&view=rev

Log:
2008-10-12  Andreas J. Guelzow <aguelzow pyrshep ca>

	* analysis-frequency.c (analysis_tool_frequency_engine_run): use
	  EXACT if requested and copy the categories preserving blankness.
	* analysis-frequency.c (analysis_tools_data_frequency_t): add field
	
2008-10-12  Andreas J. Guelzow <aguelzow pyrshep ca>

	* frequency.glade: add exact button
	* dialog-analysis-tool-frequency.c (frequency_tool_ok_clicked_cb):
	  handle exact button
	



Modified:
   trunk/src/dialogs/ChangeLog
   trunk/src/dialogs/dialog-analysis-tool-frequency.c
   trunk/src/dialogs/frequency.glade
   trunk/src/tools/ChangeLog
   trunk/src/tools/analysis-frequency.c
   trunk/src/tools/analysis-frequency.h

Modified: trunk/src/dialogs/dialog-analysis-tool-frequency.c
==============================================================================
--- trunk/src/dialogs/dialog-analysis-tool-frequency.c	(original)
+++ trunk/src/dialogs/dialog-analysis-tool-frequency.c	Mon Oct 13 03:20:12 2008
@@ -183,6 +183,8 @@
 	data->base.labels = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (w));
 	w = glade_xml_get_widget (state->base.gui, "percentage-button");
 	data->percentage = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (w));
+	w = glade_xml_get_widget (state->base.gui, "exact-button");
+	data->exact = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (w));
 
 	if (!cmd_analysis_tool (WORKBOOK_CONTROL (state->base.wbcg), state->base.sheet,
 			       dao, data, analysis_tool_frequency_engine))

Modified: trunk/src/dialogs/frequency.glade
==============================================================================
--- trunk/src/dialogs/frequency.glade	(original)
+++ trunk/src/dialogs/frequency.glade	Mon Oct 13 03:20:12 2008
@@ -370,6 +370,22 @@
                     <property name="position">4</property>
                   </packing>
                 </child>
+                <child>
+                  <widget class="GtkCheckButton" id="exact-button">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="label" translatable="yes">Use e_xact comparisons</property>
+                    <property name="use_underline">True</property>
+                    <property name="response_id">0</property>
+                    <property name="active">True</property>
+                    <property name="draw_indicator">True</property>
+                  </widget>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">False</property>
+                    <property name="position">5</property>
+                  </packing>
+                </child>
               </widget>
               <packing>
                 <property name="position">2</property>

Modified: trunk/src/tools/analysis-frequency.c
==============================================================================
--- trunk/src/tools/analysis-frequency.c	(original)
+++ trunk/src/tools/analysis-frequency.c	Mon Oct 13 03:20:12 2008
@@ -51,8 +51,10 @@
 	GnmFunc *fd_sum;
 	GnmFunc *fd_if;
 	GnmFunc *fd_index;
+	GnmFunc *fd_isblank;
 	GnmFunc *fd_rows = NULL;
 	GnmFunc *fd_columns = NULL;
+	GnmFunc *fd_exact = NULL;
 
 	fd_sum = gnm_func_lookup ("SUM", NULL);
 	gnm_func_ref (fd_sum);
@@ -60,7 +62,13 @@
 	gnm_func_ref (fd_if);
 	fd_index = gnm_func_lookup ("INDEX", NULL);
 	gnm_func_ref (fd_index);
+	fd_isblank = gnm_func_lookup ("ISBLANK", NULL);
+	gnm_func_ref (fd_isblank);
 	
+	if (info->exact) {
+		fd_exact = gnm_func_lookup ("EXACT", NULL);
+		gnm_func_ref (fd_exact);
+	}
 	if (info->percentage) {
 		fd_rows = gnm_func_lookup ("ROWS", NULL);
 		gnm_func_ref (fd_rows);
@@ -88,13 +96,24 @@
 		expr_bin = gnm_expr_new_constant (info->bin);
 
 		for (i = 1; i <= i_h_limit; i++)
-			for (j = 1; j <= i_w_limit; j++)
+			for (j = 1; j <= i_w_limit; j++) {
+				GnmExpr const *expr_index;
+
+				expr_index =  gnm_expr_new_funcall3
+					(fd_index,
+					 gnm_expr_copy (expr_bin),
+					 gnm_expr_new_constant (value_new_int (i)),
+					 gnm_expr_new_constant (value_new_int (j)));
+				
 				dao_set_cell_expr (dao, 0, row++,
 						   gnm_expr_new_funcall3
-						   (fd_index,
-						    gnm_expr_copy (expr_bin),
-						    gnm_expr_new_constant (value_new_int (i)),
-						    gnm_expr_new_constant (value_new_int (j))));
+						   (fd_if,
+						    gnm_expr_new_funcall1
+						    (fd_isblank,
+						     gnm_expr_copy (expr_index)),
+						    gnm_expr_new_constant (value_new_string ("")),
+						    expr_index));
+			}
 		gnm_expr_free (expr_bin);
 	} else {
 		i_limit = info->n;
@@ -140,14 +159,21 @@
 		}
 
 		expr_data = gnm_expr_new_constant (val);
-		expr_if = gnm_expr_new_funcall3
-			(fd_if,
-			 gnm_expr_new_binary
-			 (gnm_expr_copy (expr_data),
-			  GNM_EXPR_OP_EQUAL, make_cellref (- col, 0)),
-			 gnm_expr_new_constant (value_new_int (1)),
-			 gnm_expr_new_constant (value_new_int (0)));
-		expr_count = gnm_expr_new_funcall1 (fd_sum, expr_if);
+		
+		if (info->exact)
+			expr_if = gnm_expr_new_funcall2 
+				(fd_exact, gnm_expr_copy (expr_data), 
+				 make_cellref (- col, 0));
+		else
+			expr_if = gnm_expr_new_binary
+				(gnm_expr_copy (expr_data),
+				 GNM_EXPR_OP_EQUAL, make_cellref (- col, 0));
+
+		expr_count = gnm_expr_new_funcall1 (fd_sum,  
+						    gnm_expr_new_funcall3
+						    (fd_if, expr_if,
+						     gnm_expr_new_constant (value_new_int (1)),
+						     gnm_expr_new_constant (value_new_int (0))));
 
 		if (info->percentage) {
 			dao_set_format  (dao, col, 2, col, i_limit + 2, "0.0%");
@@ -171,10 +197,13 @@
 	gnm_func_unref (fd_if);
 	gnm_func_unref (fd_sum);
 	gnm_func_unref (fd_index);
+	gnm_func_unref (fd_isblank);
 	if (fd_rows != NULL)
 		gnm_func_unref (fd_rows);
 	if (fd_columns != NULL)
 		gnm_func_unref (fd_columns);
+	if (fd_exact != NULL)
+		gnm_func_unref (fd_exact);
 
 	/* Create Chart if requested */
 	if (info->chart != NO_CHART) {

Modified: trunk/src/tools/analysis-frequency.h
==============================================================================
--- trunk/src/tools/analysis-frequency.h	(original)
+++ trunk/src/tools/analysis-frequency.h	Mon Oct 13 03:20:12 2008
@@ -48,6 +48,7 @@
 	gnm_float min;
 	gint       n;
 	gboolean   percentage;
+	gboolean   exact;
 	chart_freq_t   chart;	
 } analysis_tools_data_frequency_t;
 



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