Commit b906f492 authored by Arturo Espinosa's avatar Arturo Espinosa

Graphic Wizard touch ups. Gnumeric got a decent CORBA interface. Gnumeric



Graphic Wizard touch ups.
Gnumeric got a decent CORBA interface.
Gnumeric got an implmeneation for above cool CORBA interface

Miguel
parent 12622861
1999-05-01 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/corba-workbook.c, src/corba-sheet.c: New files implementing
most of the new Gnumeric.idl interface.
* src/Gnumeric.idl: Make it useful.
1999-04-30 Morten Welinder <terra@diku.dk>
* src/*.h: Properly forward-declare structures. Include
......
1999-05-01 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/corba-workbook.c, src/corba-sheet.c: New files implementing
most of the new Gnumeric.idl interface.
* src/Gnumeric.idl: Make it useful.
1999-04-30 Morten Welinder <terra@diku.dk>
* src/*.h: Properly forward-declare structures. Include
......
1999-05-01 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/corba-workbook.c, src/corba-sheet.c: New files implementing
most of the new Gnumeric.idl interface.
* src/Gnumeric.idl: Make it useful.
1999-04-30 Morten Welinder <terra@diku.dk>
* src/*.h: Properly forward-declare structures. Include
......
1999-05-01 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/corba-workbook.c, src/corba-sheet.c: New files implementing
most of the new Gnumeric.idl interface.
* src/Gnumeric.idl: Make it useful.
1999-04-30 Morten Welinder <terra@diku.dk>
* src/*.h: Properly forward-declare structures. Include
......
1999-04-29 Miguel de Icaza <miguel@nuclecu.unam.mx>
* ms-ole.c (ms_ole_new): Applied patch from Michael Meeks to allow
opening of excel files in read-only mode.
1999-04-29 Michael Meeks <michael@edenproject.org>
* ms-ole.c (ms_ole_new): Revert to read-only mapping on failure.
......
#include <gnome-factory.idl>
#include <Table.idl>
module GNOME {
interface Spreadsheet : Table {
void set_string (in string text, in long col, in long row)
raises (OutOfRange);
module Gnumeric {
struct CellRange {
string cell_a;
string cell_b;
};
string get_string (in long col, in long row)
raises (OutOfRange);
};
const short VALUE_STRING = 0;
const short VALUE_INTEGER = 1;
const short VALUE_FLOAT = 2;
const short VALUE_CELLRANGE = 3;
const short VALUE_ARRAY = 4;
interface Gnumeric : Spreadsheet {
};
union Value switch(short) {
case VALUE_FLOAT: double v_float;
case VALUE_INTEGER: long v_int;
case VALUE_STRING: string str;
case VALUE_ARRAY: string array;
case VALUE_CELLRANGE: CellRange cell_range;
};
interface Sheet {
exception OutOfRange {};
exception ParseError {};
interface GnumericFactory : GenericFactory {
void cursor_set (in long base_col, in long base_row,
in long start_col, in long start_row,
in long end_col, in long end_row)
raises (OutOfRange);
void cursor_move (in long col, in long row)
raises (OutOfRange);
void make_cell_visible (in long col, in long row)
raises (OutOfRange);
//
// Selection
//
void select_all ();
boolean is_all_selected ();
void selection_reset ();
void selection_append (in long col, in long row)
raises (OutOfRange);
void selection_append_range (in long start_col,
in long start_row,
in long end_col,
in long end_row)
raises (OutOfRange);
void selection_copy ();
void selection_cut ();
void selection_paste (in long dest_col, in long dest_row,
in long paste_flags)
raises (OutOfRange);
//
// Operations on the region
//
void clear_region (in long start_col, in long start_row,
in long end_col, in long end_row)
raises (OutOfRange);
void clear_region_content (in long start_col, in long start_row,
in long end_col, in long end_row)
raises (OutOfRange);
void clear_region_comments (in long start_col, in long start_row,
in long end_col, in long end_row)
raises (OutOfRange);
void clear_region_formats (in long start_col, in long start_row,
in long end_col, in long end_row)
raises (OutOfRange);
//
// Cell management
//
Value cell_get_value (in long col, in long row)
raises (OutOfRange);
void cell_set_text (in long col, in long row, in string text)
raises (OutOfRange);
string cell_get_text (in long col, in long row)
raises (OutOfRange);
void cell_set_formula (in long col, in long row, in string formula)
raises (OutOfRange, ParseError);
void cell_set_format (in long col, in long row, in string format)
raises (OutOfRange);
string cell_get_format (in long col, in long row)
raises (OutOfRange);
void cell_set_font (in long col, in long row, in string font)
raises (OutOfRange);
string cell_get_font (in long col, in long row)
raises (OutOfRange);
void cell_set_comment (in long col, in long row, in string comment)
raises (OutOfRange);
string cell_get_comment (in long col, in long row)
raises (OutOfRange);
void cell_set_foreground (in long col, in long row, in string color)
raises (OutOfRange);
string cell_get_foreground (in long col, in long row)
raises (OutOfRange);
void cell_set_background (in long col, in long row, in string color)
raises (OutOfRange);
string cell_get_background (in long col, in long row)
raises (OutOfRange);
void cell_set_pattern (in long col, in long row, in long pattern)
raises (OutOfRange);
long cell_get_pattern (in long col, in long row)
raises (OutOfRange);
const short HALIGN_GENERAL = 1;
const short HALIGN_LEFT = 2;
const short HALIGN_RIGHT = 4;
const short HALIGN_CENTER = 8;
const short HALIGN_FILL = 16;
const short HALIGN_JUSTIFY = 32;
const short VALIGN_TOP = 1;
const short VALIGN_BOTTOM = 2;
const short VALIGN_CENTER = 4;
const short VALIGN_JUSTIFY = 8;
void cell_set_alignment (in long col, in long row,
in long halign, in long valign,
in long orientation, in boolean auto_return)
raises (OutOfRange);
void cell_get_alignment (in long col, in long row,
out long halign, out long valign,
out long orientation, out boolean auto_return)
raises (OutOfRange);
//
// Sheet administrivia
//
void set_dirty (in boolean is_dirty);
//
// Sheet manipulation
//
void insert_col (in long col, in long count);
void delete_col (in long col, in long count);
void insert_row (in long row, in long count);
void delete_row (in long row, in long count);
void shift_rows (in long col,
in long start_row, in long end_row,
in long count);
void shift_cols (in long col,
in long start_row, in long end_row,
in long count);
};
interface Workbook {
exception NameExists {};
Sheet sheet_new (in string name) raises (NameExists);
Sheet sheet_lookup (in string name);
void set_filename (in string name);
void save_to (in string filename);
Sheet sheet_current ();
Sheet sheet_nth (in long n);
long sheet_count ();
//
// Workbook administrivia
//
void set_dirty (in boolean is_dirty);
boolean sheet_rename (in string old_name, in string new_name);
//
// Recomputation
//
void recalc ();
void recalc_all ();
//
// Cell reference parsing
//
void parse (in string cellref, out Sheet sheet, out long col, out long row);
};
interface WorkbookFactory : GNOME::GenericFactory {
Workbook read (in string filename);
};
};
};
......@@ -163,14 +163,16 @@ gnumeric_SOURCES = \
gnumeric_corba_SOURCES = \
main.c \
corba-args.c \
Gnumeric-impl.c \
corba-sheet.c \
corba-workbook.c \
$(GNUMERIC_CORBA_GENERATED) \
$(GNUMERIC_BASE_SOURCES)
gnumeric_bonobo_SOURCES = \
main.c \
corba-args.c \
Gnumeric-impl.c \
corba-sheet.c \
corba-workbook.c \
$(GNUMERIC_CORBA_GENERATED) \
$(GNUMERIC_BASE_SOURCES) \
$(GNUMERIC_BONOBO_SOURCES)
......
......@@ -347,7 +347,7 @@ cell_unrealize (Cell *cell)
}
void
cell_set_comment (Cell *cell, char *str)
cell_set_comment (Cell *cell, const char *str)
{
int had_comments = FALSE;
......
......@@ -125,7 +125,7 @@ void cell_set_format_simple (Cell *cell, const char *format);
void cell_set_format_from_style (Cell *cell, StyleFormat *style_format);
void cell_set_font (Cell *cell, const char *font_name);
void cell_set_style (Cell *cell, Style *reference_style);
void cell_set_comment (Cell *cell, char *str);
void cell_set_comment (Cell *cell, const char *str);
void cell_comment_destroy (Cell *cell);
void cell_comment_reposition (Cell *cell);
void cell_set_font_from_style (Cell *cell, StyleFont *style_font);
......
/*
* corba-sheet.c: The implementation of the Sheet CORBA interfaces
* defined by Gnumeric
*
* Author:
* Miguel de Icaza (miguel@gnu.org)
*/
#include <config.h>
#include <libgnorba/gnome-factory.h>
#include <gnome.h>
#include "sheet.h"
#include "gnumeric.h"
#include "Gnumeric.h"
#define verify(cond) if (!(cond)){ out_of_range (ev); return; }
#define verify_val(cond,val) if (!(cond)){ out_of_range (ev); return (val); }
#define verify_col(c) verify (((c) >= 0 && (c < SHEET_MAX_COLS)))
#define verify_col_val(c,val) verify_val (((c) >= 0 && (c < SHEET_MAX_COLS)),val)
#define verify_row(c) verify (((c) >= 0 && (c < SHEET_MAX_ROWS)))
#define verify_row_val(c,val) verify_val (((c) >= 0 && (c < SHEET_MAX_ROWS)),val)
#define verify_region(c1,r1,c2,r2) \
verify_col(c1); verify_col(c2); verify_row(r1); verify_row(r2); \
verify(c1 <= c2);\
verify (r1 <= r2);
static void
out_of_range (CORBA_Environment *ev)
{
CORBA_exception_set (ev, CORBA_USER_EXCEPTION, ex_GNOME_Gnumeric_Sheet_OutOfRange, NULL);
}
static Sheet *
sheet_from_servant (PortableServer_Servant servant)
{
return NULL;
}
static void
Sheet_cursor_set (PortableServer_Servant servant,
const CORBA_long base_col,
const CORBA_long base_row,
const CORBA_long start_col,
const CORBA_long start_row,
const CORBA_long end_col,
const CORBA_long end_row,
CORBA_Environment * ev)
{
Sheet *sheet = sheet_from_servant (servant);
verify_region (start_col, start_row, end_col, end_row);
verify ((base_col > 0) && (base_row > 0));
verify ((base_row >= start_row) && (base_row <= end_row) &&
(base_col >= start_col) && (base_col <= end_col));
sheet_cursor_set (sheet, base_col, base_row, start_col, start_row, end_col, end_row);
}
static void
Sheet_cursor_move (PortableServer_Servant servant, const CORBA_long col, const CORBA_long row, CORBA_Environment * ev)
{
Sheet *sheet = sheet_from_servant (servant);
verify_col (col);
verify_row (row);
sheet_cursor_move (sheet, col, row);
}
static void
Sheet_make_cell_visible (PortableServer_Servant servant, const CORBA_long col, const CORBA_long row, CORBA_Environment * ev)
{
Sheet *sheet = sheet_from_servant (servant);
verify_col (col);
verify_row (row);
sheet_make_cell_visible (sheet, col, row);
}
static void
Sheet_select_all (PortableServer_Servant servant, CORBA_Environment * ev)
{
Sheet *sheet = sheet_from_servant (servant);
sheet_select_all (sheet);
}
static CORBA_boolean
Sheet_is_all_selected (PortableServer_Servant servant, CORBA_Environment * ev)
{
Sheet *sheet = sheet_from_servant (servant);
return sheet_is_all_selected (sheet);
}
static void
Sheet_selection_reset (PortableServer_Servant servant, CORBA_Environment * ev)
{
Sheet *sheet = sheet_from_servant (servant);
sheet_selection_reset (sheet);
}
static void
Sheet_selection_append (PortableServer_Servant servant,
const CORBA_long col, const CORBA_long row,
CORBA_Environment * ev)
{
Sheet *sheet = sheet_from_servant (servant);
verify_col (col);
verify_row (row);
sheet_selection_append (sheet, col, row);
}
static void
Sheet_selection_append_range (PortableServer_Servant servant,
const CORBA_long start_col, const CORBA_long start_row,
const CORBA_long end_col, const CORBA_long end_row,
CORBA_Environment * ev)
{
Sheet *sheet = sheet_from_servant (servant);
verify_region (start_col, start_row, end_col, end_row);
sheet_selection_append_range (sheet, start_col, start_row,
start_col, start_row,
end_col, end_row);
}
static void
Sheet_selection_copy (PortableServer_Servant servant, CORBA_Environment * ev)
{
Sheet *sheet = sheet_from_servant (servant);
sheet_selection_copy (sheet);
}
static void
Sheet_selection_cut (PortableServer_Servant servant, CORBA_Environment * ev)
{
Sheet *sheet = sheet_from_servant (servant);
sheet_selection_cut (sheet);
}
static void
Sheet_selection_paste (PortableServer_Servant servant,
const CORBA_long dest_col, const CORBA_long dest_row,
const CORBA_long paste_flags, CORBA_Environment * ev)
{
Sheet *sheet = sheet_from_servant (servant);
verify_col (dest_col);
verify_row (dest_row);
sheet_selection_paste (sheet, dest_col, dest_row, paste_flags, 0);
}
static void
Sheet_clear_region (PortableServer_Servant servant,
const CORBA_long start_col, const CORBA_long start_row,
const CORBA_long end_col, const CORBA_long end_row,
CORBA_Environment * ev)
{
Sheet *sheet = sheet_from_servant (servant);
verify_region (start_col, start_row, end_col, end_row);
sheet_clear_region (sheet, start_col, start_row, end_col, end_row);
}
static void
Sheet_clear_region_content (PortableServer_Servant servant,
const CORBA_long start_col, const CORBA_long start_row,
const CORBA_long end_col, const CORBA_long end_row,
CORBA_Environment * ev)
{
Sheet *sheet = sheet_from_servant (servant);
verify_region (start_col, start_row, end_col, end_row);
sheet_clear_region_content (sheet, start_col, start_row, end_col, end_row);
}
static void
Sheet_clear_region_comments (PortableServer_Servant servant,
const CORBA_long start_col, const CORBA_long start_row,
const CORBA_long end_col, const CORBA_long end_row,
CORBA_Environment * ev)
{
Sheet *sheet = sheet_from_servant (servant);
verify_region (start_col, start_row, end_col, end_row);
sheet_clear_region_comments (sheet, start_col, start_row, end_col, end_row);
}
static void
Sheet_clear_region_formats (PortableServer_Servant servant,
const CORBA_long start_col, const CORBA_long start_row,
const CORBA_long end_col, const CORBA_long end_row,
CORBA_Environment * ev)
{
Sheet *sheet = sheet_from_servant (servant);
verify_region (start_col, start_row, end_col, end_row);
sheet_clear_region_formats (sheet, start_col, start_row, end_col, end_row);
}
static GNOME_Gnumeric_Value *
Sheet_cell_get_value (PortableServer_Servant servant, const CORBA_long col, const CORBA_long row, CORBA_Environment * ev)
{
Sheet *sheet = sheet_from_servant (servant);
GNOME_Gnumeric_Value *value;
Cell *cell;
verify_col_val (col, NULL);
verify_row_val (row, NULL);
value = GNOME_Gnumeric_Value__alloc ();
cell = sheet_cell_get (sheet, col, row);
if (cell && cell->value){
switch (cell->value->type){
case VALUE_STRING:
value->_d = GNOME_Gnumeric_VALUE_STRING;
value->_u.str = CORBA_string_dup (cell->value->v.str->str);
break;
case VALUE_INTEGER:
value->_d = GNOME_Gnumeric_VALUE_INTEGER;
value->_u.v_int = cell->value->v.v_int;
break;
case VALUE_FLOAT:
value->_d = GNOME_Gnumeric_VALUE_FLOAT;
value->_u.v_float = cell->value->v.v_float;
break;
case VALUE_CELLRANGE: {
char *a, *b;
a = cellref_name (&cell->value->v.cell_range.cell_a, sheet, col, row);
b = cellref_name (&cell->value->v.cell_range.cell_b, sheet, col, row);
value->_d = GNOME_Gnumeric_VALUE_CELLRANGE;
value->_u.cell_range.cell_a = CORBA_string_dup (a);
value->_u.cell_range.cell_b = CORBA_string_dup (b);
g_free (a);
g_free (b);
break;
}
case VALUE_ARRAY:
g_error ("FIXME");
}
} else {
value->_d = GNOME_Gnumeric_VALUE_INTEGER;
value->_u.v_int = 0;
}
return value;
}
static void
Sheet_cell_set_text (PortableServer_Servant servant,
const CORBA_long col, const CORBA_long row,
const CORBA_char * text, CORBA_Environment * ev)
{
Sheet *sheet = sheet_from_servant (servant);
Cell *cell;
verify_col (col);
verify_row (row);
cell = sheet_cell_fetch (sheet, col, row);
cell_set_text (cell, text);
}
static CORBA_char *
Sheet_cell_get_text (PortableServer_Servant servant,
const CORBA_long col,
const CORBA_long row,
CORBA_Environment * ev)
{
Sheet *sheet = sheet_from_servant (servant);
Cell *cell;
verify_col_val (col, NULL);
verify_row_val (row, NULL);
cell = sheet_cell_get (sheet, col, row);
if (cell){
char *str;
str = cell_get_text (cell);
return CORBA_string_dup (str);
} else {
return CORBA_string_dup ("");
}
}
static void
Sheet_cell_set_formula (PortableServer_Servant servant,
const CORBA_long col,
const CORBA_long row,
const CORBA_char * formula,
CORBA_Environment * ev)
{
Sheet *sheet = sheet_from_servant (servant);
Cell *cell;
verify_col (col);
verify_row (row);
cell = sheet_cell_fetch (sheet, col, row);
cell_set_formula (cell, formula);
}
static void
Sheet_cell_set_format (PortableServer_Servant servant,
const CORBA_long col,
const CORBA_long row,
const CORBA_char * format,
CORBA_Environment * ev)
{
Sheet *sheet = sheet_from_servant (servant);
Cell *cell;
verify_col (col);
verify_row (row);
cell = sheet_cell_fetch (sheet, col, row);
cell_set_format (cell, format);
}
static CORBA_char *
Sheet_cell_get_format (PortableServer_Servant servant,
const CORBA_long col,
const CORBA_long row,
CORBA_Environment * ev)
{
Sheet *sheet = sheet_from_servant (servant);
Cell *cell;
verify_col_val (col, NULL);
verify_row_val (row, NULL);
cell = sheet_cell_get (sheet, col, row);
if (cell){
return CORBA_string_dup (cell->style->format->format);
} else {
return CORBA_string_dup ("");
}
}
static void
Sheet_cell_set_font (PortableServer_Servant servant,
const CORBA_long col,
const CORBA_long row,
const CORBA_char * font,
CORBA_Environment * ev)
{
Sheet *sheet = sheet_from_servant (servant);
Cell *cell;
verify_col (col);
verify_row (row);
cell = sheet_cell_fetch (sheet, col, row);
cell_set_font (cell, font);
}
static CORBA_char *
Sheet_cell_get_font (PortableServer_Servant servant, const CORBA_long col, const CORBA_long row, CORBA_Environment * ev)
{
Sheet *sheet = sheet_from_servant (servant);
Cell *cell;
verify_col_val (col, NULL);
verify_row_val (row, NULL);
cell = sheet_cell_get (sheet, col, row);
if (cell){
return CORBA_string_dup (cell->style->font->font_name);
} else {
return CORBA_string_dup ("");
}
}
static void
Sheet_cell_set_comment (PortableServer_Servant servant,
const CORBA_long col, const CORBA_long row,
const CORBA_char * comment, CORBA_Environment * ev)
{
Sheet *sheet = sheet_from_servant (servant);
Cell *cell;
verify_col (col);
verify_row (row);
cell = sheet_cell_fetch (sheet, col, row);
cell_set_comment (cell, comment);
}
static CORBA_char *
Sheet_cell_get_comment (PortableServer_Servant servant,
const CORBA_long col, const CORBA_long row,
CORBA_Environment * ev)
{
Sheet *sheet = sheet_from_servant (servant);
Cell *cell;
verify_col_val (col, NULL);
verify_row_val (row, NULL);
cell = sheet_cell_get (sheet, col, row);
if (cell)
return CORBA_string_dup (cell->comment->comment->str);
else
return CORBA_string_dup ("");
}
static void