static void filter (data_analysis_output_t *dao, Sheet *sheet, GSList *rows, gint input_col_b, gint input_col_e, gint input_row_b, gint input_row_e) { GnmCell *cell; int i, r=0; if (dao->type == InPlaceOutput) { sheet->has_filtered_rows = TRUE; colrow_set_visibility (sheet, FALSE, FALSE, input_row_b+1, input_row_e); for (i=input_row_b; i<=input_row_e; i++) { ColRowInfo *ri = sheet_row_fetch (sheet, i); ri->in_advanced_filter = TRUE; } while (rows != NULL) { const gint *row = rows->data; colrow_set_visibility (sheet, FALSE, TRUE, *row, *row); rows = rows->next; } sheet_redraw_all (sheet, TRUE); /* FIXME: what happens if we just have hidden the selection? */ } else { for (i=input_col_b; i<=input_col_e; i++) { cell = sheet_cell_get (sheet, i, input_row_b); if (cell == NULL) dao_set_cell (dao, i - input_col_b, r, NULL); else { GnmValue *value = value_dup (cell->value); dao_set_cell_value (dao, i - input_col_b, r, value); } } ++r; while (rows != NULL) { const gint *row = rows->data; for (i=input_col_b; i<=input_col_e; i++) { cell = sheet_cell_get (sheet, i, *row); if (cell == NULL) dao_set_cell (dao, i - input_col_b, r, NULL); else { GnmValue *value = value_dup (cell->value); dao_set_cell_value (dao, i - input_col_b, r, value); } } ++r; rows = rows->next; } } }
static GnmValue * summary_cb (int col, int row, GnmValue *v, summary_cb_t *p) { char *tmp = dao_find_name (p->sheet, col, row); int *index; /* Check if some of the previous scenarios already included that * cell. If so, it's row will be put into *index. */ index = g_hash_table_lookup (p->names, tmp); if (index != NULL) { dao_set_cell_value (&p->dao, 2 + p->col, 3 + *index, value_dup (v)); /* Set the colors. */ dao_set_colors (&p->dao, 2 + p->col, 3 + *index, 2 + p->col, 3 + *index, gnm_color_new_go (GO_COLOR_BLACK), gnm_color_new_go (LIGHT_GRAY)); } else { /* New cell. */ GnmCell *cell; int *r; /* Changing cell name. */ dao_set_cell (&p->dao, 0, 3 + p->row, tmp); /* GnmValue of the cell in this scenario. */ dao_set_cell_value (&p->dao, 2 + p->col, 3 + p->row, value_dup (v)); /* Current value of the cell. */ cell = sheet_cell_fetch (p->sheet, col, row); dao_set_cell_value (&p->dao, 1, 3 + p->row, value_dup (cell->value)); /* Set the colors. */ dao_set_colors (&p->dao, 2 + p->col, 3 + p->row, 2 + p->col, 3 + p->row, gnm_color_new_go (GO_COLOR_BLACK), gnm_color_new_go (LIGHT_GRAY)); /* Insert row number into the hash table. */ r = g_new (int, 1); *r = p->row; g_hash_table_insert (p->names, tmp, r); /* Increment the nbr of rows. */ p->row++; } return v; }
static gboolean tool_random_engine_run_discrete (data_analysis_output_t *dao, tools_data_random_t *info, G_GNUC_UNUSED discrete_random_tool_t *param, discrete_random_tool_local_t **continuity) { gint i; discrete_random_tool_local_t *data = *continuity; for (i = 0; i < info->n_vars; i++) { int k; for (k = 0; k < info->count; k++) { int j; gnm_float x = random_01 (); for (j = 0; data->cumul_p[j] < x; j++) ; dao_set_cell_value (dao, i, k, value_dup (data->values[j])); } } tool_random_engine_run_discrete_clear_continuity (continuity); return FALSE; }