Commit 9fc2db80 authored by Jody Goldberg's avatar Jody Goldberg Committed by Jody Goldberg
Browse files

We always create an in canvas edit item, but sometimes we jump the focus


2000-09-20  Jody Goldberg <jgoldberg@home.com>

	* src/workbook-edit.c (workbook_start_editing_at_cursor) : We always
	  create an in canvas edit item, but sometimes we jump the focus to
	  the status line.

	* src/value.c (value_new_cellrange_r) : set the sheet for both
	  cell_refs.

	* src/sheet-object-widget.c (checkbox_set_expr) : Fix.

	* src/graph-series.c (graph_series_seq_scalar) : No need to handle
	  headers here.
	(graph_series_seq_date) : or here.
	(graph_series_seq_string) : or here.
	(graph_series_eval) : Handle idl rename.
	(series_get_name) : No need to do this here.
	(impl_vector_scalar_value) : No need to calculate label.
	(impl_vector_date_value) : Ditto.
	(impl_vector_string_value) : Ditto.
	(graph_series_set_expr) : Correctly register and un register deps.
	(graph_series_new) : series names are handled at a higher level.

	* src/gnumeric-sheet.c (gnumeric_sheet_key_mode_sheet) : Restore the
	  behaviour of F2.

	* src/expr.c (cellrange_relocate) : BE smarter about checking for
	  potential 3d references.

	* idl/gnumeric-graphs.idl : Rename routines using lowercase underscore
	  rather than StuddyCaps.

	* src/workbook.c (workbook_expr_relocate) : Handle dependents.

	* src/position.c (eval_pos_init_dep) : new function.

	* configure.in : Prepare for release.
	  Update req for gnome-print to 0.23
	  Update req for libglade to 0.14
	  Comment out pspell.
	  Leave perl disabled.

	* gnumeric.spec.in : Ditto.
	* README : Ditto.

2000-09-19  Jody Goldberg <jgoldberg@home.com>

	* src/xml-io.c (natural_order_cm) : Using col_info and row_info is
	  deprecated.
parent 2eb172b2
......@@ -11,27 +11,28 @@ module GNOME {
module Gnumeric {
interface VectorNotify {
oneway void remove ();
oneway void name_changed (in string name);
};
typedef sequence<double> SeqScalar;
typedef sequence<double> SeqScalar;
interface VectorScalarNotify : VectorNotify {
oneway void changed (in short start, in SeqScalar new_values);
oneway void value_changed (in short start, in SeqScalar new_values);
};
interface VectorScalar : VectorScalarNotify {
void value (out SeqScalar values, out string name);
};
typedef sequence<long> SeqDate;
typedef sequence<long> SeqDate;
interface VectorDateNotify : VectorNotify {
oneway void changed (in short start, in SeqDate new_values);
oneway void value_changed (in short start, in SeqDate new_values);
};
interface VectorDate : VectorDateNotify {
void value (out SeqDate values, out string name);
};
typedef sequence<string> SeqString;
typedef sequence<string> SeqString;
interface VectorStringNotify : VectorNotify {
oneway void changed (in short start, in SeqString new_values);
oneway void value_changed (in short start, in SeqString new_values);
};
interface VectorString : VectorStringNotify {
void value (out SeqString values, out string name);
......@@ -39,12 +40,12 @@ module GNOME {
module Graph {
interface Manager : Bonobo::Unknown {
Bonobo::Control getTypeSelectControl ();
Bonobo::Control getLayoutConfigControl ();
Bonobo::Control get_type_select_control ();
Bonobo::Control get_layout_control ();
VectorScalarNotify addVectorScalar (in VectorScalar vec);
VectorDateNotify addVectorDate (in VectorDate vec);
VectorStringNotify addVectorString (in VectorString vec);
VectorScalarNotify add_vector_scalar (in VectorScalar vec);
VectorDateNotify add_vector_date (in VectorDate vec);
VectorStringNotify add_vector_string (in VectorString vec);
oneway void freeze ();
oneway void thaw ();
......
......@@ -11,27 +11,28 @@ module GNOME {
module Gnumeric {
interface VectorNotify {
oneway void remove ();
oneway void name_changed (in string name);
};
typedef sequence<double> SeqScalar;
typedef sequence<double> SeqScalar;
interface VectorScalarNotify : VectorNotify {
oneway void changed (in short start, in SeqScalar new_values);
oneway void value_changed (in short start, in SeqScalar new_values);
};
interface VectorScalar : VectorScalarNotify {
void value (out SeqScalar values, out string name);
};
typedef sequence<long> SeqDate;
typedef sequence<long> SeqDate;
interface VectorDateNotify : VectorNotify {
oneway void changed (in short start, in SeqDate new_values);
oneway void value_changed (in short start, in SeqDate new_values);
};
interface VectorDate : VectorDateNotify {
void value (out SeqDate values, out string name);
};
typedef sequence<string> SeqString;
typedef sequence<string> SeqString;
interface VectorStringNotify : VectorNotify {
oneway void changed (in short start, in SeqString new_values);
oneway void value_changed (in short start, in SeqString new_values);
};
interface VectorString : VectorStringNotify {
void value (out SeqString values, out string name);
......@@ -39,12 +40,12 @@ module GNOME {
module Graph {
interface Manager : Bonobo::Unknown {
Bonobo::Control getTypeSelectControl ();
Bonobo::Control getLayoutConfigControl ();
Bonobo::Control get_type_select_control ();
Bonobo::Control get_layout_control ();
VectorScalarNotify addVectorScalar (in VectorScalar vec);
VectorDateNotify addVectorDate (in VectorDate vec);
VectorStringNotify addVectorString (in VectorString vec);
VectorScalarNotify add_vector_scalar (in VectorScalar vec);
VectorDateNotify add_vector_date (in VectorDate vec);
VectorStringNotify add_vector_string (in VectorString vec);
oneway void freeze ();
oneway void thaw ();
......
2000-09-20 Jody Goldberg <jgoldberg@home.com>
* dialog-graph-guru.c (get_selector_control) : Hande idl name changes.
(cb_create_series_from_range) : Be smart about col/row headers.
2000-09-19 Morten Welinder <terra@diku.dk>
* dialog-stf-format-page.c (format_page_format_changed): Don't
......
......@@ -2293,7 +2293,6 @@ dialog_cell_format (Workbook *wb, Sheet *sheet)
* TODO
*
* Borders
* - Double lines for borders
* - Add the 'text' elements in the preview
*
* Wishlist
......
......@@ -31,6 +31,8 @@
#include "sheet-object.h"
#include "sheet-object-container.h"
#include "selection.h"
#include "ranges.h"
#include "value.h"
#include "graph-series.h"
#include "idl/gnumeric-graphs.h"
#include <liboaf/liboaf.h>
......@@ -227,7 +229,7 @@ get_selector_control (GraphGuruState *state)
GtkWidget *res = NULL;
CORBA_exception_init (&ev);
state->control = GNOME_Gnumeric_Graph_Manager_getTypeSelectControl (state->manager, &ev);
state->control = GNOME_Gnumeric_Graph_Manager_get_type_select_control (state->manager, &ev);
if (ev._major != CORBA_NO_EXCEPTION)
return NULL;
CORBA_exception_free (&ev);
......@@ -312,8 +314,16 @@ cb_create_series_from_range (Sheet *sheet, Range const *src, gpointer user_data)
GraphSeries *series;
Range vector;
int i, count;
gboolean const has_col_header = range_has_header (sheet, src, TRUE);
gboolean const has_row_header = range_has_header (sheet, src, FALSE);
vector = *src;
if (has_col_header)
vector.start.col++;
if (has_row_header)
vector.start.row++;
if (state->is_columns) {
count = vector.end.col - vector.start.col;
vector.end.col = vector.start.col;
......@@ -323,7 +333,28 @@ cb_create_series_from_range (Sheet *sheet, Range const *src, gpointer user_data)
}
for (i = 0 ; i <= count ; i++) {
series = graph_series_new (sheet, &vector);
char *name = NULL;
if (state->is_columns) {
if (has_col_header) {
Cell const *cell = sheet_cell_get (sheet,
vector.start.col,
vector.start.row-1);
name = value_get_as_string (cell->value);
}
} else {
if (has_row_header) {
Cell const *cell = sheet_cell_get (sheet,
vector.start.col-1,
vector.start.row);
name = value_get_as_string (cell->value);
}
}
/* Create a default name if need be */
if (name == NULL)
name = g_strdup_printf (_("series%d"), state->series->len+1);
series = graph_series_new (sheet, &vector, name);
graph_series_set_subscriber (series, state->manager);
g_ptr_array_add (state->series, series);
......
......@@ -1488,8 +1488,16 @@ cellrange_relocate (const Value *v,
/* Only relocate if both ends of the range need relocation */
if (needs_reloc >= 2) {
Value *res;
Sheet const *sheet_a = ref_a.sheet;
Sheet const *sheet_b = ref_b.sheet;
if (sheet_a == NULL)
sheet_a = rinfo->pos.sheet;
if (sheet_b == NULL)
sheet_b = rinfo->pos.sheet;
/* Dont allow creation of 3D references */
if (ref_a.sheet == ref_b.sheet)
if (sheet_a == sheet_b)
res = value_new_cellrange (&ref_a, &ref_b,
rinfo->pos.eval.col,
rinfo->pos.eval.row);
......
......@@ -748,7 +748,7 @@ gnumeric_sheet_key_mode_sheet (GnumericSheet *gsheet, GdkEventKey *event)
break;
case GDK_F2:
workbook_start_editing_at_cursor (wb, FALSE, TRUE);
workbook_start_editing_at_cursor (wb, FALSE, FALSE);
/* fall down */
default:
......
......@@ -748,7 +748,7 @@ gnumeric_sheet_key_mode_sheet (GnumericSheet *gsheet, GdkEventKey *event)
break;
case GDK_F2:
workbook_start_editing_at_cursor (wb, FALSE, TRUE);
workbook_start_editing_at_cursor (wb, FALSE, FALSE);
/* fall down */
default:
......
......@@ -29,7 +29,7 @@
#include "dependent.h"
#include "expr.h"
#include "value.h"
#include "ranges.h"
#include "cell.h"
#include "gnumeric-type-util.h"
typedef enum { SERIES_SCALAR, SERIES_DATE, SERIES_STRING } GraphSeriesType;
......@@ -37,10 +37,10 @@ struct _GraphSeries {
GtkObject obj;
Dependent dep;
GraphSeriesType type;
gboolean is_column;
gboolean has_header;
Range range; /* TODO : add support for discontinuous */
GraphSeriesType type;
gboolean is_column;
Range range; /* TODO : add support for discontinuous */
char *name;
CORBA_Object vector_ref;
union {
......@@ -91,8 +91,7 @@ graph_series_seq_scalar (GraphSeries *series)
values->_buffer = CORBA_sequence_CORBA_double_allocbuf (len);
/* FIXME : This is dog slow */
/* TODO : How to handle a changed header */
for (i = series->has_header ? 1 : 0; i < len ; ++i) {
for (i = 0; i < len ; ++i) {
Value const *elem = series->is_column
? value_area_get_x_y (&pos, v, 0, i)
: value_area_get_x_y (&pos, v, i, 0);
......@@ -121,8 +120,7 @@ graph_series_seq_date (GraphSeries *series)
values->_buffer = CORBA_sequence_CORBA_long_allocbuf (len);
/* FIXME : This is dog slow */
/* TODO : How to handle a changed header */
for (i = series->has_header ? 1 : 0; i < len ; ++i) {
for (i = 0; i < len ; ++i) {
Value const *elem = series->is_column
? value_area_get_x_y (&pos, v, 0, i)
: value_area_get_x_y (&pos, v, i, 0);
......@@ -149,8 +147,7 @@ graph_series_seq_string (GraphSeries *series)
values->_buffer = CORBA_sequence_CORBA_string_allocbuf (len);
/* FIXME : This is dog slow */
/* TODO : How to handle a changed header */
for (i = series->has_header ? 1 : 0; i < len ; ++i) {
for (i = 0; i < len ; ++i) {
Value const *elem = series->is_column
? value_area_get_x_y (&pos, v, 0, i)
: value_area_get_x_y (&pos, v, i, 0);
......@@ -176,19 +173,19 @@ graph_series_eval (Dependent *dep)
CORBA_exception_init (&ev);
switch (series->type) {
case SERIES_SCALAR :
GNOME_Gnumeric_VectorScalarNotify_changed (
GNOME_Gnumeric_VectorScalarNotify_value_changed (
series->subscriber.scalar,
0, graph_series_seq_scalar (series), &ev);
break;
case SERIES_DATE :
GNOME_Gnumeric_VectorDateNotify_changed (
GNOME_Gnumeric_VectorDateNotify_value_changed (
series->subscriber.date,
0, graph_series_seq_date (series), &ev);
break;
case SERIES_STRING :
GNOME_Gnumeric_VectorStringNotify_changed (
GNOME_Gnumeric_VectorStringNotify_value_changed (
series->subscriber.string,
0, graph_series_seq_string (series), &ev);
break;
......@@ -203,26 +200,6 @@ graph_series_eval (Dependent *dep)
/******************************************************************************/
static char *
series_get_name (GraphSeries *series, char const *prefix)
{
static int counter = 0;
++counter;
series->has_header = range_has_header (series->dep.sheet,
&series->range,
series->is_column);
if (series->has_header) {
Cell const *cell = sheet_cell_get (series->dep.sheet,
series->range.start.col,
series->range.start.row);
return value_get_as_string (cell->value);
} else
return g_strdup_printf ("%sseries%d", prefix, ++counter);
}
static void
impl_vector_scalar_value (PortableServer_Servant servant,
GNOME_Gnumeric_SeqScalar **values,
......@@ -230,15 +207,12 @@ impl_vector_scalar_value (PortableServer_Servant servant,
CORBA_Environment *ev)
{
GraphSeries *series = SERVANT_TO_GRAPH_SERIES (servant);
char *label;
g_return_if_fail (GRAPH_SERIES (series) != NULL);
g_return_if_fail (series->type == SERIES_SCALAR);
label = series_get_name (series, "SCALAR");
*name = CORBA_string_dup (label);
*name = CORBA_string_dup (series->name);
*values = graph_series_seq_scalar (series);
g_free (label);
}
static void
......@@ -248,15 +222,12 @@ impl_vector_date_value (PortableServer_Servant servant,
CORBA_Environment *ev)
{
GraphSeries *series = SERVANT_TO_GRAPH_SERIES (servant);
char *label;
g_return_if_fail (GRAPH_SERIES (series) != NULL);
g_return_if_fail (series->type == SERIES_DATE);
label = series_get_name (series, "DATE");
*name = CORBA_string_dup (label);
*name = CORBA_string_dup (series->name);
*values = graph_series_seq_date (series);
g_free (label);
}
static void
......@@ -266,15 +237,12 @@ impl_vector_string_value (PortableServer_Servant servant,
CORBA_Environment *ev)
{
GraphSeries *series = SERVANT_TO_GRAPH_SERIES (servant);
char *label;
g_return_if_fail (GRAPH_SERIES (series) != NULL);
g_return_if_fail (series->type == SERIES_STRING);
label = series_get_name (series, "STRING");
*name = CORBA_string_dup (label);
*name = CORBA_string_dup (series->name);
*values = graph_series_seq_string (series);
g_free (label);
}
/******************************************************************************/
......@@ -343,21 +311,21 @@ corba_implementation_classes_init (void)
static POA_GNOME_Gnumeric_VectorString__epv
vector_string_epv;
vector_scalar_notify_epv.changed = &impl_vector_scalar_changed;
vector_scalar_notify_epv.value_changed = &impl_vector_scalar_changed;
vector_scalar_epv.value = & impl_vector_scalar_value;
vector_scalar_vepv.GNOME_Gnumeric_VectorScalarNotify_epv =
&vector_scalar_notify_epv;
vector_scalar_vepv.GNOME_Gnumeric_VectorScalar_epv =
&vector_scalar_epv;
vector_date_notify_epv.changed = & impl_vector_date_changed;
vector_date_notify_epv.value_changed = & impl_vector_date_changed;
vector_date_epv.value = & impl_vector_date_value;
vector_date_vepv.GNOME_Gnumeric_VectorDateNotify_epv =
&vector_date_notify_epv;
vector_date_vepv.GNOME_Gnumeric_VectorDate_epv =
&vector_date_epv;
vector_string_notify_epv.changed = & impl_vector_string_changed;
vector_string_notify_epv.value_changed = & impl_vector_string_changed;
vector_string_epv.value = & impl_vector_string_value;
vector_string_vepv.GNOME_Gnumeric_VectorStringNotify_epv =
&vector_string_notify_epv;
......@@ -376,6 +344,10 @@ graph_series_destroy (GtkObject *object)
expr_tree_unref (series->dep.expression);
series->dep.expression = NULL;
}
if (series->name != NULL) {
g_free (series->name);
series->name = NULL;
}
}
static void
......@@ -409,9 +381,23 @@ static GNUMERIC_MAKE_TYPE (graph_series,"GraphSeries",GraphSeries,
static void
graph_series_set_expr (Dependent *dep, ExprTree *expr)
{
ParsePos pos;
char * new_str;
pos.sheet = dep->sheet;
pos.eval.col = pos.eval.row = 0;
new_str = expr_tree_as_string (expr, &pos);
printf("new = %s\n", new_str);
g_free (new_str);
new_str = expr_tree_as_string (dep->expression, &pos);
printf("old = %s\n", new_str);
g_free (new_str);
expr_tree_ref (expr);
dependent_unlink (dep, NULL);
expr_tree_unref (dep->expression);
dep->expression = expr;
dependent_changed (dep, NULL, TRUE);
}
static void
......@@ -448,7 +434,7 @@ cb_check_range_for_pure_string (Sheet *sheet, int col, int row,
}
GraphSeries *
graph_series_new (Sheet *sheet, Range const *r)
graph_series_new (Sheet *sheet, Range const *r, char *name)
{
CORBA_Environment ev;
PortableServer_Servant serv = CORBA_OBJECT_NIL;
......@@ -470,12 +456,13 @@ graph_series_new (Sheet *sheet, Range const *r)
series->type = type;
series->is_column = (r->start.col == r->end.col);
series->range = *r;
series->name = name;
series->dep.sheet = sheet;
series->dep.flags = graph_series_get_dep_type ();
series->dep.expression = expr_tree_new_constant (
value_new_cellrange_r (sheet, r));
dependent_changed (&series->dep, NULL, TRUE);
dependent_changed (&series->dep, NULL, FALSE);
CORBA_exception_init (&ev);
switch (type) {
......@@ -527,19 +514,19 @@ graph_series_set_subscriber (GraphSeries *series, CORBA_Object graph_manager)
switch (series->type) {
case SERIES_SCALAR :
series->subscriber.scalar =
GNOME_Gnumeric_Graph_Manager_addVectorScalar (manager,
GNOME_Gnumeric_Graph_Manager_add_vector_scalar (manager,
series->vector_ref, &ev);
break;
case SERIES_DATE :
series->subscriber.scalar =
GNOME_Gnumeric_Graph_Manager_addVectorDate (manager,
GNOME_Gnumeric_Graph_Manager_add_vector_date (manager,
series->vector_ref, &ev);
break;
case SERIES_STRING :
series->subscriber.scalar =
GNOME_Gnumeric_Graph_Manager_addVectorString (manager,
GNOME_Gnumeric_Graph_Manager_add_vector_string (manager,
series->vector_ref, &ev);
break;
default :
......
......@@ -6,7 +6,7 @@
typedef struct _GraphSeries GraphSeries;
GraphSeries *graph_series_new (Sheet *sheet, Range const *r);
GraphSeries *graph_series_new (Sheet *sheet, Range const *r, char *name);
void graph_series_set_subscriber (GraphSeries *series, CORBA_Object manager);
#endif /* GNUMERIC_GRAPH_SERIES_H */
......@@ -40,19 +40,31 @@ eval_pos_init (EvalPos *eval_pos, Sheet *sheet, CellPos const *pos)
return eval_pos;
}
EvalPos *
eval_pos_init_dep (EvalPos *eval_pos, Dependent const *dep)
{
g_return_val_if_fail (dep != NULL, NULL);
if (DEPENDENT_CELL == (dep->flags & DEPENDENT_TYPE_MASK)) {
Cell const *cell = CELL_TO_DEP (dep);
return eval_pos_init (eval_pos, dep->sheet, &cell->pos);
} else {
static CellPos const pos = { 0, 0 };
return eval_pos_init (eval_pos, dep->sheet, &pos);
}
}
EvalPos *
eval_pos_init_cell (EvalPos *eval_pos, Cell const *cell)
{
CellPos pos;
g_return_val_if_fail (cell != NULL, NULL);
pos = cell->pos;
return eval_pos_init (eval_pos, cell->base.sheet, &pos);
return eval_pos_init (eval_pos, cell->base.sheet, &cell->pos);
}
EvalPos *
eval_pos_init_cellref (EvalPos *dest, EvalPos const *src,
CellRef const *ref)
CellRef const *ref)
{
/* FIXME : This is a place to catch all of the strange
* usages. Please figure out what they were trying to do.
......
......@@ -23,6 +23,7 @@ struct _ParsePos {
/* Initialization routines for Evaluation Positions */
EvalPos *eval_pos_init (EvalPos *pp, Sheet *s, CellPos const *pos);
EvalPos *eval_pos_init_dep (EvalPos *eval_pos, Dependent const *dep);
EvalPos *eval_pos_init_cell (EvalPos *pp, Cell const *cell);
EvalPos *eval_pos_init_cellref (EvalPos *dest, EvalPos const *src,
CellRef const *);
......
......@@ -16,6 +16,7 @@
typedef struct {
SheetObjectBonobo parent_object;
BonoboViewFrame *view_frame;
} SheetObjectContainer;
typedef struct {
......
......@@ -379,8 +379,10 @@ static void
checkbox_set_expr (Dependent *dep, ExprTree *expr)
{
expr_tree_ref (expr);
dependent_unlink (dep, NULL);
expr_tree_unref (dep->expression);
dep->expression = expr;
dependent_changed (dep, NULL, TRUE);
}
static void
......
......@@ -551,13 +551,7 @@ sheet_object_stop_editing (SheetObject *so)
if (SO_CLASS (so)->set_active != NULL)
SO_CLASS (so)->set_active (so, FALSE);
#ifdef ENABLE_BONOBO
/* FIXME FIXME FIXME : JEG 11/Sep/2000
* Michael :
* Should we have a virtual void SheetObject::set_active(gboolean) ?
* then move this down into SheetObjectbonobo ?
* We could also remove active_object_frame from Sheet.
* That seems like it belongs at a view level.
*/
/* FIXME FIXME FIXME : JEG 11/Sep/2000 */
if (sheet->active_object_frame) {
bonobo_view_frame_view_deactivate (sheet->active_object_frame);
if (sheet->active_object_frame != NULL)
......
......@@ -173,7 +173,7 @@ value_new_cellrange_r (Sheet *sheet, const Range *r)
b = &v->cell.b;
a->sheet = sheet;
b->sheet = NULL;
b->sheet = sheet;
a->col = r->start.col;
a->row = r->start.row;
b->col = r->end.col;
......
......@@ -196,6 +196,7 @@ workbook_start_editing_at_cursor (Workbook *wb, gboolean blankp,
Sheet *sheet;
Cell *cell;
char *text = NULL;
int col, row;
g_return_if_fail (wb != NULL);
......@@ -211,12 +212,13 @@ workbook_start_editing_at_cursor (Workbook *wb, gboolean blankp,
sheet = wb->current_sheet;
g_return_if_fail (sheet != NULL);
col = sheet->cursor.edit_pos.col;
row = sheet->cursor.edit_pos.row;
application_clipboard_unant ();
workbook_edit_set_sensitive (wb, TRUE, FALSE);
cell = sheet_cell_get (sheet,
sheet->cursor.edit_pos.col,
sheet->cursor.edit_pos.row);