[gnumeric] GUI: fix problem with setting sizes of a large number of columns/rows.
- From: Morten Welinder <mortenw src gnome org>
- To: svn-commits-list gnome org
- Subject: [gnumeric] GUI: fix problem with setting sizes of a large number of columns/rows.
- Date: Thu, 9 Jul 2009 01:50:30 +0000 (UTC)
commit b2c73a3e31aaa285e5a9d00db47a9bf42840e3fe
Author: Morten Welinder <terra gnome org>
Date: Wed Jul 8 21:49:37 2009 -0400
GUI: fix problem with setting sizes of a large number of columns/rows.
ChangeLog | 7 +++++++
src/colrow.c | 29 +++++++++++++++++------------
src/colrow.h | 5 +++--
src/sheet.c | 40 +++++++++++++++++++++++++++-------------
4 files changed, 54 insertions(+), 27 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 5b95428..18cd0a0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
2009-07-08 Morten Welinder <terra gnome org>
+ * src/sheet.c (sheet_scale_changed): Compute scale only once per
+ direction. Fixes #588105.
+
+ * src/colrow.c (colrow_compute_pixel_scale): New function.
+ (colrow_compute_pixels_from_pts, colrow_compute_pts_from_pixels):
+ Take extra scale parameter.
+
* src/gnm-cell-combo.c (gnm_cell_combo_set_sv): New function.
(gnm_cell_combo_finalize, gnm_cell_combo_set_property): Call
gnm_cell_combo_set_sv to release sv weak ref.
diff --git a/src/colrow.c b/src/colrow.c
index 4c5a4ad..8b1148b 100644
--- a/src/colrow.c
+++ b/src/colrow.c
@@ -35,14 +35,21 @@
#include "cellspan.h"
#include "rendered-value.h"
+double
+colrow_compute_pixel_scale (Sheet const *sheet, gboolean horizontal)
+{
+ return sheet->last_zoom_factor_used *
+ gnm_app_display_dpi_get (horizontal) / 72.;
+}
+
void
-colrow_compute_pixels_from_pts (ColRowInfo *cri,
- Sheet const *sheet, gboolean horizontal)
+colrow_compute_pixels_from_pts (ColRowInfo *cri, Sheet const *sheet,
+ gboolean horizontal, double scale)
{
int const margin = horizontal ? 2*GNM_COL_MARGIN : 2*GNM_ROW_MARGIN;
- double scale =
- sheet->last_zoom_factor_used *
- gnm_app_display_dpi_get (horizontal) / 72.;
+
+ if (scale == -1)
+ scale = colrow_compute_pixel_scale (sheet, horizontal);
if (horizontal && sheet->display_formulas)
scale *= 2;
@@ -54,13 +61,9 @@ colrow_compute_pixels_from_pts (ColRowInfo *cri,
}
void
-colrow_compute_pts_from_pixels (ColRowInfo *cri,
- Sheet const *sheet, gboolean horizontal)
+colrow_compute_pts_from_pixels (ColRowInfo *cri, Sheet const *sheet,
+ gboolean horizontal, double scale)
{
- double scale =
- sheet->last_zoom_factor_used *
- gnm_app_display_dpi_get (horizontal) / 72.;
-
if (horizontal && sheet->display_formulas)
scale *= 2;
@@ -507,11 +510,13 @@ colrow_set_states (Sheet *sheet, gboolean is_cols,
GSList *l;
int i, max_outline, offset = first;
ColRowCollection *infos;
+ double scale;
g_return_if_fail (IS_SHEET (sheet));
infos = is_cols ? &(sheet->cols) : &(sheet->rows);
max_outline = infos->max_outline_level;
+ scale = colrow_compute_pixel_scale (sheet, is_cols);
for (l = states; l != NULL; l = l->next) {
ColRowRLEState const *rles = l->data;
@@ -535,7 +540,7 @@ colrow_set_states (Sheet *sheet, gboolean is_cols,
ColRowInfo *cri = sheet_colrow_fetch (sheet, i, is_cols);
cri->hard_size = state->hard_size;
cri->size_pts = state->size_pts;
- colrow_compute_pixels_from_pts (cri, sheet, is_cols);
+ colrow_compute_pixels_from_pts (cri, sheet, is_cols, scale);
colrow_set_outline (cri, state->outline_level,
state->is_collapsed);
}
diff --git a/src/colrow.h b/src/colrow.h
index d64bedf..6e613e3 100644
--- a/src/colrow.h
+++ b/src/colrow.h
@@ -67,10 +67,11 @@ typedef struct {
#define COL_INTERNAL_WIDTH(col) \
((col)->size_pixels - (GNM_COL_MARGIN + GNM_COL_MARGIN + 1))
+double colrow_compute_pixel_scale (Sheet const *sheet, gboolean horizontal);
void colrow_compute_pixels_from_pts (ColRowInfo *cri, Sheet const *sheet,
- gboolean horizontal);
+ gboolean horizontal, double scale);
void colrow_compute_pts_from_pixels (ColRowInfo *cri, Sheet const *sheet,
- gboolean horizontal);
+ gboolean horizontal, double scale);
gboolean colrow_is_default (ColRowInfo const *cri);
gboolean colrow_is_empty (ColRowInfo const *cri);
diff --git a/src/sheet.c b/src/sheet.c
index c9aa314..9b5506d 100644
--- a/src/sheet.c
+++ b/src/sheet.c
@@ -301,6 +301,7 @@ sheet_set_name (Sheet *sheet, char const *new_name)
struct resize_colrow {
Sheet *sheet;
gboolean is_cols;
+ double scale;
};
static gboolean
@@ -308,7 +309,8 @@ cb_colrow_compute_pixels_from_pts (GnmColRowIter const *iter,
struct resize_colrow *data)
{
colrow_compute_pixels_from_pts ((ColRowInfo *)iter->cri,
- data->sheet, data->is_cols);
+ data->sheet, data->is_cols,
+ data->scale);
return FALSE;
}
@@ -325,21 +327,30 @@ cb_clear_rendered_cells (gpointer ignored, GnmCell *cell)
static void
sheet_scale_changed (Sheet *sheet, gboolean cols_rescaled, gboolean rows_rescaled)
{
- struct resize_colrow closure;
-
g_return_if_fail (cols_rescaled || rows_rescaled);
/* Then every column and row */
if (cols_rescaled) {
- colrow_compute_pixels_from_pts (&sheet->cols.default_style, sheet, TRUE);
+ struct resize_colrow closure;
+
closure.sheet = sheet;
closure.is_cols = TRUE;
+ closure.scale = colrow_compute_pixel_scale (sheet, TRUE);
+
+ colrow_compute_pixels_from_pts (&sheet->cols.default_style,
+ sheet, TRUE, closure.scale);
colrow_foreach (&sheet->cols, 0, gnm_sheet_get_last_col (sheet),
(ColRowHandler)&cb_colrow_compute_pixels_from_pts, &closure);
}
if (rows_rescaled) {
- colrow_compute_pixels_from_pts (&sheet->rows.default_style, sheet, FALSE);
+ struct resize_colrow closure;
+
+ closure.sheet = sheet;
closure.is_cols = FALSE;
+ closure.scale = colrow_compute_pixel_scale (sheet, FALSE);
+
+ colrow_compute_pixels_from_pts (&sheet->rows.default_style,
+ sheet, FALSE, closure.scale);
colrow_foreach (&sheet->rows, 0, gnm_sheet_get_last_row (sheet),
(ColRowHandler)&cb_colrow_compute_pixels_from_pts, &closure);
}
@@ -671,8 +682,10 @@ gnm_sheet_constructor (GType type,
case GNM_SHEET_OBJECT:
sheet->hide_grid = TRUE;
sheet->hide_col_header = sheet->hide_row_header = TRUE;
- colrow_compute_pixels_from_pts (&sheet->rows.default_style, sheet, FALSE);
- colrow_compute_pixels_from_pts (&sheet->cols.default_style, sheet, TRUE);
+ colrow_compute_pixels_from_pts (&sheet->rows.default_style,
+ sheet, FALSE, -1);
+ colrow_compute_pixels_from_pts (&sheet->cols.default_style,
+ sheet, TRUE, -1);
break;
case GNM_SHEET_DATA: {
/* We have to add permanent names */
@@ -4890,12 +4903,13 @@ sheet_colrow_default_calc (Sheet *sheet, double units,
cri->hard_size = FALSE;
cri->visible = TRUE;
cri->spans = NULL;
+
if (is_pts) {
cri->size_pts = units;
- colrow_compute_pixels_from_pts (cri, sheet, is_cols);
+ colrow_compute_pixels_from_pts (cri, sheet, is_cols, -1);
} else {
cri->size_pixels = units;
- colrow_compute_pts_from_pixels (cri, sheet, is_cols);
+ colrow_compute_pts_from_pixels (cri, sheet, is_cols, -1);
}
}
@@ -5007,7 +5021,7 @@ sheet_col_set_size_pts (Sheet *sheet, int col, double width_pts,
return;
ci->size_pts = width_pts;
- colrow_compute_pixels_from_pts (ci, sheet, TRUE);
+ colrow_compute_pixels_from_pts (ci, sheet, TRUE, -1);
sheet->priv->recompute_visibility = TRUE;
sheet_flag_recompute_spans (sheet);
@@ -5030,7 +5044,7 @@ sheet_col_set_size_pixels (Sheet *sheet, int col, int width_pixels,
return;
ci->size_pixels = width_pixels;
- colrow_compute_pts_from_pixels (ci, sheet, TRUE);
+ colrow_compute_pts_from_pixels (ci, sheet, TRUE, -1);
sheet->priv->recompute_visibility = TRUE;
sheet_flag_recompute_spans (sheet);
@@ -5163,7 +5177,7 @@ sheet_row_set_size_pts (Sheet *sheet, int row, double height_pts,
return;
ri->size_pts = height_pts;
- colrow_compute_pixels_from_pts (ri, sheet, FALSE);
+ colrow_compute_pixels_from_pts (ri, sheet, FALSE, -1);
sheet->priv->recompute_visibility = TRUE;
if (sheet->priv->reposition_objects.row > row)
@@ -5196,7 +5210,7 @@ sheet_row_set_size_pixels (Sheet *sheet, int row, int height_pixels,
return;
ri->size_pixels = height_pixels;
- colrow_compute_pts_from_pixels (ri, sheet, FALSE);
+ colrow_compute_pts_from_pixels (ri, sheet, FALSE, -1);
sheet->priv->recompute_visibility = TRUE;
if (sheet->priv->reposition_objects.row > row)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]