gnumeric r17266 - in trunk: . plugins/lotus-123 plugins/openoffice schemas src src/dialogs
- From: mortenw svn gnome org
- To: svn-commits-list gnome org
- Subject: gnumeric r17266 - in trunk: . plugins/lotus-123 plugins/openoffice schemas src src/dialogs
- Date: Wed, 1 Apr 2009 00:59:15 +0000 (UTC)
Author: mortenw
Date: Wed Apr 1 00:59:15 2009
New Revision: 17266
URL: http://svn.gnome.org/viewvc/gnumeric?rev=17266&view=rev
Log:
2009-03-29 Morten Welinder <terra gnome org>
* */*.[ch]: Install variable-sheet-size patch from 168875. (Work
of Jean with help from Andreas and me.) Note: all gui parts of
are turned off for now. Search for GNUMERIC_VARIABLE_SHEET_SIZE.
Added:
trunk/src/dialogs/dialog-new-sheet.c
trunk/src/dialogs/dialog-new-sheet.h
trunk/src/dialogs/new-sheet.glade
Modified:
trunk/ChangeLog
trunk/plugins/lotus-123/lotus-types.h
trunk/plugins/lotus-123/lotus.c
trunk/plugins/openoffice/openoffice-write.c
trunk/schemas/gnumeric-general.schemas.in
trunk/src/GNOME_Gnumeric-gtk.xml.in
trunk/src/dialogs/Makefile.am
trunk/src/dialogs/dialog-preferences.c
trunk/src/format-template.c
trunk/src/gnm-pane-impl.h
trunk/src/gnm-pane.c
trunk/src/gnumeric-gconf-priv.h
trunk/src/gnumeric-gconf.c
trunk/src/gnumeric-gconf.h
trunk/src/gnumeric.h
trunk/src/item-cursor.c
trunk/src/libgnumeric.c
trunk/src/libgnumeric.h
trunk/src/main-application.c
trunk/src/ranges.c
trunk/src/sheet-control-gui.c
trunk/src/sheet-style.c
trunk/src/sheet.c
trunk/src/sheet.h
trunk/src/wbc-gtk-actions.c
trunk/src/wbc-gtk-impl.h
trunk/src/wbc-gtk.c
trunk/src/workbook.c
trunk/src/workbook.h
trunk/src/xml-sax-read.c
Modified: trunk/plugins/lotus-123/lotus-types.h
==============================================================================
--- trunk/plugins/lotus-123/lotus-types.h (original)
+++ trunk/plugins/lotus-123/lotus-types.h Wed Apr 1 00:59:15 2009
@@ -40,6 +40,7 @@
/* Stuff observed in new formats only: */
#define LOTUS_USER_RANGE 0x9
+#define LOTUS_SYSTEMRANGE 0xa
#define LOTUS_ZEROFORCE 0xb
#define LOTUS_SORTKEY_DIR 0xc
#define LOTUS_ERRCELL 0x14
Modified: trunk/plugins/lotus-123/lotus.c
==============================================================================
--- trunk/plugins/lotus-123/lotus.c (original)
+++ trunk/plugins/lotus-123/lotus.c Wed Apr 1 00:59:15 2009
@@ -29,7 +29,7 @@
#include <gsf/gsf-msole-utils.h>
#include <string.h>
-#define LOTUS_DEBUG 0
+#define LOTUS_DEBUG 1
#undef DEBUG_RLDB
#undef DEBUG_STYLE
#undef DEBUG_FORMAT
@@ -2307,6 +2307,7 @@
case LOTUS_CALCORDER:
case LOTUS_USER_RANGE:
+ case LOTUS_SYSTEMRANGE:
case LOTUS_ZEROFORCE:
case LOTUS_SORTKEY_DIR:
case LOTUS_DTLABELMISC:
Modified: trunk/plugins/openoffice/openoffice-write.c
==============================================================================
--- trunk/plugins/openoffice/openoffice-write.c (original)
+++ trunk/plugins/openoffice/openoffice-write.c Wed Apr 1 00:59:15 2009
@@ -403,10 +403,10 @@
static void
odf_write_sheet (GnmOOExport *state, Sheet const *sheet)
{
- GnmStyle *col_styles [SHEET_MAX_COLS];
- GnmRange extent;
int max_cols = gnm_sheet_get_max_cols (sheet);
int max_rows = gnm_sheet_get_max_rows (sheet);
+ GnmStyle **col_styles = g_new (GnmStyle *, max_cols);
+ GnmRange extent;
int i, col, row;
int null_cell;
int covered_cell;
@@ -486,6 +486,7 @@
}
go_slist_free_custom (sheet_merges, g_free);
+ g_free (col_styles);
}
static void
Modified: trunk/schemas/gnumeric-general.schemas.in
==============================================================================
--- trunk/schemas/gnumeric-general.schemas.in (original)
+++ trunk/schemas/gnumeric-general.schemas.in Wed Apr 1 00:59:15 2009
@@ -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>
Modified: trunk/src/GNOME_Gnumeric-gtk.xml.in
==============================================================================
--- trunk/src/GNOME_Gnumeric-gtk.xml.in (original)
+++ trunk/src/GNOME_Gnumeric-gtk.xml.in Wed Apr 1 00:59:15 2009
@@ -97,6 +97,7 @@
<menuitem action="InsertColumns"/>
<menuitem action="InsertRows"/>
<menuitem action="SheetInsert"/>
+ <menuitem action="SheetSizedInsert"/>
<separator/>
<menuitem action="ChartGuru"/>
<!-- These don't work yet for Gnome 2
Modified: trunk/src/dialogs/Makefile.am
==============================================================================
--- trunk/src/dialogs/Makefile.am (original)
+++ trunk/src/dialogs/Makefile.am Wed Apr 1 00:59:15 2009
@@ -83,7 +83,9 @@
dialog-zoom.c \
dialogs.h \
tool-dialogs.h \
- dialog-printer-setup.c
+ dialog-printer-setup.c \
+ dialog-new-sheet.c \
+ dialog-new-sheet.h
gladedir = $(gnumeric_datadir)/glade
glade_DATA = \
@@ -154,6 +156,7 @@
variance-tests.glade \
view.glade \
workbook-attr.glade \
- print.glade
+ print.glade \
+ new-sheet.glade
EXTRA_DIST = $(glade_DATA)
Added: trunk/src/dialogs/dialog-new-sheet.c
==============================================================================
--- (empty file)
+++ trunk/src/dialogs/dialog-new-sheet.c Wed Apr 1 00:59:15 2009
@@ -0,0 +1,87 @@
+/* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * dialog-new-sheet.c:
+ *
+ * Author: Jean Brefort <jean brefort normalesup org>
+ *
+ * (C) Copyright 2008 by Jean Brefort <jean brefort normalesup org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ **/
+#include <gnumeric-config.h>
+#include <gnumeric.h>
+#include "dialog-new-sheet.h"
+#include <wbc-gtk.h>
+#include <gui-util.h>
+
+static void
+cb_columns_changed (GtkSpinButton *btn, struct NewSheetState *state)
+{
+ state->columns = gtk_spin_button_get_value_as_int (btn);
+}
+
+static void
+cb_rows_changed (GtkSpinButton *btn, struct NewSheetState *state)
+{
+ state->rows = gtk_spin_button_get_value_as_int (btn);
+}
+
+static void
+cb_position_changed (GtkComboBox *box, struct NewSheetState *state)
+{
+ state->position = gtk_combo_box_get_active (box);
+}
+
+static void
+cb_name_changed (GtkEntry *entry, struct NewSheetState *state)
+{
+ g_free (state->name);
+ state->name = g_strdup (gtk_entry_get_text (entry));
+}
+
+static void
+cb_activation_changed (GtkToggleButton *btn, struct NewSheetState *state)
+{
+ state->activate = gtk_toggle_button_get_active (btn);
+}
+
+GtkWidget *
+dialog_new_sheet (WBCGtk *wbcg, struct NewSheetState *state)
+{
+ GtkWidget *w;
+ GladeXML *gui;
+
+ g_return_val_if_fail (wbcg != NULL, NULL);
+
+ gui = gnm_glade_xml_new (GO_CMD_CONTEXT (wbcg),
+ "new-sheet.glade", NULL, NULL);
+ w = glade_xml_get_widget (gui, "columns");
+ gtk_spin_button_set_value (GTK_SPIN_BUTTON (w), state->columns);
+ g_signal_connect (w, "value-changed", G_CALLBACK (cb_columns_changed), state);
+ w = glade_xml_get_widget (gui, "rows");
+ gtk_spin_button_set_value (GTK_SPIN_BUTTON (w), state->rows);
+ g_signal_connect (w, "value-changed", G_CALLBACK (cb_rows_changed), state);
+ w = glade_xml_get_widget (gui, "position");
+ gtk_combo_box_set_active (GTK_COMBO_BOX (w), state->position);
+ g_signal_connect (w, "changed", G_CALLBACK (cb_position_changed), state);
+ w = glade_xml_get_widget (gui, "name");
+ gtk_entry_set_text (GTK_ENTRY (w), state->name);
+ g_signal_connect (w, "changed", G_CALLBACK (cb_name_changed), state);
+ w = glade_xml_get_widget (gui, "activate");
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (w), state->activate);
+ g_signal_connect (w, "toggled", G_CALLBACK (cb_activation_changed), state);
+
+ return glade_xml_get_widget (gui, "new_sheet");
+}
Added: trunk/src/dialogs/dialog-new-sheet.h
==============================================================================
--- (empty file)
+++ trunk/src/dialogs/dialog-new-sheet.h Wed Apr 1 00:59:15 2009
@@ -0,0 +1,31 @@
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+#ifndef GNUMERIC_DIALOG_NEW_SHEET_H
+#define GNUMERIC_DIALOG_NEW_SHEET_H
+
+#include "gui-gnumeric.h"
+#include <gtk/gtk.h>
+
+struct NewSheetState
+{
+ int columns, rows, position;
+ char *name;
+ gboolean activate;
+};
+
+GtkWidget* dialog_new_sheet (WBCGtk *wbcg, struct NewSheetState *state);
+
+#endif
Modified: trunk/src/dialogs/dialog-preferences.c
==============================================================================
--- trunk/src/dialogs/dialog-preferences.c (original)
+++ trunk/src/dialogs/dialog-preferences.c Wed Apr 1 00:59:15 2009
@@ -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,16 @@
page, row++, 1, 1, 64, 1,
gnm_gconf_set_workbook_nsheets,
_("Default Number of Sheets"));
+#ifdef GNUMERIC_VARIABLE_SHEET_SIZE
+ 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"));
+#endif
bool_pref_create_widget (node, GNM_CONF_GUI_ED_LIVESCROLLING,
page, row++,
gnm_gconf_set_gui_livescrolling,
Added: trunk/src/dialogs/new-sheet.glade
==============================================================================
--- (empty file)
+++ trunk/src/dialogs/new-sheet.glade Wed Apr 1 00:59:15 2009
@@ -0,0 +1,208 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
+<!--*- mode: xml -*-->
+<glade-interface>
+ <widget class="GtkDialog" id="new_sheet">
+ <property name="border_width">6</property>
+ <property name="title" translatable="yes">New sheet</property>
+ <property name="modal">True</property>
+ <property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
+ <property name="has_separator">False</property>
+ <child internal-child="vbox">
+ <widget class="GtkVBox" id="dialog-vbox1">
+ <property name="visible">True</property>
+ <property name="spacing">8</property>
+ <child>
+ <widget class="GtkAlignment" id="alignment1">
+ <property name="visible">True</property>
+ <property name="xscale">0.75</property>
+ <child>
+ <widget class="GtkTable" id="table1">
+ <property name="visible">True</property>
+ <property name="n_rows">6</property>
+ <property name="n_columns">2</property>
+ <property name="column_spacing">15</property>
+ <property name="row_spacing">5</property>
+ <child>
+ <widget class="GtkEntry" id="name">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ </widget>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">4</property>
+ <property name="bottom_attach">5</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkCheckButton" id="activate">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes">_Activate new sheet</property>
+ <property name="use_underline">True</property>
+ <property name="response_id">0</property>
+ <property name="draw_indicator">True</property>
+ </widget>
+ <packing>
+ <property name="right_attach">2</property>
+ <property name="top_attach">5</property>
+ <property name="bottom_attach">6</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkLabel" id="label5">
+ <property name="visible">True</property>
+ <property name="xalign">1</property>
+ <property name="label" translatable="yes">_Name:</property>
+ <property name="use_underline">True</property>
+ <property name="wrap_mode">PANGO_WRAP_WORD_CHAR</property>
+ <property name="ellipsize">PANGO_ELLIPSIZE_MIDDLE</property>
+ </widget>
+ <packing>
+ <property name="top_attach">4</property>
+ <property name="bottom_attach">5</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkLabel" id="label3">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">New sheet properties</property>
+ </widget>
+ <packing>
+ <property name="right_attach">2</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkSpinButton" id="rows">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="adjustment">65536 1 16777216 8192 65536 65536</property>
+ </widget>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkSpinButton" id="columns">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="adjustment">256 1 4096 64 256 256</property>
+ </widget>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkLabel" id="label2">
+ <property name="visible">True</property>
+ <property name="xalign">1</property>
+ <property name="label" translatable="yes">_Rows:</property>
+ <property name="use_underline">True</property>
+ </widget>
+ <packing>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkLabel" id="label1">
+ <property name="visible">True</property>
+ <property name="xalign">1</property>
+ <property name="label" translatable="yes">Colu_mns:</property>
+ <property name="use_underline">True</property>
+ </widget>
+ <packing>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkLabel" id="label4">
+ <property name="visible">True</property>
+ <property name="xalign">1</property>
+ <property name="label" translatable="yes">_Position:</property>
+ <property name="use_underline">True</property>
+ <property name="ellipsize">PANGO_ELLIPSIZE_END</property>
+ <property name="width_chars">0</property>
+ </widget>
+ <packing>
+ <property name="top_attach">3</property>
+ <property name="bottom_attach">4</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkComboBox" id="position">
+ <property name="visible">True</property>
+ <property name="items" translatable="yes">Start
+Before current
+After current
+End
+</property>
+ </widget>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">3</property>
+ <property name="bottom_attach">4</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+ </widget>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child internal-child="action_area">
+ <widget class="GtkHButtonBox" id="dialog-action_area1">
+ <property name="visible">True</property>
+ <property name="layout_style">GTK_BUTTONBOX_END</property>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <widget class="GtkButton" id="cancelbutton">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="can_default">True</property>
+ <property name="label">gtk-cancel</property>
+ <property name="use_stock">True</property>
+ <property name="response_id">0</property>
+ </widget>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkButton" id="okbutton">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="can_default">True</property>
+ <property name="has_default">True</property>
+ <property name="label">gtk-ok</property>
+ <property name="use_stock">True</property>
+ <property name="response_id">-5</property>
+ </widget>
+ <packing>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="pack_type">GTK_PACK_END</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+ </widget>
+</glade-interface>
Modified: trunk/src/format-template.c
==============================================================================
--- trunk/src/format-template.c (original)
+++ trunk/src/format-template.c Wed Apr 1 00:59:15 2009
@@ -47,7 +47,7 @@
return !strcmp (CXML2C (a), s);
}
-#define ROW_COL_KEY(row,col) GINT_TO_POINTER (row * SHEET_MAX_COLS + col)
+#define ROW_COL_KEY(row,col) GINT_TO_POINTER (row * gnm_sheet_get_max_cols (sheet) + col)
/******************************************************************************
* FormatTemplateMember - Getters/setters and creation
@@ -66,7 +66,7 @@
TemplateMember *member;
/* Sanity check for ROW_COL_KEY. */
- g_assert (INT_MAX / SHEET_MAX_COLS > SHEET_MAX_ROWS);
+ g_assert (INT_MAX / gnm_sheet_get_max_cols (NULL) > gnm_sheet_get_max_rows (NULL));
member = g_new (TemplateMember, 1);
@@ -966,6 +966,7 @@
cb_format_hash_style (GnmFormatTemplate *ft, GnmRange *r, GnmStyle *mstyle, GHashTable *table)
{
int row, col;
+ Sheet *sheet = NULL;
/*
* Filter out undesired elements
@@ -1029,6 +1030,7 @@
GnmStyle *
format_template_get_style (GnmFormatTemplate *ft, int row, int col)
{
+ Sheet *sheet = NULL;
g_return_val_if_fail (ft != NULL, NULL);
g_return_val_if_fail (ft->table != NULL, NULL);
Modified: trunk/src/gnm-pane-impl.h
==============================================================================
--- trunk/src/gnm-pane-impl.h (original)
+++ trunk/src/gnm-pane-impl.h Wed Apr 1 00:59:15 2009
@@ -8,8 +8,8 @@
G_BEGIN_DECLS
-#define GNM_PANE_MAX_X 1000000
-#define GNM_PANE_MAX_Y 6000000
+#define GNM_PANE_MAX_X 1600000
+#define GNM_PANE_MAX_Y 1536000000
struct _GnmPane {
GnmSimpleCanvas simple;
Modified: trunk/src/gnm-pane.c
==============================================================================
--- trunk/src/gnm-pane.c (original)
+++ trunk/src/gnm-pane.c Wed Apr 1 00:59:15 2009
@@ -1707,9 +1707,9 @@
* fetched.*/
if (text_is_rtl &&
event->x < (-64000 / pane->simple.canvas.pixels_per_unit)) {
-#if SHEET_MAX_COLS > 700 /* a guestimate */
-#warning WARNING We need a better solution to the rtl event kludge with SHEET_MAX_COLS so large
-#endif
+/*#if SHEET_MAX_COLS > 700*/ /* a guestimate */
+#warning WARNING We need a better solution to the rtl event kludge with gnm_sheet_get_max_cols (sheet) so large
+/*#endif*/
foo_canvas_w2c (canvas, event->x + 65536, event->y, &x, &y);
} else
foo_canvas_w2c (canvas, event->x, event->y, &x, &y);
Modified: trunk/src/gnumeric-gconf-priv.h
==============================================================================
--- trunk/src/gnumeric-gconf-priv.h (original)
+++ trunk/src/gnumeric-gconf-priv.h Wed Apr 1 00:59:15 2009
@@ -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"
Modified: trunk/src/gnumeric-gconf.c
==============================================================================
--- trunk/src/gnumeric-gconf.c (original)
+++ trunk/src/gnumeric-gconf.c Wed Apr 1 00:59:15 2009
@@ -184,6 +184,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 (
@@ -837,6 +847,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)
Modified: trunk/src/gnumeric-gconf.h
==============================================================================
--- trunk/src/gnumeric-gconf.h (original)
+++ trunk/src/gnumeric-gconf.h Wed Apr 1 00:59:15 2009
@@ -40,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;
@@ -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 */
Modified: trunk/src/gnumeric.h
==============================================================================
--- trunk/src/gnumeric.h (original)
+++ trunk/src/gnumeric.h Wed Apr 1 00:59:15 2009
@@ -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.
*/
Modified: trunk/src/item-cursor.c
==============================================================================
--- trunk/src/item-cursor.c (original)
+++ trunk/src/item-cursor.c Wed Apr 1 00:59:15 2009
@@ -1083,6 +1083,7 @@
int const w = (ic->pos.end.col - ic->pos.start.col);
int const h = (ic->pos.end.row - ic->pos.start.row);
GnmRange r;
+ Sheet *sheet = scg_sheet (pane->simple.scg);
r.start.col = info->col - ic->col_delta;
if (r.start.col < 0)
Modified: trunk/src/libgnumeric.c
==============================================================================
--- trunk/src/libgnumeric.c (original)
+++ trunk/src/libgnumeric.c Wed Apr 1 00:59:15 2009
@@ -71,6 +71,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;
Modified: trunk/src/libgnumeric.h
==============================================================================
--- trunk/src/libgnumeric.h (original)
+++ trunk/src/libgnumeric.h Wed Apr 1 00:59:15 2009
@@ -30,6 +30,8 @@
/* 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;
+
G_END_DECLS
#endif /* _GNM_LIBGNUMERIC_H_ */
Modified: trunk/src/main-application.c
==============================================================================
--- trunk/src/main-application.c (original)
+++ trunk/src/main-application.c Wed Apr 1 00:59:15 2009
@@ -68,6 +68,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 +84,16 @@
N_("Don't display warning dialogs when importing"),
NULL
},
+#ifdef GNUMERIC_VARIABLE_SHEET_SIZE
+ { "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
+ },
+#endif
/*********************************
* Hidden Actions */
@@ -384,6 +396,10 @@
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 < GNM_MAX_COLS))
+ gnm_sheet_max_cols <<= 1;
+ while ((gnm_sheet_max_rows < rows) && (gnm_sheet_max_rows < GNM_MAX_ROWS))
+ gnm_sheet_max_rows <<= 1;
/* Keep in sync with .desktop file */
g_set_application_name (_("Gnumeric Spreadsheet"));
Modified: trunk/src/ranges.c
==============================================================================
--- trunk/src/ranges.c (original)
+++ trunk/src/ranges.c Wed Apr 1 00:59:15 2009
@@ -37,8 +37,8 @@
{
r->start.col = 0;
r->start.row = 0;
- r->end.col = gnm_sheet_get_max_cols (NULL) - 1;
- r->end.row = gnm_sheet_get_max_rows (NULL) - 1;
+ r->end.col = G_MAXINT / 2;
+ r->end.row = G_MAXINT / 2;
return r;
}
@@ -700,10 +700,10 @@
g_return_val_if_fail (range != NULL, FALSE);
g_return_val_if_fail (range->start.col >= 0, FALSE);
g_return_val_if_fail (range->end.col >= range->start.col, FALSE);
- g_return_val_if_fail (range->end.col < gnm_sheet_get_max_cols (NULL), FALSE);
+ g_return_val_if_fail (range->end.col <= G_MAXINT / 2, FALSE);
g_return_val_if_fail (range->start.row >= 0, FALSE);
g_return_val_if_fail (range->end.row >= range->start.row, FALSE);
- g_return_val_if_fail (range->end.row < gnm_sheet_get_max_rows (NULL), FALSE);
+ g_return_val_if_fail (range->end.row <= G_MAXINT / 2, FALSE);
return TRUE;
}
Modified: trunk/src/sheet-control-gui.c
==============================================================================
--- trunk/src/sheet-control-gui.c (original)
+++ trunk/src/sheet-control-gui.c Wed Apr 1 00:59:15 2009
@@ -732,7 +732,6 @@
FooCanvas *colc;
int col_offset;
- g_return_val_if_fail (0 <= new_first_col && new_first_col < gnm_sheet_get_max_cols (sheet), 0);
col_offset = pane->first_offset.col +=
scg_colrow_distance_get (pane->simple.scg, TRUE, pane->first.col, new_first_col);
@@ -798,8 +797,6 @@
FooCanvas *rowc;
int row_offset;
- g_return_val_if_fail (0 <= new_first_row && new_first_row < gnm_sheet_get_max_rows (sheet), 0);
-
row_offset = pane->first_offset.row +=
scg_colrow_distance_get (pane->simple.scg, FALSE, pane->first.row, new_first_row);
pane->first.row = new_first_row;
@@ -865,12 +862,18 @@
gboolean changed = FALSE;
int col_offset, row_offset;
+ g_return_if_fail (0 <= col &&
+ col < gnm_sheet_get_max_cols (scg_sheet (pane->simple.scg)));
+ g_return_if_fail (0 <= row &&
+ row < gnm_sheet_get_max_rows (scg_sheet (pane->simple.scg)));
+
if (pane->first.col != col || force_scroll) {
if (force_scroll) {
/* Clear the offsets in case col/row size changed */
pane->first_offset.col = 0;
pane->first.col = 0;
}
+
col_offset = bar_set_left_col (pane, col);
changed = TRUE;
} else {
@@ -1077,17 +1080,18 @@
scg_set_panes (SheetControl *sc)
{
SheetControlGUI *scg = (SheetControlGUI *) sc;
- gboolean const being_frozen = sv_is_frozen (sc->view);
+ SheetView *sv = sc->view;
+ gboolean const being_frozen = sv_is_frozen (sv);
if (being_frozen) {
- GnmCellPos const *tl = &sc->view->frozen_top_left;
- GnmCellPos const *br = &sc->view->unfrozen_top_left;
+ GnmCellPos const *tl = &sv->frozen_top_left;
+ GnmCellPos const *br = &sv->unfrozen_top_left;
gboolean const freeze_h = br->col > tl->col;
gboolean const freeze_v = br->row > tl->row;
gnm_pane_bound_set (scg->pane[0],
br->col, br->row,
- gnm_sheet_get_max_cols (sc->sheet) - 1, gnm_sheet_get_max_rows (sc->sheet) - 1);
+ gnm_sheet_get_max_cols (sv->sheet) - 1, gnm_sheet_get_max_rows (sv->sheet) - 1);
if (freeze_h) {
scg->active_panes = 2;
@@ -1107,7 +1111,7 @@
0, 0);
}
gnm_pane_bound_set (scg->pane[1],
- tl->col, br->row, br->col - 1, gnm_sheet_get_max_rows (sc->sheet) - 1);
+ tl->col, br->row, br->col - 1, gnm_sheet_get_max_rows (sv->sheet) - 1);
}
if (freeze_h && freeze_v) {
scg->active_panes = 4;
@@ -1141,7 +1145,7 @@
0, 0);
}
gnm_pane_bound_set (scg->pane[3],
- br->col, tl->row, gnm_sheet_get_max_cols (sc->sheet) - 1, br->row - 1);
+ br->col, tl->row, gnm_sheet_get_max_cols (sv->sheet) - 1, br->row - 1);
}
} else {
int i;
@@ -1153,7 +1157,7 @@
scg->active_panes = 1;
gnm_pane_bound_set (scg->pane[0],
- 0, 0, gnm_sheet_get_max_cols (sc->sheet) - 1, gnm_sheet_get_max_rows (sc->sheet) - 1);
+ 0, 0, gnm_sheet_get_max_cols (sv->sheet) - 1, gnm_sheet_get_max_rows (sv->sheet) - 1);
}
gtk_widget_show_all (GTK_WIDGET (scg->inner_table));
@@ -2593,10 +2597,10 @@
g_return_val_if_fail (from >= 0, 1);
if (is_cols) {
- g_return_val_if_fail (to <= gnm_sheet_get_max_cols (sc->sheet), 1);
+ g_return_val_if_fail (to <= gnm_sheet_get_max_cols (sheet), 1);
collection = &sheet->cols;
} else {
- g_return_val_if_fail (to <= gnm_sheet_get_max_rows (sc->sheet), 1);
+ g_return_val_if_fail (to <= gnm_sheet_get_max_rows (sheet), 1);
collection = &sheet->rows;
}
@@ -2803,12 +2807,12 @@
if (col < 0) {
base_col = 0;
- col = gnm_sheet_get_max_cols (((SheetControl*) scg)->sheet) - 1;
+ col = gnm_sheet_get_max_cols (scg_sheet (scg)) - 1;
} else
base_col = scg->rangesel.base_corner.col;
if (row < 0) {
base_row = 0;
- row = gnm_sheet_get_max_rows (((SheetControl*) scg)->sheet) - 1;
+ row = gnm_sheet_get_max_rows (scg_sheet (scg)) - 1;
} else
base_row = scg->rangesel.base_corner.row;
Modified: trunk/src/sheet-style.c
==============================================================================
--- trunk/src/sheet-style.c (original)
+++ trunk/src/sheet-style.c Wed Apr 1 00:59:15 2009
@@ -183,35 +183,11 @@
/* 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
+ * and GNM_MAX_COLS and GNM_MAX_ROWS in gnumeric.h */
+#define TILE_TOP_LEVEL 5
-/* 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)
-
-
-/* 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,
@@ -232,14 +208,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 {
@@ -462,12 +442,36 @@
sheet_style_init (Sheet *sheet)
{
GnmStyle *default_style;
+ int l = 0, w = TILE_SIZE_COL, h = TILE_SIZE_ROW;
/* 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 (gnm_sheet_get_max_cols (sheet) <= GNM_MAX_COLS);
+ g_assert (gnm_sheet_get_max_rows (sheet) <= GNM_MAX_ROWS);
g_return_if_fail (IS_SHEET (sheet));
+ while (w < gnm_sheet_get_max_cols (sheet)) {
+ w *= TILE_SIZE_COL;
+ sheet->tile_top_level++;
+ }
+ while (h < gnm_sheet_get_max_rows (sheet)) {
+ h *= TILE_SIZE_ROW;
+ l++;
+ }
+ if (l > sheet->tile_top_level)
+ sheet->tile_top_level = l;
+ h = 16;
+ w = 4;
+ sheet->max_height = 1;
+ sheet->max_width = 1;
+ for (l = 0 ; l < sheet->tile_top_level; l++) {
+ h *= TILE_SIZE_ROW;
+ w *= TILE_SIZE_COL;
+ }
+ sheet->max_height = h / TILE_SIZE_ROW;
+ sheet->max_width = w / TILE_SIZE_COL;
+ sheet->partial_row = sheet->max_rows != h;
+ sheet->partial_col = sheet->max_cols != w;
+
#if USE_TILE_POOLS
if (tile_pool_users++ == 0) {
tile_pools[TILE_SIMPLE] =
@@ -494,7 +498,7 @@
}
#endif
- if (gnm_sheet_get_max_cols (sheet) > 364238) {
+ if (GNM_MAX_COLS > 364238) {
/* Oh, yeah? */
g_warning (_("This is a special version of Gnumeric. It has been compiled\n"
"with support for a very large number of columns. Access to the\n"
@@ -502,6 +506,7 @@
"name. Expect weirdness."));
}
+
sheet->style_data = g_new (GnmSheetStyleData, 1);
sheet->style_data->style_hash =
g_hash_table_new (gnm_style_hash, (GCompareFunc) gnm_style_equal);
@@ -1001,9 +1006,9 @@
CellTileType type;
g_return_if_fail (col >= 0);
- g_return_if_fail (col < SHEET_MAX_COLS);
+ g_return_if_fail (col < gnm_sheet_get_max_cols (NULL));
g_return_if_fail (row >= 0);
- g_return_if_fail (row < SHEET_MAX_ROWS);
+ g_return_if_fail (row < gnm_sheet_get_max_rows (NULL));
tail_recursion :
g_return_if_fail (TILE_TOP_LEVEL >= level && level >= 0);
@@ -1062,7 +1067,7 @@
g_return_if_fail (range != NULL);
cell_tile_apply (&sheet->style_data->styles,
- TILE_TOP_LEVEL, 0, 0,
+ sheet->tile_top_level, 0, 0,
range, rstyle_ctor (&rs, style, NULL, sheet));
rstyle_dtor (&rs);
}
@@ -1162,7 +1167,7 @@
g_return_if_fail (IS_SHEET (sheet));
cell_tile_apply_pos (&sheet->style_data->styles,
- TILE_TOP_LEVEL, col, row,
+ sheet->tile_top_level, col, row,
rstyle_ctor (&rs, NULL, pstyle, sheet));
rstyle_dtor (&rs);
}
@@ -1185,7 +1190,7 @@
g_return_if_fail (IS_SHEET (sheet));
cell_tile_apply_pos (&sheet->style_data->styles,
- TILE_TOP_LEVEL, col, row,
+ sheet->tile_top_level, col, row,
rstyle_ctor (&rs, style, NULL, sheet));
rstyle_dtor (&rs);
}
@@ -1218,9 +1223,9 @@
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 c, r, level = TILE_TOP_LEVEL;
+ int width = sheet->max_width;
+ int height = sheet->max_height;
+ int c, r, level = sheet->tile_top_level;
CellTile *tile = sheet->style_data->styles;
tail_recursion :
@@ -1387,7 +1392,7 @@
sr->sheet = sheet;
sr->vertical [sr->start_col] = gnm_style_border_none ();
- get_style_row (sheet->style_data->styles, TILE_TOP_LEVEL, 0, 0, sr);
+ get_style_row (sheet->style_data->styles, sheet->tile_top_level, 0, 0, sr);
}
/**
@@ -1450,7 +1455,7 @@
g_return_if_fail (range != NULL);
cell_tile_apply (&sheet->style_data->styles,
- TILE_TOP_LEVEL, 0, 0,
+ sheet->tile_top_level, 0, 0,
range, rstyle_ctor (&rs, NULL, pstyle, sheet));
rstyle_dtor (&rs);
}
@@ -1707,7 +1712,7 @@
user.accum = *style;
user.conflicts = 0; /* no conflicts yet */
foreach_tile (sheet->style_data->styles,
- TILE_TOP_LEVEL, 0, 0, r,
+ sheet->tile_top_level, 0, 0, r,
(ForeachTileFunc)cb_find_conflicts, &user);
/* copy over the diagonals */
@@ -1845,7 +1850,7 @@
col = 0;
corner.row = 0;
styles = sheet_style_get_list (rinfo->origin_sheet,
- range_init_cols (&r, col, col));
+ range_init (&r, col, 0, col, gnm_sheet_get_max_rows (rinfo->origin_sheet)-1));
if (o > 0)
for (ptr = styles ; ptr != NULL ; ptr = ptr->next)
((GnmStyleRegion *)ptr->data)->range.end.col = o;
@@ -1894,7 +1899,7 @@
{
gboolean res = FALSE;
foreach_tile (sheet->style_data->styles,
- TILE_TOP_LEVEL, 0, 0, src,
+ sheet->tile_top_level, 0, 0, src,
cb_visible_content, &res);
return res;
}
@@ -1946,7 +1951,7 @@
*
* A simple implementation that finds the smallest range containing all visible styles
* and containing res. x If @most_common_in_cols is specified it finds the most common
- * style for each column (0..SHEET_MAX_COLS-1) and ignores that style in
+ * style for each column (0..gnm_sheet_get_max_cols (sheet)-1) and ignores that style in
* boundary calculations.
*/
void
@@ -1966,7 +1971,7 @@
data.res = res;
data.most_common_in_cols = most_common_in_cols;
foreach_tile (sheet->style_data->styles,
- TILE_TOP_LEVEL, 0, 0, range_init_full_sheet(&r),
+ sheet->tile_top_level, 0, 0, range_init_full_sheet(&r),
cb_style_extent, &data);
}
@@ -2000,32 +2005,39 @@
gboolean (*style_equal) (GnmStyle const *a, GnmStyle const *b);
} StyleListMerge;
+struct add_node_closure {
+ Sheet const *sheet;
+ StyleListMerge *mi;
+};
+
static void
cb_style_list_add_node (GnmStyle *style,
int corner_col, int corner_row, int width, int height,
GnmRange const *apply_to, gpointer user)
{
- StyleListMerge *mi = user;
+ StyleListMerge *mi = ((struct add_node_closure*) user)->mi;
GnmStyleRegion *sr = NULL;
GnmCellPos key;
GnmRange range;
-
+ /* FIXME we need a real Sheet here */
+ Sheet const *sheet = ((struct add_node_closure*) user)->sheet;
+
range.start.col = corner_col;
range.start.row = corner_row;
range.end.col = corner_col + width - 1;
range.end.row = corner_row + height - 1;
-#if PARTIAL_TILE_COL
- if (corner_col >= SHEET_MAX_COLS)
- return;
- range.end.col = MIN (range.end.col, SHEET_MAX_COLS - 1);
-#endif
+ if (sheet->partial_col) {
+ if (corner_col >= gnm_sheet_get_max_cols (sheet))
+ return;
+ range.end.col = MIN (range.end.col, gnm_sheet_get_max_cols (sheet) - 1);
+ }
-#if PARTIAL_TILE_ROW
- if (corner_row >= SHEET_MAX_ROWS)
- return;
- range.end.row = MIN (range.end.row, SHEET_MAX_ROWS - 1);
-#endif
+ if (sheet->partial_row) {
+ if (corner_row >= gnm_sheet_get_max_rows (sheet))
+ return;
+ range.end.row = MIN (range.end.row, gnm_sheet_get_max_rows (sheet) - 1);
+ }
if (apply_to) {
range.start.col -= apply_to->start.col;
@@ -2134,14 +2146,17 @@
{
GnmStyleList *res = NULL;
StyleListMerge mi;
+ struct add_node_closure cl;
mi.style_equal = gnm_style_equal;
mi.cache = g_hash_table_new ((GHashFunc)&gnm_cellpos_hash,
(GCompareFunc)&gnm_cellpos_equal);
+ cl.mi = &mi;
+ cl.sheet = sheet;
foreach_tile (sheet->style_data->styles,
- TILE_TOP_LEVEL, 0, 0, r,
- cb_style_list_add_node, &mi);
+ sheet->tile_top_level, 0, 0, r,
+ cb_style_list_add_node, &cl);
#ifdef DEBUG_STYLE_LIST
g_printerr ("=========\n");
#endif
@@ -2190,7 +2205,7 @@
(GCompareFunc)&gnm_cellpos_equal);
foreach_tile (sheet->style_data->styles,
- TILE_TOP_LEVEL, 0, 0, r,
+ sheet->tile_top_level, 0, 0, r,
cb_style_list_add_conditions, &mi);
#ifdef DEBUG_STYLE_LIST
g_printerr ("=========\n");
@@ -2240,7 +2255,7 @@
(GCompareFunc)&gnm_cellpos_equal);
foreach_tile (sheet->style_data->styles,
- TILE_TOP_LEVEL, 0, 0, r,
+ sheet->tile_top_level, 0, 0, r,
cb_style_list_add_hlink, &mi);
#ifdef DEBUG_STYLE_LIST
g_printerr ("=========\n");
@@ -2293,7 +2308,7 @@
(GCompareFunc)&gnm_cellpos_equal);
foreach_tile (sheet->style_data->styles,
- TILE_TOP_LEVEL, 0, 0, r,
+ sheet->tile_top_level, 0, 0, r,
cb_style_list_add_validation, &mi);
#ifdef DEBUG_STYLE_LIST
g_printerr ("=========\n");
@@ -2440,7 +2455,7 @@
range_init_cols (&r, col, col);
accumulator = g_hash_table_new (gnm_style_hash, (GCompareFunc) gnm_style_equal);
foreach_tile (sheet->style_data->styles,
- TILE_TOP_LEVEL, 0, 0, &r,
+ sheet->tile_top_level, 0, 0, &r,
cb_accumulate_count, accumulator);
res.style = NULL;
@@ -2476,7 +2491,7 @@
g_return_val_if_fail (r != NULL, NULL);
foreach_tile (sheet->style_data->styles,
- TILE_TOP_LEVEL, 0, 0, r,
+ sheet->tile_top_level, 0, 0, r,
cb_find_link, &res);
return res;
}
@@ -2502,7 +2517,7 @@
debug_very_style_hash (Sheet *sheet)
{
foreach_tile (sheet->style_data->styles,
- TILE_TOP_LEVEL, 0, 0, NULL,
+ sheet->tile_top_level, 0, 0, NULL,
cb_validate, sheet);
}
#endif
Modified: trunk/src/sheet.c
==============================================================================
--- trunk/src/sheet.c (original)
+++ trunk/src/sheet.c Wed Apr 1 00:59:15 2009
@@ -119,7 +119,10 @@
PROP_TAB_FOREGROUND,
PROP_TAB_BACKGROUND,
- PROP_ZOOM_FACTOR
+ PROP_ZOOM_FACTOR,
+
+ PROP_COLUMNS,
+ PROP_ROWS
};
static void gnm_sheet_finalize (GObject *obj);
@@ -471,6 +474,12 @@
case PROP_ZOOM_FACTOR:
sheet_set_zoom_factor (sheet, g_value_get_double (value));
break;
+ case PROP_COLUMNS:
+ sheet->max_cols = g_value_get_int (value);
+ break;
+ case PROP_ROWS:
+ sheet->max_rows = g_value_get_int (value);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
@@ -583,6 +592,12 @@
case PROP_ZOOM_FACTOR:
g_value_set_double (value, sheet->last_zoom_factor_used);
break;
+ case PROP_COLUMNS:
+ g_value_set_int (value, sheet->max_cols);
+ break;
+ case PROP_ROWS:
+ g_value_set_int (value, sheet->max_rows);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
@@ -598,10 +613,6 @@
/* Init, focus, and load handle setting these if/when necessary */
sheet->priv->recompute_visibility = TRUE;
sheet->priv->recompute_spans = TRUE;
- sheet->priv->reposition_objects.row = gnm_sheet_get_max_rows (sheet);
- sheet->priv->reposition_objects.col = gnm_sheet_get_max_cols (sheet);
-
- range_init_full_sheet (&sheet->priv->unhidden_region);
sheet->is_protected = FALSE;
sheet->protected_allow.edit_scenarios = FALSE;
@@ -637,13 +648,9 @@
sheet->solver_parameters = solver_param_new ();
sheet->cols.max_used = -1;
- g_ptr_array_set_size (sheet->cols.info = g_ptr_array_new (),
- COLROW_SEGMENT_INDEX (gnm_sheet_get_max_cols (sheet) - 1) + 1);
sheet_col_set_default_size_pts (sheet, 48);
sheet->rows.max_used = -1;
- g_ptr_array_set_size (sheet->rows.info = g_ptr_array_new (),
- COLROW_SEGMENT_INDEX (gnm_sheet_get_max_rows (sheet) - 1) + 1);
sheet_row_set_default_size_pts (sheet, 12.75);
sheet->print_info = print_info_new (FALSE);
@@ -671,7 +678,7 @@
sheet->names = NULL;
sheet->convs = gnm_conventions_default;
- sheet_style_init (sheet);
+ sheet->style_data = NULL;
/*
* "zoom-factor" is a construction parameter and will thus
@@ -859,6 +866,20 @@
G_PARAM_CONSTRUCT |
G_PARAM_READWRITE));
+ g_object_class_install_property (gobject_class, PROP_COLUMNS,
+ g_param_spec_int ("columns",
+ _("Columns"),
+ _("Columns number in the sheet"),
+ 0, GNM_MAX_COLS, GNM_DEFAULT_COLS,
+ GSF_PARAM_STATIC | G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+
+ g_object_class_install_property (gobject_class, PROP_ROWS,
+ g_param_spec_int ("rows",
+ _("Rows"),
+ _("Rows number in the sheet"),
+ 0, GNM_MAX_ROWS, GNM_DEFAULT_ROWS,
+ GSF_PARAM_STATIC | G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+
signals[DETACHED_FROM_WORKBOOK] = g_signal_new
("detached_from_workbook",
GNM_SHEET_TYPE,
@@ -902,17 +923,28 @@
* The type can not be changed later
**/
Sheet *
-sheet_new_with_type (Workbook *wb, char const *name, GnmSheetType type)
+sheet_new_with_type (Workbook *wb, char const *name, GnmSheetType type, int columns, int rows)
{
Sheet *sheet;
g_return_val_if_fail (wb != NULL, NULL);
g_return_val_if_fail (name != NULL, NULL);
+ g_return_val_if_fail (columns <= GNM_MAX_COLS, NULL);
+ g_return_val_if_fail (rows <= GNM_MAX_ROWS, NULL);
sheet = g_object_new (GNM_SHEET_TYPE,
"zoom-factor", (double)gnm_app_prefs->zoom,
- NULL);
+ "columns", columns, "rows", rows, NULL);
+ sheet_style_init (sheet);
+ sheet->priv->reposition_objects.row = gnm_sheet_get_max_rows (sheet);
+ sheet->priv->reposition_objects.col = gnm_sheet_get_max_cols (sheet);
+ range_init_full_sheet (&sheet->priv->unhidden_region);
+ g_ptr_array_set_size (sheet->cols.info = g_ptr_array_new (),
+ COLROW_SEGMENT_INDEX (gnm_sheet_get_max_cols (sheet) - 1) + 1);
+ g_ptr_array_set_size (sheet->rows.info = g_ptr_array_new (),
+ COLROW_SEGMENT_INDEX (gnm_sheet_get_max_rows (sheet) - 1) + 1);
+ sheet->deps = gnm_dep_container_new (sheet);
sheet->index_in_wb = -1;
sheet->workbook = wb;
sheet->name_unquoted = g_strdup (name);
@@ -950,6 +982,8 @@
}
}
+ sheet->max_cols = columns;
+ sheet->max_rows = rows;
return sheet;
}
@@ -964,7 +998,25 @@
Sheet *
sheet_new (Workbook *wb, char const *name)
{
- return sheet_new_with_type (wb, name, GNM_SHEET_DATA);
+ return sheet_new_with_type (wb, name, GNM_SHEET_DATA,
+ gnm_sheet_get_max_cols (NULL),
+ gnm_sheet_get_max_rows (NULL));
+}
+
+/**
+ * sheet_new_with_size :
+ * @wb : #Workbook
+ * @name : An unquoted name in utf8
+ * @columns : The requested columns number.
+ * @rows : The requested rows number.
+ *
+ * Create a new Sheet of type SHEET_DATA, and associate it with @wb.
+ * The type can not be changed later
+ **/
+Sheet *
+sheet_new_with_size (Workbook *wb, char const *name, int columns, int rows)
+{
+ return sheet_new_with_type (wb, name, GNM_SHEET_DATA, columns, rows);
}
/****************************************************************************/
@@ -4833,6 +4885,7 @@
sheet->priv->recompute_visibility = TRUE;
sheet->priv->reposition_objects.row = 0;
}
+
void
sheet_row_set_default_size_pixels (Sheet *sheet, int height_pixels)
{
@@ -5316,3 +5369,15 @@
if (sheet->names)
gnm_named_expr_collection_foreach (sheet->names, func, data);
}
+
+int
+gnm_sheet_get_max_rows (Sheet const *sheet)
+{
+ return (sheet)? sheet->max_rows: gnm_sheet_max_rows;
+}
+
+int
+gnm_sheet_get_max_cols (Sheet const *sheet)
+{
+ return (sheet)? sheet->max_cols: gnm_sheet_max_cols;
+}
Modified: trunk/src/sheet.h
==============================================================================
--- trunk/src/sheet.h (original)
+++ trunk/src/sheet.h Wed Apr 1 00:59:15 2009
@@ -102,6 +102,12 @@
/* This needs to move elsewhere and get shared. */
PangoContext *context;
+
+ /* Size related data */
+ int max_rows, max_cols;
+ /* tile related data */
+ int tile_top_level, max_width, max_height;
+ gboolean partial_row, partial_col;
};
#define GNM_SHEET_TYPE (gnm_sheet_get_type ())
@@ -111,13 +117,14 @@
GType gnm_sheet_get_type (void);
Sheet *sheet_new (Workbook *wb, char const *name);
+Sheet *sheet_new_with_size (Workbook *wb, char const *name, int columns, int rows);
Sheet *sheet_new_with_type (Workbook *wb, char const *name,
- GnmSheetType type);
+ GnmSheetType type, int columns, int rows);
Sheet *sheet_dup (Sheet const *source_sheet);
void sheet_destroy_contents (Sheet *sheet);
-#define gnm_sheet_get_max_cols(sheet) SHEET_MAX_COLS
-#define gnm_sheet_get_max_rows(sheet) SHEET_MAX_ROWS
+int gnm_sheet_get_max_rows (Sheet const *sheet);
+int gnm_sheet_get_max_cols (Sheet const *sheet);
#define gnm_sheet_get_last_col(sheet) (gnm_sheet_get_max_cols(sheet) - 1)
#define gnm_sheet_get_last_row(sheet) (gnm_sheet_get_max_rows(sheet) - 1)
@@ -315,7 +322,6 @@
void sheet_move_range (GnmExprRelocateInfo const *rinfo,
GOUndo **pundo, GOCmdContext *cc);
-
typedef enum {
CLEAR_VALUES = 0x01,
CLEAR_FORMATS = 0x02,
Modified: trunk/src/wbc-gtk-actions.c
==============================================================================
--- trunk/src/wbc-gtk-actions.c (original)
+++ trunk/src/wbc-gtk-actions.c Wed Apr 1 00:59:15 2009
@@ -1871,6 +1871,12 @@
{ "SheetInsert", NULL, N_("_Sheet"),
NULL, N_("Insert a new sheet"),
G_CALLBACK (wbcg_insert_sheet) },
+#ifdef GNUMERIC_VARIABLE_SHEET_SIZE
+ /* Not yet... */
+ { "SheetSizedInsert", NULL, N_("Sheet with si_ze..."),
+ NULL, N_("Insert a new sheet with a specific size"),
+ G_CALLBACK (wbcg_insert_sized_sheet) },
+#endif
{ "InsertSheetAtEnd", NULL, N_("_Append"),
NULL, N_("Append a new sheet"),
G_CALLBACK (wbcg_append_sheet) },
Modified: trunk/src/wbc-gtk-impl.h
==============================================================================
--- trunk/src/wbc-gtk-impl.h (original)
+++ trunk/src/wbc-gtk-impl.h Wed Apr 1 00:59:15 2009
@@ -157,6 +157,7 @@
/* Protected functions */
gboolean wbc_gtk_close (WBCGtk *wbcg);
void wbcg_insert_sheet (GtkWidget *ignored, WBCGtk *wbcg);
+void wbcg_insert_sized_sheet(GtkWidget *ignored, WBCGtk *wbcg);
void wbcg_append_sheet (GtkWidget *ignored, WBCGtk *wbcg);
void wbcg_clone_sheet (GtkWidget *ignored, WBCGtk *wbcg);
Modified: trunk/src/wbc-gtk.c
==============================================================================
--- trunk/src/wbc-gtk.c (original)
+++ trunk/src/wbc-gtk.c Wed Apr 1 00:59:15 2009
@@ -55,6 +55,7 @@
#include "gnm-pane-impl.h"
#include "graph.h"
#include "selection.h"
+#include "dialogs/dialog-new-sheet.h"
#include <goffice/graph/gog-data-allocator.h>
#include <goffice/graph/gog-data-set.h>
@@ -405,6 +406,52 @@
}
void
+wbcg_insert_sized_sheet (GtkWidget *unused, WBCGtk *wbcg)
+{
+ WorkbookControl *wbc = WORKBOOK_CONTROL (wbcg);
+ Sheet *sheet = wb_control_cur_sheet (wbc);
+ Workbook *wb = sheet->workbook;
+ WorkbookSheetState *old_state;
+ struct NewSheetState state;
+ GtkWidget *w;
+ state.columns = gnm_sheet_get_max_cols (sheet);
+ state.rows = gnm_sheet_get_max_rows (sheet);
+ state.position = 1;
+ state.name = workbook_sheet_get_free_name (wb, _("Sheet"), TRUE, FALSE);
+ state.activate = TRUE;
+ w = dialog_new_sheet (wbcg, &state);
+ if (gtk_dialog_run (GTK_DIALOG (w)) == GTK_RESPONSE_OK) {
+ int index;
+ Sheet *new_sheet;
+ switch (state.position) {
+ case 0:
+ index = 0;
+ break;
+ case 1:
+ index = sheet->index_in_wb;
+ break;
+ case 2:
+ index = sheet->index_in_wb + 1;
+ break;
+ case 3:
+ index = workbook_sheet_count (wb);
+ break;
+ default:
+ index = sheet->index_in_wb;
+ break;
+ }
+ old_state = workbook_sheet_state_new (wb);
+ new_sheet = workbook_sheet_add_sized (wb, index, state.columns, state.rows);
+ cmd_reorganize_sheets (wbc, old_state, sheet);
+ if (state.name && strlen (state.name))
+ g_object_set (new_sheet, "name", state.name, NULL);
+ if (state.activate)
+ wb_control_sheet_focus (wbc, new_sheet);
+ }
+ gtk_widget_destroy (w);
+}
+
+void
wbcg_append_sheet (GtkWidget *unused, WBCGtk *wbcg)
{
WorkbookControl *wbc = WORKBOOK_CONTROL (wbcg);
@@ -2213,7 +2260,7 @@
len = go_pango_measure_string (
gtk_widget_get_pango_context (GTK_WIDGET (wbcg_toplevel (wbcg))),
GTK_WIDGET (entry)->style->font_desc,
- cell_coord_name (gnm_sheet_get_max_cols (NULL) - 1, gnm_sheet_get_max_rows (NULL) - 1));
+ cell_coord_name (GNM_MAX_COLS - 1, GNM_MAX_ROWS - 1));
/*
* Add a little extra since font might be proportional and since
* we also put user defined names there.
Modified: trunk/src/workbook.c
==============================================================================
--- trunk/src/workbook.c (original)
+++ trunk/src/workbook.c Wed Apr 1 00:59:15 2009
@@ -868,8 +868,15 @@
Sheet *
workbook_sheet_add (Workbook *wb, int pos)
{
+ return workbook_sheet_add_sized (wb, pos,
+ GNM_DEFAULT_COLS, GNM_DEFAULT_ROWS);
+}
+
+Sheet *
+workbook_sheet_add_sized (Workbook *wb, int pos, int columns, int rows)
+{
char *name = workbook_sheet_get_free_name (wb, _("Sheet"), TRUE, FALSE);
- Sheet *new_sheet = sheet_new (wb, name);
+ Sheet *new_sheet = sheet_new_with_size (wb, name, columns, rows);
g_free (name);
if (pos == -1)
Modified: trunk/src/workbook.h
==============================================================================
--- trunk/src/workbook.h (original)
+++ trunk/src/workbook.h Wed Apr 1 00:59:15 2009
@@ -24,6 +24,7 @@
void workbook_sheet_attach (Workbook *wb, Sheet *new_sheet);
void workbook_sheet_attach_at_pos (Workbook *wb, Sheet *new_sheet, int pos);
Sheet *workbook_sheet_add (Workbook *wb, int pos);
+Sheet *workbook_sheet_add_sized (Workbook *wb, int pos, int columns, int rows);
void workbook_sheet_delete (Sheet *sheet);
void workbook_sheet_move (Sheet *sheet, int direction);
char *workbook_sheet_get_free_name (Workbook *wb,
Modified: trunk/src/xml-sax-read.c
==============================================================================
--- trunk/src/xml-sax-read.c (original)
+++ trunk/src/xml-sax-read.c Wed Apr 1 00:59:15 2009
@@ -471,8 +471,9 @@
{
XMLSaxParseState *state = (XMLSaxParseState *)xin->user_state;
- state->sheet_cols = gnm_sheet_get_max_cols (NULL);
- state->sheet_rows = gnm_sheet_get_max_rows (NULL);
+ /* Defaults for legacy files. */
+ state->sheet_cols = 256;
+ state->sheet_rows = 65536;
for (; attrs != NULL && attrs[0] && attrs[1] ; attrs += 2) {
if (gnm_xml_attr_int (attrs, "gnm:Cols", &state->sheet_cols))
@@ -493,7 +494,10 @@
g_return_if_fail (name != NULL);
if (NULL == workbook_sheet_by_name (state->wb, name))
- workbook_sheet_attach (state->wb, sheet_new (state->wb, name));
+ workbook_sheet_attach (state->wb,
+ sheet_new_with_size (state->wb, name,
+ state->sheet_cols,
+ state->sheet_rows));
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]