40
40
Sheet const *sheet, gboolean horizontal)
42
42
int const margin = horizontal ? 2*GNM_COL_MARGIN : 2*GNM_ROW_MARGIN;
44
44
sheet->last_zoom_factor_used *
45
45
gnm_app_display_dpi_get (horizontal) / 72.;
47
if (horizontal && sheet->display_formulas)
47
50
cri->size_pixels = (int)(cri->size_pts * scale + 0.5);
48
52
if (cri->size_pixels <= margin)
49
53
cri->size_pixels = margin + 1;
53
57
colrow_compute_pts_from_pixels (ColRowInfo *cri,
54
58
Sheet const *sheet, gboolean horizontal)
57
61
sheet->last_zoom_factor_used *
58
62
gnm_app_display_dpi_get (horizontal) / 72.;
64
if (horizontal && sheet->display_formulas)
60
67
cri->size_pts = cri->size_pixels / scale;
62
69
/* Disable this until we decide how to deal with scaling */
301
colrow_make_state (G_GNUC_UNUSED Sheet *sheet, int count,
302
float size_pts, gboolean hard_size,
308
colrow_set_single_state (ColRowState *state,
309
Sheet *sheet, int i, gboolean is_cols)
305
ColRowRLEState *rles = g_new0 (ColRowRLEState, 1);
306
rles->length = count;
307
rles->state.size_pts = size_pts;
308
rles->state.outline_level = outline_level;
309
rles->state.is_collapsed = FALSE;
310
rles->state.hard_size = hard_size;
311
rles->state.visible = TRUE;
312
rles->state.is_default = FALSE;
313
return g_slist_prepend (NULL, rles);
311
ColRowInfo const *info = sheet_colrow_get_info (sheet, i, is_cols);
312
state->is_default = colrow_is_default (info);
313
state->size_pts = info->size_pts;
314
state->outline_level = info->outline_level;
315
state->is_collapsed = info->is_collapsed;
316
state->hard_size = info->hard_size;
317
state->visible = info->visible;
316
320
ColRowStateList *
319
323
ColRowStateList *list = NULL;
320
324
ColRowRLEState *rles;
321
/* gcc is wrong run_state is always initialized */
322
ColRowState run_state, cur_state;
323
int i, run_length = 0;
325
ColRowState run_state;
325
328
g_return_val_if_fail (IS_SHEET (sheet), NULL);
326
329
g_return_val_if_fail (first <= last, NULL);
328
for (i = first; i <= last; ++i) {
329
ColRowInfo const *info = sheet_colrow_get_info (sheet, i, is_cols);
331
cur_state.is_default = colrow_is_default (info);
332
cur_state.size_pts = info->size_pts;
333
cur_state.outline_level = info->outline_level;
334
cur_state.is_collapsed = info->is_collapsed;
335
cur_state.hard_size = info->hard_size;
336
cur_state.visible = info->visible;
338
/* Initialize the run_size in the first loop */
339
if (run_length == 0) {
340
run_state = cur_state;
331
colrow_set_single_state (&run_state, sheet, first, is_cols);
334
for (i = first + 1; i <= last; ++i) {
335
ColRowState cur_state;
336
colrow_set_single_state (&cur_state, sheet, i, is_cols);
345
338
/* If state changed, start a new block */
346
339
if (cur_state.is_default != run_state.is_default ||
349
342
cur_state.is_collapsed != run_state.is_collapsed ||
350
343
cur_state.hard_size != run_state.hard_size ||
351
344
cur_state.visible != run_state.visible) {
352
rles = g_new0 (ColRowRLEState, 1);
345
rles = g_new (ColRowRLEState, 1);
353
346
rles->length = run_length;
354
347
rles->state = run_state;
355
348
list = g_slist_prepend (list, rles);
363
356
/* Store the final run */
364
if (run_length > 0) {
365
rles = g_new0 (ColRowRLEState, 1);
366
rles->length = run_length;
367
rles->state = run_state;
368
list = g_slist_prepend (list, rles);
357
rles = g_new (ColRowRLEState, 1);
358
rles->length = run_length;
359
rles->state = run_state;
360
list = g_slist_prepend (list, rles);
371
362
return g_slist_reverse (list);
443
434
rles->state.size_pts = sheet_col_get_default_size_pts (sheet);
444
435
sheet_col_set_default_size_pixels (sheet, new_size);
445
colrow_foreach (&sheet->cols, 0, gnm_sheet_get_max_cols (sheet)-1,
436
colrow_foreach (&sheet->cols, 0, gnm_sheet_get_last_col (sheet),
446
437
&cb_set_colrow_size, &closure);
448
439
rles->state.size_pts = sheet_row_get_default_size_pts (sheet);
449
440
sheet_row_set_default_size_pixels (sheet, new_size);
450
colrow_foreach (&sheet->rows, 0, gnm_sheet_get_max_rows (sheet)-1,
441
colrow_foreach (&sheet->rows, 0, gnm_sheet_get_last_row (sheet),
451
442
&cb_set_colrow_size, &closure);
454
445
/* force a re-render of cells with expanding formats */
456
447
sheet_foreach_cell_in_range (sheet, CELL_ITER_IGNORE_BLANK,
457
0, 0, gnm_sheet_get_max_cols (sheet)-1, gnm_sheet_get_max_rows (sheet)-1,
448
0, 0, gnm_sheet_get_last_col (sheet), gnm_sheet_get_last_row (sheet),
458
449
(CellIterFunc) &cb_clear_variable_width_content, NULL);
460
451
/* Result is a magic 'default' record + >= 1 normal */
465
456
/* force a re-render of cells with expanding formats */
466
457
sheet_foreach_cell_in_range (sheet, CELL_ITER_IGNORE_BLANK,
467
index->first, 0, index->last, gnm_sheet_get_max_rows (sheet)-1,
458
index->first, 0, index->last, gnm_sheet_get_last_row (sheet),
468
459
(CellIterFunc) &cb_clear_variable_width_content, NULL);
470
461
/* In order to properly reposition cell comments in
480
471
/* Fall back to assigning the defaul if it is empty */
482
? sheet_col_size_fit_pixels (sheet, i, 0, gnm_sheet_get_max_rows (sheet) - 1, FALSE)
483
: sheet_row_size_fit_pixels (sheet, i, 0, gnm_sheet_get_max_cols (sheet) - 1, FALSE);
473
? sheet_col_size_fit_pixels (sheet, i, 0, gnm_sheet_get_last_row (sheet), FALSE)
474
: sheet_row_size_fit_pixels (sheet, i, 0, gnm_sheet_get_last_col (sheet), FALSE);
606
597
/* force a re-render of cells with expanding formats */
608
599
sheet_foreach_cell_in_range (sheet, CELL_ITER_IGNORE_BLANK,
609
index->first, 0, index->last, gnm_sheet_get_max_rows (sheet)-1,
600
index->first, 0, index->last, gnm_sheet_get_last_row (sheet),
610
601
(CellIterFunc) &cb_clear_variable_width_content, NULL);
611
602
colrow_state_list_destroy (ptr->data);
612
603
selection = selection->prev;
909
sheet_queue_respan (sheet, 0, gnm_sheet_get_max_rows (sheet)-1);
900
sheet_queue_respan (sheet, 0, gnm_sheet_get_last_row (sheet));
910
901
if (list != NULL)
911
902
sheet_redraw_all (sheet, TRUE);
1168
1159
* and replace them with the default.
1171
colrow_reset_defaults (Sheet *sheet, gboolean is_cols,
1162
colrow_reset_defaults (Sheet *sheet, gboolean is_cols, int maxima)
1174
1164
ColRowCollection *infos = is_cols ? &sheet->cols : &sheet->rows;
1175
1165
ColRowInfo const *default_cri = &infos->default_style;
1178
1168
int const end = colrow_max (is_cols, sheet);
1179
1169
int inner, inner_start, inner_last, i;
1171
if (maxima >= end) {
1172
g_warning ("In colrow_reset_defaults, someone set maxima to %d >= %d", maxima, end);
1176
/* From here on, maxima is the first unused. */
1181
1179
i = COLROW_SEGMENT_START(maxima);
1182
1180
inner_start = maxima - i;
1183
1181
for ( ; i < end ; i += COLROW_SEGMENT_SIZE) {
1200
1198
inner_start = 0;
1202
infos->max_used = maxima;
1200
infos->max_used = maxima - 1;
1204
colrow_resize (ColRowCollection *infos, int size)
1206
int end_idx = COLROW_SEGMENT_INDEX (size);
1207
int i = infos->info->len - 1;
1209
while (i >= end_idx) {
1210
ColRowSegment *segment = g_ptr_array_index (infos->info, i);
1213
g_ptr_array_index (infos->info, i) = NULL;
1218
g_ptr_array_set_size (infos->info, end_idx);