Hi,

I tried to change rows and/or columns number using new command line
options. Attached patch has not been fully tested, of course, and might
be quite dangerous. Just posted for comments. Only "#if USE_TILE_POOLS"
code has been tested a bit.

"gnumeric -r 100000" will give 131072 rows (only power of 2 are allowed
with the patch, but this can easily be changed).

Cheers,
Jean
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 = 0x10000;
+int gnm_sheet_max_cols = 0x100;
+
 static gboolean param_show_version = FALSE;
 static char *param_lib_dir  = NULL;
 static char *param_data_dir = NULL;
@@ -253,7 +256,7 @@
 	gnome_vfs_init ();
 #endif
 
-	libgoffice_init ();
+	libgoffice_init ("gnumeric");
 	plugin_service_define ("function_group",
 		&plugin_service_function_group_get_type);
 	plugin_service_define ("ui",
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 (gnm_sheet_max_cols < cols)
+		gnm_sheet_max_cols <<= 1;
+	while (gnm_sheet_max_rows < rows)
+		gnm_sheet_max_rows <<= 1;
+	sheet_style_init_tiles ();
 
 	/* Keep in sync with .desktop file */
 	g_set_application_name (_("Gnumeric Spreadsheet"));
Index: src/sheet-style.c
===================================================================
--- src/sheet-style.c	(révision 16516)
+++ src/sheet-style.c	(copie de travail)
@@ -186,31 +186,12 @@
  */
 #define 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
+static int gnm_tile_size_row = 16;
+static int gnm_tile_size_col = 4;
+
+#define TILE_SIZE_COL gnm_tile_size_col
+#define TILE_SIZE_ROW gnm_tile_size_row
 #define PARTIAL_TILE_COL (SHEET_MAX_COLS != TILE_SIZE_COL * TILE_SIZE_COL * TILE_SIZE_COL * 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 {
@@ -221,25 +202,25 @@
 	TILE_MATRIX	=  3,
 	TILE_PTR_MATRIX	=  4
 } CellTileType;
-static int const tile_size [] = {
+static int tile_size [] = {
 	1,				/* TILE_SIMPLE */
-	TILE_SIZE_COL,			/* TILE_COL */
-	TILE_SIZE_ROW,			/* TILE_ROW */
-	TILE_SIZE_COL * TILE_SIZE_ROW	/* TILE_MATRIX */
+	4,			/* TILE_COL */
+	16,			/* TILE_ROW */
+	4 * 16	/* TILE_MATRIX */
 };
-static int const tile_widths [] = {
+static int tile_widths [] = {
 	1,
-	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
+	4,
+	4 * 4,
+	4 * 4 * 4,
+	4 * 4 * 4 * 4
 };
-static int const tile_heights [] = {
+static int 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
+	16,
+	16 * 16,
+	16 * 16 * 16,
+	16 * 16 * 16 * 16
 };
 
 typedef struct {
@@ -248,21 +229,67 @@
 } CellTileStyleSimple;
 typedef struct {
 	CellTileType const type;
-	GnmStyle *style [TILE_SIZE_COL];
+	GnmStyle *style [];
 } CellTileStyleCol;
 typedef struct {
 	CellTileType const type;
-	GnmStyle *style [TILE_SIZE_ROW];
+	GnmStyle *style [];
 } CellTileStyleRow;
 typedef struct {
 	CellTileType const type;
-	GnmStyle *style [TILE_SIZE_COL * TILE_SIZE_ROW];
+	GnmStyle *style [];
 } CellTileStyleMatrix;
 typedef struct {
 	CellTileType const type;
-	CellTile	*ptr [TILE_SIZE_COL * TILE_SIZE_ROW];
+	CellTile	*ptr [];
 } CellTilePtrMatrix;
 
+static int tile_simple_size = sizeof (CellTileStyleSimple);
+static int tile_col_size = sizeof (CellTileStyleSimple) + sizeof (void*) * 3;
+static int tile_row_size = sizeof (CellTileStyleSimple) + sizeof (void*) * 15;
+static int tile_matrix_size = sizeof (CellTileStyleSimple) + sizeof (void*) * 63;
+
+void
+sheet_style_init_tiles (void)
+{
+		/* This is good until a million columns.  */
+		if (gnm_sheet_max_cols > 4 * 4 * 4 * 4) {
+				if (gnm_sheet_max_cols <= 5 * 5 * 5 * 5)
+						gnm_tile_size_col = 5;
+				else if (gnm_sheet_max_cols <= 8 * 8 * 8 * 8)
+						gnm_tile_size_col = 8;
+				else if (gnm_sheet_max_cols <= 16 * 16 * 16 * 16)
+						gnm_tile_size_col = 16;
+				else
+						gnm_tile_size_col = 32;
+		}
+		/* This is good until 16M rows.  */
+		if (gnm_sheet_max_rows > 16 * 16 * 16 * 16) {
+				if (gnm_sheet_max_rows <= 20 * 20 * 20 * 20)
+						gnm_tile_size_row = 20;
+				else if (gnm_sheet_max_rows <= 32 * 32 * 32 * 32)
+						gnm_tile_size_row = 32;
+				else
+						gnm_tile_size_row = 64;
+		}
+		if (gnm_tile_size_col > 4 || gnm_tile_size_row > 16) {
+				tile_size[1] = gnm_tile_size_col;
+				tile_size[2] = gnm_tile_size_row;
+				tile_size[3] = gnm_tile_size_row * gnm_tile_size_col;
+				tile_widths[1] = gnm_tile_size_col;
+				tile_widths[2] = gnm_tile_size_col * gnm_tile_size_col;
+				tile_widths[3] = gnm_tile_size_col * gnm_tile_size_col * gnm_tile_size_col;
+				tile_widths[4] = gnm_tile_size_col * gnm_tile_size_col * gnm_tile_size_col * gnm_tile_size_col;
+				tile_heights[1] = gnm_tile_size_row;
+				tile_heights[2] = gnm_tile_size_row * gnm_tile_size_row;
+				tile_heights[3] = gnm_tile_size_row * gnm_tile_size_row * gnm_tile_size_row;
+				tile_heights[4] = gnm_tile_size_row * gnm_tile_size_row * gnm_tile_size_row * gnm_tile_size_row;
+				tile_col_size = sizeof (CellTileStyleSimple) + sizeof (void*) * (gnm_tile_size_col - 1);
+				tile_row_size = sizeof (CellTileStyleSimple) + sizeof (void*) * (gnm_tile_size_row - 1);
+				tile_matrix_size = sizeof (CellTileStyleSimple) + sizeof (void*) * (gnm_tile_size_row * gnm_tile_size_col - 1);
+		}
+}
+
 union _CellTile {
 	CellTileType const type;
 	CellTileStyleSimple	style_any;
@@ -276,10 +303,10 @@
 #if USE_TILE_POOLS
 static int tile_pool_users;
 static GOMemChunk *tile_pools[5];
-#define CHUNK_ALLOC(T,p) ((T*)go_mem_chunk_alloc (p))
+#define CHUNK_ALLOC(T,p, s) ((T*)go_mem_chunk_alloc (p))
 #define CHUNK_FREE(p,v) go_mem_chunk_free ((p), (v))
 #else
-#define CHUNK_ALLOC(T,c) g_new (T,1)
+#define CHUNK_ALLOC(T,c, s) ((T*)g_malloc (s))
 #define CHUNK_FREE(p,v) g_free ((v))
 #endif
 
@@ -318,16 +345,16 @@
 	CellTile *res;
 
 #if USE_TILE_POOLS
-	res = CHUNK_ALLOC (CellTile, tile_pools[t]);
+	res = CHUNK_ALLOC (CellTile, tile_pools[t], 1);
 #else
 	switch (t) {
-	case TILE_SIMPLE : res = (CellTile *)g_new (CellTileStyleSimple, 1);
+	case TILE_SIMPLE : res = (CellTile *) g_malloc (tile_simple_size);
 			   break;
-	case TILE_COL :	   res = (CellTile *)g_new (CellTileStyleCol, 1);
+	case TILE_COL :	   res = (CellTile *) g_malloc (tile_col_size);
 			   break;
-	case TILE_ROW :	   res = (CellTile *)g_new (CellTileStyleRow, 1);
+	case TILE_ROW :	   res = (CellTile *) g_malloc (tile_row_size);
 			   break;
-	case TILE_MATRIX : res = (CellTile *)g_new (CellTileStyleMatrix, 1);
+	case TILE_MATRIX : res = (CellTile *) g_malloc (tile_matrix_size);
 			   break;
 	default : g_return_val_if_fail (FALSE, NULL);
 		return NULL;
@@ -355,7 +382,7 @@
 	g_return_val_if_fail (TILE_SIMPLE <= t->type &&
 			      TILE_MATRIX >= t->type, NULL);
 
-	res = CHUNK_ALLOC (CellTilePtrMatrix, tile_pools[TILE_PTR_MATRIX]);
+	res = CHUNK_ALLOC (CellTilePtrMatrix, tile_pools[TILE_PTR_MATRIX], tile_matrix_size);
 	*((CellTileType *)&(res->type)) = TILE_PTR_MATRIX;
 
 	/* TODO :
@@ -472,21 +499,21 @@
 	if (tile_pool_users++ == 0) {
 		tile_pools[TILE_SIMPLE] =
 			go_mem_chunk_new ("simple tile pool",
-					   sizeof (CellTileStyleSimple),
+					   tile_simple_size,
 					   16 * 1024 - 128);
 		tile_pools[TILE_COL] =
 			go_mem_chunk_new ("column tile pool",
-					   sizeof (CellTileStyleCol),
+					   tile_col_size,
 					   16 * 1024 - 128);
 		tile_pools[TILE_ROW] =
 			go_mem_chunk_new ("row tile pool",
-					   sizeof (CellTileStyleRow),
+					   tile_row_size,
 					   16 * 1024 - 128);
 		tile_pools[TILE_MATRIX] =
 			go_mem_chunk_new ("matrix tile pool",
-					   sizeof (CellTileStyleMatrix),
+					   tile_matrix_size,
 					   MAX (16 * 1024 - 128,
-						100 * sizeof (CellTileStyleMatrix)));
+						100 * tile_matrix_size));
 
 		/* If this fails one day, just make two pools.  */
 		g_assert (sizeof (CellTileStyleMatrix) == sizeof (CellTilePtrMatrix));
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,9 @@
 
 G_BEGIN_DECLS
 
-#define SHEET_MAX_ROWS		(16*16*16*16)	/* 0, 1, ... */
-#define SHEET_MAX_COLS		(4*4*4*4)	/* 0, 1, ... */
-
+extern 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
 /*
  * Note: more than 364238 columns will introduce a column named TRUE.
  */
@@ -175,6 +175,8 @@
 typedef struct _PrintInformation        PrintInformation;
 typedef struct _SolverParameters	SolverParameters;
 
+typedef struct _GnmCanvasRect		GnmCanvasRect;
+
 G_END_DECLS
 
 #endif /* _GNM_GNUMERIC_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;
_______________________________________________
gnumeric-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/gnumeric-list

Reply via email to