This version of the patch compiles and seems to work.

Le mardi 22 avril 2008 à 16:04 +0200, Jean Bréfort a écrit :
> Hi,
> 
> Here comes the second version of my patch updated after Jody's comments
> on IRC.
> 
> A few issues:
> - the pacth for gnm-conf.* contains changes related to a move of the
> go-conf code to goffice (done locally but not commited).
> - the rows and columns numbers entered as command line options are just
> for getting more rows and/or columns fora single session, so I did not
> code anything to update the configuration from them.
> - rows and columns numbers are restricted to powers of 2. I suppose this
> is not a necessity, and he minimas might be lower than 65536 rows and
> 256 columns.
> - it is not possible to have more that 4096 columns and 16777216 rows
> with this code. I suppose it should be enough for mot people, and having
> more than 4GCells will certainly result in serious performances issues.
> 
> Cheers,
> Jean 

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 @@
         <long>The number of sheets initially created in a new workbook.</long>
         </locale>
       </schema>
+       <schema>
+        <key>/schemas/apps/gnumeric/core/workbook/n-rows</key>
+        <applyto>/apps/gnumeric/core/workbook/n-rows</applyto>
+        <owner>Gnumeric</owner>
+        <type>int</type>
+	    <default>65536</default>
+        <locale name="C">
+        <short>Default Number of rows in a sheet</short>
+        <long>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.</long>
+        </locale>
+      </schema>
+       <schema>
+        <key>/schemas/apps/gnumeric/core/workbook/n-cols</key>
+        <applyto>/apps/gnumeric/core/workbook/n-cols</applyto>
+        <owner>Gnumeric</owner>
+        <type>int</type>
+	    <default>256</default>
+        <locale name="C">
+        <short>Default Number of columnss in a sheet</short>
+        <long>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.</long>
+        </locale>
+      </schema>
       <schema>
         <key>/schemas/apps/gnumeric/core/gui/screen/horizontaldpi</key>
         <applyto>/apps/gnumeric/core/gui/screen/horizontaldpi</applyto>
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/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/dialogs/dialog-stf-format-page.c
===================================================================
--- src/dialogs/dialog-stf-format-page.c	(révision 16516)
+++ src/dialogs/dialog-stf-format-page.c	(copie de travail)
@@ -23,6 +23,7 @@
 #include <gnumeric-config.h>
 #include <glib/gi18n-lib.h>
 #include <gnumeric.h>
+#include <libgnumeric.h>
 #include "dialog-stf.h"
 #include <gnm-format.h>
 #include <workbook.h>
Index: src/dialogs/dialog-stf-main-page.c
===================================================================
--- src/dialogs/dialog-stf-main-page.c	(révision 16516)
+++ src/dialogs/dialog-stf-main-page.c	(copie de travail)
@@ -22,6 +22,7 @@
 #include <gnumeric-config.h>
 #include <glib/gi18n-lib.h>
 #include <gnumeric.h>
+#include <libgnumeric.h>
 #include "dialog-stf.h"
 #include <gui-util.h>
 #include <workbook.h>
Index: src/position.c
===================================================================
--- src/position.c	(révision 16516)
+++ src/position.c	(copie de travail)
@@ -22,6 +22,7 @@
  */
 #include <gnumeric-config.h>
 #include "gnumeric.h"
+#include "libgnumeric.h"
 #include "position.h"
 
 #include "sheet.h"
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)
@@ -191,6 +191,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 (
@@ -814,6 +824,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)
Index: src/gnumeric-gconf.h
===================================================================
--- src/gnumeric-gconf.h	(révision 16516)
+++ src/gnumeric-gconf.h	(copie de travail)
@@ -39,6 +39,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;
@@ -189,6 +191,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 */
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-filter.c
===================================================================
--- src/sheet-filter.c	(révision 16516)
+++ src/sheet-filter.c	(copie de travail)
@@ -20,6 +20,7 @@
  * USA
  */
 #include <gnumeric-config.h>
+#include "libgnumeric.h"
 #include "sheet-filter.h"
 #include "sheet-filter-combo.h"
 
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,8 +1231,8 @@
 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;
 
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/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/dif/dif.c
===================================================================
--- plugins/dif/dif.c	(révision 16516)
+++ plugins/dif/dif.c	(copie de travail)
@@ -11,6 +11,7 @@
 #include <gnumeric-config.h>
 #include <glib/gi18n-lib.h>
 #include <gnumeric.h>
+#include <libgnumeric.h>
 
 #include <cell.h>
 #include <sheet.h>
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;
Index: plugins/xbase/xbase.c
===================================================================
--- plugins/xbase/xbase.c	(révision 16516)
+++ plugins/xbase/xbase.c	(copie de travail)
@@ -2,6 +2,7 @@
 #include <gnumeric-config.h>
 #include <glib/gi18n-lib.h>
 #include <gnumeric.h>
+#include <libgnumeric.h>
 #include "xbase.h"
 
 #include <gnm-format.h>
_______________________________________________
gnumeric-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/gnumeric-list

Reply via email to