Commit eec41abe authored by Miguel de Icaza's avatar Miguel de Icaza Committed by Miguel de Icaza
Browse files

Notify the sheet that the cell changed using sheet_cell_changed.

2000-02-29  Miguel de Icaza  <miguel@nuclecu.unam.mx>

	* src/cell.c (cell_content_changed): Notify the sheet that the
	cell changed using sheet_cell_changed.

	* src/sheet-vector.c: New file.  Implements the Gnumeric:Vector
	interface (and supports non-contiguous ranges)

	* src/sheet.c (sheet_destroy): free private structure.
	(sheet_new): init private structure.
	(sheet_cell_changed): New function.

	* src/sheet-private.h: New file.

	* src/sheet.h: Sheet structure includes SheetPrivate field now.
parent e0d6f46d
2000-02-29 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/cell.c (cell_content_changed): Notify the sheet that the
cell changed using sheet_cell_changed.
* src/sheet-vector.c: New file. Implements the Gnumeric:Vector
interface (and supports non-contiguous ranges)
* src/sheet.c (sheet_destroy): free private structure.
(sheet_new): init private structure.
(sheet_cell_changed): New function.
* src/sheet-private.h: New file.
* src/sheet.h: Sheet structure includes SheetPrivate field now.
2000-02-29 Jody Goldberg <jgoldberg@home.com>
* src/workbook-format-toolbar.c (change_selection_font) : Add underline.
......
2000-02-29 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/cell.c (cell_content_changed): Notify the sheet that the
cell changed using sheet_cell_changed.
* src/sheet-vector.c: New file. Implements the Gnumeric:Vector
interface (and supports non-contiguous ranges)
* src/sheet.c (sheet_destroy): free private structure.
(sheet_new): init private structure.
(sheet_cell_changed): New function.
* src/sheet-private.h: New file.
* src/sheet.h: Sheet structure includes SheetPrivate field now.
2000-02-29 Jody Goldberg <jgoldberg@home.com>
* src/workbook-format-toolbar.c (change_selection_font) : Add underline.
......
2000-02-29 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/cell.c (cell_content_changed): Notify the sheet that the
cell changed using sheet_cell_changed.
* src/sheet-vector.c: New file. Implements the Gnumeric:Vector
interface (and supports non-contiguous ranges)
* src/sheet.c (sheet_destroy): free private structure.
(sheet_new): init private structure.
(sheet_cell_changed): New function.
* src/sheet-private.h: New file.
* src/sheet.h: Sheet structure includes SheetPrivate field now.
2000-02-29 Jody Goldberg <jgoldberg@home.com>
* src/workbook-format-toolbar.c (change_selection_font) : Add underline.
......
2000-02-29 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/cell.c (cell_content_changed): Notify the sheet that the
cell changed using sheet_cell_changed.
* src/sheet-vector.c: New file. Implements the Gnumeric:Vector
interface (and supports non-contiguous ranges)
* src/sheet.c (sheet_destroy): free private structure.
(sheet_new): init private structure.
(sheet_cell_changed): New function.
* src/sheet-private.h: New file.
* src/sheet.h: Sheet structure includes SheetPrivate field now.
2000-02-29 Jody Goldberg <jgoldberg@home.com>
* src/workbook-format-toolbar.c (change_selection_font) : Add underline.
......
2000-02-29 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/cell.c (cell_content_changed): Notify the sheet that the
cell changed using sheet_cell_changed.
* src/sheet-vector.c: New file. Implements the Gnumeric:Vector
interface (and supports non-contiguous ranges)
* src/sheet.c (sheet_destroy): free private structure.
(sheet_new): init private structure.
(sheet_cell_changed): New function.
* src/sheet-private.h: New file.
* src/sheet.h: Sheet structure includes SheetPrivate field now.
2000-02-29 Jody Goldberg <jgoldberg@home.com>
* src/workbook-format-toolbar.c (change_selection_font) : Add underline.
......
2000-02-29 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/cell.c (cell_content_changed): Notify the sheet that the
cell changed using sheet_cell_changed.
* src/sheet-vector.c: New file. Implements the Gnumeric:Vector
interface (and supports non-contiguous ranges)
* src/sheet.c (sheet_destroy): free private structure.
(sheet_new): init private structure.
(sheet_cell_changed): New function.
* src/sheet-private.h: New file.
* src/sheet.h: Sheet structure includes SheetPrivate field now.
2000-02-29 Jody Goldberg <jgoldberg@home.com>
* src/workbook-format-toolbar.c (change_selection_font) : Add underline.
......
2000-02-29 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/cell.c (cell_content_changed): Notify the sheet that the
cell changed using sheet_cell_changed.
* src/sheet-vector.c: New file. Implements the Gnumeric:Vector
interface (and supports non-contiguous ranges)
* src/sheet.c (sheet_destroy): free private structure.
(sheet_new): init private structure.
(sheet_cell_changed): New function.
* src/sheet-private.h: New file.
* src/sheet.h: Sheet structure includes SheetPrivate field now.
2000-02-29 Jody Goldberg <jgoldberg@home.com>
* src/workbook-format-toolbar.c (change_selection_font) : Add underline.
......
......@@ -291,3 +291,11 @@ Office 2000 and 'explorer' compatibility.
* Html export
* Export style information for blank cells.
* Cell Changed
* The graphics code uses a "cell has been modified" hook, and it
scans the list of vectors for ranges that are covered, and need to
be notified of changes.
Needs to be optimized.
\ No newline at end of file
......@@ -27,6 +27,9 @@ graph_vector_new (GNOME_Gnumeric_Vector vector, GraphVectorChangeNotifyFn change
if (guess)
gv->contains_numbers = GNOME_Gnumeric_Vector_only_numbers (vector, &ev);
/*
* FIXME: we should only transfer a few numbers, and load more on demand.
*/
if (gv->contains_numbers)
gv->u.double_vec = GNOME_Gnumeric_Vector_get_numbers (vector, 0, -1, &ev);
else
......@@ -63,6 +66,11 @@ graph_vector_destroy (GraphVector *vector)
int
graph_vector_count (GraphVector *vector)
{
/*
* FIXME: Note that we should cache the size of the actual
* vector, as this just works for the current code base (in
* which the entire vector is tranfered
*/
if (vector->contains_numbers)
return vector->u.double_vec->_length;
else
......
......@@ -156,6 +156,7 @@ GNUMERIC_BASE_SOURCES = \
selection.h \
sheet.c \
sheet.h \
sheet-private.h \
sheet-autofill.c \
sheet-autofill.h \
sheet-object.c \
......@@ -210,7 +211,9 @@ GNUMERIC_BONOBO_SOURCES = \
sheet-object-container.c \
sheet-object-container.h \
sheet-object-item.c \
sheet-object-item.h
sheet-object-item.h \
sheet-vector.c \
sheet-vector.h
Gnumeric-impl.o: Gnumeric.h
......
......@@ -543,6 +543,8 @@ cell_content_changed (Cell *cell)
deps = cell_get_dependencies (cell);
if (deps)
cell_queue_recalc_list (deps, TRUE);
sheet_cell_changed (cell);
}
......
......@@ -21,6 +21,7 @@
#include "cell.h"
#include "colrow.h"
#include "value.h"
#include "sheet-private.h"
#define verify(cond) if (!(cond)){ out_of_range (ev); return; }
#define verify_val(cond,val) if (!(cond)){ out_of_range (ev); return (val); }
......@@ -1295,7 +1296,8 @@ sheet_corba_setup (Sheet *sheet)
POA_GNOME_Gnumeric_Sheet__init ((PortableServer_Servant) ss, &ev);
objid = PortableServer_POA_activate_object (gnumeric_poa, ss, &ev);
CORBA_free (objid);
sheet->corba_server = PortableServer_POA_servant_to_reference (gnumeric_poa, ss, &ev);
sheet->private->corba_server = PortableServer_POA_servant_to_reference (gnumeric_poa, ss, &ev);
CORBA_exception_free (&ev);
}
......@@ -1307,11 +1309,12 @@ sheet_corba_shutdown (Sheet *sheet)
g_return_if_fail (sheet != NULL);
g_return_if_fail (IS_SHEET (sheet));
g_return_if_fail (sheet->corba_server != NULL);
g_return_if_fail (sheet->private->corba_server != NULL);
g_warning ("Should release all the corba resources here");
CORBA_exception_init (&ev);
PortableServer_POA_deactivate_object (gnumeric_poa, sheet->corba_server, &ev);
PortableServer_POA_deactivate_object (gnumeric_poa, sheet->private->corba_server, &ev);
CORBA_exception_free (&ev);
}
......@@ -17,6 +17,7 @@
#include "commands.h"
#include "command-context-corba.h"
#include "workbook-private.h"
#include "sheet-private.h"
typedef struct {
POA_GNOME_Gnumeric_Workbook servant;
......@@ -37,7 +38,7 @@ workbook_from_servant (PortableServer_Servant servant)
static inline GNOME_Gnumeric_Sheet
corba_sheet (Sheet *sheet, CORBA_Environment *ev)
{
return CORBA_Object_duplicate (sheet->corba_server, ev);
return CORBA_Object_duplicate (sheet->private->corba_server, ev);
}
static GNOME_Gnumeric_Sheet
......
......@@ -17,6 +17,7 @@
#include "sheet.h"
#include "workbook.h"
#include "embeddable-grid.h"
#include "sheet-private.h"
/*
* Our vectors for providing methods
......@@ -37,7 +38,7 @@ Grid_get_sheet (PortableServer_Servant servant, CORBA_Environment *ev)
{
EmbeddableGrid *eg = embeddable_grid_from_servant (servant);
return CORBA_Object_duplicate (eg->sheet->corba_server, ev);
return CORBA_Object_duplicate (eg->sheet->private->corba_server, ev);
}
void
......
#ifndef GNUMERIC_SHEET_PRIVATE_H
#define GNUMERIC_SHEET_PRIVATE_H
struct _SheetPrivate {
#ifdef ENABLE_BONOBO
void *corba_server;
GSList *sheet_vectors;
#endif
};
#endif /* GNUMERIC_SHEET_PRIVATE_H */
/*
* sheet-vector.c: Implements sheet vectors.
*
* Author:
* Miguel de Icaza (miguel@gnu.org)
*
* (C) 1999, 2000 Helix Code, Inc. (http://www.helixcode.com)
*/
#include <config.h>
#include <bonobo/bonobo-object.h>
#include "Gnumeric.h"
#include "gnumeric.h"
#include "sheet-vector.h"
#include "sheet.h"
#include "sheet-private.h"
#include "value.h"
#include "cell.h"
#include "ranges.h"
/* The entry point vectors for the server we provide */
static POA_GNOME_Gnumeric_Vector__epv vector_epv;
static POA_GNOME_Gnumeric_Vector__vepv vector_vepv;
#define vector_from_servant(x) SHEET_VECTOR (bonobo_object_from_servant (x))
static BonoboObjectClass *vector_parent_class;
static CORBA_boolean
impl_vector_only_numbers (PortableServer_Servant servant, CORBA_Environment *ev)
{
return CORBA_TRUE;
}
static int
find_block (SheetVector *vec, int index, int *ret_top, int *ret_idx)
{
int total, i;
for (i = total = 0; i < vec->n_blocks; i++){
int old_total = total;
total += vec->blocks [i].size;
if (index < total){
*ret_top = total;
*ret_idx = old_total - index;
return i;
}
}
g_error ("Should not happen");
return 0;
}
static GNOME_Gnumeric_DoubleVec *
impl_vector_get_numbers (PortableServer_Servant servant,
CORBA_short low, CORBA_short high,
CORBA_Environment *ev)
{
SheetVector *vec = vector_from_servant (servant);
GNOME_Gnumeric_DoubleVec *res;
RangeBlock *block;
int block_top, block_idx;
int i, j, cols, rows, idx;
if (high == -1)
high = vec->len;
if ((low < 0) || (high > vec->len)){
CORBA_exception_set (ev, CORBA_USER_EXCEPTION, ex_GNOME_Gnumeric_Sheet_OutOfRange, NULL);
return NULL;
}
res = GNOME_Gnumeric_DoubleVec__alloc ();
if (res == NULL)
return NULL;
res->_length = (high - low);
res->_maximum = res->_length;
res->_buffer = CORBA_sequence_CORBA_double_allocbuf (res->_length);
/*
* Fill in the values
*/
block_idx = find_block (vec, low, &block_top, &idx);
block = &vec->blocks [block_idx++];
j = 0;
cols = block->range.end.col - block->range.start.col;
rows = block->range.end.row - block->range.start.row;
for (i = low; i < high; i++){
Cell *cell;
int col, row;
if (i == block_top){
block = &vec->blocks [block_idx++];
block_top += block->size;
idx = 0;
cols = block->range.end.col - block->range.start.col;
rows = block->range.end.row - block->range.start.row;
}
col = idx / rows;
row = idx % rows;
cell = sheet_cell_get (vec->sheet, col, row);
if (cell)
res->_buffer [j++] = value_get_as_float (cell->value);
else
res->_buffer [j++] = 0.0;
}
return res;
}
static GNOME_Gnumeric_VecValueVec *
impl_vector_get_vec_values (PortableServer_Servant servant,
CORBA_short low, CORBA_short high,
CORBA_Environment *ev)
{
SheetVector *vec = vector_from_servant (servant);
GNOME_Gnumeric_VecValueVec *res;
RangeBlock *block;
int block_top, block_idx;
int i, j, cols, rows, idx;
if (high == -1)
high = vec->len;
if ((low < 0) || (high > vec->len)){
CORBA_exception_set (ev, CORBA_USER_EXCEPTION, ex_GNOME_Gnumeric_Sheet_OutOfRange, NULL);
return NULL;
}
res = GNOME_Gnumeric_VecValueVec__alloc ();
if (res == NULL)
return NULL;
res->_length = (high - low);
res->_maximum = res->_length;
res->_buffer = CORBA_sequence_GNOME_Gnumeric_VecValue_allocbuf (res->_length);
/*
* Fill in the values
*/
block_idx = find_block (vec, low, &block_top, &idx);
block = &vec->blocks [block_idx++];
j = 0;
cols = block->range.end.col - block->range.start.col;
rows = block->range.end.row - block->range.start.row;
for (i = low; i < high; i++){
GNOME_Gnumeric_VecValue vecvalue;
Cell *cell;
int col, row;
if (i == block_top){
block = &vec->blocks [block_idx++];
block_top += block->size;
idx = 0;
cols = block->range.end.col - block->range.start.col;
rows = block->range.end.row - block->range.start.row;
}
col = idx / rows;
row = idx % rows;
cell = sheet_cell_get (vec->sheet, col, row);
if (cell){
Value *value = cell->value;
switch (value->type){
case VALUE_EMPTY:
case VALUE_ERROR:
case VALUE_CELLRANGE:
case VALUE_ARRAY:
vecvalue._d= GNOME_Gnumeric_VALUE_FLOAT;
vecvalue._u.v_float = 0.0;
break;
case VALUE_INTEGER:
vecvalue._d= GNOME_Gnumeric_VALUE_FLOAT;
vecvalue._u.v_float = value->v.v_int;
break;
case VALUE_FLOAT:
vecvalue._d= GNOME_Gnumeric_VALUE_FLOAT;
vecvalue._u.v_float = value->v.v_float;
break;
case VALUE_BOOLEAN:
vecvalue._d= GNOME_Gnumeric_VALUE_FLOAT;
vecvalue._u.v_float = value->v.v_bool;
break;
case VALUE_STRING:
vecvalue._d= GNOME_Gnumeric_VALUE_STRING;
vecvalue._u.str = CORBA_string_dup (value->v.str->str);
break;
}
} else {
vecvalue._d = GNOME_Gnumeric_VALUE_FLOAT;
vecvalue._u.v_float = 0.0;
}
res->_buffer [j] = vecvalue;
j++;
}
return res;
}
static CORBA_short
impl_vector_count (PortableServer_Servant servant, CORBA_Environment *ev)
{
SheetVector *vec = vector_from_servant (servant);
return vec->len;
}
static void
impl_vector_set (PortableServer_Servant servant, CORBA_short pos,
CORBA_double val, CORBA_Environment *ev)
{
SheetVector *vec = vector_from_servant (servant);
g_error ("Not implemented");
}
static void
impl_vector_set_notify (PortableServer_Servant servant,
GNOME_Gnumeric_VectorNotify vector_notify,
CORBA_Environment *ev)
{
SheetVector *vec = vector_from_servant (servant);
vec->notify = vector_notify;
}
static void
sheet_vector_destroy (GtkObject *object)
{
SheetVector *vec = SHEET_VECTOR (object);
vec->sheet->private->sheet_vectors = g_slist_remove (vec->sheet->private->sheet_vectors, vec);
if (vec->blocks)
g_free (vec->blocks);
GTK_OBJECT_CLASS (vector_parent_class)->destroy (object);
}
static void
init_vector_corba_class (void)
{
vector_epv.only_numbers = impl_vector_only_numbers;
vector_epv.get_numbers = impl_vector_get_numbers;
vector_epv.get_vec_values = impl_vector_get_vec_values;
vector_epv.set = impl_vector_set;
vector_epv.count = impl_vector_count;
vector_epv.set_notify = impl_vector_set_notify;
vector_vepv.Bonobo_Unknown_epv = bonobo_object_get_epv ();
vector_vepv.GNOME_Gnumeric_Vector_epv = &vector_epv;
}
static void
sheet_vector_class_init (GtkObjectClass *object_class)
{
vector_parent_class = gtk_type_class (bonobo_object_get_type ());
object_class->destroy = sheet_vector_destroy;
init_vector_corba_class ();
}
static void
sheet_vector_init (GtkObject *object)
{
SheetVector *vector = SHEET_VECTOR (object);
vector->notify = CORBA_OBJECT_NIL;
}
GtkType
sheet_vector_get_type (void)
{
static GtkType type = 0;
if (!type){
GtkTypeInfo info = {
"SheetVector",
sizeof (SheetVector),
sizeof (SheetVectorClass),
(GtkClassInitFunc) sheet_vector_class_init,
(GtkObjectInitFunc) sheet_vector_init,
NULL, /* reserved 1 */
NULL, /* reserved 2 */
(GtkClassInitFunc) NULL
};
type = gtk_type_unique (bonobo_object_get_type (), &info);
}
return type;
}
GNOME_Gnumeric_Vector
sheet_vector_corba_object_create (BonoboObject *object)
{
POA_GNOME_Gnumeric_Vector *servant;
CORBA_Environment ev;
servant = (POA_GNOME_Gnumeric_Vector *) g_new0 (BonoboObjectServant, 1);
servant->vepv = &vector_vepv;
CORBA_exception_init (&ev);
POA_GNOME_Gnumeric_Vector__init ((PortableServer_Servant) servant, &ev);
if (ev._major != CORBA_NO_EXCEPTION){
g_free (servant);
CORBA_exception_free (&ev);
return CORBA_OBJECT_NIL;
}
CORBA_exception_free (&ev);
return (Bonobo_View) bonobo_object_activate_servant (object, servant);
}
SheetVector *
sheet_vector_new (Sheet *sheet)
{
SheetVector *sheet_vector;
GNOME_Gnumeric_Vector corba_vector;
sheet_vector = gtk_type_new (sheet_vector_get_type ());
corba_vector = sheet_vector_corba_object_create (BONOBO_OBJECT (sheet_vector));
if (corba_vector == NULL){
gtk_object_destroy (GTK_OBJECT (sheet_vector));
return NULL;
}