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

fetch row information, not column information. Fix the routine.

1999-09-17  Miguel de Icaza  <miguel@gnu.org>

	* src/sheet.c (sheet_row_size_fit): fetch row information, not
	column information.  Fix the routine.

	* src/workbook-cmd-format.c (workbook_cmd_format_column_auto_fit):
	(workbook_cmd_format_column_width):
	(workbook_cmd_format_row_auto_fit):
	(workbook_cmd_format_row_height): Fix the range being scanned to
	be inclusive.
parent de71f695
...@@ -719,16 +719,17 @@ int ...@@ -719,16 +719,17 @@ int
sheet_row_size_fit (Sheet *sheet, int row) sheet_row_size_fit (Sheet *sheet, int row)
{ {
ColRowInfo *ri; ColRowInfo *ri;
GList *l; GList *clist;
int max = 0; int max = 0;
int margins; int margins;
int height;
g_return_val_if_fail (sheet != NULL, 0); g_return_val_if_fail (sheet != NULL, 0);
g_return_val_if_fail (IS_SHEET (sheet), 0); g_return_val_if_fail (IS_SHEET (sheet), 0);
g_return_val_if_fail (row >= 0, 0); g_return_val_if_fail (row >= 0, 0);
g_return_val_if_fail (row < SHEET_MAX_ROWS, 0); g_return_val_if_fail (row < SHEET_MAX_ROWS, 0);
ri = sheet_col_get_info (sheet, row); ri = sheet_row_get_info (sheet, row);
/* /*
* If ri == sheet->default_row_style then it means * If ri == sheet->default_row_style then it means
...@@ -738,11 +739,19 @@ sheet_row_size_fit (Sheet *sheet, int row) ...@@ -738,11 +739,19 @@ sheet_row_size_fit (Sheet *sheet, int row)
return ri->pixels; return ri->pixels;
margins = ri->margin_a + ri->margin_b; margins = ri->margin_a + ri->margin_b;
for (l = ri->data; l; l = l->next){ /*
Cell *cell = l->data; * Now, we need to scan all columns, as the list of rows
int height; * does not contains pointers to the cells.
*/
for (clist = sheet->cols_info; clist; clist = clist->next){
ColRowInfo *ci = clist->data;
Cell *cell;
cell = sheet_cell_get (sheet, ci->pos, row);
if (!cell)
continue;
height = cell->height + margins; height = cell->height + margins;
if (height > max) if (height > max)
......
...@@ -111,7 +111,7 @@ workbook_cmd_format_column_auto_fit (GtkWidget *widget, Workbook *wb) ...@@ -111,7 +111,7 @@ workbook_cmd_format_column_auto_fit (GtkWidget *widget, Workbook *wb)
for (l = sheet->selections; l; l = l->next){ for (l = sheet->selections; l; l = l->next){
SheetSelection *ss = l->data; SheetSelection *ss = l->data;
for (col = ss->user.start.col; col < ss->user.end.col; col++){ for (col = ss->user.start.col; col <= ss->user.end.col; col++){
int ideal_size; int ideal_size;
ideal_size = sheet_col_size_fit (sheet, col); ideal_size = sheet_col_size_fit (sheet, col);
...@@ -137,7 +137,7 @@ workbook_cmd_format_column_width (GtkWidget *widget, Workbook *wb) ...@@ -137,7 +137,7 @@ workbook_cmd_format_column_width (GtkWidget *widget, Workbook *wb)
for (l = sheet->selections; l; l = l->next){ for (l = sheet->selections; l; l = l->next){
SheetSelection *ss = l->data; SheetSelection *ss = l->data;
for (col = ss->user.start.col; col < ss->user.end.col; col++){ for (col = ss->user.start.col; col <= ss->user.end.col; col++){
ColRowInfo *ci; ColRowInfo *ci;
ci = sheet_col_get_info (sheet, col); ci = sheet_col_get_info (sheet, col);
...@@ -189,7 +189,7 @@ workbook_cmd_format_row_auto_fit (GtkWidget *widget, Workbook *wb) ...@@ -189,7 +189,7 @@ workbook_cmd_format_row_auto_fit (GtkWidget *widget, Workbook *wb)
for (l = sheet->selections; l; l = l->next){ for (l = sheet->selections; l; l = l->next){
SheetSelection *ss = l->data; SheetSelection *ss = l->data;
for (row = ss->user.start.row; row < ss->user.end.row; row++){ for (row = ss->user.start.row; row <= ss->user.end.row; row++){
int ideal_size; int ideal_size;
ideal_size = sheet_row_size_fit (sheet, row); ideal_size = sheet_row_size_fit (sheet, row);
...@@ -215,7 +215,7 @@ workbook_cmd_format_row_height (GtkWidget *widget, Workbook *wb) ...@@ -215,7 +215,7 @@ workbook_cmd_format_row_height (GtkWidget *widget, Workbook *wb)
SheetSelection *ss = l->data; SheetSelection *ss = l->data;
int row; int row;
for (row = ss->user.start.row; row < ss->user.end.row; row++){ for (row = ss->user.start.row; row <= ss->user.end.row; row++){
ColRowInfo *ri; ColRowInfo *ri;
ri = sheet_row_get_info (sheet, row); ri = sheet_row_get_info (sheet, row);
......
...@@ -2164,6 +2164,7 @@ create_format_toolbar (Workbook *wb) ...@@ -2164,6 +2164,7 @@ create_format_toolbar (Workbook *wb)
* Create a font name selector * Create a font name selector
*/ */
wb->priv->option_menu = gtk_option_menu_new (); wb->priv->option_menu = gtk_option_menu_new ();
gtk_container_set_border_width (GTK_CONTAINER (wb->priv->option_menu), 0);
menu = gtk_menu_new (); menu = gtk_menu_new ();
/* An empty item for the case of no font that applies */ /* An empty item for the case of no font that applies */
......
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