Commit 77a3108a authored by Andreas J. Guelzow 's avatar Andreas J. Guelzow Committed by Andreas J. Guelzow

add field (cmd_analysis_tool_undo): delete associated sheet objects

2008-09-18  Andreas J. Guelzow <aguelzow@pyrshep.ca>

	* src/commands.c (CmdAnalysis_Tool): add field
	(cmd_analysis_tool_undo): delete associated sheet objects
	(cmd_analysis_tool_draw_old_so): new
	(cmd_analysis_tool_redo): use the above
	(cmd_analysis_tool_finalize): handle new fields

2008-09-18  Andreas J. Guelzow <aguelzow@pyrshep.ca>

	* analysis-histogram.c (analysis_tool_histogram_engine_run): we need to 
	keep the values around for potential redos.
	(analysis_tool_histogram_engine): clean up when asked to do so.
	* analysis-tools.h (analysis_tool_generic_clean): needs to be non-static
	* analysis-tools.c (analysis_tool_generic_clean): make non-static
	  and remove unneeded argument. Change all callers.
	* dao.h (data_analysis_output_t): add fields
	(dao_free): new
	(dao_surrender_so): new
	(dao_set_omit_so): new
	* dao.c (dao_free): new
	(dao_surrender_so): new
	(dao_set_omit_so): new
	(dao_init): handle new fields
	(dao_set_sheet_object): don't write sheet objects when omit_so is true.


svn path=/trunk/; revision=16807
parent bad096ee
......@@ -758,7 +758,7 @@ Architecture Changes
38) Printing
38.1) cell text wraps differently when printing than
displaying due to scaling differences in font size.
displaying due to scaling differences in font size. (DONE)
38.2) explicit page breaks
38.3) PI:comment_placement
38.4) PI:display_errors
......
2008-09-18 Andreas J. Guelzow <aguelzow@pyrshep.ca>
* src/commands.c (CmdAnalysis_Tool): add field
(cmd_analysis_tool_undo): delete associated sheet objects
(cmd_analysis_tool_draw_old_so): new
(cmd_analysis_tool_redo): use the above
(cmd_analysis_tool_finalize): handle new fields
2008-09-14 Jody Goldberg <jody@gnome.org>
* src/selection.c (sv_selection_apply_in_order) : suppress warning.
......
......@@ -4942,8 +4942,9 @@ typedef struct {
ColRowStateList *col_info;
ColRowStateList *row_info;
GnmRange old_range;
GnmCellRegion *old_contents;
GnmRange old_range;
GnmCellRegion *old_contents;
GSList *newSheetObjects;
} CmdAnalysis_Tool;
MAKE_GNM_COMMAND (CmdAnalysis_Tool, cmd_analysis_tool, NULL)
......@@ -4987,6 +4988,9 @@ cmd_analysis_tool_undo (GnmCommand *cmd, WorkbookControl *wbc)
dao_set_colrow_state_list (me->dao, FALSE, me->row_info);
me->row_info = colrow_state_list_destroy (me->row_info);
}
if (me->newSheetObjects == NULL)
me->newSheetObjects = dao_surrender_so (me->dao);
g_slist_foreach (me->newSheetObjects, (GFunc)sheet_object_clear_sheet, NULL);
workbook_recalc (me->dao->sheet->workbook);
sheet_update (me->dao->sheet);
}
......@@ -4994,6 +4998,13 @@ cmd_analysis_tool_undo (GnmCommand *cmd, WorkbookControl *wbc)
return FALSE;
}
static void
cmd_analysis_tool_draw_old_so (SheetObject *so, data_analysis_output_t *dao)
{
g_object_ref (G_OBJECT (so));
dao_set_sheet_object (dao, 0, 1, so);
}
static gboolean
cmd_analysis_tool_redo (GnmCommand *cmd, WorkbookControl *wbc)
{
......@@ -5033,6 +5044,9 @@ cmd_analysis_tool_redo (GnmCommand *cmd, WorkbookControl *wbc)
break;
}
if (me->newSheetObjects != NULL)
dao_set_omit_so (me->dao, TRUE);
if (me->engine (me->dao, me->specs, TOOL_ENGINE_FORMAT_OUTPUT_RANGE, NULL))
return TRUE;
......@@ -5043,6 +5057,18 @@ cmd_analysis_tool_redo (GnmCommand *cmd, WorkbookControl *wbc)
} else
return TRUE;
}
if (me->newSheetObjects != NULL)
{
GSList *l = g_slist_reverse
(g_slist_copy (me->newSheetObjects));
dao_set_omit_so (me->dao, FALSE);
g_slist_foreach (l,
(GFunc) cmd_analysis_tool_draw_old_so,
me->dao);
g_slist_free (l);
}
if (continuity) {
g_warning ("There shouldn't be any data left in here!");
}
......@@ -5074,11 +5100,13 @@ cmd_analysis_tool_finalize (GObject *cmd)
if (me->specs_owned) {
g_free (me->specs);
g_free (me->dao);
dao_free (me->dao);
}
if (me->old_contents)
cellregion_unref (me->old_contents);
go_slist_free_custom (me->newSheetObjects, g_object_unref);
gnm_command_finalize (cmd);
}
......
2008-09-18 Andreas J. Guelzow <aguelzow@pyrshep.ca>
* analysis-histogram.c (analysis_tool_histogram_engine_run): we need to
keep the values around for potential redos.
(analysis_tool_histogram_engine): clean up when asked to do so.
* analysis-tools.h (analysis_tool_generic_clean): needs to be non-static
* analysis-tools.c (analysis_tool_generic_clean): make non-static
and remove unneeded argument. Change all callers.
* dao.h (data_analysis_output_t): add fields
(dao_free): new
(dao_surrender_so): new
(dao_set_omit_so): new
* dao.c (dao_free): new
(dao_surrender_so): new
(dao_set_omit_so): new
(dao_init): handle new fields
(dao_set_sheet_object): don't write sheet objects when omit_so is true.
2008-09-17 Andreas J. Guelzow <aguelzow@pyrshep.ca>
* analysis-histogram.c (analysis_tool_histogram_engine_run): set the
......
......@@ -225,7 +225,7 @@ analysis_tool_histogram_engine_run (data_analysis_output_t *dao,
}
for (l = info->base.input, col = to_col + 1; l; col++, l = l->next) {
GnmValue *val = l->data;
GnmValue *val = value_dup ((GnmValue *)l->data);
GnmValue *val_c = NULL;
GnmExpr const *expr_count;
GnmExpr const *expr_data;
......@@ -428,7 +428,7 @@ analysis_tool_histogram_engine (data_analysis_output_t *dao, gpointer specs,
return FALSE;
}
case TOOL_ENGINE_CLEAN_UP:
return FALSE;
return analysis_tool_generic_clean (specs);
case TOOL_ENGINE_LAST_VALIDITY_CHECK:
return FALSE;
case TOOL_ENGINE_PREPARE_OUTPUT_RANGE:
......
......@@ -684,9 +684,8 @@ write_data (data_analysis_output_t *dao, GArray *data)
(CellIterFunc)&cb_write_data, data);
}
static gboolean
analysis_tool_generic_clean (G_GNUC_UNUSED data_analysis_output_t *dao,
gpointer specs)
gboolean
analysis_tool_generic_clean (gpointer specs)
{
analysis_tools_data_generic_t *info = specs;
......@@ -832,7 +831,7 @@ analysis_tool_correlation_engine (data_analysis_output_t *dao, gpointer specs,
1 + g_slist_length (info->input));
return FALSE;
case TOOL_ENGINE_CLEAN_UP:
return analysis_tool_generic_clean (dao, specs);
return analysis_tool_generic_clean (specs);
case TOOL_ENGINE_LAST_VALIDITY_CHECK:
return FALSE;
case TOOL_ENGINE_PREPARE_OUTPUT_RANGE:
......@@ -886,7 +885,7 @@ analysis_tool_covariance_engine (data_analysis_output_t *dao, gpointer specs,
1 + g_slist_length (info->input));
return FALSE;
case TOOL_ENGINE_CLEAN_UP:
return analysis_tool_generic_clean (dao, specs);
return analysis_tool_generic_clean (specs);
case TOOL_ENGINE_LAST_VALIDITY_CHECK:
return FALSE;
case TOOL_ENGINE_PREPARE_OUTPUT_RANGE:
......@@ -1273,7 +1272,7 @@ analysis_tool_descriptive_engine (data_analysis_output_t *dao, gpointer specs,
(info->kth_smallest ? 4 : 0 ) - 1);
return FALSE;
case TOOL_ENGINE_CLEAN_UP:
return analysis_tool_generic_clean (dao, specs);
return analysis_tool_generic_clean (specs);
case TOOL_ENGINE_LAST_VALIDITY_CHECK:
return FALSE;
case TOOL_ENGINE_PREPARE_OUTPUT_RANGE:
......@@ -1395,7 +1394,7 @@ analysis_tool_sampling_engine (data_analysis_output_t *dao, gpointer specs,
1 + info->size);
return FALSE;
case TOOL_ENGINE_CLEAN_UP:
return analysis_tool_generic_clean (dao, specs);
return analysis_tool_generic_clean (specs);
case TOOL_ENGINE_LAST_VALIDITY_CHECK:
return FALSE;
case TOOL_ENGINE_PREPARE_OUTPUT_RANGE:
......@@ -3436,7 +3435,7 @@ analysis_tool_moving_average_engine (data_analysis_output_t *dao, gpointer specs
1 + analysis_tool_calc_length (specs));
return FALSE;
case TOOL_ENGINE_CLEAN_UP:
return analysis_tool_generic_clean (dao, specs);
return analysis_tool_generic_clean (specs);
case TOOL_ENGINE_LAST_VALIDITY_CHECK:
return FALSE;
case TOOL_ENGINE_PREPARE_OUTPUT_RANGE:
......@@ -3569,7 +3568,7 @@ analysis_tool_exponential_smoothing_engine (data_analysis_output_t *dao,
1 + analysis_tool_calc_length (specs));
return FALSE;
case TOOL_ENGINE_CLEAN_UP:
return analysis_tool_generic_clean (dao, specs);
return analysis_tool_generic_clean (specs);
case TOOL_ENGINE_LAST_VALIDITY_CHECK:
return FALSE;
case TOOL_ENGINE_PREPARE_OUTPUT_RANGE:
......@@ -3701,7 +3700,7 @@ analysis_tool_ranking_engine (data_analysis_output_t *dao, gpointer specs,
1 + analysis_tool_calc_length (specs));
return FALSE;
case TOOL_ENGINE_CLEAN_UP:
return analysis_tool_generic_clean (dao, specs);
return analysis_tool_generic_clean (specs);
case TOOL_ENGINE_LAST_VALIDITY_CHECK:
return FALSE;
case TOOL_ENGINE_PREPARE_OUTPUT_RANGE:
......@@ -4035,7 +4034,7 @@ analysis_tool_anova_single_engine (data_analysis_output_t *dao, gpointer specs,
dao_adjust (dao, 7, 11 + g_slist_length (info->base.input));
return FALSE;
case TOOL_ENGINE_CLEAN_UP:
return analysis_tool_generic_clean (dao, specs);
return analysis_tool_generic_clean (specs);
case TOOL_ENGINE_LAST_VALIDITY_CHECK:
return FALSE;
case TOOL_ENGINE_PREPARE_OUTPUT_RANGE:
......@@ -4869,7 +4868,7 @@ analysis_tool_fourier_engine (data_analysis_output_t *dao, gpointer specs,
2 + analysis_tool_fourier_calc_length (specs));
return FALSE;
case TOOL_ENGINE_CLEAN_UP:
return analysis_tool_generic_clean (dao, specs);
return analysis_tool_generic_clean (specs);
case TOOL_ENGINE_LAST_VALIDITY_CHECK:
return FALSE;
case TOOL_ENGINE_PREPARE_OUTPUT_RANGE:
......
......@@ -226,14 +226,11 @@ typedef struct {
gboolean analysis_tool_anova_two_factor_engine (data_analysis_output_t *dao, gpointer specs,
analysis_tool_engine_t selector, gpointer result);
/* THINGS NEEDED FOR THE HISTOGRAM SPLIT-OUT */
/*
* prepare_input_range:
* @input_range:
* @group_by:
*
*/
/********************************************************************/
/* Functions also needed elsewhere. */
gboolean analysis_tool_generic_clean (gpointer specs);
void prepare_input_range (GSList **input_range, group_by_t group_by);
const GnmExpr *make_cellref (int dx, int dy);
......
......@@ -64,8 +64,11 @@ data_analysis_output_t *
dao_init (data_analysis_output_t *dao,
data_analysis_output_type_t type)
{
if (dao == NULL)
if (dao == NULL) {
dao = g_new (data_analysis_output_t, 1);
dao->use_gfree = TRUE;
} else
dao->use_gfree = FALSE;
dao->type = type;
dao->start_col = 0;
......@@ -80,10 +83,21 @@ dao_init (data_analysis_output_t *dao,
dao->retain_format = FALSE;
dao->retain_comments = FALSE;
dao->put_formulas = FALSE;
dao->sos = NULL;
dao->omit_so = FALSE;
return dao;
}
void dao_free (data_analysis_output_t *dao)
{
go_slist_free_custom (dao->sos, g_object_unref);
dao->sos = NULL;
if (dao->use_gfree)
g_free (dao);
}
data_analysis_output_t *
dao_load_from_value (data_analysis_output_t *dao,
GnmValue *output_range)
......@@ -1156,6 +1170,11 @@ dao_set_sheet_object (data_analysis_output_t *dao, int col, int row, SheetObject
GnmRange anchor_r;
g_return_if_fail (so != NULL);
if (dao->omit_so) {
g_object_unref (so);
return;
}
range_init (&anchor_r, dao->start_col + col, dao->start_row + row,
dao->start_col + ((dao->cols < 5) ? dao->cols : 5),
......@@ -1164,7 +1183,8 @@ dao_set_sheet_object (data_analysis_output_t *dao, int col, int row, SheetObject
sheet_object_anchor_init (&anchor, &anchor_r, 0, GOD_ANCHOR_DIR_UNKNOWN);
sheet_object_set_anchor (so, &anchor);
sheet_object_set_sheet (so, dao->sheet);
g_object_unref (so);
dao->sos = g_slist_prepend (dao->sos, so);
}
GOData *
......@@ -1172,3 +1192,18 @@ dao_go_data_vector (data_analysis_output_t *dao, int ax, int ay, int bx, int by
{
return gnm_go_data_vector_new_expr (dao->sheet, gnm_expr_top_new (dao_get_rangeref (dao, ax, ay, bx, by)));
}
GSList *
dao_surrender_so (data_analysis_output_t *dao)
{
GSList *l = dao->sos;
dao->sos = NULL;
return l;
}
void
dao_set_omit_so (data_analysis_output_t *dao, gboolean omit)
{
dao->omit_so = omit;
}
......@@ -49,12 +49,16 @@ typedef struct {
gboolean retain_comments;
gboolean put_formulas;
WorkbookControl *wbc;
GSList *sos;
gboolean omit_so;
gboolean use_gfree;
} data_analysis_output_t;
data_analysis_output_t *dao_init (data_analysis_output_t *dao,
data_analysis_output_type_t type);
data_analysis_output_t *dao_load_from_value (data_analysis_output_t *dao,
GnmValue *output_range);
void dao_free (data_analysis_output_t *dao);
void dao_autofit_columns (data_analysis_output_t *dao);
void dao_autofit_these_columns (data_analysis_output_t *dao, int from_col,
......@@ -133,4 +137,11 @@ GnmExpr const *dao_get_rangeref (data_analysis_output_t *dao, int ax, int ay, i
GOData *dao_go_data_vector (data_analysis_output_t *dao, int ax, int ay, int bx, int by);
/* The following 2 functions are intended solely for undo support */
/* of sheet objects normally created by the dao. */
GSList *dao_surrender_so (data_analysis_output_t *dao);
void dao_set_omit_so (data_analysis_output_t *dao, gboolean omit);
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment