Commit 76a1bbbc authored by Almer S. Tigelaar's avatar Almer S. Tigelaar Committed by Almer S. Tigelaar

Add new GlobalRange.

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

	* src/gnumeric.h : Add new GlobalRange.

	* src/ranges.[ch] (global_range_new): Create a new globalrange.
	(global_range_free): Free.
	(global_range_overlap): Utility function.
	(global_range_dup): Idem.

	* src/sheet.[ch] (sheet_cell_get_value): New function.

	* src/workbook-control-gui.c (cb_data_consolidate) :
	Entry point for the data consolidation dialog.

	* src/GNOME_Gnumeric.xml : Add consolidate menu item.

	* src/commands.c (cmd_consolidate) : Undo/redo for consolidate.
	(cmd_consolidate_destroy) : Idem.
	(cmd_consolidate_redo) : Idem.
	(cmd_consolidate_undo) : Idem.

	* src/consolidate.[ch] : Consolidation low-level code.

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

	* dialog-consolidate.c : Implementation of the consolidation dialog.

	* consolidate.glade : Idem.
parent c3d47ee4
2001-06-06 Almer S. Tigelaar <almer@gnome.org>
* src/gnumeric.h : Add new GlobalRange.
* src/ranges.[ch] (global_range_new): Create a new globalrange.
(global_range_free): Free.
(global_range_overlap): Utility function.
(global_range_dup): Idem.
* src/sheet.[ch] (sheet_cell_get_value): New function.
* src/workbook-control-gui.c (cb_data_consolidate) :
Entry point for the data consolidation dialog.
* src/GNOME_Gnumeric.xml : Add consolidate menu item.
* src/commands.c (cmd_consolidate) : Undo/redo for consolidate.
(cmd_consolidate_destroy) : Idem.
(cmd_consolidate_redo) : Idem.
(cmd_consolidate_undo) : Idem.
* src/consolidate.[ch] : Consolidation low-level code.
2001-06-05 Zbigniew Chyla <cyba@gnome.pl>
* src/gnumeric-util.[ch] (gnumeric_dialog_file_selection): New
......
......@@ -9,6 +9,7 @@ Almer:
importer.
* Clean-up row naming.
* Fix the STF exporter (it works again).
* Add new consolidation feature.
Jody:
* Fix ctrl-enter filling.
......
2001-06-06 Almer S. Tigelaar <almer@gnome.org>
* src/gnumeric.h : Add new GlobalRange.
* src/ranges.[ch] (global_range_new): Create a new globalrange.
(global_range_free): Free.
(global_range_overlap): Utility function.
(global_range_dup): Idem.
* src/sheet.[ch] (sheet_cell_get_value): New function.
* src/workbook-control-gui.c (cb_data_consolidate) :
Entry point for the data consolidation dialog.
* src/GNOME_Gnumeric.xml : Add consolidate menu item.
* src/commands.c (cmd_consolidate) : Undo/redo for consolidate.
(cmd_consolidate_destroy) : Idem.
(cmd_consolidate_redo) : Idem.
(cmd_consolidate_undo) : Idem.
* src/consolidate.[ch] : Consolidation low-level code.
2001-06-05 Zbigniew Chyla <cyba@gnome.pl>
* src/gnumeric-util.[ch] (gnumeric_dialog_file_selection): New
......
2001-06-06 Almer S. Tigelaar <almer@gnome.org>
* src/gnumeric.h : Add new GlobalRange.
* src/ranges.[ch] (global_range_new): Create a new globalrange.
(global_range_free): Free.
(global_range_overlap): Utility function.
(global_range_dup): Idem.
* src/sheet.[ch] (sheet_cell_get_value): New function.
* src/workbook-control-gui.c (cb_data_consolidate) :
Entry point for the data consolidation dialog.
* src/GNOME_Gnumeric.xml : Add consolidate menu item.
* src/commands.c (cmd_consolidate) : Undo/redo for consolidate.
(cmd_consolidate_destroy) : Idem.
(cmd_consolidate_redo) : Idem.
(cmd_consolidate_undo) : Idem.
* src/consolidate.[ch] : Consolidation low-level code.
2001-06-05 Zbigniew Chyla <cyba@gnome.pl>
* src/gnumeric-util.[ch] (gnumeric_dialog_file_selection): New
......
2001-06-06 Almer S. Tigelaar <almer@gnome.org>
* src/gnumeric.h : Add new GlobalRange.
* src/ranges.[ch] (global_range_new): Create a new globalrange.
(global_range_free): Free.
(global_range_overlap): Utility function.
(global_range_dup): Idem.
* src/sheet.[ch] (sheet_cell_get_value): New function.
* src/workbook-control-gui.c (cb_data_consolidate) :
Entry point for the data consolidation dialog.
* src/GNOME_Gnumeric.xml : Add consolidate menu item.
* src/commands.c (cmd_consolidate) : Undo/redo for consolidate.
(cmd_consolidate_destroy) : Idem.
(cmd_consolidate_redo) : Idem.
(cmd_consolidate_undo) : Idem.
* src/consolidate.[ch] : Consolidation low-level code.
2001-06-05 Zbigniew Chyla <cyba@gnome.pl>
* src/gnumeric-util.[ch] (gnumeric_dialog_file_selection): New
......
2001-06-06 Almer S. Tigelaar <almer@gnome.org>
* src/gnumeric.h : Add new GlobalRange.
* src/ranges.[ch] (global_range_new): Create a new globalrange.
(global_range_free): Free.
(global_range_overlap): Utility function.
(global_range_dup): Idem.
* src/sheet.[ch] (sheet_cell_get_value): New function.
* src/workbook-control-gui.c (cb_data_consolidate) :
Entry point for the data consolidation dialog.
* src/GNOME_Gnumeric.xml : Add consolidate menu item.
* src/commands.c (cmd_consolidate) : Undo/redo for consolidate.
(cmd_consolidate_destroy) : Idem.
(cmd_consolidate_redo) : Idem.
(cmd_consolidate_undo) : Idem.
* src/consolidate.[ch] : Consolidation low-level code.
2001-06-05 Zbigniew Chyla <cyba@gnome.pl>
* src/gnumeric-util.[ch] (gnumeric_dialog_file_selection): New
......
......@@ -283,10 +283,6 @@ under "1.0" are more important.
indicate where new pages start when printing. Jody has been
doing work on this.
* Consolidate
+ ?
* Subtotals
+ This will really need to wait for a while.
......
......@@ -452,6 +452,10 @@
_label="_Filter..."
_tip="Filter data with given criteria"/>
<menuitem name="DataConsolidate" verb=""
_label="_Consolidate..."
_tip="Consolidate regions using a function"/>
<separator/>
<submenu name="Outline" _label="_Group and Outline">
......
......@@ -72,6 +72,8 @@ GNUMERIC_BASE_SOURCES = \
command-context-priv.h \
command-context-corba.c \
command-context-corba.h \
consolidate.c \
consolidate.h \
io-context.c \
io-context.h \
io-context-priv.h \
......
......@@ -1930,7 +1930,6 @@ cmd_sort_redo (GnumericCommand *cmd, WorkbookControl *wbc)
return FALSE;
}
gboolean
cmd_sort (WorkbookControl *wbc, SortData *data)
{
......@@ -3769,6 +3768,92 @@ cmd_colrow_std_size (WorkbookControl *wbc, Sheet *sheet,
/******************************************************************/
#define CMD_CONSOLIDATE_TYPE (cmd_consolidate_get_type ())
#define CMD_CONSOLIDATE(o) (GTK_CHECK_CAST ((o), CMD_CONSOLIDATE_TYPE, CmdConsolidate))
typedef struct
{
GnumericCommand parent;
Consolidate *cs;
Range old_range;
CellRegion *old_content;
} CmdConsolidate;
GNUMERIC_MAKE_COMMAND (CmdConsolidate, cmd_consolidate);
static gboolean
cmd_consolidate_undo (GnumericCommand *cmd, WorkbookControl *wbc)
{
CmdConsolidate *me = CMD_CONSOLIDATE (cmd);
PasteTarget pt;
g_return_val_if_fail (me != NULL, TRUE);
clipboard_paste_region (wbc, paste_target_init (&pt, me->cs->dst->sheet, &me->old_range, PASTE_ALL_TYPES),
me->old_content);
cellregion_free (me->old_content);
me->old_content = NULL;
return FALSE;
}
static gboolean
cmd_consolidate_redo (GnumericCommand *cmd, WorkbookControl *wbc)
{
CmdConsolidate *me = CMD_CONSOLIDATE (cmd);
g_return_val_if_fail (me != NULL, TRUE);
/* Retrieve maximum extent of the result and back the area up */
me->old_range = consolidate_get_dest_bounding_box (me->cs);
me->old_content = clipboard_copy_range (me->cs->dst->sheet, &me->old_range);
/* Apply consolidation */
consolidate_apply (me->cs);
return FALSE;
}
static void
cmd_consolidate_destroy (GtkObject *cmd)
{
CmdConsolidate *me = CMD_CONSOLIDATE (cmd);
if (me->cs)
consolidate_free (me->cs);
if (me->old_content)
cellregion_free (me->old_content);
gnumeric_command_destroy (cmd);
}
gboolean
cmd_consolidate (WorkbookControl *wbc, Consolidate *cs)
{
GtkObject *obj;
CmdConsolidate *me;
g_return_val_if_fail (cs != NULL, TRUE);
obj = gtk_type_new (CMD_CONSOLIDATE_TYPE);
me = CMD_CONSOLIDATE (obj);
/* Store the specs for the object */
me->cs = cs;
me->parent.sheet = cs->dst->sheet;
me->parent.size = 1; /* Changed in initial redo. */
me->parent.cmd_descriptor = g_strdup_printf (_("Consolidating to %s!%s"),
cs->dst->sheet->name_quoted,
range_name (&cs->dst->range));
/* Register the command object */
return command_push_undo (wbc, obj);
}
/******************************************************************/
#define CMD_ZOOM_TYPE (cmd_zoom_get_type ())
#define CMD_ZOOM(o) (GTK_CHECK_CAST ((o), CMD_ZOOM_TYPE, CmdZoom))
......
......@@ -2,6 +2,7 @@
#ifndef GNUMERIC_COMMANDS_H
#define GNUMERIC_COMMANDS_H
#include "consolidate.h"
#include "gnumeric.h"
#include "format-template.h"
#include "sort.h"
......@@ -76,6 +77,8 @@ gboolean cmd_search_replace (WorkbookControl *wbc, Sheet *sheet, SearchRepla
gboolean cmd_colrow_std_size (WorkbookControl *wbc, Sheet *sheet,
gboolean is_cols, double new_default);
gboolean cmd_consolidate (WorkbookControl *wbc, Consolidate *cs);
gboolean cmd_zoom (WorkbookControl *wbc, GSList *sheets, double factor);
#endif /* GNUMERIC_COMMANDS_H */
This diff is collapsed.
#ifndef GNUMERIC_CONSOLIDATE_H
#define GNUMERIC_CONSOLIDATE_H
#include "gnumeric.h"
typedef enum {
/*
* These can be both set, both unset or
* one of them can be set. Indicates
* what sort of consolidation we will
* execute
*/
CONSOLIDATE_ROW_LABELS = 1 << 0,
CONSOLIDATE_COL_LABELS = 1 << 1,
/*
* If set the row and/or column labels
* will be copied to the destination area
*/
CONSOLIDATE_COPY_LABELS = 1 << 2,
/* If this is set we put the outcome
* of our formulas into the destination
* otherwise we put formulas
*/
CONSOLIDATE_PUT_VALUES = 1 << 3,
} ConsolidateMode;
typedef struct _Consolidate {
FunctionDefinition *fd;
GlobalRange *dst;
GSList *src;
ConsolidateMode mode;
} Consolidate;
Consolidate *consolidate_new (void);
void consolidate_free (Consolidate *cs);
void consolidate_set_function (Consolidate *cs, FunctionDefinition *fd);
void consolidate_set_mode (Consolidate *cs, ConsolidateMode mode);
gboolean consolidate_set_destination (Consolidate *cs, Sheet *sheet, Range const *r);
gboolean consolidate_add_source (Consolidate *cs, Sheet *sheet, Range const *r);
Range consolidate_get_dest_bounding_box (Consolidate *cs);
void consolidate_apply (Consolidate *cs);
#endif
2001-06-06 Almer S. Tigelaar <almer@gnome.org>
* dialog-consolidate.c : Implementation of the consolidation dialog.
* consolidate.glade : Idem.
2001-06-05 Zbigniew Chyla <cyba@gnome.pl>
* Makefile.am (glade_DATA): Removed import.glade.
......
......@@ -35,6 +35,7 @@ std_SOURCES = \
dialog-cell-comment.c \
dialog-cell-format.c \
dialog-cell-sort.c \
dialog-consolidate.c \
dialog-function-select.c \
dialog-function-wizard.c \
dialog-goal-seek.c \
......@@ -85,6 +86,7 @@ glade_DATA = \
cell-sort.glade \
col-width.glade \
colrow.glade \
consolidate.glade \
delete-cells.glade \
dialog-stf-export.glade \
dialog-stf.glade \
......
<?xml version="1.0"?>
<GTK-Interface>
<project>
<name>Consolidate</name>
<program_name>consolidate</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>
</project>
<widget>
<class>GnomeDialog</class>
<name>dialog</name>
<visible>False</visible>
<title>Data consolidation</title>
<type>GTK_WINDOW_TOPLEVEL</type>
<position>GTK_WIN_POS_NONE</position>
<modal>False</modal>
<allow_shrink>False</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_END</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>btn_ok</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>btn_cancel</name>
<can_default>True</can_default>
<can_focus>True</can_focus>
<stock_button>GNOME_STOCK_BUTTON_CANCEL</stock_button>
</widget>
</widget>
<widget>
<class>GtkVBox</class>
<name>vbox1</name>
<homogeneous>False</homogeneous>
<spacing>6</spacing>
<child>
<padding>0</padding>
<expand>True</expand>
<fill>True</fill>
</child>
<widget>
<class>GtkHBox</class>
<name>hbox1</name>
<homogeneous>False</homogeneous>
<spacing>6</spacing>
<child>
<padding>0</padding>
<expand>True</expand>
<fill>True</fill>
</child>
<widget>
<class>GtkTable</class>
<name>table1</name>
<rows>3</rows>
<columns>2</columns>
<homogeneous>False</homogeneous>
<row_spacing>4</row_spacing>
<column_spacing>4</column_spacing>
<child>
<padding>0</padding>
<expand>True</expand>
<fill>True</fill>
</child>
<widget>
<class>GtkLabel</class>
<name>label3</name>
<label>_Function :</label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>0</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<focus_target>function</focus_target>
<child>
<left_attach>0</left_attach>
<right_attach>1</right_attach>
<top_attach>0</top_attach>
<bottom_attach>1</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>False</yfill>
</child>
</widget>
<widget>
<class>GtkLabel</class>
<name>label4</name>
<label>_Destination :</label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>0</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<left_attach>0</left_attach>
<right_attach>1</right_attach>
<top_attach>2</top_attach>
<bottom_attach>3</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>False</yfill>
</child>
</widget>
<widget>
<class>GtkOptionMenu</class>
<name>function</name>
<tooltip>The function to use when consolidating</tooltip>
<can_focus>True</can_focus>
<items>Sum
Min
Max
Average
Count
Product
Stdev (sample)
Stdevp (population)
Var (sample)
Varp (population)
</items>
<initial_choice>0</initial_choice>
<child>
<left_attach>1</left_attach>
<right_attach>2</right_attach>
<top_attach>0</top_attach>
<bottom_attach>1</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>False</yfill>
</child>
</widget>
<widget>
<class>GtkLabel</class>
<name>label5</name>
<label>_Put :</label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>0</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<default_focus_target>put</default_focus_target>
<child>
<left_attach>0</left_attach>
<right_attach>1</right_attach>
<top_attach>1</top_attach>
<bottom_attach>2</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>False</yfill>
</child>
</widget>
<widget>
<class>GtkOptionMenu</class>
<name>put</name>
<can_focus>True</can_focus>
<items>Values
Formulas
</items>
<initial_choice>0</initial_choice>
<child>
<left_attach>1</left_attach>
<right_attach>2</right_attach>
<top_attach>1</top_attach>
<bottom_attach>2</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>False</yfill>
</child>
</widget>
</widget>
</widget>
<widget>
<class>GtkFrame</class>
<name>frame1</name>
<label>Source areas</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>vbox3</name>
<border_width>6</border_width>
<homogeneous>False</homogeneous>
<spacing>6</spacing>
<widget>
<class>GtkHBox</class>
<name>hbox2</name>
<homogeneous>False</homogeneous>
<spacing>6</spacing>
<child>
<padding>0</padding>
<expand>True</expand>
<fill>True</fill>
</child>
<widget>
<class>Placeholder</class>
</widget>
<widget>
<class>GtkButton</class>
<name>add</name>
<tooltip>Add the entered area to the list of source areas</tooltip>
<can_default>True</can_default>
<can_focus>True</can_focus>
<label>_Add</label>
<relief>GTK_RELIEF_NORMAL</relief>
<child>
<padding>0</padding>
<expand>True</expand>
<fill>True</fill>
<pack>GTK_PACK_END</pack>
</child>
</widget>
</widget>
<widget>
<class>GtkScrolledWindow</class>
<name>scrolledwindow1</name>
<hscrollbar_policy>GTK_POLICY_AUTOMATIC</hscrollbar_policy>
<vscrollbar_policy>GTK_POLICY_AUTOMATIC</vscrollbar_policy>
<hupdate_policy>GTK_UPDATE_CONTINUOUS</hupdate_policy>
<vupdate_policy>GTK_UPDATE_CONTINUOUS</vupdate_policy>
<child>
<padding>0</padding>
<expand>True</expand>
<fill>True</fill>
</child>
<widget>
<class>GtkCList</class>
<name>areas</name>
<can_focus>True</can_focus>
<columns>1</columns>
<column_widths>80</column_widths>
<selection_mode>GTK_SELECTION_SINGLE</selection_mode>
<show_titles>False</show_titles>
<shadow_type>GTK_SHADOW_IN</shadow_type>
<widget>
<class>GtkLabel</class>
<child_name>CList:title</child_name>
<name>label2</name>
<label>label2</label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>0.5</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
</widget>
</widget>
</widget>
<widget>
<class>GtkHBox</class>
<name>hbox3</name>
<homogeneous>False</homogeneous>
<spacing>6</spacing>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
<widget>
<class>GtkButton</class>
<name>clear</name>
<tooltip>Clear the list of source areas</tooltip>
<can_focus>True</can_focus>
<label>_Clear</label>
<relief>GTK_RELIEF_NORMAL</relief>
<child>
<padding>0</padding>
<expand>True</expand>
<fill>True</fill>
</child>
</widget>
<widget>
<class>GtkButton</class>
<name>delete</name>
<tooltip>Delete the currently selected source area</tooltip>
<can_focus>True</can_focus>
<label>D_elete</label>
<relief>GTK_RELIEF_NORMAL</relief>
<child>
<padding>0</padding>
<expand>True</expand>
<fill>True</fill>
</child>
</widget>
</widget>
</widget>
</widget>
<widget>
<class>GtkFrame</class>
<name>frame2</name>