Index: schemas/gnumeric-general.schemas.in =================================================================== --- schemas/gnumeric-general.schemas.in (révision 16516) +++ schemas/gnumeric-general.schemas.in (copie de travail) @@ -112,6 +112,32 @@ The number of sheets initially created in a new workbook. + + /schemas/apps/gnumeric/core/workbook/n-rows + /apps/gnumeric/core/workbook/n-rows + Gnumeric + int + 65536 + + Default Number of rows in a sheet + The number of rows in each sheet. This setting will be used + only in a new gnumeric session. Whatever value is given here, the real + number of rows will be a power of 2 between 65539 and 16777216. + + + + /schemas/apps/gnumeric/core/workbook/n-cols + /apps/gnumeric/core/workbook/n-cols + Gnumeric + int + 256 + + Default Number of columnss in a sheet + The number of columns in each sheet. This setting will be used + only in a new gnumeric session. Whatever value is given here, the real + number of columns will be a power of 2 between 256 and 4096. + + /schemas/apps/gnumeric/core/gui/screen/horizontaldpi /apps/gnumeric/core/gui/screen/horizontaldpi Index: src/libgnumeric.c =================================================================== --- src/libgnumeric.c (révision 16516) +++ src/libgnumeric.c (copie de travail) @@ -75,6 +75,9 @@ /* TODO : get rid of this monstrosity */ gboolean initial_workbook_open_complete = FALSE; +int gnm_sheet_max_rows = GNM_DEFAULT_ROWS; +int gnm_sheet_max_cols = GNM_DEFAULT_COLS; + static gboolean param_show_version = FALSE; static char *param_lib_dir = NULL; static char *param_data_dir = NULL; Index: src/libgnumeric.h =================================================================== --- src/libgnumeric.h (révision 16516) +++ src/libgnumeric.h (copie de travail) @@ -30,6 +30,10 @@ /* Internal */ int gnm_dump_func_defs (char const* filename, int dump_type); /* changes as needed */ +GNM_VAR_DECL int gnm_sheet_max_rows, gnm_sheet_max_cols; +#define SHEET_MAX_COLS gnm_sheet_max_cols +#define SHEET_MAX_ROWS gnm_sheet_max_rows + G_END_DECLS #endif /* _GNM_LIBGNUMERIC_H_ */ Index: src/gnm-pane-impl.h =================================================================== --- src/gnm-pane-impl.h (révision 16516) +++ src/gnm-pane-impl.h (copie de travail) @@ -8,8 +8,8 @@ G_BEGIN_DECLS -#define GNM_PANE_MAX_X 1000000 -#define GNM_PANE_MAX_Y 6000000 +#define GNM_PANE_MAX_X G_MAXINT +#define GNM_PANE_MAX_Y G_MAXINT struct _GnmPane { GnmSimpleCanvas simple; Index: src/main-application.c =================================================================== --- src/main-application.c (révision 16516) +++ src/main-application.c (copie de travail) @@ -33,6 +33,7 @@ #include "gnumeric-paths.h" #include "session.h" #include "sheet.h" +#include "sheet-style.h" #include "gutils.h" #include "gnm-plugin.h" @@ -68,6 +69,8 @@ static gchar *func_state_file = NULL; static gchar *geometry = NULL; static gchar **startup_files; +static int rows = 0; +static int cols = 0; static const GOptionEntry gnumeric_options [] = { /********************************* @@ -82,6 +85,14 @@ N_("Don't display warning dialogs when importing"), NULL }, + { "rows", 'r', 0, G_OPTION_ARG_INT, &rows, + N_("Minimum number of rows"), + NULL + }, + { "cols", 'c', 0, G_OPTION_ARG_INT, &cols, + N_("Minimum number of columns"), + NULL + }, /********************************* * Hidden Actions */ @@ -388,6 +399,11 @@ return gnm_dump_func_defs (func_def_file, 1); if (split_funcdocs) return gnm_dump_func_defs (NULL, 2); + while ((SHEET_MAX_COLS < cols) && (SHEET_MAX_COLS < GNM_MAX_COLS)) + SHEET_MAX_COLS <<= 1; + while ((SHEET_MAX_ROWS < rows) && (SHEET_MAX_ROWS < GNM_MAX_ROWS)) + SHEET_MAX_ROWS <<= 1; + sheet_style_init_tiles (); /* Keep in sync with .desktop file */ g_set_application_name (_("Gnumeric Spreadsheet")); Index: src/gnumeric-gconf.c =================================================================== --- src/gnumeric-gconf.c (révision 16516) +++ src/gnumeric-gconf.c (copie de travail) @@ -49,14 +49,6 @@ #define d(code) #endif -#ifdef GNM_WITH_GNOME -#include "gnm-conf-gconf.c" -#elif defined G_OS_WIN32 -#include "gnm-conf-win32.c" -#else -#include "gnm-conf-keyfile.c" -#endif - static void gnm_conf_init_page_setup (GOConfNode *node) { @@ -191,6 +183,16 @@ node, GNM_CONF_GUI_RES_V, 10., 1000., 96.); prefs.initial_sheet_number = go_conf_load_int ( root, GNM_CONF_WORKBOOK_NSHEETS, 1, 64, 3); + prefs.row_number = go_conf_load_int ( + root, GNM_CONF_WORKBOOK_NROWS, GNM_DEFAULT_ROWS, GNM_MAX_ROWS, GNM_DEFAULT_ROWS); + while (gnm_sheet_max_rows < prefs.row_number && gnm_sheet_max_rows < GNM_MAX_ROWS) + gnm_sheet_max_rows <<= 1; + prefs.row_number = gnm_sheet_max_rows; + prefs.col_number = go_conf_load_int ( + root, GNM_CONF_WORKBOOK_NCOLS, GNM_DEFAULT_COLS, GNM_MAX_COLS, GNM_DEFAULT_COLS); + while (gnm_sheet_max_cols < prefs.col_number && gnm_sheet_max_cols < GNM_MAX_COLS) + gnm_sheet_max_cols <<= 1; + prefs.col_number = gnm_sheet_max_cols; prefs.horizontal_window_fraction = go_conf_load_double ( node, GNM_CONF_GUI_WINDOW_X, .1, 1., .6); prefs.vertical_window_fraction = go_conf_load_double ( @@ -370,7 +372,6 @@ void gnm_conf_init (gboolean fast) { - go_conf_init (); root = go_conf_get_node (NULL, GNM_CONF_DIR); gnm_conf_init_essential (); if (fast) @@ -814,6 +815,24 @@ } void +gnm_gconf_set_workbook_nrows (gint val) +{ + int n = GNM_DEFAULT_ROWS; + while (n < val && n < GNM_MAX_ROWS) + n <<= 1; + go_conf_set_int (root, GNM_CONF_WORKBOOK_NROWS, n); +} + +void +gnm_gconf_set_workbook_ncols (gint val) +{ + int n = GNM_DEFAULT_COLS; + while (n < val && n < GNM_MAX_COLS) + n <<= 1; + go_conf_set_int (root, GNM_CONF_WORKBOOK_NCOLS, n); +} + +void gnm_gconf_set_xml_compression (gint val) { if (val < 0) @@ -1042,52 +1061,3 @@ go_conf_set_bool ( root, GNM_CONF_CUTANDPASTE_DIR "/" GNM_CONF_CUTANDPASTE_PREFER_CLIPBOARD, val != FALSE); } - -/***************************************************************************/ - -gchar * -go_conf_get_enum_as_str (GOConfNode *node, gchar const *key) -{ - return go_conf_get_string (node, key); -} -int -go_conf_load_enum (GOConfNode *node, gchar const *key, GType t, int default_val) -{ - int res; - gchar *val_str = go_conf_load_string (node, key); - gboolean use_default = TRUE; - - if (NULL != val_str) { - GEnumClass *enum_class = G_ENUM_CLASS (g_type_class_ref (t)); - GEnumValue *enum_value = g_enum_get_value_by_nick (enum_class, val_str); - if (NULL == enum_value) - enum_value = g_enum_get_value_by_name (enum_class, val_str); - - if (NULL != enum_value) { - use_default = FALSE; - res = enum_value->value; - } else { - g_warning ("Unknown value '%s' for %s", val_str, key); - } - - g_type_class_unref (enum_class); - g_free (val_str); - - } - - if (use_default) { - d (g_warning ("Using default value '%d'", default_val)); - return default_val; - } - return res; -} - -void -go_conf_set_enum (GOConfNode *node, gchar const *key, GType t, gint val) -{ - GEnumClass *enum_class = G_ENUM_CLASS (g_type_class_ref (t)); - GEnumValue *enum_value = g_enum_get_value (enum_class, val); - go_conf_set_string (node, key, enum_value->value_nick); - g_type_class_unref (enum_class); -} - Index: src/gnumeric-gconf.h =================================================================== --- src/gnumeric-gconf.h (révision 16516) +++ src/gnumeric-gconf.h (copie de travail) @@ -7,6 +7,7 @@ #include #include #include +#include #include #include @@ -39,6 +40,8 @@ gint undo_max_number; gint initial_sheet_number; + gint row_number; + gint col_number; float horizontal_window_fraction; float vertical_window_fraction; float zoom; @@ -99,8 +102,6 @@ } GnmAppPrefs; GNM_VAR_DECL GnmAppPrefs const *gnm_app_prefs; -typedef struct _GOConfNode GOConfNode; - void gnm_conf_init (gboolean fast); void gnm_conf_shutdown (void); GOConfNode *gnm_conf_get_root (void); @@ -189,6 +190,8 @@ /* workbook */ void gnm_gconf_set_workbook_nsheets (gint value); +void gnm_gconf_set_workbook_nrows (gint value); +void gnm_gconf_set_workbook_ncols (gint value); void gnm_gconf_set_unfocused_rs (gboolean value); /* function selector and formula guru */ @@ -200,45 +203,6 @@ /* application interface */ void gnm_gconf_set_prefer_clipboard (gboolean value); -/**************************************************************/ - -GOConfNode * go_conf_get_node (GOConfNode *parent, gchar const *key); -void go_conf_free_node (GOConfNode *node); - -gchar *go_conf_get_short_desc (GOConfNode *node, gchar const *key); -gchar *go_conf_get_long_desc (GOConfNode *node, gchar const *key); -GType go_conf_get_type (GOConfNode *node, gchar const *key); -gchar *go_conf_get_value_as_str (GOConfNode *node, gchar const *key); -gboolean go_conf_set_value_from_str (GOConfNode *node, gchar const *key, gchar const *val_str); - -gboolean go_conf_get_bool (GOConfNode *node, gchar const *key); -gint go_conf_get_int (GOConfNode *node, gchar const *key); -gdouble go_conf_get_double (GOConfNode *node, gchar const *key); -gchar *go_conf_get_string (GOConfNode *node, gchar const *key); -GSList *go_conf_get_str_list (GOConfNode *node, gchar const *key); -gchar *go_conf_get_enum_as_str(GOConfNode *node, gchar const *key); - -gboolean go_conf_load_bool (GOConfNode *node, gchar const *key, gboolean default_val); -gint go_conf_load_int (GOConfNode *node, gchar const *key, gint minima, gint maxima, gint default_val); -gdouble go_conf_load_double (GOConfNode *node, gchar const *key, gdouble minima, gdouble maxima, gdouble default_val); -gchar *go_conf_load_string (GOConfNode *node, gchar const *key); -GSList *go_conf_load_str_list (GOConfNode *node, gchar const *key); -int go_conf_load_enum (GOConfNode *node, gchar const *key, GType t, int default_val); - -void go_conf_set_bool (GOConfNode *node, gchar const *key, gboolean val); -void go_conf_set_int (GOConfNode *node, gchar const *key, gint val); -void go_conf_set_double (GOConfNode *node, gchar const *key, gnm_float val); -void go_conf_set_string (GOConfNode *node, gchar const *key, gchar const *str); -void go_conf_set_str_list (GOConfNode *node, gchar const *key, GSList *list); -void go_conf_set_enum (GOConfNode *node, gchar const *key, GType t, gint val); - -void go_conf_sync (GOConfNode *node); - -typedef void (*GOConfMonitorFunc) (GOConfNode *node, gchar const *key, gpointer data); -void go_conf_remove_monitor (guint monitor_id); -guint go_conf_add_monitor (GOConfNode *node, gchar const *key, - GOConfMonitorFunc monitor, gpointer data); - G_END_DECLS #endif /* _GNM_GCONF_H_ */ Index: src/gnumeric-gconf-priv.h =================================================================== --- src/gnumeric-gconf-priv.h (révision 16516) +++ src/gnumeric-gconf-priv.h (copie de travail) @@ -98,6 +98,8 @@ #define GNM_CONF_FILE_SINGLE_SHEET_SAVE "save/single_sheet" #define GNM_CONF_WORKBOOK_NSHEETS "core/workbook/n-sheet" +#define GNM_CONF_WORKBOOK_NROWS "core/workbook/n-rows" +#define GNM_CONF_WORKBOOK_NCOLS "core/workbook/n-cols" #define GNM_CONF_GUI_DIR "core/gui" #define GNM_CONF_GUI_RES_H "screen/horizontaldpi" Index: src/sheet-style.c =================================================================== --- src/sheet-style.c (révision 16516) +++ src/sheet-style.c (copie de travail) @@ -184,35 +184,19 @@ /* If you change this, change the tile_{widths,heights} here, in sheet_style_get * and in the sanity check in sheet_style_init */ -#define TILE_TOP_LEVEL 3 +static int TILE_TOP_LEVEL = 3; -/* This is good until a million columns. */ -#if SHEET_MAX_COLS <= 4 * 4 * 4 * 4 #define TILE_SIZE_COL 4 -#elif SHEET_MAX_COLS <= 5 * 5 * 5 * 5 -#define TILE_SIZE_COL 5 -#elif SHEET_MAX_COLS <= 8 * 8 * 8 * 8 -#define TILE_SIZE_COL 8 -#elif SHEET_MAX_COLS <= 16 * 16 * 16 * 16 -#define TILE_SIZE_COL 16 -#else -#define TILE_SIZE_COL 32 -#endif -#define PARTIAL_TILE_COL (SHEET_MAX_COLS != TILE_SIZE_COL * TILE_SIZE_COL * TILE_SIZE_COL * TILE_SIZE_COL) +#define TILE_SIZE_ROW 16 +static int max_rows = TILE_SIZE_ROW, + max_cols = TILE_SIZE_COL, + max_height = 1, + max_width = 1; +#define PARTIAL_TILE_COL (SHEET_MAX_COLS != max_cols) +#define PARTIAL_TILE_ROW (SHEET_MAX_ROWS != max_rows) +static int MAX_ROWS = TILE_SIZE_ROW, MAX_COLS = TILE_SIZE_COL; -/* This is good until 16M rows. */ -#if SHEET_MAX_ROWS <= 16 * 16 * 16 * 16 -#define TILE_SIZE_ROW 16 -#elif SHEET_MAX_ROWS <= 20 * 20 * 20 * 20 -#define TILE_SIZE_ROW 20 -#elif SHEET_MAX_ROWS <= 32 * 32 * 32 * 32 -#define TILE_SIZE_ROW 32 -#else -#define TILE_SIZE_ROW 64 -#endif -#define PARTIAL_TILE_ROW (SHEET_MAX_ROWS != TILE_SIZE_ROW * TILE_SIZE_ROW * TILE_SIZE_ROW * TILE_SIZE_ROW) - typedef enum { TILE_UNDEFINED = -1, TILE_SIMPLE = 0, @@ -232,14 +216,18 @@ TILE_SIZE_COL, TILE_SIZE_COL * TILE_SIZE_COL, TILE_SIZE_COL * TILE_SIZE_COL * TILE_SIZE_COL, - TILE_SIZE_COL * TILE_SIZE_COL * TILE_SIZE_COL * TILE_SIZE_COL + TILE_SIZE_COL * TILE_SIZE_COL * TILE_SIZE_COL * TILE_SIZE_COL, + TILE_SIZE_COL * TILE_SIZE_COL * TILE_SIZE_COL * TILE_SIZE_COL * TILE_SIZE_COL, + TILE_SIZE_COL * TILE_SIZE_COL * TILE_SIZE_COL * TILE_SIZE_COL * TILE_SIZE_COL * TILE_SIZE_COL }; static int const tile_heights [] = { 1, TILE_SIZE_ROW, TILE_SIZE_ROW * TILE_SIZE_ROW, TILE_SIZE_ROW * TILE_SIZE_ROW * TILE_SIZE_ROW, - TILE_SIZE_ROW * TILE_SIZE_ROW * TILE_SIZE_ROW * TILE_SIZE_ROW + TILE_SIZE_ROW * TILE_SIZE_ROW * TILE_SIZE_ROW * TILE_SIZE_ROW, + TILE_SIZE_ROW * TILE_SIZE_ROW * TILE_SIZE_ROW * TILE_SIZE_ROW * TILE_SIZE_ROW, + TILE_SIZE_ROW * TILE_SIZE_ROW * TILE_SIZE_ROW * TILE_SIZE_ROW * TILE_SIZE_ROW * TILE_SIZE_ROW }; typedef struct { @@ -263,6 +251,31 @@ CellTile *ptr [TILE_SIZE_COL * TILE_SIZE_ROW]; } CellTilePtrMatrix; +void +sheet_style_init_tiles (void) +{ + int l = 0; + while (MAX_COLS < gnm_sheet_max_cols) { + MAX_COLS *= TILE_SIZE_COL; + l++; + } + if (l > TILE_TOP_LEVEL) + TILE_TOP_LEVEL = l; + l = 0; + while (MAX_ROWS < gnm_sheet_max_rows) { + MAX_ROWS *= TILE_SIZE_ROW; + l++; + } + if (l > TILE_TOP_LEVEL) + TILE_TOP_LEVEL = l; + for (l = 0 ; l< TILE_TOP_LEVEL; l++) { + max_rows *= TILE_SIZE_ROW; + max_cols *= TILE_SIZE_COL; + } + max_height = max_rows / TILE_SIZE_ROW; + max_width =max_cols / TILE_SIZE_COL; +} + union _CellTile { CellTileType const type; CellTileStyleSimple style_any; @@ -464,8 +477,8 @@ GnmStyle *default_style; /* some simple sanity checks */ - g_assert (SHEET_MAX_COLS <= TILE_SIZE_COL * TILE_SIZE_COL * TILE_SIZE_COL * TILE_SIZE_COL); - g_assert (SHEET_MAX_ROWS <= TILE_SIZE_ROW * TILE_SIZE_ROW * TILE_SIZE_ROW * TILE_SIZE_ROW); + g_assert (SHEET_MAX_COLS <= MAX_COLS); + g_assert (SHEET_MAX_ROWS <= MAX_ROWS); g_return_if_fail (IS_SHEET (sheet)); #if USE_TILE_POOLS @@ -1218,12 +1231,12 @@ GnmStyle const * sheet_style_get (Sheet const *sheet, int col, int row) { - int width = TILE_SIZE_COL*TILE_SIZE_COL*TILE_SIZE_COL; - int height = TILE_SIZE_ROW*TILE_SIZE_ROW*TILE_SIZE_ROW; + int width = max_width; + int height = max_height; int c, r, level = TILE_TOP_LEVEL; CellTile *tile = sheet->style_data->styles; tail_recursion : c = col / width; r = row / height; Index: src/sheet-style.h =================================================================== --- src/sheet-style.h (révision 16516) +++ src/sheet-style.h (copie de travail) @@ -81,6 +81,7 @@ /* For internal use only */ void sheet_style_unlink (Sheet *sheet, GnmStyle *st); +void sheet_style_init_tiles (void); G_END_DECLS Index: src/colrow.h =================================================================== --- src/colrow.h (révision 16516) +++ src/colrow.h (copie de travail) @@ -131,7 +131,7 @@ ColRowVisList *list); /* Misc */ -#define colrow_max(is_cols) ((is_cols) ? SHEET_MAX_COLS : SHEET_MAX_ROWS) +#define colrow_max(is_cols) ((is_cols) ? gnm_sheet_max_cols : gnm_sheet_max_rows) void colrow_reset_defaults (Sheet *sheet, gboolean is_cols, int maxima); int colrow_find_adjacent_visible (Sheet *sheet, gboolean is_cols, int index, gboolean forward); Index: src/dialogs/dialog-preferences.c =================================================================== --- src/dialogs/dialog-preferences.c (révision 16516) +++ src/dialogs/dialog-preferences.c (copie de travail) @@ -574,7 +574,7 @@ G_GNUC_UNUSED GtkNotebook *notebook, G_GNUC_UNUSED gint page_num) { - GtkWidget *page = gtk_table_new (4, 2, FALSE); + GtkWidget *page = gtk_table_new (7, 2, FALSE); gint row = 0; GOConfNode *node; @@ -595,6 +595,14 @@ page, row++, 1, 1, 64, 1, gnm_gconf_set_workbook_nsheets, _("Default Number of Sheets")); + int_pref_create_widget (state->root, GNM_CONF_WORKBOOK_NROWS, + page, row++, GNM_DEFAULT_ROWS, GNM_DEFAULT_ROWS, GNM_MAX_ROWS, GNM_DEFAULT_ROWS, + gnm_gconf_set_workbook_nrows, + _("Number of rows in a sheet")); + int_pref_create_widget (state->root, GNM_CONF_WORKBOOK_NCOLS, + page, row++, GNM_DEFAULT_COLS, GNM_DEFAULT_COLS, GNM_MAX_COLS, GNM_DEFAULT_COLS, + gnm_gconf_set_workbook_ncols, + _("Number of columns in a sheet")); bool_pref_create_widget (node, GNM_CONF_GUI_ED_LIVESCROLLING, page, row++, gnm_gconf_set_gui_livescrolling, Index: src/gnumeric.h =================================================================== --- src/gnumeric.h (révision 16516) +++ src/gnumeric.h (copie de travail) @@ -8,9 +8,12 @@ G_BEGIN_DECLS -#define SHEET_MAX_ROWS (16*16*16*16) /* 0, 1, ... */ -#define SHEET_MAX_COLS (4*4*4*4) /* 0, 1, ... */ - +/* really used rows and columns should not exceed these values (TILE_TOP_LEVEL + can't exceed 5 currently) */ +#define GNM_DEFAULT_ROWS 0x10000 +#define GNM_MAX_ROWS 0x1000000 +#define GNM_DEFAULT_COLS 0x100 +#define GNM_MAX_COLS 0x1000 /* * Note: more than 364238 columns will introduce a column named TRUE. */ Index: plugins/excel/ms-excel-write.c =================================================================== --- plugins/excel/ms-excel-write.c (révision 16516) +++ plugins/excel/ms-excel-write.c (copie de travail) @@ -4900,6 +4900,8 @@ g_return_val_if_fail (sheet, NULL); g_return_val_if_fail (ewb, NULL); + esheet->col_xf = g_new (guint16, gnm_sheet_max_cols); + esheet->col_style = g_new (GnmStyle*, gnm_sheet_max_cols); excel_sheet_extent (sheet, &extent, esheet->col_style, XLS_MaxCol, maxrows, ewb->io_context); @@ -4968,6 +4970,8 @@ style_list_free (esheet->conditions); style_list_free (esheet->hlinks); style_list_free (esheet->validations); + g_free (esheet->col_style); + g_free (esheet->col_xf); g_free (esheet); } Index: plugins/excel/ms-excel-write.h =================================================================== --- plugins/excel/ms-excel-write.h (révision 16516) +++ plugins/excel/ms-excel-write.h (copie de travail) @@ -45,8 +45,8 @@ unsigned streamPos; guint32 boundsheetPos; gint32 max_col, max_row; - guint16 col_xf [SHEET_MAX_COLS]; - GnmStyle *col_style [SHEET_MAX_COLS]; + guint16 *col_xf; + GnmStyle **col_style; GnmStyleList *conditions, *hlinks, *validations; GSList *blips, *textboxes; GHashTable *comments;