Commit 475dd1df authored by Andreas J. Guelzow's avatar Andreas J. Guelzow Committed by Andreas J. Guelzow

handle sheet objects and change ref in checkboxes new new new new remove

2002-03-13  Andreas J. Guelzow <aguelzow@taliesin.ca>

	* src/commands.c (cmd_merge_data_redo) : handle sheet objects
	  and change ref in checkboxes
	* src/sheet-object-widget.c (sheet_widget_checkbox_switch_link_sheet) :
	  new
	* src/sheet-object-widget.h (sheet_widget_checkbox_switch_link_sheet) :
	  new
	* src/sheet-object.c (sheet_object_clone_sheet_in_range) : new
	* src/sheet-object.h (sheet_object_clone_sheet_in_range) : new
	* src/workbook-control-gui.c (cb_tools_merge) : remove unused var
parent fd78d2d0
2002-03-13 Andreas J. Guelzow <aguelzow@taliesin.ca>
* src/commands.c (cmd_merge_data_redo) : handle sheet objects
and change ref in checkboxes
* src/sheet-object-widget.c (sheet_widget_checkbox_switch_link_sheet) :
new
* src/sheet-object-widget.h (sheet_widget_checkbox_switch_link_sheet) :
new
* src/sheet-object.c (sheet_object_clone_sheet_in_range) : new
* src/sheet-object.h (sheet_object_clone_sheet_in_range) : new
* src/workbook-control-gui.c (cb_tools_merge) : remove unused var
2002-03-12 Jody Goldberg <jody@gnome.org>
* src/workbook-control-gui.c (cb_sheet_label_edit_finished) : renamed
......
2002-03-13 Andreas J. Guelzow <aguelzow@taliesin.ca>
* src/commands.c (cmd_merge_data_redo) : handle sheet objects
and change ref in checkboxes
* src/sheet-object-widget.c (sheet_widget_checkbox_switch_link_sheet) :
new
* src/sheet-object-widget.h (sheet_widget_checkbox_switch_link_sheet) :
new
* src/sheet-object.c (sheet_object_clone_sheet_in_range) : new
* src/sheet-object.h (sheet_object_clone_sheet_in_range) : new
* src/workbook-control-gui.c (cb_tools_merge) : remove unused var
2002-03-12 Jody Goldberg <jody@gnome.org>
* src/workbook-control-gui.c (cb_sheet_label_edit_finished) : renamed
......
2002-03-13 Andreas J. Guelzow <aguelzow@taliesin.ca>
* src/commands.c (cmd_merge_data_redo) : handle sheet objects
and change ref in checkboxes
* src/sheet-object-widget.c (sheet_widget_checkbox_switch_link_sheet) :
new
* src/sheet-object-widget.h (sheet_widget_checkbox_switch_link_sheet) :
new
* src/sheet-object.c (sheet_object_clone_sheet_in_range) : new
* src/sheet-object.h (sheet_object_clone_sheet_in_range) : new
* src/workbook-control-gui.c (cb_tools_merge) : remove unused var
2002-03-12 Jody Goldberg <jody@gnome.org>
* src/workbook-control-gui.c (cb_sheet_label_edit_finished) : renamed
......
......@@ -55,6 +55,7 @@
#include "gutils.h"
#include "gui-util.h"
#include "sheet-object-cell-comment.h"
#include "sheet-object-widget.h"
#include "sheet-object.h"
#include "sheet-control.h"
......@@ -4446,15 +4447,27 @@ cmd_merge_data_redo (GnumericCommand *cmd, WorkbookControl *wbc)
GSList *this_field = me->merge_fields;
GSList *this_data = me->merge_data;
range_init (&merge_range, cell->a.col, cell->a.row,
cell->b.col, cell->b.row);
merge_content = clipboard_copy_range (cell->a.sheet, &merge_range);
for (i = 0; i < me->n; i++) {
Sheet *new_sheet;
GSList *a_box;
GSList *check_boxes;
new_sheet = workbook_sheet_add (me->sheet->workbook, NULL, FALSE);
me->sheet_list = g_slist_prepend (me->sheet_list, new_sheet);
sheet_object_clone_sheet_in_range (cell->a.sheet, new_sheet, &merge_range);
check_boxes = sheet_objects_get (new_sheet, &merge_range,
sheet_widget_checkbox_get_type ());
a_box = check_boxes;
while (a_box) {
sheet_widget_checkbox_switch_link_sheet (SHEET_OBJECT (a_box->data),
cell->a.sheet, new_sheet);
a_box = a_box->next;
}
g_slist_free (check_boxes);
clipboard_paste_region (me->wbc, paste_target_init (&pt, new_sheet,
&merge_range, PASTE_ALL_TYPES),
merge_content);
......
......@@ -1331,6 +1331,30 @@ sheet_widget_checkbox_set_link (SheetObject *so, ExprTree *expr)
dependent_set_expr (&swc->dep, expr);
}
gboolean
sheet_widget_checkbox_switch_link_sheet (SheetObject *so, Sheet *old_sheet, Sheet *new_sheet)
{
SheetWidgetCheckbox *swc = SHEET_WIDGET_CHECKBOX (so);
if (swc->dep.expression != NULL) {
Value *val = expr_tree_get_range (swc->dep.expression);
if (val) {
ExprTree *expr;
RangeRef *cell = &val->v_range.cell;
if (cell->a.sheet == old_sheet)
cell->a.sheet = new_sheet;
if (cell->b.sheet == old_sheet)
cell->b.sheet = new_sheet;
expr = expr_tree_new_constant (val);
sheet_widget_checkbox_set_link (so, expr);
return TRUE;
}
}
return FALSE;
}
SOW_MAKE_TYPE (checkbox, Checkbox,
&sheet_widget_checkbox_user_config,
&sheet_widget_checkbox_set_sheet,
......
......@@ -21,5 +21,6 @@ void sheet_widget_scrollbar_set_details (SheetObject *so, ExprTree *link,
int value, int min, int max, int inc, int page);
void sheet_widget_checkbox_set_link (SheetObject *so, ExprTree *expr);
gboolean sheet_widget_checkbox_switch_link_sheet (SheetObject *so, Sheet *old_sheet, Sheet *new_sheet);
#endif /* GNUMERIC_SHEET_OBJECT_WIDGET_H */
......@@ -901,6 +901,43 @@ sheet_object_clone_sheet (const Sheet *src, Sheet *dst)
dst->sheet_objects = g_list_reverse (new_list);
}
/**
* sheet_object_clone_sheet_in_range:
* @src: The source sheet to read the objects from
* @dst: The destination sheet to attach the objects to
* @range: Optional Range of interest
*
* Clones the objects of the src sheet and attaches them into the dst sheet
*
* FIXME: sheet_object_clone_sheet_in_range and sheet_object_clone_sheet should be
* combined
*
**/
void
sheet_object_clone_sheet_in_range (const Sheet *src, Sheet *dst, Range *range)
{
SheetObject *so;
SheetObject *new_so;
GList *list;
GList *new_list = NULL;
g_return_if_fail (IS_SHEET (dst));
g_return_if_fail (dst->sheet_objects == NULL);
g_return_if_fail (range != NULL);
list = src->sheet_objects;
for (; list != NULL; list = list->next) {
so = (SheetObject *) list->data;
if (range == NULL || range_overlap (range, &so->anchor.cell_bound)) {
new_so = sheet_object_clone (so, dst);
if (new_so != NULL)
new_list = g_list_prepend (new_list, new_so);
}
}
dst->sheet_objects = g_list_reverse (new_list);
}
/**
* sheet_object_direction_set:
......
......@@ -60,6 +60,7 @@ void sheet_object_print (SheetObject const *so,
GnomePrintContext *ctx,
double base_x, double base_y);
void sheet_object_clone_sheet (Sheet const *src, Sheet *dst);
void sheet_object_clone_sheet_in_range (Sheet const *src, Sheet *dst, Range *range);
void sheet_object_realize (SheetObject *co);
void sheet_object_update_bounds (SheetObject *so, CellPos const *p);
void sheet_object_default_size (SheetObject *so,
......
......@@ -2155,7 +2155,6 @@ cb_tools_tabulate (GtkWidget *widget, WorkbookControlGUI *wbcg)
static void
cb_tools_merge (GtkWidget *widget, WorkbookControlGUI *wbcg)
{
WorkbookControl *wbc = WORKBOOK_CONTROL (wbcg);
dialog_merge (wbcg);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment