[gnumeric] partial fix to autofitting rows and columns on data entry
- From: Andreas J. Guelzow <guelzow src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] partial fix to autofitting rows and columns on data entry
- Date: Fri, 13 Aug 2010 18:34:31 +0000 (UTC)
commit ca230162d63d81e00b5d8bc8e5933597780fbc49
Author: Andreas J Guelzow <aguelzow pyrshep ca>
Date: Fri Aug 13 12:33:45 2010 -0600
partial fix to autofitting rows and columns on data entry
2010-08-13 Andreas J. Guelzow <aguelzow pyrshep ca>
* src/colrow.c (colrow_set_sizes): revert last change
* src/commands.c (cmd_set_text_full_autofit_*): new
(cmd_set_text_full): don't use colrow_set_sizes but colrow_autofit
* src/undo.c (gnm_undo_colrow_set_sizes_new): fix comment
ChangeLog | 7 ++++++
src/colrow.c | 4 +-
src/commands.c | 61 ++++++++++++++++++++++++++++++++++++++++++-------------
src/undo.c | 4 +-
4 files changed, 57 insertions(+), 19 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 68b4877..0b1ff91 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
2010-08-13 Andreas J. Guelzow <aguelzow pyrshep ca>
+ * src/colrow.c (colrow_set_sizes): revert last change
+ * src/commands.c (cmd_set_text_full_autofit_*): new
+ (cmd_set_text_full): don't use colrow_set_sizes but colrow_autofit
+ * src/undo.c (gnm_undo_colrow_set_sizes_new): fix comment
+
+2010-08-13 Andreas J. Guelzow <aguelzow pyrshep ca>
+
* src/colrow.c (colrow_set_sizes): use -2 as an indicator only to auto-fit
non-strings
* src/commands.c (cmd_set_text_full): use size -2
diff --git a/src/colrow.c b/src/colrow.c
index f37cb20..641a5f1 100644
--- a/src/colrow.c
+++ b/src/colrow.c
@@ -529,8 +529,8 @@ colrow_set_sizes (Sheet *sheet, gboolean is_cols,
from = to;
/* Fall back to assigning the default if it is empty */
tmp = (is_cols)
- ? sheet_col_size_fit_pixels (sheet, i, from, to, tmp == -2)
- : sheet_row_size_fit_pixels (sheet, i, from, to, tmp == -2);
+ ? sheet_col_size_fit_pixels (sheet, i, from, to, FALSE)
+ : sheet_row_size_fit_pixels (sheet, i, from, to, FALSE);
}
if (tmp > 0) {
if (is_cols)
diff --git a/src/commands.c b/src/commands.c
index 525a6aa..2728957 100644
--- a/src/commands.c
+++ b/src/commands.c
@@ -733,6 +733,22 @@ command_undo_sheet_delete (Sheet* sheet)
return (TRUE);
}
+static void
+cmd_set_text_full_autofit_row (Sheet *sheet, GnmRange *r)
+{
+ colrow_autofit (sheet, r, FALSE, FALSE,
+ TRUE, FALSE, NULL, NULL);
+}
+
+static void
+cmd_set_text_full_autofit_col (Sheet *sheet, GnmRange *r)
+{
+ colrow_autofit (sheet, r, TRUE, TRUE,
+ TRUE, FALSE, NULL, NULL);
+}
+
+
+
/******************************************************************/
/*
@@ -757,7 +773,7 @@ cmd_set_text_full (WorkbookControl *wbc, GSList *selection, GnmEvalPos *ep,
GnmExprTop const *texpr = NULL;
GOUndo *undo = NULL;
GOUndo *redo = NULL;
- gboolean result;
+ gboolean result, autofit_row = TRUE;
char *text = NULL;
char *name;
Sheet *sheet = ep->sheet;
@@ -827,6 +843,7 @@ cmd_set_text_full (WorkbookControl *wbc, GSList *selection, GnmEvalPos *ep,
if (new_style)
gnm_style_unref (new_style);
gnm_expr_top_unref (texpr);
+ autofit_row = FALSE;
} else {
GString *text_str;
PangoAttrList *adj_markup = NULL;
@@ -871,30 +888,44 @@ cmd_set_text_full (WorkbookControl *wbc, GSList *selection, GnmEvalPos *ep,
for (l = selection; l != NULL; l = l->next) {
GnmRange *r = l->data;
+ GnmRange *new_r;
+
+ new_r = g_new (GnmRange, 1);
+ *new_r = *r;
+ if (autofit_row) {
+ redo = go_undo_combine
+ (go_undo_binary_new
+ (sheet, new_r,
+ (GOUndoBinaryFunc) cmd_set_text_full_autofit_row,
+ NULL, g_free),
+ redo);
+ cri_row_list = colrow_get_index_list
+ (r->start.row, r->end.row, cri_row_list);
+ } else {
+ redo = go_undo_combine
+ (go_undo_binary_new
+ (sheet, new_r,
+ (GOUndoBinaryFunc) cmd_set_text_full_autofit_col,
+ NULL, g_free),
+ redo);
+ cri_col_list = colrow_get_index_list
+ (r->start.col, r->end.col, cri_col_list);
+ }
- cri_col_list = colrow_get_index_list
- (r->start.col, r->end.col, cri_col_list);
- cri_row_list = colrow_get_index_list
- (r->start.row, r->end.row, cri_row_list);
}
undo = go_undo_combine (undo,
gnm_undo_colrow_restore_state_group_new
(sheet, TRUE,
- colrow_index_list_copy (cri_col_list),
+ cri_col_list,
colrow_get_sizes (sheet, TRUE,
- cri_col_list, -2)));
+ cri_col_list, -1)));
undo = go_undo_combine (undo,
gnm_undo_colrow_restore_state_group_new
(sheet, FALSE,
- colrow_index_list_copy (cri_row_list),
+ cri_row_list,
colrow_get_sizes (sheet, FALSE,
- cri_row_list, -2)));
- redo = go_undo_combine (gnm_undo_colrow_set_sizes_new
- (sheet, TRUE, cri_col_list, -2, NULL),
- redo);
- redo = go_undo_combine (gnm_undo_colrow_set_sizes_new
- (sheet, FALSE, cri_row_list, -2, NULL),
- redo);
+ cri_row_list, -1)));
+
result = cmd_generic (wbc, text, undo, redo);
g_free (text);
diff --git a/src/undo.c b/src/undo.c
index f8074fd..cdcd1c9 100644
--- a/src/undo.c
+++ b/src/undo.c
@@ -134,7 +134,7 @@ GSF_CLASS (GNMUndoColrowSetSizes, gnm_undo_colrow_set_sizes,
/**
* gnm_undo_colrow_set_sizes_new:
*
- * If r is non-null and new_size == -1 or -2, selection is ignored.
+ * If r is non-null and new_size < 0, selection is ignored.
*
* Returns: a new undo object.
**/
@@ -154,7 +154,7 @@ gnm_undo_colrow_set_sizes_new (Sheet *sheet, gboolean is_cols,
ua->is_cols = is_cols;
ua->new_size = new_size;
- if (r == NULL || new_size > -1) {
+ if (r == NULL || new_size >= 0) {
ua->selection = selection;
ua->from = 0;
ua->to = -1;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]