Commit a27f4f0f authored by Jody Goldberg's avatar Jody Goldberg Committed by Jody Goldberg

move frozen panes here. from here.


2002-06-27  Jody Goldberg <jody@gnome.org>

	* src/sheet-view.c : move frozen panes here.
	* src/sheet.c : from here.

	* src/sheet-control-gui.c (scg_resize) : freezing in in view now.
	(scg_scrollbar_config) : ditto.
	(gnm_canvas_update_inital_top_left) : ditto.
	(scg_set_left_col) : ditto.
	(scg_set_top_row) : ditto.
	(scg_make_cell_visible) : ditto.
	(scg_set_panes) : ditto.
	* src/workbook-control-gui.c (wbcg_menu_state_update) : ditto.
	(cb_view_freeze_panes) : ditto.
	* src/xml-io.c (xml_read_sheet_layout) : ditto.
	(xml_write_sheet_layout) : ditto.
parent 55137528
2002-06-27 Jody Goldberg <jody@gnome.org>
* src/sheet-view.c : move frozen panes here.
* src/sheet.c : from here.
* src/sheet-control-gui.c (scg_resize) : freezing in in view now.
(scg_scrollbar_config) : ditto.
(gnm_canvas_update_inital_top_left) : ditto.
(scg_set_left_col) : ditto.
(scg_set_top_row) : ditto.
(scg_make_cell_visible) : ditto.
(scg_set_panes) : ditto.
* src/workbook-control-gui.c (wbcg_menu_state_update) : ditto.
(cb_view_freeze_panes) : ditto.
* src/xml-io.c (xml_read_sheet_layout) : ditto.
(xml_write_sheet_layout) : ditto.
2002-06-27 Jody Goldberg <jody@gnome.org>
* src/main-application.c : include gui-file.h
......
......@@ -15,12 +15,15 @@ Jody:
* Improve the Applix importer.
* Fix lifecycle for 3d references.
* Fix goto dialog's handling of invalid addresses.
* forward port missing patched from 1.0
* forward port missing patches from 1.0
* Finally add SheetView
* Move animated cursor selection to sheetview
* Handle enabling paste special on an application level
* Move selection to SheetView
* Parse and evaluate constructed references, no depends yet.
* Read edit_pos from xls for multi-selection case.
* Save selection correctly for xls.
* Move freeze state to SheetView.
Jukka:
* More solver enhancements:
......
2002-06-27 Jody Goldberg <jody@gnome.org>
* src/sheet-view.c : move frozen panes here.
* src/sheet.c : from here.
* src/sheet-control-gui.c (scg_resize) : freezing in in view now.
(scg_scrollbar_config) : ditto.
(gnm_canvas_update_inital_top_left) : ditto.
(scg_set_left_col) : ditto.
(scg_set_top_row) : ditto.
(scg_make_cell_visible) : ditto.
(scg_set_panes) : ditto.
* src/workbook-control-gui.c (wbcg_menu_state_update) : ditto.
(cb_view_freeze_panes) : ditto.
* src/xml-io.c (xml_read_sheet_layout) : ditto.
(xml_write_sheet_layout) : ditto.
2002-06-27 Jody Goldberg <jody@gnome.org>
* src/main-application.c : include gui-file.h
......
2002-06-27 Jody Goldberg <jody@gnome.org>
* src/sheet-view.c : move frozen panes here.
* src/sheet.c : from here.
* src/sheet-control-gui.c (scg_resize) : freezing in in view now.
(scg_scrollbar_config) : ditto.
(gnm_canvas_update_inital_top_left) : ditto.
(scg_set_left_col) : ditto.
(scg_set_top_row) : ditto.
(scg_make_cell_visible) : ditto.
(scg_set_panes) : ditto.
* src/workbook-control-gui.c (wbcg_menu_state_update) : ditto.
(cb_view_freeze_panes) : ditto.
* src/xml-io.c (xml_read_sheet_layout) : ditto.
(xml_write_sheet_layout) : ditto.
2002-06-27 Jody Goldberg <jody@gnome.org>
* src/main-application.c : include gui-file.h
......
......@@ -41,7 +41,7 @@ PKG_CHECK_MODULES(GNUMERIC,[
glib-2.0 >= 2.0.0
gobject-2.0 >= 2.0.0
gmodule-2.0 >= 2.0.0
libgsf-1 >= 0.0.0
libgsf-1 >= 1.1.0
gtk+-2.0 >= 2.0.0
libxml-2.0 >= 2.4.12
libglade-2.0 >= 1.99.7
......
2002-06-27 Jody Goldberg <jody@gnome.org>
* applix-read.c (applix_read_view) : top left is in view now.
2002-06-21 Jody Goldberg <jody@gnome.org>
* applix-read.c (applix_parse_cellref) : take a CellPos.
......
......@@ -825,7 +825,8 @@ applix_read_view (ApplixReadState *state, unsigned char *buffer)
if (!a_strncmp (buffer, "View Top Left: ")) {
CellPos pos;
if (applix_parse_cellref (state, buffer+15, &sheet, &pos, ':'))
sheet_set_initial_top_left (sheet, pos.col, pos.row);
sv_set_initial_top_left (sheet_get_view (sheet, state->wb_view),
pos.col, pos.row);
} else if (!a_strncmp (buffer, "View Open Cell: ")) {
CellPos pos;
if (applix_parse_cellref (state, buffer+16, &sheet, &pos, ':'))
......
2002-06-27 Jody Goldberg <jody@gnome.org>
* ms-excel-read.c (ms_excel_read_selection) : put the edit_pos in the
right place.
* ms-excel-write.c (write_sheet_tail) : Use stern_brocot to get a
reasonable fraction.
(write_sheet_selection) : split the writing of the selection out into
here and implement it.
2002-06-22 Jody Goldberg <jody@gnome.org>
* ms-formula-write.c (operations) : export intersection.
......
......@@ -3012,42 +3012,44 @@ ms_excel_read_imdata (BiffQuery *q)
static void
ms_excel_read_selection (BiffQuery *q, ExcelSheet *esheet)
{
/* FIXME : pane_number will be relevant for split panes.
* because frozen panes are bound together this does not matter.
*/
/* int const pane_number = GSF_LE_GET_GUINT8 (q->data); */
int const act_row = GSF_LE_GET_GUINT16 (q->data + 1);
int const act_col = GSF_LE_GET_GUINT16 (q->data + 3);
int num_refs = GSF_LE_GET_GUINT16 (q->data + 7);
CellPos edit_pos, tmp;
/* the range containing the edit_pos */
int i, j = GSF_LE_GET_GUINT16 (q->data + 5);
int num_refs = GSF_LE_GET_GUINT16 (q->data + 7);
guint8 *refs;
SheetView *sv = sheet_get_view (esheet->gnum_sheet, esheet->wb->wbv);
Range r;
d (1, printf ("Start selection\n"););
d (6, printf ("Cursor: %d %d\n", act_col, act_row););
edit_pos.row = GSF_LE_GET_GUINT16 (q->data + 1);
edit_pos.col = GSF_LE_GET_GUINT16 (q->data + 3);
d (5, printf ("Start selection\n"););
d (5, printf ("Cursor: %s in Ref #%d\n", cell_pos_name (&edit_pos),
j););
/* FIXME : pane_number will be relevant for split panes.
* because frozen panes are bound together this does not matter.
*/
sv_selection_reset (sv);
for (refs = q->data + 9; num_refs > 0; refs += 6, num_refs--) {
int const start_row = GSF_LE_GET_GUINT16 (refs + 0);
int const start_col = GSF_LE_GET_GUINT8 (refs + 4);
int const end_row = GSF_LE_GET_GUINT16 (refs + 2);
int const end_col = GSF_LE_GET_GUINT8 (refs + 5);
d (6, printf ("Ref %d = %d %d %d %d\n", num_refs,
start_col, start_row, end_col, end_row););
for (i = 0; i++ < num_refs ; ) {
refs = q->data + 9 + 6 * (++j % num_refs);
r.start.row = GSF_LE_GET_GUINT16 (refs + 0);
r.end.row = GSF_LE_GET_GUINT16 (refs + 2);
r.start.col = GSF_LE_GET_GUINT8 (refs + 4);
r.end.col = GSF_LE_GET_GUINT8 (refs + 5);
d (5, printf ("Ref %d = %s\n", i-1, range_name (&r)););
tmp = (i == num_refs) ? edit_pos : r.start;
sv_selection_add_range (sv,
start_col, start_row,
start_col, start_row,
end_col, end_row);
tmp.col, tmp.row,
r.start.col, r.start.row,
r.end.col, r.end.row);
}
#if 0
/* FIXME: Disable for now. We need to reset the index of the
* current selection range too. This can do odd things
* if the last range is NOT the currently selected range.
*/
sheet_cursor_move (esheet->gnum_sheet, act_col, act_row, FALSE, FALSE);
#endif
d (1, printf ("Done selection\n"););
d (5, printf ("Done selection\n"););
}
/**
......@@ -3342,13 +3344,13 @@ ms_excel_read_pane (BiffQuery *q, ExcelSheet *esheet, WorkbookView *wb_view)
guint16 y = GSF_LE_GET_GUINT16 (q->data + 2);
guint16 rwTop = GSF_LE_GET_GUINT16 (q->data + 4);
guint16 colLeft = GSF_LE_GET_GUINT16 (q->data + 6);
Sheet *sheet = esheet->gnum_sheet;
SheetView *sv = sheet_get_view (esheet->gnum_sheet, esheet->wb->wbv);
CellPos frozen, unfrozen;
frozen = unfrozen = sheet->initial_top_left;
frozen = unfrozen = sv->initial_top_left;
unfrozen.col += x; unfrozen.row += y;
sheet_freeze_panes (sheet, &frozen, &unfrozen);
sheet_set_initial_top_left (sheet, colLeft, rwTop);
sv_freeze_panes (sv, &frozen, &unfrozen);
sv_set_initial_top_left (sv, colLeft, rwTop);
} else {
g_warning ("EXCEL : no support for split panes yet");
}
......@@ -3360,6 +3362,8 @@ ms_excel_read_pane (BiffQuery *q, ExcelSheet *esheet, WorkbookView *wb_view)
static void
ms_excel_read_window2 (BiffQuery *q, ExcelSheet *esheet, WorkbookView *wb_view)
{
SheetView *sv = sheet_get_view (esheet->gnum_sheet, esheet->wb->wbv);
if (q->length >= 10) {
guint16 const options = GSF_LE_GET_GUINT16 (q->data + 0);
/* coords are 0 based */
......@@ -3377,7 +3381,7 @@ ms_excel_read_window2 (BiffQuery *q, ExcelSheet *esheet, WorkbookView *wb_view)
/* NOTE : This is top left of screen even if frozen, modify when
* we read PANE
*/
sheet_set_initial_top_left (esheet->gnum_sheet, left_col, top_row);
sv_set_initial_top_left (sv, left_col, top_row);
if (!(options & 0x0020)) {
StyleColor *pattern_color;
......
......@@ -48,7 +48,7 @@
#include <expr-name.h>
#include <gutils.h>
#include <str.h>
#include <mathfunc.h>
#include <libole2/ms-ole.h>
#include <stdio.h>
......@@ -469,7 +469,8 @@ write_window2 (BiffPut *bp, MsBiffVersion ver, ExcelSheet *esheet)
guint16 options = 0x0A0;
guint8 *data;
CellPos top_left;
Sheet *sheet = esheet->gnum_sheet;
Sheet const *sheet = esheet->gnum_sheet;
SheetView const *sv = sheet_get_view (sheet, esheet->wb->gnum_wb_view);
StyleColor *sheet_auto = sheet_style_get_auto_pattern_color (sheet);
StyleColor *default_auto = style_color_auto_pattern ();
guint32 biff_pat_col = 0x40; /* default grid color index == auto */
......@@ -480,11 +481,11 @@ write_window2 (BiffPut *bp, MsBiffVersion ver, ExcelSheet *esheet)
options |= 0x0002;
if (!sheet->hide_col_header || !sheet->hide_row_header)
options |= 0x0004;
if (sheet_is_frozen (sheet)) {
if (sv_is_frozen (sv)) {
options |= 0x0008;
top_left = sheet->frozen_top_left;
top_left = sv->frozen_top_left;
} else
top_left = sheet->initial_top_left; /* belongs in sheetView */
top_left = sv->initial_top_left;
if (!sheet->hide_zero)
options |= 0x0010;
/* Grid / auto pattern color */
......@@ -529,16 +530,17 @@ static void
write_pane (BiffPut *bp, MsBiffVersion ver, ExcelSheet *esheet)
{
guint8 *data = ms_biff_put_len_next (bp, BIFF_PANE, 10);
Sheet const *sheet = esheet->gnum_sheet;
int const frozen_height = sheet->unfrozen_top_left.row -
sheet->frozen_top_left.row;
int const frozen_width = sheet->unfrozen_top_left.col -
sheet->frozen_top_left.col;
SheetView const *sv = sheet_get_view (esheet->gnum_sheet,
esheet->wb->gnum_wb_view);
int const frozen_height = sv->unfrozen_top_left.row -
sv->frozen_top_left.row;
int const frozen_width = sv->unfrozen_top_left.col -
sv->frozen_top_left.col;
MS_OLE_SET_GUINT16 (data + 0, frozen_width);
MS_OLE_SET_GUINT16 (data + 2, frozen_height);
MS_OLE_SET_GUINT16 (data + 4, sheet->initial_top_left.row);
MS_OLE_SET_GUINT16 (data + 6, sheet->initial_top_left.col);
MS_OLE_SET_GUINT16 (data + 4, sv->initial_top_left.row);
MS_OLE_SET_GUINT16 (data + 6, sv->initial_top_left.col);
MS_OLE_SET_GUINT16 (data + 8, 0); /* active pane */
ms_biff_put_commit (bp);
......@@ -3282,6 +3284,33 @@ write_sheet_head (BiffPut *bp, ExcelSheet *esheet)
write_dimension (bp, esheet);
}
static void
write_sheet_selection (ExcelSheet *esheet, BiffPut *bp)
{
SheetView const *sv = sheet_get_view (esheet->gnum_sheet,
esheet->wb->gnum_wb_view);
int n = g_list_length (sv->selections);
GList *ptr;
guint8 *data;
data = ms_biff_put_len_next (bp, BIFF_SELECTION, 15);
MS_OLE_SET_GUINT8 (data + 0, 0); /* pane 0 */
MS_OLE_SET_GUINT16 (data + 1, sv->edit_pos.row);
MS_OLE_SET_GUINT16 (data + 3, sv->edit_pos.col);
MS_OLE_SET_GUINT16 (data + 5, 0); /* our edit_pos is in 1st range */
MS_OLE_SET_GUINT16 (data + 7, n);
data += 9;
for (ptr = sv->selections ; ptr != NULL ; ptr = ptr->next, data += 6) {
Range const *r = ptr->data;
MS_OLE_SET_GUINT16 (data + 0, r->start.row);
MS_OLE_SET_GUINT16 (data + 2, r->end.row);
MS_OLE_SET_GUINT8 (data + 4, r->start.col);
MS_OLE_SET_GUINT8 (data + 5, r->end.col);
}
ms_biff_put_commit (bp);
}
static void
write_sheet_tail (IOContext *context, BiffPut *bp, ExcelSheet *esheet)
{
......@@ -3293,24 +3322,16 @@ write_sheet_tail (IOContext *context, BiffPut *bp, ExcelSheet *esheet)
write_pane (bp, ver, esheet);
if (ver >= MS_BIFF_V8) {
/* Dont over think this just force the fraction into a/1000 */
int const zoom = esheet->gnum_sheet->last_zoom_factor_used * 1000 + .5;
int num, denom;
stern_brocot (esheet->gnum_sheet->last_zoom_factor_used,
1000, &num, &denom);
data = ms_biff_put_len_next (bp, BIFF_SCL, 4);
MS_OLE_SET_GUINT16 (data + 0, (guint16)zoom);
MS_OLE_SET_GUINT16 (data + 2, 1000);
MS_OLE_SET_GUINT16 (data + 0, (guint16)num);
MS_OLE_SET_GUINT16 (data + 2, denom);
ms_biff_put_commit (bp);
}
/* See: S59DE2.HTM */
#warning YUCK! store the real selection
data = ms_biff_put_len_next (bp, BIFF_SELECTION, 15);
MS_OLE_SET_GUINT32 (data + 0, 0x00000103);
MS_OLE_SET_GUINT32 (data + 4, 0x01000000);
MS_OLE_SET_GUINT32 (data + 8, 0x01000100);
MS_OLE_SET_GUINT16 (data + 12, 0x0);
MS_OLE_SET_GUINT8 (data + 14, 0x0);
ms_biff_put_commit (bp);
write_sheet_selection (esheet, bp);
write_mergecells (bp, ver, esheet);
/* See: S59D90.HTM: Global Column Widths... not cricual.
......
2002-06-27 Jody Goldberg <jody@gnome.org>
* xml-sax-read.c (xml_sax_sheet_layout) : top left is
in view now.
(xml_sax_sheet_freezepanes) : as is freezing.
2002-06-20 Jody Goldberg <jody@gnome.org>
* xml-sax-read.c (xml_sax_selection_range) : use sheet_get_view.
......
......@@ -859,7 +859,9 @@ xml_sax_sheet_layout (XMLSaxParseState *state, xmlChar const **attrs)
for (; attrs != NULL && attrs[0] && attrs[1] ; attrs += 2)
if (xml_sax_attr_cellpos (attrs, "TopLeft", &tmp))
sheet_set_initial_top_left (state->sheet, tmp.col, tmp.row);
sv_set_initial_top_left (
sheet_get_view (state->sheet, state->wb_view),
tmp.col, tmp.row);
else
xml_sax_unknown_attr (state, attrs, "SheetLayout");
}
......@@ -879,7 +881,8 @@ xml_sax_sheet_freezepanes (XMLSaxParseState *state, xmlChar const **attrs)
xml_sax_unknown_attr (state, attrs, "SheetLayout");
if (flags == 3)
sheet_freeze_panes (state->sheet, &frozen_tl, &unfrozen_tl);
sv_freeze_panes (sheet_get_view (state->sheet, state->wb_view),
&frozen_tl, &unfrozen_tl);
}
static void
......
......@@ -1222,4 +1222,3 @@ sv_selection_walk_step (SheetView *sv,
sv_set_edit_pos (sv, &destination);
sv_make_cell_visible (sv, destination.col, destination.row, TRUE);
}
......@@ -219,7 +219,7 @@ static void
scg_resize (SheetControl *sc, gboolean force_scroll)
{
SheetControlGUI *scg = (SheetControlGUI *)sc;
Sheet *sheet;
Sheet const *sheet;
GnumericCanvas *gcanvas;
int h, w, btn_h, btn_w, tmp;
double zoom;
......@@ -261,8 +261,8 @@ scg_resize (SheetControl *sc, gboolean force_scroll)
gnome_canvas_set_scroll_region (scg->pane[0].row.canvas,
0, 0, w / zoom, GNUMERIC_CANVAS_FACTOR_Y / zoom);
} else {
CellPos const *tl = &sheet->frozen_top_left;
CellPos const *br = &sheet->unfrozen_top_left;
CellPos const *tl = &sc->view->frozen_top_left;
CellPos const *br = &sc->view->unfrozen_top_left;
int const l = scg_colrow_distance_get (scg, TRUE,
0, tl->col);
int const r = scg_colrow_distance_get (scg, TRUE,
......@@ -362,15 +362,16 @@ scg_scrollbar_config (SheetControl const *sc)
GtkAdjustment *va = GTK_ADJUSTMENT (scg->va);
GtkAdjustment *ha = GTK_ADJUSTMENT (scg->ha);
GnumericCanvas *gcanvas = scg_pane (scg, 0);
Sheet *sheet = sc->sheet;
Sheet const *sheet = sc->sheet;
SheetView const*sv = sc->view;
int const last_col = gcanvas->last_full.col;
int const last_row = gcanvas->last_full.row;
int max_col = last_col;
int max_row = last_row;
if (sheet_is_frozen (sheet)) {
ha->lower = sheet->unfrozen_top_left.col;
va->lower = sheet->unfrozen_top_left.row;
if (sv_is_frozen (sv)) {
ha->lower = sv->unfrozen_top_left.col;
va->lower = sv->unfrozen_top_left.row;
} else
ha->lower = va->lower = 0;
......@@ -617,18 +618,14 @@ scg_init (SheetControlGUI *scg)
/**
* gnm_canvas_update_inital_top_left :
* A convenience routine to store the new topleft back in the view.
* FIXME : for now we don't have a sheetView so we endup just storing it in the
* Sheet. Having this operation wrapped nicely here will make it easy to fix
* later.
*/
static void
gnm_canvas_update_inital_top_left (GnumericCanvas const *gcanvas)
{
/* FIXME : we need SheetView */
if (gcanvas->pane->index == 0) {
Sheet *sheet = gcanvas->simple.scg->sheet_control.sheet;
sheet->initial_top_left.col = gcanvas->first.col;
sheet->initial_top_left.row = gcanvas->first.row;
SheetView *sv = gcanvas->simple.scg->sheet_control.view;
sv->initial_top_left.col = gcanvas->first.col;
sv->initial_top_left.row = gcanvas->first.row;
}
}
......@@ -683,7 +680,7 @@ scg_set_left_col (SheetControlGUI *scg, int col)
col = bound->end.col;
if (scg->pane[3].is_active) {
int right = sheet->unfrozen_top_left.col;
int right = scg->sheet_control.view->unfrozen_top_left.col;
if (col < right)
col = right;
gnm_canvas_set_left_col (scg_pane (scg, 3), col);
......@@ -742,7 +739,7 @@ scg_set_top_row (SheetControlGUI *scg, int row)
row = bound->end.row;
if (scg->pane[1].is_active) {
int bottom = sheet->unfrozen_top_left.row;
int bottom = scg->sheet_control.view->unfrozen_top_left.row;
if (row < bottom)
row = bottom;
gnm_canvas_set_top_row (scg_pane (scg, 1), row);
......@@ -884,13 +881,13 @@ void
scg_make_cell_visible (SheetControlGUI *scg, int col, int row,
gboolean force_scroll, gboolean couple_panes)
{
Sheet const *sheet = ((SheetControl *) scg)->sheet;
SheetView const *sv = ((SheetControl *) scg)->view;
CellPos const *tl, *br;
g_return_if_fail (IS_SHEET_CONTROL_GUI (scg));
tl = &sheet->frozen_top_left;
br = &sheet->unfrozen_top_left;
tl = &sv->frozen_top_left;
br = &sv->unfrozen_top_left;
if (col < br->col) {
if (row >= br->row) { /* pane 1 */
if (col < tl->col)
......@@ -898,11 +895,9 @@ scg_make_cell_visible (SheetControlGUI *scg, int col, int row,
gnm_canvas_make_cell_visible (scg->pane[1].gcanvas,
col, row, force_scroll);
gnm_canvas_set_top_left (scg->pane[0].gcanvas,
couple_panes
? br->col
: scg->pane[0].gcanvas->first.col,
scg->pane[1].gcanvas->first.row,
force_scroll);
couple_panes ? br->col : scg->pane[0].gcanvas->first.col,
scg->pane[1].gcanvas->first.row,
force_scroll);
if (couple_panes)
gnm_canvas_set_left_col (scg->pane[3].gcanvas, br->col);
} else if (couple_panes) { /* pane 2 */
......@@ -962,7 +957,7 @@ static void
scg_set_panes (SheetControl *sc)
{
SheetControlGUI *scg = (SheetControlGUI *) sc;
gboolean const being_frozen = sheet_is_frozen (sc->sheet);
gboolean const being_frozen = sv_is_frozen (sc->view);
gboolean const was_frozen = scg->pane[2].gcanvas != NULL;
if (!being_frozen && !was_frozen)
......@@ -970,8 +965,8 @@ scg_set_panes (SheetControl *sc)
/* TODO : support just h or v split */
if (being_frozen) {
CellPos const *tl = &sc->sheet->frozen_top_left;
CellPos const *br = &sc->sheet->unfrozen_top_left;
CellPos const *tl = &sc->view->frozen_top_left;
CellPos const *br = &sc->view->unfrozen_top_left;
gnm_pane_init (scg->pane + 1, scg, FALSE, 1);
gnm_pane_init (scg->pane + 2, scg, TRUE, 2);
......@@ -1033,7 +1028,7 @@ scg_set_panes (SheetControl *sc)
scg_resize (SHEET_CONTROL (scg), TRUE);
if (being_frozen) {
CellPos const *tl = &sc->sheet->frozen_top_left;
CellPos const *tl = &sc->view->frozen_top_left;
gnm_canvas_set_left_col (scg->pane[1].gcanvas, tl->col);
gnm_canvas_set_top_row (scg->pane[3].gcanvas, tl->row);
......
......@@ -193,6 +193,11 @@ sheet_view_init (GObject *object)
sv->selection_content_changed = TRUE;
sv->reposition_selection = TRUE;
sv->auto_expr_timer = 0;
sv->frozen_top_left.col = sv->frozen_top_left.row =
sv->unfrozen_top_left.col = sv->unfrozen_top_left.row = -1;
sv->initial_top_left.col = sv->initial_top_left.row = 0;
sv_selection_add_pos (sv, 0, 0);
}
......@@ -200,12 +205,31 @@ E_MAKE_TYPE (sheet_view, "SheetView", SheetView,
sheet_view_class_init, sheet_view_init,
G_TYPE_OBJECT);
static void
sv_init_sc (SheetView const *sv, SheetControl *sc)
{
/* set_panes will change the initial so cache it */
CellPos initial = sv->initial_top_left;
sc_set_panes (sc);
/* And this will restore it */
sc_set_top_left (sc, initial.col, initial.row);
sc_scrollbar_config (sc);
/* Set the visible bound, not the logical bound */
sc_cursor_bound (sc, selection_first_range (sv, NULL, NULL));
sc_ant (sc);
}
SheetView *
sheet_view_new (Sheet *sheet, WorkbookView *wbv)
{
SheetView *sv = g_object_new (SHEET_VIEW_TYPE, NULL);
sheet_attach_view (sheet, sv);
sv->wbv = wbv;
SHEET_VIEW_FOREACH_CONTROL (sv, control,
sv_init_sc (sv, control););
return sv;
}
......@@ -577,3 +601,92 @@ sv_is_region_empty_or_selected (SheetView const *sv, Range const *r)
sv->sheet, TRUE, r->start.col, r->start.row, r->end.col, r->end.row,
fail_if_not_selected, (gpointer)sv) == NULL;
}
/**
* sv_freeze_panes :
* @sheet : the sheet
* @frozen : top left corner of the frozen region
* @unfrozen : top left corner of the unfrozen region
*
* By definition the unfrozen region must be below the frozen.
*/
void
sv_freeze_panes (SheetView *sv,
CellPos const *frozen,
CellPos const *unfrozen)
{
g_return_if_fail (IS_SHEET_VIEW (sv));
if (frozen != NULL) {
g_return_if_fail (unfrozen != NULL);
g_return_if_fail (unfrozen->col > frozen->col);
g_return_if_fail (unfrozen->row > frozen->row);
/* Just in case */
if (unfrozen->col != (SHEET_MAX_COLS-1) &&
unfrozen->row != (SHEET_MAX_ROWS-1)) {
g_return_if_fail (unfrozen->row > frozen->row);
sv->frozen_top_left = *frozen;
sv->unfrozen_top_left = *unfrozen;
} else
frozen = unfrozen = NULL;
}
if (frozen == NULL) {
g_return_if_fail (unfrozen == NULL);
/* no change */
if (sv->frozen_top_left.col < 0 &&
sv->frozen_top_left.row < 0 &&
sv->unfrozen_top_left.col < 0 &&
sv->unfrozen_top_left.row < 0)
return;
sv->initial_top_left = sv->frozen_top_left;
sv->frozen_top_left.col = sv->frozen_top_left.row =
sv->unfrozen_top_left.col = sv->unfrozen_top_left.row = -1;
}
SHEET_VIEW_FOREACH_CONTROL (sv, control,
sv_init_sc (sv, control););