[gnumeric] More work on variable-size sheets. Expect warnings.
- From: Morten Welinder <mortenw src gnome org>
- To: svn-commits-list gnome org
- Subject: [gnumeric] More work on variable-size sheets. Expect warnings.
- Date: Fri, 17 Apr 2009 08:29:39 -0400 (EDT)
commit ed78145423a5ee8579947445f6de7eadc3838f22
Author: Morten Welinder <terra gnome org>
Date: Fri Apr 17 08:28:40 2009 -0400
More work on variable-size sheets. Expect warnings.
---
ChangeLog | 17 ++++++++++++++
src/parse-util.c | 18 +++++++++++----
src/selection.c | 2 +-
src/sheet-object-widget.c | 18 ++++++++------
src/sheet-view.c | 53 ++++++++++++++++++++++++--------------------
src/sheet.c | 2 +
6 files changed, 72 insertions(+), 38 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index bab27f8..09f11aa 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,20 @@
+2009-04-16 Morten Welinder <terra gnome org>
+
+ * src/parse-util.c (col_parse, row_parse): Handle MAGIC_MAX_SHEET.
+ (std_sheet_name_quote): Use MAGIC_MAX_SHEET to query any possible
+ sheet.
+ (MAGIC_MAX_SHEET): Define locally.
+
+ * src/sheet-view.c (sv_set_edit_pos): Don't do anything -- not
+ even checks on position -- if the new position is the same as the
+ old one. If we do change, make sure we have a sheet.
+
+ * src/sheet.c (gnm_sheet_get_max_rows, gnm_sheet_get_max_cols):
+ Complain if sheet is NULL.
+
+ * src/selection.c (sheet_selection_set_internal): If we don't have
+ a sheet yet, don't enable insert/delete.
+
2009-04-15 Andreas J. Guelzow <aguelzow pyrshep ca>
* src/commands.h (cmd_so_set_checkbox): new
diff --git a/src/parse-util.c b/src/parse-util.c
index a1d317d..b741d6f 100644
--- a/src/parse-util.c
+++ b/src/parse-util.c
@@ -47,7 +47,11 @@
#include <glib.h>
#include <string.h>
-#define FIXME_SHEET NULL
+/*
+ * This constant should not escape this file. It represents a sheet whose
+ * dimensions are maximal in all directions.
+ */
+#define MAGIC_MAX_SHEET ((Sheet*)GUINT_TO_POINTER(1))
static void
col_name_internal (GString *target, int col)
@@ -117,7 +121,9 @@ col_parse (char const *str, Sheet const *sheet,
{
char const *ptr, *start = str;
int col = -1;
- int max = gnm_sheet_get_max_cols (sheet);
+ int max = (sheet == MAGIC_MAX_SHEET)
+ ? GNM_MAX_COLS
+ : gnm_sheet_get_max_cols (sheet);
if (!(*relative = (*start != '$')))
start++;
@@ -179,7 +185,9 @@ row_parse (char const *str, Sheet const *sheet,
{
char const *end, *ptr = str;
long int row;
- int max = gnm_sheet_get_max_rows (sheet);
+ int max = (sheet == MAGIC_MAX_SHEET)
+ ? GNM_MAX_ROWS
+ : gnm_sheet_get_max_rows (sheet);
if (!(*relative = (*ptr != '$')))
ptr++;
@@ -1257,13 +1265,13 @@ std_sheet_name_quote (GnmConventions const *convs,
int col, row;
unsigned char col_relative, row_relative;
- if (!col_parse (str, FIXME_SHEET, &col, &col_relative))
+ if (!col_parse (str, MAGIC_MAX_SHEET, &col, &col_relative))
goto unquoted;
p = str + nletters;
while (*p == '0')
p++, ndigits--;
- if (!row_parse (p, FIXME_SHEET, &row, &row_relative))
+ if (!row_parse (p, MAGIC_MAX_SHEET, &row, &row_relative))
goto unquoted;
goto quoted;
diff --git a/src/selection.c b/src/selection.c
index dc24961..eaa2233 100644
--- a/src/selection.c
+++ b/src/selection.c
@@ -534,7 +534,7 @@ set_menu_flags:
* whole row, a whole column or the whole sheet and de-activate
* insert row/cols and the flags accordingly.
*/
- do_rows = do_cols = TRUE;
+ do_rows = do_cols = (sv->sheet != NULL);
for (list = sv->selections; list && (do_cols || do_rows); list = list->next) {
GnmRange const *r = list->data;
diff --git a/src/sheet-object-widget.c b/src/sheet-object-widget.c
index 81eadc0..d864b44 100644
--- a/src/sheet-object-widget.c
+++ b/src/sheet-object-widget.c
@@ -427,7 +427,8 @@ cb_frame_config_ok_clicked (GtkWidget *button, FrameConfigState *state)
{
gchar const *text = gtk_entry_get_text(GTK_ENTRY(state->label));
- cmd_so_set_frame_label (WORKBOOK_CONTROL (state->wbcg), SHEET_OBJECT (state->swf),
+ cmd_so_set_frame_label (WORKBOOK_CONTROL (state->wbcg),
+ SHEET_OBJECT (state->swf),
g_strdup (state->old_label), g_strdup (text));
gtk_widget_destroy (state->dialog);
}
@@ -439,16 +440,17 @@ sheet_widget_frame_set_label (SheetObject *so, char const* str)
GList *ptr;
str = str ? str : "";
-
- if (swf->label)
- g_free (swf->label);
+
+ if (go_str_compare (str, swf->label) == 0)
+ return;
+
+ g_free (swf->label);
swf->label = g_strdup (str);
for (ptr = swf->sow.realized_list; ptr != NULL; ptr = ptr->next) {
- gtk_frame_set_label
- (GTK_FRAME (FOO_CANVAS_WIDGET (ptr->data)->widget),
- str);
- }
+ FooCanvasWidget *item = FOO_CANVAS_WIDGET (ptr->data);
+ gtk_frame_set_label (GTK_FRAME (item->widget), str);
+ }
}
static void
diff --git a/src/sheet-view.c b/src/sheet-view.c
index 3674549..33ced18 100644
--- a/src/sheet-view.c
+++ b/src/sheet-view.c
@@ -472,43 +472,48 @@ void
sv_set_edit_pos (SheetView *sv, GnmCellPos const *pos)
{
GnmCellPos old;
+ GnmRange const *merged;
g_return_if_fail (IS_SHEET_VIEW (sv));
g_return_if_fail (pos != NULL);
+
+ old = sv->edit_pos;
+ sv->first_tab_col = -1; /* invalidate */
+
+ if (old.col == pos->col && old.row == pos->row)
+ return;
+
+ g_return_if_fail (IS_SHEET (sv->sheet));
g_return_if_fail (pos->col >= 0);
g_return_if_fail (pos->col < gnm_sheet_get_max_cols (sv->sheet));
g_return_if_fail (pos->row >= 0);
g_return_if_fail (pos->row < gnm_sheet_get_max_rows (sv->sheet));
- old = sv->edit_pos;
- sv->first_tab_col = -1; /* invalidate */
- if (old.col != pos->col || old.row != pos->row) {
- GnmRange const *merged = gnm_sheet_merge_is_corner (sv->sheet, &old);
+ merged = gnm_sheet_merge_is_corner (sv->sheet, &old);
- sv->edit_pos_changed.location =
+ sv->edit_pos_changed.location =
sv->edit_pos_changed.content =
sv->edit_pos_changed.style = TRUE;
- /* Redraw before change */
- if (merged == NULL) {
- GnmRange tmp; tmp.start = tmp.end = old;
- sv_redraw_range (sv, &tmp);
- } else
- sv_redraw_range (sv, merged);
-
- sv->edit_pos_real = *pos;
-
- /* Redraw after change (handling merged cells) */
- merged = gnm_sheet_merge_contains_pos (sv->sheet, &sv->edit_pos_real);
- if (merged == NULL) {
- GnmRange tmp; tmp.start = tmp.end = *pos;
- sv_redraw_range (sv, &tmp);
- sv->edit_pos = sv->edit_pos_real;
- } else {
- sv_redraw_range (sv, merged);
- sv->edit_pos = merged->start;
- }
+ /* Redraw before change */
+ if (merged == NULL) {
+ GnmRange tmp; tmp.start = tmp.end = old;
+ sv_redraw_range (sv, &tmp);
+ } else
+ sv_redraw_range (sv, merged);
+
+ sv->edit_pos_real = *pos;
+
+ /* Redraw after change (handling merged cells) */
+ merged = gnm_sheet_merge_contains_pos (sv->sheet, &sv->edit_pos_real);
+ if (merged == NULL) {
+ GnmRange tmp; tmp.start = tmp.end = *pos;
+ sv_redraw_range (sv, &tmp);
+ sv->edit_pos = sv->edit_pos_real;
+ } else {
+ sv_redraw_range (sv, merged);
+ sv->edit_pos = merged->start;
}
}
diff --git a/src/sheet.c b/src/sheet.c
index 707bf28..0f2aa54 100644
--- a/src/sheet.c
+++ b/src/sheet.c
@@ -5494,6 +5494,7 @@ int
gnm_sheet_get_max_rows (Sheet const *sheet)
{
if (G_UNLIKELY (!sheet)) {
+ g_warning ("NULL sheet in gnm_sheet_get_max_rows!");
/* FIXME: This needs to go. */
return GNM_DEFAULT_ROWS;
}
@@ -5508,6 +5509,7 @@ int
gnm_sheet_get_max_cols (Sheet const *sheet)
{
if (G_UNLIKELY (!sheet)) {
+ g_warning ("NULL sheet in gnm_sheet_get_max_cols!");
/* FIXME: This needs to go. */
return GNM_DEFAULT_COLS;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]