[gnumeric] Tools: fix handing of "as values".
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] Tools: fix handing of "as values".
- Date: Thu, 4 Nov 2010 15:16:53 +0000 (UTC)
commit bca4b6ccadbad690f17d28ad710ff67bed3e6f14
Author: Morten Welinder <terra gnome org>
Date: Thu Nov 4 11:15:54 2010 -0400
Tools: fix handing of "as values".
ChangeLog | 5 +++++
NEWS | 1 +
src/cell.c | 32 ++++++++++++++++++++++++++++++--
src/tools/ChangeLog | 6 ++++++
src/tools/dao.c | 34 +++++++++++++++++++++++-----------
5 files changed, 65 insertions(+), 13 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index c1cea86..8a75f79 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2010-11-04 Morten Welinder <terra gnome org>
+
+ * src/cell.c (gnm_cell_convert_expr_to_value): Handle array
+ corners.
+
2010-10-29 Jean Brefort <jean brefort normalesup org>
* src/sheet-object-graph.c (sog_cb_copy_to_new_sheet),
diff --git a/NEWS b/NEWS
index 53c45d6..8705a0e 100644
--- a/NEWS
+++ b/NEWS
@@ -25,6 +25,7 @@ Morten:
* Fix print area problem from broken xls.
* Fix printing crash. [#632439]
* Partially fix problem with undefined names. [#633140]
+ * Fix analysis tools problems when "as values" is chosen.
--------------------------------------------------------------------------
Gnumeric 1.10.11
diff --git a/src/cell.c b/src/cell.c
index eeda429..c673217 100644
--- a/src/cell.c
+++ b/src/cell.c
@@ -782,6 +782,21 @@ gnm_cell_set_format (GnmCell *cell, char const *format)
sheet_style_apply_range (cell->base.sheet, &r, mstyle);
}
+static GnmValue *
+cb_set_array_value (GnmCellIter const *iter, gpointer user)
+{
+ GnmCell *cell = iter->cell;
+
+ /* Clipboard cells, e.g., are not attached to a sheet. */
+ if (gnm_cell_expr_is_linked (cell))
+ dependent_unlink (GNM_CELL_TO_DEP (cell));
+
+ gnm_expr_top_unref (cell->base.texpr);
+ cell->base.texpr = NULL;
+
+ return NULL;
+}
+
/**
* gnm_cell_convert_expr_to_value : drops the expression keeps its value. Then uses the formatted
* result as if that had been entered.
@@ -793,12 +808,12 @@ gnm_cell_set_format (GnmCell *cell, char const *format)
*
* WARNING : This is an internal routine that does not queue redraws,
* does not auto-resize, and does not calculate spans.
- *
- * NOTE : This DOES NOT check for array partitioning.
*/
void
gnm_cell_convert_expr_to_value (GnmCell *cell)
{
+ GnmExprArrayCorner const *array;
+
g_return_if_fail (cell != NULL);
g_return_if_fail (gnm_cell_has_expr (cell));
@@ -806,6 +821,19 @@ gnm_cell_convert_expr_to_value (GnmCell *cell)
if (gnm_cell_expr_is_linked (cell))
dependent_unlink (GNM_CELL_TO_DEP (cell));
+ array = gnm_expr_top_get_array_corner (cell->base.texpr);
+ if (array) {
+ sheet_foreach_cell_in_range (cell->base.sheet, CELL_ITER_ALL,
+ cell->pos.col, cell->pos.row,
+ cell->pos.col + array->cols - 1,
+ cell->pos.row + array->rows - 1,
+ cb_set_array_value,
+ NULL);
+ return;
+ }
+
+ g_return_if_fail (!gnm_cell_is_array (cell));
+
gnm_expr_top_unref (cell->base.texpr);
cell->base.texpr = NULL;
}
diff --git a/src/tools/ChangeLog b/src/tools/ChangeLog
index 16a3dcb..30d2efb 100644
--- a/src/tools/ChangeLog
+++ b/src/tools/ChangeLog
@@ -1,3 +1,9 @@
+2010-11-04 Morten Welinder <terra gnome org>
+
+ * dao.c (dao_convert_to_values): Use sheet_foreach_cell_in_range
+ to avoid near-infinite loop. Fix handling of arrays. [Debian
+ 602257]
+
2010-10-02 Andreas J. Guelzow <aguelzow pyrshep ca>
* analysis-tools.c (analysis_tool_fourier_engine_run): use new
diff --git a/src/tools/dao.c b/src/tools/dao.c
index 8e2ff34..7b95de2 100644
--- a/src/tools/dao.c
+++ b/src/tools/dao.c
@@ -1073,23 +1073,35 @@ dao_put_formulas (data_analysis_output_t *dao)
return dao->put_formulas;
}
+static GnmValue *
+cb_convert_to_value (GnmCellIter const *iter, gpointer user)
+{
+ GnmCell *cell = iter->cell;
+ if (!cell || !gnm_cell_has_expr (cell))
+ return NULL;
+
+ gnm_cell_eval (cell);
+
+ if (gnm_expr_top_is_array_elem (cell->base.texpr, NULL, NULL))
+ return NULL;
+
+ gnm_cell_convert_expr_to_value (cell);
+ return NULL;
+}
+
+
void
dao_convert_to_values (data_analysis_output_t *dao)
{
- int row, col;
-
if (dao->put_formulas)
return;
- workbook_recalc (dao->sheet->workbook);
- for (row = 0; row < dao->rows; row++) {
- for (col = 0; col < dao->cols; col++) {
- GnmCell *cell = sheet_cell_get (dao->sheet,
- dao->start_col + col, dao->start_row + row);
- if (cell != NULL && gnm_cell_has_expr (cell))
- gnm_cell_convert_expr_to_value (cell);
- }
- }
+ sheet_foreach_cell_in_range (dao->sheet, CELL_ITER_IGNORE_BLANK,
+ dao->start_col, dao->start_row,
+ dao->start_col + dao->cols - 1,
+ dao->start_row + dao->rows - 1,
+ cb_convert_to_value,
+ NULL);
}
void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]