Commit e301f704 authored by Almer S. Tigelaar's avatar Almer S. Tigelaar Committed by Almer S. Tigelaar

Implement group undo/redo (cmd_group_redo): Idem. (cmd_group_destroy):

2001-06-02  Almer S. Tigelaar  <almer@gnome.org>

        * src/commands.[ch] (cmd_group_undo): Implement group undo/redo
  	(cmd_group_redo): Idem.
  	(cmd_group_destroy): Idem.
  	(cmd_group): Idem.

  	* src/workbook-control-gui.c (cb_data_group): Implement.
  	(cb_data_ungroup): Idem.
  	(group_ungroup_colrow): Utility function to determine if
  	columns or rows need to be grouped/ungrouped.

  	* src/sheet.[ch] (sheet_col_row_group_ungroup): New, high level routine
 	for adjusting outlines.
 	(sheet_col_row_fit_gutter): Dynamically adjust gutter size.
 	(cb_outline_level): Callback for the above.
 	(sheet_col_row_can_group): Query if a range of cols/rows
 	can actually group/ungroup.
 	(sheet_col_row_set_outline_level): Deprecated, remove.

 	* src/colrow.[ch] (colrow_set_outline): Set outline on a col/row.

  	* src/GNOME_Gnumeric.xml: DataOutlineUnGroup change to
  	DataOutlineUngroup.

2001-06-02  Almer S. Tigelaar  <almer@gnome.org>

	* colrow.glade: New simple dialog.

	* dialog-simple-input.c, dialogs.h
	(dialog_choose_cols_vs_rows): New, let user choose
	between columns or rows.

2001-06-02  Almer S. Tigelaar  <almer@gnome.org>

	* (ms_excel_read_row): Set outline using
	new functions.
	(ms_excel_read_colinfo): Idem.
parent 9fc2426c
......@@ -17,7 +17,6 @@ Long term breakage
- outline mode
: finish implementing optionally putting markers above/left
: implement group/ungroup menu items (with undo, Almer is working on this)
: connect the hide/show menu items
- It is possible to navigate to hidden cols/rows at the start/end of the sheet.
......
2001-06-02 Almer S. Tigelaar <almer@gnome.org>
* src/commands.[ch] (cmd_group_undo): Implement group undo/redo
(cmd_group_redo): Idem.
(cmd_group_destroy): Idem.
(cmd_group): Idem.
* src/workbook-control-gui.c (cb_data_group): Implement.
(cb_data_ungroup): Idem.
(group_ungroup_colrow): Utility function to determine if
columns or rows need to be grouped/ungrouped.
* src/sheet.[ch] (sheet_col_row_group_ungroup): New, high level routine
for adjusting outlines.
(sheet_col_row_fit_gutter): Dynamically adjust gutter size.
(cb_outline_level): Callback for the above.
(sheet_col_row_can_group): Query if a range of cols/rows
can actually group/ungroup.
(sheet_col_row_set_outline_level): Deprecated, remove.
* src/colrow.[ch] (colrow_set_outline): Set outline on a col/row.
* src/GNOME_Gnumeric.xml: DataOutlineUnGroup change to
DataOutlineUngroup.
2001-06-02 Jody Goldberg <jgoldberg@home.com>
* src/main.c (handle_paint_events) : be consistent and don't block.
......
......@@ -2,6 +2,7 @@ Gnumeric 0.66
Almer:
* Some work on the SAX importer.
* Finish Group/Ungroup
Jody:
* Fix ctrl-enter filling.
......
2001-06-02 Almer S. Tigelaar <almer@gnome.org>
* src/commands.[ch] (cmd_group_undo): Implement group undo/redo
(cmd_group_redo): Idem.
(cmd_group_destroy): Idem.
(cmd_group): Idem.
* src/workbook-control-gui.c (cb_data_group): Implement.
(cb_data_ungroup): Idem.
(group_ungroup_colrow): Utility function to determine if
columns or rows need to be grouped/ungrouped.
* src/sheet.[ch] (sheet_col_row_group_ungroup): New, high level routine
for adjusting outlines.
(sheet_col_row_fit_gutter): Dynamically adjust gutter size.
(cb_outline_level): Callback for the above.
(sheet_col_row_can_group): Query if a range of cols/rows
can actually group/ungroup.
(sheet_col_row_set_outline_level): Deprecated, remove.
* src/colrow.[ch] (colrow_set_outline): Set outline on a col/row.
* src/GNOME_Gnumeric.xml: DataOutlineUnGroup change to
DataOutlineUngroup.
2001-06-02 Jody Goldberg <jgoldberg@home.com>
* src/main.c (handle_paint_events) : be consistent and don't block.
......
2001-06-02 Almer S. Tigelaar <almer@gnome.org>
* src/commands.[ch] (cmd_group_undo): Implement group undo/redo
(cmd_group_redo): Idem.
(cmd_group_destroy): Idem.
(cmd_group): Idem.
* src/workbook-control-gui.c (cb_data_group): Implement.
(cb_data_ungroup): Idem.
(group_ungroup_colrow): Utility function to determine if
columns or rows need to be grouped/ungrouped.
* src/sheet.[ch] (sheet_col_row_group_ungroup): New, high level routine
for adjusting outlines.
(sheet_col_row_fit_gutter): Dynamically adjust gutter size.
(cb_outline_level): Callback for the above.
(sheet_col_row_can_group): Query if a range of cols/rows
can actually group/ungroup.
(sheet_col_row_set_outline_level): Deprecated, remove.
* src/colrow.[ch] (colrow_set_outline): Set outline on a col/row.
* src/GNOME_Gnumeric.xml: DataOutlineUnGroup change to
DataOutlineUngroup.
2001-06-02 Jody Goldberg <jgoldberg@home.com>
* src/main.c (handle_paint_events) : be consistent and don't block.
......
2001-06-02 Almer S. Tigelaar <almer@gnome.org>
* src/commands.[ch] (cmd_group_undo): Implement group undo/redo
(cmd_group_redo): Idem.
(cmd_group_destroy): Idem.
(cmd_group): Idem.
* src/workbook-control-gui.c (cb_data_group): Implement.
(cb_data_ungroup): Idem.
(group_ungroup_colrow): Utility function to determine if
columns or rows need to be grouped/ungrouped.
* src/sheet.[ch] (sheet_col_row_group_ungroup): New, high level routine
for adjusting outlines.
(sheet_col_row_fit_gutter): Dynamically adjust gutter size.
(cb_outline_level): Callback for the above.
(sheet_col_row_can_group): Query if a range of cols/rows
can actually group/ungroup.
(sheet_col_row_set_outline_level): Deprecated, remove.
* src/colrow.[ch] (colrow_set_outline): Set outline on a col/row.
* src/GNOME_Gnumeric.xml: DataOutlineUnGroup change to
DataOutlineUngroup.
2001-06-02 Jody Goldberg <jgoldberg@home.com>
* src/main.c (handle_paint_events) : be consistent and don't block.
......
2001-06-02 Almer S. Tigelaar <almer@gnome.org>
* src/commands.[ch] (cmd_group_undo): Implement group undo/redo
(cmd_group_redo): Idem.
(cmd_group_destroy): Idem.
(cmd_group): Idem.
* src/workbook-control-gui.c (cb_data_group): Implement.
(cb_data_ungroup): Idem.
(group_ungroup_colrow): Utility function to determine if
columns or rows need to be grouped/ungrouped.
* src/sheet.[ch] (sheet_col_row_group_ungroup): New, high level routine
for adjusting outlines.
(sheet_col_row_fit_gutter): Dynamically adjust gutter size.
(cb_outline_level): Callback for the above.
(sheet_col_row_can_group): Query if a range of cols/rows
can actually group/ungroup.
(sheet_col_row_set_outline_level): Deprecated, remove.
* src/colrow.[ch] (colrow_set_outline): Set outline on a col/row.
* src/GNOME_Gnumeric.xml: DataOutlineUnGroup change to
DataOutlineUngroup.
2001-06-02 Jody Goldberg <jgoldberg@home.com>
* src/main.c (handle_paint_events) : be consistent and don't block.
......
2001-06-02 Almer S. Tigelaar <almer@gnome.org>
* (ms_excel_read_row): Set outline using
new functions.
(ms_excel_read_colinfo): Idem.
2001-05-31 Karl Eichwalder <ke@suse.de>
* boot.c (excel_save): Add dot.
......
......@@ -2899,9 +2899,11 @@ ms_excel_read_row (BiffQuery *q, ExcelSheet *sheet)
}
#endif
}
sheet_col_row_set_outline_level (sheet->gnum_sheet, row, FALSE,
(unsigned)(flags&0x7),
flags & 0x10);
if ((unsigned)(flags&0x7) > 0) {
ColRowInfo *cri = sheet_row_fetch (sheet->gnum_sheet, row);
colrow_set_outline (cri, FALSE, (unsigned)(flags&0x7), FALSE, flags & 0x10);
}
}
/**
......@@ -2957,8 +2959,10 @@ ms_excel_read_colinfo (BiffQuery *q, ExcelSheet *sheet)
lastcol = SHEET_MAX_COLS-1;
for (lp = firstcol; lp <= lastcol; ++lp) {
sheet_col_set_size_pts (sheet->gnum_sheet, lp, col_width, TRUE);
sheet_col_row_set_outline_level (sheet->gnum_sheet, lp, TRUE,
outline_level, collapsed);
if (outline_level > 0) {
ColRowInfo *cri = sheet_col_fetch (sheet->gnum_sheet, lp);
colrow_set_outline (cri, TRUE, outline_level, FALSE, collapsed);
}
}
if (xf != 0)
......
......@@ -471,7 +471,7 @@
_label="_Group"
_tip="Add an outline group"/>
<menuitem name="DataOutlineUnGroup" verb=""
<menuitem name="DataOutlineUngroup" verb=""
pixtype="stock" pixname="Gnumeric_Ungroup"
_label="_Ungroup"
_tip="Remove an outline group"/>
......
......@@ -710,6 +710,30 @@ colrow_set_visibility_list (Sheet *sheet, gboolean const is_cols,
sheet_redraw_headers (sheet, TRUE, TRUE, NULL);
}
/**
* colrow_set_outline :
*
* Sets the outline level for a col/row.
* Returns the new outline level of @index.
*/
int
colrow_set_outline (ColRowInfo *cri, gboolean is_cols,
int outline_level, gboolean relative,
gboolean is_collapsed)
{
int newlevel = relative ? cri->outline_level + outline_level : outline_level;
cri->is_collapsed = (is_collapsed != 0); /* needed for XL plugin */
g_return_val_if_fail (newlevel >= 0, 0);
cri->outline_level = newlevel;
#if 0
printf ("%d = %d %d\n", index+1, outline_level, is_collapsed);
#endif
return cri->outline_level;
}
/**
* colrow_adjust_outline_dir
* @colrows :
......
......@@ -81,6 +81,9 @@ void colrow_restore_sizes_group (Sheet *sheet, gboolean const is_cols,
int old_size);
/* Support for Col/Row visibility */
int colrow_set_outline (ColRowInfo *cri, gboolean is_cols,
int outline_level, gboolean relative,
gboolean is_collapsed);
void colrow_adjust_outline_dir (ColRowCollection *colrows,
gboolean pre_or_post);
int colrow_find_outline_bound (Sheet const *sheet, gboolean is_cols,
......
......@@ -2170,6 +2170,126 @@ cmd_colrow_outline_change (WorkbookControl *wbc, Sheet *sheet,
/******************************************************************/
#define CMD_GROUP_TYPE (cmd_group_get_type ())
#define CMD_GROUP(o) (GTK_CHECK_CAST ((o), CMD_GROUP_TYPE, CmdGroup))
typedef struct
{
GnumericCommand parent;
Sheet *sheet;
Range range;
gboolean is_cols;
gboolean group;
int gutter_size;
} CmdGroup;
GNUMERIC_MAKE_COMMAND (CmdGroup, cmd_group);
static gboolean
cmd_group_undo (GnumericCommand *cmd, WorkbookControl *wbc)
{
CmdGroup *me = CMD_GROUP (cmd);
/*
* No need to worry about failure, cmd_group handles this
*/
sheet_col_row_group_ungroup (me->sheet,
me->is_cols ? me->range.start.col : me->range.start.row,
me->is_cols ? me->range.end.col : me->range.end.row,
me->is_cols, !me->group, FALSE);
if (me->is_cols)
sheet_col_row_gutter (me->sheet, me->gutter_size, me->sheet->rows.max_outline_level);
else
sheet_col_row_gutter (me->sheet, me->sheet->cols.max_outline_level, me->gutter_size);
g_return_val_if_fail (me != NULL, TRUE);
return FALSE;
}
static gboolean
cmd_group_redo (GnumericCommand *cmd, WorkbookControl *wbc)
{
CmdGroup *me = CMD_GROUP (cmd);
g_return_val_if_fail (me != NULL, TRUE);
/* Save gutter level */
me->gutter_size = me->is_cols
? me->sheet->cols.max_outline_level
: me->sheet->rows.max_outline_level;
/*
* No need to worry about failure, cmd_group handles this.
*/
sheet_col_row_group_ungroup (me->sheet,
me->is_cols ? me->range.start.col : me->range.start.row,
me->is_cols ? me->range.end.col : me->range.end.row,
me->is_cols, me->group, FALSE);
return FALSE;
}
static void
cmd_group_destroy (GtkObject *cmd)
{
gnumeric_command_destroy (cmd);
}
gboolean
cmd_group (WorkbookControl *wbc, Sheet *sheet,
gboolean is_cols, gboolean group)
{
GtkObject *obj;
CmdGroup *me;
g_return_val_if_fail (wbc != NULL, TRUE);
g_return_val_if_fail (sheet != NULL, TRUE);
obj = gtk_type_new (CMD_GROUP_TYPE);
me = CMD_GROUP (obj);
me->sheet = sheet;
me->range = *selection_first_range (sheet, NULL, NULL);
/* Check if this really is possible and display an error if it's not */
if (sheet_col_row_can_group (sheet,
is_cols ? me->range.start.col : me->range.start.row,
is_cols ? me->range.end.col : me->range.end.row,
is_cols) != group) {
if (group)
gnumeric_error_system (COMMAND_CONTEXT (wbc), is_cols
? _("Those columns are already grouped")
: _("Those rows are already grouped"));
else
gnumeric_error_system (COMMAND_CONTEXT (wbc), is_cols
? _("Those columns are not grouped, you can't ungroup them")
: _("Those rows are not grouped, you can't ungroup them"));
cmd_group_destroy (GTK_OBJECT (me));
return TRUE;
}
me->is_cols = is_cols;
me->group = group;
me->parent.sheet = sheet;
me->parent.size = 1;
me->parent.cmd_descriptor = is_cols
? g_strdup_printf (group ? _("Group columns %s") : _("Ungroup columns %s"),
cols_name (me->range.start.col, me->range.end.col))
: g_strdup_printf (group ? _("Group rows %d:%d") : _("Ungroup rows %d:%d"),
me->range.start.row + 1, me->range.end.row + 1);
/* Register the command object */
return command_push_undo (wbc, obj);
}
/******************************************************************/
#define CMD_PASTE_CUT_TYPE (cmd_paste_cut_get_type ())
#define CMD_PASTE_CUT(o) (GTK_CHECK_CAST ((o), CMD_PASTE_CUT_TYPE, CmdPasteCut))
......
......@@ -63,6 +63,9 @@ gboolean cmd_colrow_hide_selection (WorkbookControl *wbc, Sheet *sheet,
gboolean cmd_colrow_outline_change (WorkbookControl *wbc, Sheet *sheet,
gboolean is_cols, int index, int depth);
gboolean cmd_group (WorkbookControl *wbc, Sheet *sheet,
gboolean is_cols, gboolean group);
gboolean cmd_merge_cells (WorkbookControl *wbc, Sheet *sheet,
GSList const *selection);
gboolean cmd_unmerge_cells (WorkbookControl *wbc, Sheet *sheet,
......
2001-06-02 Almer S. Tigelaar <almer@gnome.org>
* colrow.glade: New simple dialog.
* dialog-simple-input.c, dialogs.h
(dialog_choose_cols_vs_rows): New, let user choose
between columns or rows.
2001-05-27 Almer S. Tigelaar <almer@gnome.org>
* validate.glade: Make non-modal.
......
......@@ -84,6 +84,7 @@ glade_DATA = \
cell-format.glade \
cell-sort.glade \
col-width.glade \
colrow.glade \
delete-cells.glade \
dialog-stf-export.glade \
dialog-stf.glade \
......
<?xml version="1.0"?>
<GTK-Interface>
<project>
<name>row-height</name>
<program_name>row-height</program_name>
<directory></directory>
<source_directory>src</source_directory>
<pixmaps_directory>pixmaps</pixmaps_directory>
<language>C</language>
<gnome_support>True</gnome_support>
<gettext_support>True</gettext_support>
<output_main_file>False</output_main_file>
<output_support_files>False</output_support_files>
</project>
<widget>
<class>GnomeDialog</class>
<name>dialog1</name>
<visible>False</visible>
<title>Group/Ungroup</title>
<type>GTK_WINDOW_TOPLEVEL</type>
<position>GTK_WIN_POS_NONE</position>
<modal>False</modal>
<allow_shrink>True</allow_shrink>
<allow_grow>True</allow_grow>
<auto_shrink>False</auto_shrink>
<auto_close>False</auto_close>
<hide_on_close>False</hide_on_close>
<widget>
<class>GtkVBox</class>
<child_name>GnomeDialog:vbox</child_name>
<name>dialog-vbox1</name>
<homogeneous>False</homogeneous>
<spacing>8</spacing>
<child>
<padding>4</padding>
<expand>True</expand>
<fill>True</fill>
</child>
<widget>
<class>GtkHButtonBox</class>
<child_name>GnomeDialog:action_area</child_name>
<name>dialog-action_area1</name>
<layout_style>GTK_BUTTONBOX_DEFAULT_STYLE</layout_style>
<spacing>8</spacing>
<child_min_width>85</child_min_width>
<child_min_height>27</child_min_height>
<child_ipad_x>7</child_ipad_x>
<child_ipad_y>0</child_ipad_y>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>True</fill>
<pack>GTK_PACK_END</pack>
</child>
<widget>
<class>GtkButton</class>
<name>button1</name>
<can_default>True</can_default>
<has_default>True</has_default>
<can_focus>True</can_focus>
<stock_button>GNOME_STOCK_BUTTON_OK</stock_button>
</widget>
<widget>
<class>GtkButton</class>
<name>button3</name>
<can_default>True</can_default>
<can_focus>True</can_focus>
<stock_button>GNOME_STOCK_BUTTON_CANCEL</stock_button>
</widget>
</widget>
<widget>
<class>GtkFrame</class>
<name>frame1</name>
<label>What</label>
<label_xalign>0</label_xalign>
<shadow_type>GTK_SHADOW_ETCHED_IN</shadow_type>
<child>
<padding>0</padding>
<expand>True</expand>
<fill>True</fill>
</child>
<widget>
<class>GtkVBox</class>
<name>vbox1</name>
<border_width>5</border_width>
<homogeneous>False</homogeneous>
<spacing>5</spacing>
<widget>
<class>GtkRadioButton</class>
<name>rows</name>
<can_focus>True</can_focus>
<label>Rows</label>
<active>True</active>
<draw_indicator>True</draw_indicator>
<group>colrow</group>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
<widget>
<class>GtkRadioButton</class>
<name>radiobutton2</name>
<can_focus>True</can_focus>
<label>Columns</label>
<active>False</active>
<draw_indicator>True</draw_indicator>
<group>colrow</group>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
</widget>
</widget>
</widget>
</widget>
</GTK-Interface>
......@@ -4,6 +4,7 @@
*
* Author:
* Miguel de Icaza (miguel@gnu.org)
* Almer S. Tigelaar (almer@gnome.org)
*/
#include <config.h>
#include <math.h>
......@@ -14,6 +15,47 @@
#include "dialogs.h"
#include "workbook.h"
gboolean
dialog_choose_cols_vs_rows (WorkbookControlGUI *wbcg, const char *title,
gboolean *is_cols)
{
GladeXML *gui;
GnomeDialog *dialog;
GtkToggleButton *rows;
gboolean res = FALSE;
gui = gnumeric_glade_xml_new (wbcg, "colrow.glade");
if (gui == NULL)
return FALSE;
dialog = GNOME_DIALOG (glade_xml_get_widget (gui, "dialog1"));
if (dialog == NULL){
g_warning ("Can not find the `dialog1' widget in colrow.glade");
gtk_object_destroy (GTK_OBJECT (gui));
return FALSE;
}
rows = GTK_TOGGLE_BUTTON (glade_xml_get_widget (gui, "rows"));
gtk_window_set_title (GTK_WINDOW (dialog), title);
switch (gnumeric_dialog_run (wbcg, dialog)){
case 1: /* cancel */
res = FALSE;
break;
case -1: /* window manager close */
gtk_object_destroy (GTK_OBJECT (gui));
return FALSE;
default:
res = TRUE;
*is_cols = !gtk_toggle_button_get_active (rows);
}
gnome_dialog_close (dialog);
gtk_object_destroy (GTK_OBJECT (gui));
return res;
}
gboolean
dialog_get_number (WorkbookControlGUI *wbcg,
const char *glade_file, double *init_and_return)
......
......@@ -52,6 +52,8 @@ void dialog_sheet_order (WorkbookControlGUI *wbcg);
gboolean dialog_get_number (WorkbookControlGUI *wbcg,
const char *glade_file,
double *init_and_return_value);
gboolean dialog_choose_cols_vs_rows (WorkbookControlGUI *wbcg, const char *title,
gboolean *is_cols);
typedef gboolean (*SearchReplaceDialogCallback) (WorkbookControlGUI *wbcg, SearchReplace *sr);
void dialog_search_replace (WorkbookControlGUI *wbcg,
......
......@@ -366,6 +366,11 @@ item_bar_draw (GnomeCanvasItem *item, GdkDrawable *drawable, int x, int y, int w
gdk_draw_line (drawable, item_bar->lines,
left+size/2, top+3,
left+size/2, top+size-4);
/*
* This fails miserably if grouped cols/rows are present, why
* is this here? This is basically assuming that if col X is
* not visible than col X + 1 must be collapsed ?!?
*/
if (!cri->is_collapsed)
g_warning ("expected collapsed %s", col_name (col));
}
......
......@@ -964,20 +964,124 @@ sheet_cell_fetch (Sheet *sheet, int col, int row)
}
/**
* sheet_col_row_set_indent :
* sheet_col_row_can_group:
*
* Returns TRUE if @from to @to can be grouped, return
* FALSE otherwise. You can invert the result if you need
* to find out if a group can be ungrouped.
**/
gboolean
sheet_col_row_can_group (Sheet *sheet, int from, int to, gboolean is_cols)
{
ColRowInfo *from_cri, *to_cri;
g_return_val_if_fail (sheet != NULL, FALSE);
g_return_val_if_fail (from >= 0, FALSE);
g_return_val_if_fail (is_cols ? to < SHEET_MAX_COLS : to < SHEET_MAX_ROWS, FALSE);
from_cri = is_cols
? sheet_col_fetch (sheet, from)
: sheet_row_fetch (sheet, from);
to_cri = is_cols
? sheet_col_fetch (sheet, to)
: sheet_row_fetch (sheet, to);
/* Groups on outline level 0 (no outline) may always be formed */
if (from_cri->outline_level == 0 || to_cri->outline_level == 0)
return TRUE;
/* We just won't group a group that already exists (or doesn't), it's useless */
if (colrow_find_outline_bound (sheet, is_cols, from, from_cri->outline_level, FALSE) != from
|| colrow_find_outline_bound (sheet, is_cols, to, to_cri->outline_level, TRUE) != to)
return TRUE;
else
return FALSE;
}
static gboolean
cb_outline_level (ColRowInfo *info, int *outline_level)
{
return (info->outline_level > *outline_level);
}
/**
* sheet_col_row_fit_gutter:
* @sheet: Sheet to change for.
* @outline_level: The new outline level.
* @is_cols: Column gutter or row gutter?
* @group: Was the change to @outline_level a result of a group or an ungroup
* operation? (important to set this right)
*
* Attempts to change the gutter's size to fit @outline_level if possible.
*
* Returns : TRUE if the gutter's size was adjusted, FALSE otherwise.
**/
static gboolean
sheet_col_row_fit_gutter (Sheet *sheet, int outline_level, gboolean is_cols, gboolean group)
{
int gutter_size = is_cols
? sheet->cols.max_outline_level
: sheet->rows.max_outline_level;
int new_gutter_size = outline_level > 0 ? outline_level + 1 : outline_level;
gboolean adjust = FALSE;
/* If the outline_level has been decreased we check all other
* outline levels and if possible decrease the indent of the gutter.
* If the level has been increased we check if the gutter is currently
* big enough to hold this outline_level and if not we increase the
* gutter's indent
*/
void
sheet_col_row_set_outline_level (Sheet *sheet, int index, gboolean is_cols,
int outline_level, gboolean is_collapsed)
if (!group)
adjust = !colrow_foreach (is_cols ? &sheet->cols : &sheet->rows,
0, (is_cols ? SHEET_MAX_COLS : SHEET_MAX_ROWS) - 1,
(ColRowHandler) cb_outline_level, &outline_level);
else if (group && new_gutter_size > gutter_size)
adjust = TRUE;
if (adjust) {
if (is_cols)
sheet_col_row_gutter (sheet, new_gutter_size, sheet->rows.max_outline_level);
else
sheet_col_row_gutter (sheet, sheet->cols.max_outline_level, new_gutter_size);
}
return adjust;
}
gboolean
sheet_col_row_group_ungroup (Sheet *sheet, int from, int to, gboolean is_cols,
gboolean inc, gboolean is_collapsed)
{
int i;
int highest;
g_return_val_if_fail (sheet != NULL, FALSE);
g_return_val_if_fail (from >= 0, FALSE);
g_return_val_if_fail (is_cols ? to < SHEET_MAX_COLS : to < SHEET_MAX_ROWS, FALSE);
/* Can we group/ungroup ? */
if (inc != sheet_col_row_can_group (sheet, from, to, is_cols))
return FALSE;
/* Set new outline for each col/row and find highest outline level */
for (highest = -1, i = from; i <= to; i++) {
ColRowInfo *cri = is_cols
? sheet_col_fetch (sheet, index)
: sheet_row_fetch (sheet, index);
cri->outline_level = outline_level;
cri->is_collapsed = (is_collapsed != 0);
#if 0
printf ("%d = %d %d\n", index+1, outline_level, is_collapsed);
#endif
? sheet_col_fetch (sheet, i)
: sheet_row_fetch (sheet, i);
int newlevel = colrow_set_outline (cri, is_cols, inc ? +1 : -1, TRUE, is_collapsed);