Commit 9cff38c9 authored by Jody Goldberg's avatar Jody Goldberg

1st pass at supporting overlapping selection regions correctly.

parent 6722600e
......@@ -34,6 +34,41 @@
* src/functions/fn-*: Started adding examples to all functions.
1999-09-08 Jody Goldberg <jgoldberg@home.com>
* src/*.c : Have Range use CellPos, and SheetSelection use Range.
* src/functions/fn-sheet.c (gnumeric_selection) :
Switch to selection_apply.
* src/sheet.c (sheet_set_selection) : Keep GNUMERIC_SHEET_VIEW
local to sheet.c
* src/selection.c (sheet_selection_change,
selection_append_range,
sheet_selection_extend_to) :
Use sheet_set_selection.
* src/dialogs/dialog-cell-format.c (apply_font_format,
cell_properties_apply) :
adjust to changes in SheetSelection.
* src/functions/fn-sheet.c (gnumeric_selection) : Switch to
selection_apply.
* src/gnumeric-util.c (range_contains) : Ditto. Const.
* src/selection.c (sheet_selection_clear,
sheet_selection_clear_comments,
sheet_selection_clear_content,
sheet_selection_clear_formats) :
Use selection_apply.
(selection_apply) : New function to abstracting selections enabling
correct support for overlapping selection regions.
(sheet_selection_to_list) : Use selection_apply.
* src/value.c (value_new_array_empty) : New function.
1999-09-08 Michael Meeks <michael@nuclecu.unam.mx>
* src/sheet-object.c (control_point_handle_event): substantialy
......
Gnumeric 0.33
Jody:
* Improve selection to correctly handle overlapping ranges.
--------------------------------------------------------------------------
Gnumeric 0.33, 0.34, 0.35
Jukka:
* Implemented ACCRINT, ACCRINTM, DISC, FVSCHEDULE, INTRATE,
......@@ -8,6 +13,9 @@ Jukka:
Miguel:
* Implemented Print Preview
Jody:
* Bug fixes.
--------------------------------------------------------------------------
Gnumeric 0.32
......
......@@ -34,6 +34,41 @@
* src/functions/fn-*: Started adding examples to all functions.
1999-09-08 Jody Goldberg <jgoldberg@home.com>
* src/*.c : Have Range use CellPos, and SheetSelection use Range.
* src/functions/fn-sheet.c (gnumeric_selection) :
Switch to selection_apply.
* src/sheet.c (sheet_set_selection) : Keep GNUMERIC_SHEET_VIEW
local to sheet.c
* src/selection.c (sheet_selection_change,
selection_append_range,
sheet_selection_extend_to) :
Use sheet_set_selection.
* src/dialogs/dialog-cell-format.c (apply_font_format,
cell_properties_apply) :
adjust to changes in SheetSelection.
* src/functions/fn-sheet.c (gnumeric_selection) : Switch to
selection_apply.
* src/gnumeric-util.c (range_contains) : Ditto. Const.
* src/selection.c (sheet_selection_clear,
sheet_selection_clear_comments,
sheet_selection_clear_content,
sheet_selection_clear_formats) :
Use selection_apply.
(selection_apply) : New function to abstracting selections enabling
correct support for overlapping selection regions.
(sheet_selection_to_list) : Use selection_apply.
* src/value.c (value_new_array_empty) : New function.
1999-09-08 Michael Meeks <michael@nuclecu.unam.mx>
* src/sheet-object.c (control_point_handle_event): substantialy
......
......@@ -102,8 +102,8 @@ get_data(Sheet *sheet, Range *range, data_set_t *data)
data->n = 0;
data->array = NULL;
for (col=range->start_col; col<=range->end_col; col++)
for (row=range->start_row; row<=range->end_row; row++) {
for (col=range->start.col; col<=range->end.col; col++)
for (row=range->start.row; row<=range->end.row; row++) {
cell = sheet_cell_get(sheet, col, row);
if (cell != NULL && cell->value != NULL) {
v = cell->value;
......@@ -149,7 +149,7 @@ get_data_groupped_by_columns(Sheet *sheet, Range *range, int col,
data->n = 0;
data->array = NULL;
for (row=range->start_row; row<=range->end_row; row++) {
for (row=range->start.row; row<=range->end.row; row++) {
cell = sheet_cell_get(sheet, col, row);
if (cell != NULL && cell->value != NULL) {
v = cell->value;
......@@ -195,7 +195,7 @@ get_data_groupped_by_rows(Sheet *sheet, Range *range, int row,
data->n = 0;
data->array = NULL;
for (col=range->start_col; col<=range->end_col; col++) {
for (col=range->start.col; col<=range->end.col; col++) {
cell = sheet_cell_get(sheet, col, row);
if (cell != NULL && cell->value != NULL) {
v = cell->value;
......@@ -304,8 +304,8 @@ correlation_tool (Workbook *wb, Sheet *sheet,
int vars, cols, rows, col, row, i;
int error;
cols = input_range->end_col - input_range->start_col + 1;
rows = input_range->end_row - input_range->start_row + 1;
cols = input_range->end.col - input_range->start.col + 1;
rows = input_range->end.row - input_range->start.row + 1;
prepare_output(wb, dao, "Correlations");
......@@ -318,8 +318,8 @@ correlation_tool (Workbook *wb, Sheet *sheet,
for (col=0; col<vars; col++) {
char *s;
cell = sheet_cell_get
(sheet, input_range->start_col+col,
input_range->start_row);
(sheet, input_range->start.col+col,
input_range->start.row);
if (cell != NULL && cell->value != NULL) {
s = value_get_as_string(cell->value);
set_cell (dao, 0, col+1, s);
......@@ -327,7 +327,7 @@ correlation_tool (Workbook *wb, Sheet *sheet,
} else
return 1;
}
input_range->start_row++;
input_range->start.row++;
} else
for (col=0; col<vars; col++) {
sprintf(buf, "Column %d", col+1);
......@@ -347,8 +347,8 @@ correlation_tool (Workbook *wb, Sheet *sheet,
for (col=0; col<vars; col++) {
char *s;
cell = sheet_cell_get
(sheet, input_range->start_col,
input_range->start_row+col);
(sheet, input_range->start.col,
input_range->start.row+col);
if (cell != NULL && cell->value != NULL) {
s = value_get_as_string(cell->value);
set_cell (dao, 0, col+1, s);
......@@ -356,7 +356,7 @@ correlation_tool (Workbook *wb, Sheet *sheet,
} else
return 1;
}
input_range->start_col++;
input_range->start.col++;
} else
for (col=0; col<vars; col++) {
sprintf(buf, "Row %d", col+1);
......@@ -453,8 +453,8 @@ covariance_tool (Workbook *wb, Sheet *sheet,
prepare_output(wb, dao, "Covariances");
cols = input_range->end_col - input_range->start_col + 1;
rows = input_range->end_row - input_range->start_row + 1;
cols = input_range->end.col - input_range->start.col + 1;
rows = input_range->end.row - input_range->start.row + 1;
set_cell (dao, 0, 0, "");
......@@ -465,8 +465,8 @@ covariance_tool (Workbook *wb, Sheet *sheet,
for (col=0; col<vars; col++) {
char *s;
cell = sheet_cell_get
(sheet, input_range->start_col+col,
input_range->start_row);
(sheet, input_range->start.col+col,
input_range->start.row);
if (cell != NULL && cell->value != NULL) {
s = value_get_as_string(cell->value);
set_cell (dao, 0, col+1, s);
......@@ -474,7 +474,7 @@ covariance_tool (Workbook *wb, Sheet *sheet,
} else
return 1;
}
input_range->start_row++;
input_range->start.row++;
} else
for (col=0; col<vars; col++) {
sprintf(buf, "Column %d", col+1);
......@@ -494,8 +494,8 @@ covariance_tool (Workbook *wb, Sheet *sheet,
for (col=0; col<vars; col++) {
char *s;
cell = sheet_cell_get
(sheet, input_range->start_col,
input_range->start_row+col);
(sheet, input_range->start.col,
input_range->start.row+col);
if (cell != NULL && cell->value != NULL) {
s = value_get_as_string(cell->value);
set_cell (dao, 0, col+1, s);
......@@ -503,7 +503,7 @@ covariance_tool (Workbook *wb, Sheet *sheet,
} else
return 1;
}
input_range->start_col++;
input_range->start.col++;
} else
for (col=0; col<vars; col++) {
sprintf(buf, "Row %d", col+1);
......@@ -816,8 +816,8 @@ descriptive_stat_tool (Workbook *wb, Sheet *current_sheet,
data_set_t *data_sets;
int vars, cols, rows, i;
cols = input_range->end_col - input_range->start_col + 1;
rows = input_range->end_row - input_range->start_row + 1;
cols = input_range->end.col - input_range->start.col + 1;
rows = input_range->end.row - input_range->start.row + 1;
if (columns_flag) {
vars = cols;
......@@ -1007,21 +1007,21 @@ int ztest_tool (Workbook *wb, Sheet *sheet, Range *input_range1,
char *s;
Cell *cell;
cell = sheet_cell_get(sheet, input_range1->start_col,
input_range1->start_row);
cell = sheet_cell_get(sheet, input_range1->start.col,
input_range1->start.row);
if (cell != NULL && cell->value != NULL) {
s = value_get_as_string(cell->value);
set_cell (dao, 1, 0, s);
}
cell = sheet_cell_get(sheet, input_range2->start_col,
input_range2->start_row);
cell = sheet_cell_get(sheet, input_range2->start.col,
input_range2->start.row);
if (cell != NULL && cell->value != NULL) {
s = value_get_as_string(cell->value);
set_cell (dao, 2, 0, s);
}
input_range1->start_row++;
input_range2->start_row++;
input_range1->start.row++;
input_range2->start.row++;
} else {
set_cell (dao, 1, 0, "Variable 1");
set_cell (dao, 2, 0, "Variable 2");
......@@ -1137,21 +1137,21 @@ ttest_paired_tool (Workbook *wb, Sheet *sheet, Range *input_range1,
char *s;
Cell *cell;
cell = sheet_cell_get(sheet, input_range1->start_col,
input_range1->start_row);
cell = sheet_cell_get(sheet, input_range1->start.col,
input_range1->start.row);
if (cell != NULL && cell->value != NULL) {
s = value_get_as_string(cell->value);
set_cell (dao, 1, 0, s);
}
cell = sheet_cell_get(sheet, input_range2->start_col,
input_range2->start_row);
cell = sheet_cell_get(sheet, input_range2->start.col,
input_range2->start.row);
if (cell != NULL && cell->value != NULL) {
s = value_get_as_string(cell->value);
set_cell (dao, 2, 0, s);
}
input_range1->start_row++;
input_range2->start_row++;
input_range1->start.row++;
input_range2->start.row++;
} else {
set_cell (dao, 1, 0, "Variable 1");
set_cell (dao, 2, 0, "Variable 2");
......@@ -1284,21 +1284,21 @@ ttest_eq_var_tool (Workbook *wb, Sheet *sheet, Range *input_range1,
char *s;
Cell *cell;
cell = sheet_cell_get(sheet, input_range1->start_col,
input_range1->start_row);
cell = sheet_cell_get(sheet, input_range1->start.col,
input_range1->start.row);
if (cell != NULL && cell->value != NULL) {
s = value_get_as_string(cell->value);
set_cell (dao, 1, 0, s);
}
cell = sheet_cell_get(sheet, input_range2->start_col,
input_range2->start_row);
cell = sheet_cell_get(sheet, input_range2->start.col,
input_range2->start.row);
if (cell != NULL && cell->value != NULL) {
s = value_get_as_string(cell->value);
set_cell (dao, 2, 0, s);
}
input_range1->start_row++;
input_range2->start_row++;
input_range1->start.row++;
input_range2->start.row++;
} else {
set_cell (dao, 1, 0, "Variable 1");
set_cell (dao, 2, 0, "Variable 2");
......@@ -1410,21 +1410,21 @@ ttest_neq_var_tool (Workbook *wb, Sheet *sheet, Range *input_range1,
char *s;
Cell *cell;
cell = sheet_cell_get(sheet, input_range1->start_col,
input_range1->start_row);
cell = sheet_cell_get(sheet, input_range1->start.col,
input_range1->start.row);
if (cell != NULL && cell->value != NULL) {
s = value_get_as_string(cell->value);
set_cell (dao, 1, 0, s);
}
cell = sheet_cell_get(sheet, input_range2->start_col,
input_range2->start_row);
cell = sheet_cell_get(sheet, input_range2->start.col,
input_range2->start.row);
if (cell != NULL && cell->value != NULL) {
s = value_get_as_string(cell->value);
set_cell (dao, 2, 0, s);
}
input_range1->start_row++;
input_range2->start_row++;
input_range1->start.row++;
input_range2->start.row++;
} else {
set_cell (dao, 1, 0, "Variable 1");
set_cell (dao, 2, 0, "Variable 2");
......@@ -1534,21 +1534,21 @@ ftest_tool (Workbook *wb, Sheet *sheet, Range *input_range1,
char *s;
Cell *cell;
cell = sheet_cell_get(sheet, input_range1->start_col,
input_range1->start_row);
cell = sheet_cell_get(sheet, input_range1->start.col,
input_range1->start.row);
if (cell != NULL && cell->value != NULL) {
s = value_get_as_string(cell->value);
set_cell (dao, 1, 0, s);
}
cell = sheet_cell_get(sheet, input_range2->start_col,
input_range2->start_row);
cell = sheet_cell_get(sheet, input_range2->start.col,
input_range2->start.row);
if (cell != NULL && cell->value != NULL) {
s = value_get_as_string(cell->value);
set_cell (dao, 2, 0, s);
}
input_range1->start_row++;
input_range2->start_row++;
input_range1->start.row++;
input_range2->start.row++;
} else {
set_cell (dao, 1, 0, "Variable 1");
set_cell (dao, 2, 0, "Variable 2");
......@@ -1885,8 +1885,8 @@ int average_tool (Workbook *wb, Sheet *sheet, Range *range, int interval,
int cols, rows, row, add_cursor, del_cursor, count;
/* TODO: Standard error output */
cols = range->end_col - range->start_col + 1;
rows = range->end_row - range->start_row + 1;
cols = range->end.col - range->start.col + 1;
rows = range->end.row - range->start.row + 1;
if ((cols != 1 && rows != 1) || interval < 1)
return 1;
......@@ -1965,8 +1965,8 @@ int ranking_tool (Workbook *wb, Sheet *sheet, Range *input_range,
prepare_output(wb, dao, "Ranks");
cols = input_range->end_col - input_range->start_col + 1;
rows = input_range->end_row - input_range->start_row + 1;
cols = input_range->end.col - input_range->start.col + 1;
rows = input_range->end.row - input_range->start.row + 1;
if (columns_flag) {
vars = cols;
......@@ -1975,8 +1975,8 @@ int ranking_tool (Workbook *wb, Sheet *sheet, Range *input_range,
if (dao->labels_flag) {
char *s;
Cell *cell = sheet_cell_get
(sheet, input_range->start_col+col,
input_range->start_row);
(sheet, input_range->start.col+col,
input_range->start.row);
if (cell != NULL && cell->value != NULL) {
s = value_get_as_string(cell->value);
set_cell (dao, col*4+1, 0, s);
......@@ -1991,7 +1991,7 @@ int ranking_tool (Workbook *wb, Sheet *sheet, Range *input_range,
data_sets = g_new(data_set_t, vars);
if (dao->labels_flag)
input_range->start_row++;
input_range->start.row++;
for (i=0; i<vars; i++)
get_data_groupped_by_columns(sheet,
......@@ -2005,8 +2005,8 @@ int ranking_tool (Workbook *wb, Sheet *sheet, Range *input_range,
if (dao->labels_flag) {
char *s;
Cell *cell = sheet_cell_get
(sheet, input_range->start_col,
input_range->start_row+col);
(sheet, input_range->start.col,
input_range->start.row+col);
if (cell != NULL && cell->value != NULL) {
s = value_get_as_string(cell->value);
set_cell (dao, col*4+1, 0, s);
......@@ -2021,7 +2021,7 @@ int ranking_tool (Workbook *wb, Sheet *sheet, Range *input_range,
data_sets = g_new(data_set_t, vars);
if (dao->labels_flag)
input_range->start_col++;
input_range->start.col++;
for (i=0; i<vars; i++)
get_data_groupped_by_rows(sheet,
......@@ -2107,8 +2107,8 @@ int anova_single_factor_tool (Workbook *wb, Sheet *sheet, Range *range,
prepare_output(wb, dao, "Anova");
cols = range->end_col - range->start_col + 1;
rows = range->end_row - range->start_row + 1;
cols = range->end.col - range->start.col + 1;
rows = range->end.row - range->start.row + 1;
set_cell (dao, 0, 0, "Anova: Single Factor");
set_cell (dao, 0, 2, "SUMMARY");
......@@ -2124,8 +2124,8 @@ int anova_single_factor_tool (Workbook *wb, Sheet *sheet, Range *range,
if (dao->labels_flag) {
char *s;
Cell *cell = sheet_cell_get
(sheet, range->start_col+col,
range->start_row);
(sheet, range->start.col+col,
range->start.row);
if (cell != NULL && cell->value != NULL) {
s = value_get_as_string(cell->value);
set_cell (dao, 0, col+4, s);
......@@ -2138,7 +2138,7 @@ int anova_single_factor_tool (Workbook *wb, Sheet *sheet, Range *range,
data_sets = g_new(data_set_t, vars);
if (dao->labels_flag)
range->start_row++;
range->start.row++;
for (i=0; i<vars; i++)
get_data_groupped_by_columns(sheet,
......@@ -2150,8 +2150,8 @@ int anova_single_factor_tool (Workbook *wb, Sheet *sheet, Range *range,
if (dao->labels_flag) {
char *s;
Cell *cell = sheet_cell_get
(sheet, range->start_col,
range->start_row+col);
(sheet, range->start.col,
range->start.row+col);
if (cell != NULL && cell->value != NULL) {
s = value_get_as_string(cell->value);
set_cell (dao, 0, col+4, s);
......@@ -2164,7 +2164,7 @@ int anova_single_factor_tool (Workbook *wb, Sheet *sheet, Range *range,
data_sets = g_new(data_set_t, vars);
if (dao->labels_flag)
range->start_col++;
range->start.col++;
for (i=0; i<vars; i++)
get_data_groupped_by_rows(sheet,
......@@ -2297,8 +2297,8 @@ int anova_two_factor_without_r_tool (Workbook *wb, Sheet *sheet, Range *range,
prepare_output(wb, dao, "Anova");
cols = range->end_col - range->start_col + 1;
rows = range->end_row - range->start_row + 1;
cols = range->end.col - range->start.col + 1;
rows = range->end.row - range->start.row + 1;
set_cell (dao, 0, 0, "Anova: Two-Factor Without Replication");
set_cell (dao, 0, 2, "SUMMARY");
......
......@@ -16,6 +16,7 @@
#include "gnumeric-util.h"
#include "clipboard.h"
#include "eval.h"
#include "selection.h"
#include "render-ascii.h"
/*
......@@ -136,7 +137,8 @@ do_clipboard_paste_cell_region (CellRegion *region, Sheet *dest_sheet,
sheet_clear_region (dest_sheet,
dest_col, dest_row,
dest_col + paste_width - 1,
dest_row + paste_height - 1);
dest_row + paste_height - 1,
NULL);
/* If no operations are defined, we clear the area */
if (!(paste_flags & PASTE_OPER_MASK))
......@@ -285,13 +287,13 @@ sheet_paste_selection (Sheet *sheet, CellRegion *content, SheetSelection *ss, cl
int end_col, end_row;
/* Compute the bigger bounding box (selection u clipboard-region) */
if (ss->end_col - ss->start_col + 1 > content->cols)
paste_width = ss->end_col - ss->start_col + 1;
if (ss->user.end.col - ss->user.start.col + 1 > content->cols)
paste_width = ss->user.end.col - ss->user.start.col + 1;
else
paste_width = content->cols;
if (ss->end_row - ss->start_row + 1 > content->rows)
paste_height = ss->end_row - ss->start_row + 1;
if (ss->user.end.row - ss->user.start.row + 1 > content->rows)
paste_height = ss->user.end.row - ss->user.start.row + 1;
else
paste_height = content->rows;
......
......@@ -75,13 +75,13 @@ dependency_equal (gconstpointer v, gconstpointer v2)
if (r1->sheet != r2->sheet)
return 0;
if (r1->range.start_col != r2->range.start_col)
if (r1->range.start.col != r2->range.start.col)
return 0;
if (r1->range.start_row != r2->range.start_row)
if (r1->range.start.row != r2->range.start.row)
return 0;
if (r1->range.end_col != r2->range.end_col)
if (r1->range.end.col != r2->range.end.col)
return 0;
if (r1->range.end_row != r2->range.end_row)
if (r1->range.end.row != r2->range.end.row)
return 0;
return 1;
......@@ -95,8 +95,8 @@ dependency_hash_func (gconstpointer v)
{
const DependencyRange *r = v;
return ((((r->range.start_row << 8) + r->range.end_row) << 8) +
(r->range.start_col << 8) + (r->range.end_col));
return ((((r->range.start.row << 8) + r->range.end.row) << 8) +
(r->range.start.col << 8) + (r->range.end.col));
}
/*
......@@ -151,8 +151,8 @@ add_cell_range_deps (Cell *cell, const CellRef *a, const CellRef *b)
int row = cell->row->pos;
/* Convert to absolute cordinates */
cell_get_abs_col_row (a, col, row, &range.range.start_col, &range.range.start_row);
cell_get_abs_col_row (b, col, row, &range.range.end_col, &range.range.end_row);
cell_get_abs_col_row (a, col, row, &range.range.start.col, &range.range.start.row);
cell_get_abs_col_row (b, col, row, &range.range.end.col, &range.range.end.row);
range.ref_count = 0;
if (b->sheet && a->sheet != b->sheet)
......@@ -250,9 +250,9 @@ add_tree_deps (Cell *cell, ExprTree *tree)
Cell * corner = tree->u.array.corner.cell;
range.ref_count = 0;
range.sheet = cell->sheet;
range.range.start_col = range.range.end_col =
range.range.start.col = range.range.end.col =
corner->col->pos;
range.range.start_row = range.range.end_row =
range.range.start.row = range.range.end.row =
corner->row->pos;
add_cell_range_dep (cell, &range);
} else
......
......@@ -305,10 +305,10 @@ parse_output(int output, Sheet *sheet,
Range range;
text = gtk_entry_get_text (GTK_ENTRY (entry));
if (output == 2 && !parse_range (text, &range.start_col,
&range.start_row,
&range.end_col,
&range.end_row)) {
if (output == 2 && !parse_range (text, &range.start.col,
&range.start.row,
&range.end.col,
&range.end.row)) {
error_in_entry(wb, entry,
"You should introduce a valid cell range "
"in 'Into a Range:'");
......@@ -324,10 +324,10 @@ parse_output(int output, Sheet *sheet,
break;
case 2:
dao->type = RangeOutput;
dao->start_col = range.start_col;
dao->start_row = range.start_row;
dao->cols = range.end_col-range.start_col+1;
dao->rows = range.end_row-range.start_row+1;
dao->start_col = range.start.col;
dao->start_row = range.start.row;
dao->cols = range.end.col-range.start.col+1;
dao->rows = range.end.row-range.start.row+1;
dao->sheet = sheet;
break;
}
......@@ -445,10 +445,10 @@ correlation_dialog_loop:
output = gtk_radio_group_get_selected (output_ops);
text = gtk_entry_get_text (GTK_ENTRY (range_entry));