Commit d3276a42 authored by Miguel de Icaza's avatar Miguel de Icaza Committed by Arturo Espinosa

New version that makes sure the column information has been allocated.

1998-09-25  Miguel de Icaza  <miguel@nuclecu.unam.mx>

	* src/sheet.c (sheet_selection_row_extend_to,
	sheet_selection_col_extend_to): New version that makes sure the
	column information has been allocated.

	* src/workbook.c (workbook_parse_and_jump): Maximum ranges were a
	little bit off.

	* src/parser.y (return_cellref): Fixed the same bug we had in
	parse_cell_name:  The parsing of the column name to a column index
	was wrong here too.

	* src/sheet.c (sheet_row_info_set_height,
	sheet_col_info_set_width): New functions based on the older
	non-ColRowInfo versions.

	* src/sheet-view.c (sheet_view_row_size_changed,
	sheet_view_col_size_changed): Apply changes globaly if the whole
	sheet is selected.
parent bff209aa
1998-09-25 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/sheet.c (sheet_selection_row_extend_to,
sheet_selection_col_extend_to): New version that makes sure the
column information has been allocated.
* src/workbook.c (workbook_parse_and_jump): Maximum ranges were a
little bit off.
* src/parser.y (return_cellref): Fixed the same bug we had in
parse_cell_name: The parsing of the column name to a column index
was wrong here too.
* src/sheet.c (sheet_row_info_set_height,
sheet_col_info_set_width): New functions based on the older
non-ColRowInfo versions.
* src/sheet-view.c (sheet_view_row_size_changed,
sheet_view_col_size_changed): Apply changes globaly if the whole
sheet is selected.
1998-09-25 Adrian Likins <adrian@gimp.org>
* docs/dndselection.sgml, selection.sml: more docs, some
......
1998-09-25 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/sheet.c (sheet_selection_row_extend_to,
sheet_selection_col_extend_to): New version that makes sure the
column information has been allocated.
* src/workbook.c (workbook_parse_and_jump): Maximum ranges were a
little bit off.
* src/parser.y (return_cellref): Fixed the same bug we had in
parse_cell_name: The parsing of the column name to a column index
was wrong here too.
* src/sheet.c (sheet_row_info_set_height,
sheet_col_info_set_width): New functions based on the older
non-ColRowInfo versions.
* src/sheet-view.c (sheet_view_row_size_changed,
sheet_view_col_size_changed): Apply changes globaly if the whole
sheet is selected.
1998-09-25 Adrian Likins <adrian@gimp.org>
* docs/dndselection.sgml, selection.sml: more docs, some
......
1998-09-25 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/sheet.c (sheet_selection_row_extend_to,
sheet_selection_col_extend_to): New version that makes sure the
column information has been allocated.
* src/workbook.c (workbook_parse_and_jump): Maximum ranges were a
little bit off.
* src/parser.y (return_cellref): Fixed the same bug we had in
parse_cell_name: The parsing of the column name to a column index
was wrong here too.
* src/sheet.c (sheet_row_info_set_height,
sheet_col_info_set_width): New functions based on the older
non-ColRowInfo versions.
* src/sheet-view.c (sheet_view_row_size_changed,
sheet_view_col_size_changed): Apply changes globaly if the whole
sheet is selected.
1998-09-25 Adrian Likins <adrian@gimp.org>
* docs/dndselection.sgml, selection.sml: more docs, some
......
1998-09-25 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/sheet.c (sheet_selection_row_extend_to,
sheet_selection_col_extend_to): New version that makes sure the
column information has been allocated.
* src/workbook.c (workbook_parse_and_jump): Maximum ranges were a
little bit off.
* src/parser.y (return_cellref): Fixed the same bug we had in
parse_cell_name: The parsing of the column name to a column index
was wrong here too.
* src/sheet.c (sheet_row_info_set_height,
sheet_col_info_set_width): New functions based on the older
non-ColRowInfo versions.
* src/sheet-view.c (sheet_view_row_size_changed,
sheet_view_col_size_changed): Apply changes globaly if the whole
sheet is selected.
1998-09-25 Adrian Likins <adrian@gimp.org>
* docs/dndselection.sgml, selection.sml: more docs, some
......
......@@ -437,11 +437,14 @@ item_bar_event (GnomeCanvasItem *item, GdkEvent *e)
}
else if (ITEM_BAR_IS_SELECTING (item_bar))
{
element = get_col_from_pos (item_bar, pos);
gtk_signal_emit (GTK_OBJECT (item),
item_bar_signals [SELECTION_CHANGED],
element, FALSE);
gtk_signal_emit (
GTK_OBJECT (item),
item_bar_signals [SELECTION_CHANGED],
element, FALSE);
set_cursor (item_bar, pos);
}
else
......
......@@ -23,6 +23,8 @@ typedef struct {
int resize_guide_offset;
int dragging : 1;
/* Where the selection started */
int start_selection;
} ItemBar;
......
......@@ -50,9 +50,12 @@ typedef struct {
GnomeCanvasItemClass parent_class;
} ItemCursorClass;
void item_cursor_set_bounds (ItemCursor *item_cursor,
int start_col, int start_row,
int end_col, int end_row);
void item_cursor_set_bounds (ItemCursor *item_cursor,
int start_col, int start_row,
int end_col, int end_row);
void item_cursor_set_visibility (ItemCursor *item_cursor,
int visible);
#endif
......@@ -253,7 +253,7 @@ return_cellref (char *p)
col = toupper (*p++) - 'A';
if (toupper (*p) >= 'A' && toupper (*p) <= 'Z')
col = col * ('Z'-'A') + toupper (*p++) - 'A';
col = (col+1) * ('Z'-'A'+1) + toupper (*p++) - 'A';
/* Try to parse a row */
if (*p == '$'){
......
......@@ -13,6 +13,7 @@
#include <string.h>
#include "gnumeric.h"
#include "gnumeric-sheet.h"
#include "item-cursor.h"
static GtkTableClass *sheet_view_parent_class;
......@@ -223,8 +224,6 @@ sheet_view_col_selection_changed (ItemBar *item_bar, int column, int reset, Shee
ColRowInfo *ci;
Sheet *sheet = sheet_view->sheet;
ci = sheet_col_get (sheet, column);
if (reset){
sheet_cursor_set (sheet, column, 0, column, SHEET_MAX_ROWS - 1);
sheet_selection_reset_only (sheet);
......@@ -232,6 +231,7 @@ sheet_view_col_selection_changed (ItemBar *item_bar, int column, int reset, Shee
column, 0,
column, 0,
column, SHEET_MAX_ROWS-1);
ci = sheet_col_get (sheet, column);
sheet_col_set_selection (sheet, ci, 1);
} else
sheet_selection_col_extend_to (sheet, column);
......@@ -242,7 +242,10 @@ sheet_view_col_size_changed (ItemBar *item_bar, int col, int width, SheetView *s
{
Sheet *sheet = sheet_view->sheet;
GList *l;
if (sheet_is_all_selected (sheet))
sheet_col_info_set_width (sheet, &sheet->default_col_style, width);
for (l = sheet->cols_info; l; l = l->next){
ColRowInfo *ci = l->data;
......@@ -259,8 +262,6 @@ sheet_view_row_selection_changed (ItemBar *item_bar, int row, int reset, SheetVi
ColRowInfo *ri;
Sheet *sheet = sheet_view->sheet;
ri = sheet_row_get (sheet, row);
if (reset){
sheet_cursor_set (sheet, 0, row, SHEET_MAX_COLS-1, row);
sheet_selection_reset_only (sheet);
......@@ -268,6 +269,7 @@ sheet_view_row_selection_changed (ItemBar *item_bar, int row, int reset, SheetVi
0, row,
0, row,
SHEET_MAX_COLS-1, row);
ri = sheet_row_get (sheet, row);
sheet_row_set_selection (sheet, ri, 1);
} else
sheet_selection_row_extend_to (sheet, row);
......@@ -279,6 +281,9 @@ sheet_view_row_size_changed (ItemBar *item_bar, int row, int height, SheetView *
Sheet *sheet = sheet_view->sheet;
GList *l;
if (sheet_is_all_selected (sheet))
sheet_row_info_set_height (sheet, &sheet->default_row_style, height, TRUE);
for (l = sheet->rows_info; l; l = l->next){
ColRowInfo *ri = l->data;
......
......@@ -13,6 +13,7 @@
#include <string.h>
#include "gnumeric.h"
#include "gnumeric-sheet.h"
#include "item-cursor.h"
static GtkTableClass *sheet_view_parent_class;
......@@ -223,8 +224,6 @@ sheet_view_col_selection_changed (ItemBar *item_bar, int column, int reset, Shee
ColRowInfo *ci;
Sheet *sheet = sheet_view->sheet;
ci = sheet_col_get (sheet, column);
if (reset){
sheet_cursor_set (sheet, column, 0, column, SHEET_MAX_ROWS - 1);
sheet_selection_reset_only (sheet);
......@@ -232,6 +231,7 @@ sheet_view_col_selection_changed (ItemBar *item_bar, int column, int reset, Shee
column, 0,
column, 0,
column, SHEET_MAX_ROWS-1);
ci = sheet_col_get (sheet, column);
sheet_col_set_selection (sheet, ci, 1);
} else
sheet_selection_col_extend_to (sheet, column);
......@@ -242,7 +242,10 @@ sheet_view_col_size_changed (ItemBar *item_bar, int col, int width, SheetView *s
{
Sheet *sheet = sheet_view->sheet;
GList *l;
if (sheet_is_all_selected (sheet))
sheet_col_info_set_width (sheet, &sheet->default_col_style, width);
for (l = sheet->cols_info; l; l = l->next){
ColRowInfo *ci = l->data;
......@@ -259,8 +262,6 @@ sheet_view_row_selection_changed (ItemBar *item_bar, int row, int reset, SheetVi
ColRowInfo *ri;
Sheet *sheet = sheet_view->sheet;
ri = sheet_row_get (sheet, row);
if (reset){
sheet_cursor_set (sheet, 0, row, SHEET_MAX_COLS-1, row);
sheet_selection_reset_only (sheet);
......@@ -268,6 +269,7 @@ sheet_view_row_selection_changed (ItemBar *item_bar, int row, int reset, SheetVi
0, row,
0, row,
SHEET_MAX_COLS-1, row);
ri = sheet_row_get (sheet, row);
sheet_row_set_selection (sheet, ri, 1);
} else
sheet_selection_row_extend_to (sheet, row);
......@@ -279,6 +281,9 @@ sheet_view_row_size_changed (ItemBar *item_bar, int row, int height, SheetView *
Sheet *sheet = sheet_view->sheet;
GList *l;
if (sheet_is_all_selected (sheet))
sheet_row_info_set_height (sheet, &sheet->default_row_style, height, TRUE);
for (l = sheet->rows_info; l; l = l->next){
ColRowInfo *ri = l->data;
......
......@@ -341,6 +341,23 @@ colrow_set_units (Sheet *sheet, ColRowInfo *info)
(info->margin_a + info->margin_b + 1)) / pix;
}
void
sheet_row_info_set_height (Sheet *sheet, ColRowInfo *ri, int height, gboolean height_set_by_user)
{
g_return_if_fail (sheet != NULL);
g_return_if_fail (IS_SHEET (sheet));
g_return_if_fail (ri != NULL);
if (height_set_by_user)
ri->hard_size = 1;
ri->pixels = height;
colrow_set_units (sheet, ri);
sheet_compute_visible_ranges (sheet);
sheet_redraw_all (sheet);
}
/*
* sheet_row_set_height
* @sheet: The sheet
......@@ -358,6 +375,9 @@ sheet_row_set_height (Sheet *sheet, int row, int height, gboolean height_set_by_
ColRowInfo *ri;
int add = 0;
g_return_if_fail (sheet != NULL);
g_return_if_fail (IS_SHEET (sheet));
ri = sheet_row_get_info (sheet, row);
if (ri == &sheet->default_row_style){
ri = sheet_duplicate_colrow (ri);
......@@ -365,15 +385,10 @@ sheet_row_set_height (Sheet *sheet, int row, int height, gboolean height_set_by_
add = 1;
}
if (height_set_by_user)
ri->hard_size = 1;
sheet_row_info_set_height (sheet, ri, height, height_set_by_user);
ri->pixels = height;
colrow_set_units (sheet, ri);
if (add)
sheet_row_add (sheet, ri);
sheet_compute_visible_ranges (sheet);
sheet_redraw_all (sheet);
}
/*
......@@ -450,29 +465,44 @@ sheet_recompute_spans_for_col (Sheet *sheet, int col)
g_list_free (cells);
}
void
sheet_col_info_set_width (Sheet *sheet, ColRowInfo *ci, int width)
{
g_return_if_fail (sheet != NULL);
g_return_if_fail (IS_SHEET (sheet));
g_return_if_fail (ci != NULL);
ci->pixels = width;
colrow_set_units (sheet, ci);
sheet_compute_visible_ranges (sheet);
sheet_redraw_all (sheet);
}
void
sheet_col_set_width (Sheet *sheet, int col, int width)
{
ColRowInfo *ci;
int add = 0;
g_return_if_fail (sheet != NULL);
g_return_if_fail (IS_SHEET (sheet));
ci = sheet_col_get_info (sheet, col);
if (ci == &sheet->default_col_style){
ci->pos = col;
ci = sheet_duplicate_colrow (ci);
add = 1;
}
ci->pixels = width;
ci->pos = col;
colrow_set_units (sheet, ci);
sheet_col_info_set_width (sheet, ci, width);
if (add)
sheet_col_add (sheet, ci);
/* Compute the spans */
sheet_recompute_spans_for_col (sheet, col);
sheet_compute_visible_ranges (sheet);
sheet_redraw_all (sheet);
}
static inline int
......@@ -912,8 +942,7 @@ void
sheet_selection_col_extend_to (Sheet *sheet, int col)
{
SheetSelection *ss, old_selection;
GList *cols;
int max_col, min_col, state;
int max_col, min_col, state, i;
g_return_if_fail (sheet != NULL);
g_return_if_fail (IS_SHEET (sheet));
......@@ -927,15 +956,10 @@ sheet_selection_col_extend_to (Sheet *sheet, int col)
min_col = MIN (old_selection.start_col, ss->start_col);
max_col = MAX (old_selection.end_col, ss->end_col);
for (cols = sheet->cols_info; cols; cols = cols->next){
ColRowInfo *ci = cols->data;
if (ci->pos < min_col)
continue;
if (ci->pos > max_col)
break;
for (i = min_col; i <= max_col; i++){
ColRowInfo *ci = sheet_col_get (sheet, i);
if ((ci->pos < ss->start_col) ||
(ci->pos > ss->end_col))
state = 0;
......@@ -959,8 +983,7 @@ void
sheet_selection_row_extend_to (Sheet *sheet, int row)
{
SheetSelection *ss, old_selection;
GList *rows;
int min_row, max_row, state;
int min_row, max_row, state, i;
g_return_if_fail (sheet != NULL);
g_return_if_fail (IS_SHEET (sheet));
......@@ -975,16 +998,11 @@ sheet_selection_row_extend_to (Sheet *sheet, int row)
min_row = MIN (old_selection.start_row, ss->start_row);
max_row = MAX (old_selection.end_row, ss->end_row);
for (rows = sheet->rows_info; rows; rows = rows->next){
ColRowInfo *ri = rows->data;
if (ri->pos < min_row)
continue;
if (ri->pos > max_row)
break;
for (i = min_row; i <= max_row; i++){
ColRowInfo *ri = sheet_row_get (sheet, i);
if ((ri->pos < ss->start_col) ||
(ri->pos > ss->end_col))
if ((ri->pos < ss->start_row) ||
(ri->pos > ss->end_row))
state = 0;
else
state = 1;
......
......@@ -232,9 +232,14 @@ void sheet_clear_region_content (Sheet *sheet,
/* Sets the width/height of a column row in terms of pixels */
void sheet_col_set_width (Sheet *sheet,
int col, int width);
void sheet_col_info_set_width (Sheet *sheet,
ColRowInfo *ci, int width);
void sheet_row_set_height (Sheet *sheet,
int row, int width,
gboolean height_set_by_user);
void sheet_row_info_set_height (Sheet *sheet,
ColRowInfo *ri, int width,
gboolean height_set_by_user);
void sheet_row_set_internal_height (Sheet *sheet, ColRowInfo *ri, int height);
void sheet_col_set_selection (Sheet *sheet,
ColRowInfo *ci, int value);
......
......@@ -619,12 +619,12 @@ workbook_parse_and_jump (Workbook *wb, char *text)
} else {
Sheet *sheet = workbook_get_current_sheet (wb);
if (col > SHEET_MAX_COLS-2){
if (col > SHEET_MAX_COLS-1){
gnumeric_notice (_("Column out of range"));
return FALSE;
}
if (row > SHEET_MAX_ROWS-2){
if (row > SHEET_MAX_ROWS-1){
gnumeric_notice (_("Row number out of range"));
return FALSE;
}
......
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