Commit 8c13818d authored by Arturo Espinosa's avatar Arturo Espinosa

Get the Excel plugin incorporated into the build process (right now it is



Get the Excel plugin incorporated into the build process (right now
it is not a real plugin, it gets loaded directly into gnumeric address
space, I guess we can fix this).

Cell comments are working, but still need some work.

Miguel.
parent a4cd1aba
1998-11-02 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/cell.c, src/workbook.c, src/sheet-view.c: Finish cell
comment display routines. Now we only need the dialog box to
insert/edit a cell comment.
1998-10-30 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/cell.c (cell_set_comment): new implementation.
1998-10-28 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/fn-date.c (gnumeric_date): Fix longstanding off by one
......
1998-11-02 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/cell.c, src/workbook.c, src/sheet-view.c: Finish cell
comment display routines. Now we only need the dialog box to
insert/edit a cell comment.
1998-10-30 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/cell.c (cell_set_comment): new implementation.
1998-10-28 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/fn-date.c (gnumeric_date): Fix longstanding off by one
......
SUBDIRS = intl po macros src plugins
SUBDIRS = intl po macros plugins src
EXTRA_DIST = gnumeric.desktop README HACKING
......
1998-11-02 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/cell.c, src/workbook.c, src/sheet-view.c: Finish cell
comment display routines. Now we only need the dialog box to
insert/edit a cell comment.
1998-10-30 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/cell.c (cell_set_comment): new implementation.
1998-10-28 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/fn-date.c (gnumeric_date): Fix longstanding off by one
......
1998-11-02 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/cell.c, src/workbook.c, src/sheet-view.c: Finish cell
comment display routines. Now we only need the dialog box to
insert/edit a cell comment.
1998-10-30 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/cell.c (cell_set_comment): new implementation.
1998-10-28 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/fn-date.c (gnumeric_date): Fix longstanding off by one
......
......@@ -2,6 +2,18 @@
GNOME Spread Sheet task list
* Comments
Comments location needs to be reset on col/row dimenssion changes.
cell_relocate should also relocate the comment.
* Cell range naming
Finish implementing.
* Cell references to other sheets.
* Number formatting
The formatting code should take the current GtkFont for the cell
......
......@@ -109,6 +109,7 @@ Makefile
src/Makefile
plugins/Makefile
plugins/sample/Makefile
plugins/excel/Makefile
plugins/python/Makefile
plugins/perl/Makefile
plugins/perl/ext/Makefile.PL
......
......@@ -11,4 +11,4 @@ else
PERL =
endif
SUBDIRS = sample $(PYTHON) $(PERL) stat
SUBDIRS = sample $(PYTHON) $(PERL) stat excel
INCLUDES = \
-DGNOMELOCALEDIR=\""$(datadir)/locale"\" \
-DGNUMERIC_VERSION=\""$(VERSION)"\" \
-I$(includedir) \
-I$(top_srcdir)/src \
$(GNOME_INCLUDEDIR)
noinst_LIBRARIES = libexcel.a
libexcel_a_SOURCES = \
ms-biff.c \
ms-biff.h \
ms-excel.c \
ms-excel.h \
ms-ole.c \
ms-ole.h
......@@ -471,7 +471,7 @@ static void ms_excel_read_sheet (BIFF_QUERY *q, MS_EXCEL_WORKBOOK *wb,
Workbook *ms_excelReadWorkbook(MS_OLE_FILE *file)
{
MS_EXCEL_WORKBOOK *wb ;
MS_EXCEL_WORKBOOK *wb = NULL ;
xmlNodePtr child ;
if (!ms_ole_analyse_file (file))
......
......@@ -471,7 +471,7 @@ static void ms_excel_read_sheet (BIFF_QUERY *q, MS_EXCEL_WORKBOOK *wb,
Workbook *ms_excelReadWorkbook(MS_OLE_FILE *file)
{
MS_EXCEL_WORKBOOK *wb ;
MS_EXCEL_WORKBOOK *wb = NULL ;
xmlNodePtr child ;
if (!ms_ole_analyse_file (file))
......
......@@ -4,7 +4,7 @@
bin_PROGRAMS = gnumeric
noinst_PROGRAMS = number-match
#noinst_PROGRAMS = number-match
INCLUDES = \
-DGNOMELOCALEDIR=\""$(datadir)/locale"\" \
......@@ -120,7 +120,9 @@ gnumeric_SOURCES = \
$(GNUMERIC_BASE_SOURCES)
gnumeric_LDFLAGS = -export-dynamic
gnumeric_LDADD = \
../plugins/excel/libexcel.a \
$(GNOME_LIBDIR) \
$(GNOMEUI_LIBS) \
$(GNOME_XML_LIB) \
......@@ -136,11 +138,11 @@ dist-hook:
EXTRA_DIST = Gnumeric.idl
number_match_SOURCES = number-match.c formats.c dates.c number-match-test.c
#number_match_SOURCES = number-match.c formats.c dates.c number-match-test.c
number_match_LDADD = \
$(GNOME_LIBDIR) \
$(GNOMEUI_LIBS) \
$(GNOME_XML_LIB) \
$(INTLLIBS)
#number_match_LDADD = \
# $(GNOME_LIBDIR) \
# $(GNOMEUI_LIBS) \
# $(GNOME_XML_LIB) \
# $(INTLLIBS)
......@@ -12,6 +12,7 @@
#include "eval.h"
#include "format.h"
#include "color.h"
#include "cursors.h"
static int redraws_frozen = 0;
static GHashTable *cell_hash_queue;
......@@ -168,6 +169,139 @@ cell_set_style (Cell *cell, Style *reference_style)
cell_queue_redraw (cell);
}
void
cell_comment_destroy (Cell *cell)
{
CellComment *comment;
GList *l;
g_return_if_fail (cell != NULL);
comment = cell->comment;
if (!comment)
return;
cell->comment = NULL;
/* Free resources */
string_unref (comment->comment);
for (l = comment->realized_list; l; l = l->next)
gtk_object_destroy (l->data);
g_free (comment);
}
static void
cell_display_comment (Cell *cell)
{
GtkWidget *window, *label;
int x, y;
g_return_if_fail (cell != NULL);
window = gtk_window_new (GTK_WINDOW_POPUP);
label = gtk_label_new (cell->comment->comment->str);
gtk_container_add (GTK_CONTAINER (window), label);
gdk_window_get_pointer (NULL, &x, &y, NULL);
gtk_widget_set_uposition (window, x+10, y+10);
gtk_widget_show_all (window);
cell->comment->window = window;
}
static gint
cell_popup_comment (gpointer data)
{
Cell *cell = data;
cell->comment->timer_tag = -1;
cell_display_comment (cell);
return FALSE;
}
static int
cell_comment_clicked (GnomeCanvasItem *item, GdkEvent *event, Cell *cell)
{
GnomeCanvas *canvas = item->canvas;
switch (event->type){
case GDK_BUTTON_RELEASE:
if (event->button.button != 1)
return FALSE;
if (cell->comment->window)
return FALSE;
cell_display_comment (cell);
break;
case GDK_BUTTON_PRESS:
if (event->button.button != 1)
return FALSE;
break;
case GDK_ENTER_NOTIFY:
cell->comment->timer_tag = gtk_timeout_add (1000, cell_popup_comment, cell);
cursor_set_widget (canvas, GNUMERIC_CURSOR_ARROW);
break;
case GDK_LEAVE_NOTIFY:
if (cell->comment->timer_tag != -1){
gtk_timeout_remove (cell->comment->timer_tag);
cell->comment->timer_tag = -1;
}
if (cell->comment->window){
gtk_object_destroy (GTK_OBJECT (cell->comment->window));
cell->comment->window = NULL;
}
break;
default:
return FALSE;
}
return TRUE;
}
void
cell_set_comment (Cell *cell, char *str)
{
GList *l;
int had_comments = FALSE;
g_return_if_fail (cell != NULL);
g_return_if_fail (str != NULL);
cell_modified (cell);
cell_comment_destroy (cell);
cell->comment = g_new (CellComment, 1);
cell->comment->realized_list = NULL;
cell->comment->timer_tag = -1;
cell->comment->window = NULL;
cell->comment->comment = string_get (str);
if (had_comments)
cell_queue_redraw (cell);
for (l = ((Sheet *)cell->sheet)->sheet_views; l; l = l->next){
SheetView *sheet_view = SHEET_VIEW (l->data);
GnomeCanvasItem *o;
o = sheet_view_create_comment_marker (
sheet_view,
cell->col->pos, cell->row->pos);
cell->comment->realized_list = g_list_prepend (
cell->comment->realized_list, o);
gtk_signal_connect (GTK_OBJECT (o), "event",
GTK_SIGNAL_FUNC (cell_comment_clicked), cell);
}
}
void
cell_set_foreground (Cell *cell, gushort red, gushort green, gushort blue)
{
......@@ -429,6 +563,9 @@ cell_copy (Cell *cell)
new_cell->style = style_duplicate (new_cell->style);
new_cell->value = value_duplicate (new_cell->value);
new_cell->comment = NULL;
cell_set_comment (new_cell, cell->comment->comment->str);
return new_cell;
}
......@@ -446,8 +583,7 @@ cell_destroy (Cell *cell)
if (cell->render_color)
style_color_unref (cell->render_color);
if (cell->comment)
string_unref (cell->comment);
cell_comment_destroy (cell);
string_unref (cell->entered_text);
string_unref (cell->text);
......@@ -560,62 +696,50 @@ cell_set_format (Cell *cell, char *format)
cell_queue_redraw (cell);
}
void
cell_set_comment (Cell *cell, char *str)
{
int had_comments = FALSE;
g_return_if_fail (cell != NULL);
g_return_if_fail (str != NULL);
cell_modified (cell);
if (cell->comment){
string_unref (cell->comment);
had_comments = TRUE;
}
cell->comment = string_get (str);
if (had_comments)
cell_queue_redraw (cell);
}
/*
* cell_formula_relocate:
* cell_relocate:
* @cell: The cell that is changing position
* @target_col: The new column
* @target_row: The new row.
*
* This routine is used to move a cell to a different location:
*
* The parsed tree is decoded as if it were evaluated at the new position
* and then it is reparsed (important only for keeping the ->entered_text
* information syncronized).
*
* Auxiliary items canvas items attached to the cell are moved.
*/
void
cell_formula_relocate (Cell *cell, int target_col, int target_row)
cell_relocate (Cell *cell, int target_col, int target_row)
{
char *text, *formula;
g_return_if_fail (cell != NULL);
g_return_if_fail (cell->entered_text);
g_return_if_fail (cell->parsed_node);
/* 1. Tag the cell as modified */
cell_modified (cell);
string_unref (cell->entered_text);
/* 2. If the cell contains a formula, relocate the formula */
if (cell->parsed_node){
char *text, *formula;
string_unref (cell->entered_text);
text = expr_decode_tree (cell->parsed_node, target_col, target_row);
text = expr_decode_tree (cell->parsed_node, target_col, target_row);
formula = g_copy_strings ("=", text, NULL);
cell->entered_text = string_get (formula);
formula = g_copy_strings ("=", text, NULL);
cell->entered_text = string_get (formula);
cell_set_formula (cell, formula);
g_free (formula);
g_free (text);
cell_set_formula (cell, formula);
cell_formula_changed (cell);
g_free (formula);
g_free (text);
cell_formula_changed (cell);
}
/* 3. Move any auxiliary canvas items */
}
/*
......@@ -1048,31 +1172,6 @@ str_trim_spaces (char *s)
return s;
}
#define TRIANGLE_WIDTH 6
static void
cell_draw_comment (Cell *cell, GdkGC *gc, GdkDrawable *drawable, int x1, int y1)
{
GdkPoint points [3];
int width;
gdk_gc_set_foreground (gc, &gs_red);
gdk_gc_set_background (gc, &gs_red);
width = cell->col->pixels;
y1++;
points [0].x = x1 + width;
points [0].y = y1;
points [1].x = x1 + width;
points [1].y = y1 + TRIANGLE_WIDTH;
points [2].x = x1 + width - TRIANGLE_WIDTH;
points [2].y = y1;
gdk_draw_polygon (drawable, gc, TRUE, points, 3);
gdk_gc_set_background (gc, &gs_white);
gdk_gc_set_foreground (gc, &gs_black);
}
/*
* Returns the number of columns used for the draw
*/
......@@ -1252,10 +1351,6 @@ cell_draw (Cell *cell, void *sv, GdkGC *gc, GdkDrawable *drawable, int x1, int y
} while (halign == HALIGN_FILL && total < rect.width);
}
/* Draw the comment indicator */
if (cell->comment)
cell_draw_comment (cell, gc, drawable, x1, y1);
return end_col - start_col + 1;
}
......
......@@ -24,29 +24,49 @@ typedef struct {
#define CELL_HAS_COMMENT 2
#define CELL_FORMAT_SET 4
/**
* CellComment:
*
* Holds the comment string as well as the GnomeCanvasItem marker
* that appears on the spreadsheet
*/
typedef struct {
String *comment;
int timer_tag;
void *window;
/* A list of GnomeCanvasItems, one per SheetView */
GList *realized_list;
} CellComment;
/**
* Cell:
*
* Definition of a Gnumeric Cell
*/
typedef struct {
void *sheet;
ColRowInfo *col;
ColRowInfo *row;
/* Text as entered by the user */
String *entered_text;
String *entered_text;
/* Type of the content and the actual parsed content */
ExprTree *parsed_node; /* Parse tree with the expression */
Value *value; /* Last value computed */
Style *style; /* The Cell's style */
ExprTree *parsed_node; /* Parse tree with the expression */
Value *value; /* Last value computed */
Style *style; /* The Cell's style */
StyleColor *render_color; /* If a manually entered color has been selected */
StyleColor *render_color; /* If a manually entered color has been selected */
/* computed versions of the cell contents */
String *text; /* Text rendered and displayed */
int width; /* Width of text */
int height; /* Height of text */
String *text; /* Text rendered and displayed */
int width; /* Width of text */
int height; /* Height of text */
String *comment;
int flags;
char generation;
CellComment *comment;
int flags;
char generation;
} Cell;
typedef GList CellList;
......@@ -87,6 +107,7 @@ void cell_set_format_simple (Cell *cell, char *format);
void cell_set_font (Cell *cell, char *font_name);
void cell_set_style (Cell *cell, Style *reference_style);
void cell_set_comment (Cell *cell, char *str);
void cell_comment_destroy (Cell *cell);
void cell_set_font_from_style (Cell *cell, StyleFont *style_font);
void cell_set_foreground (Cell *cell, gushort red, gushort green, gushort blue);
void cell_set_background (Cell *cell, gushort red, gushort green, gushort blue);
......@@ -94,7 +115,7 @@ void cell_set_pattern (Cell *cell, int pattern);
void cell_set_alignment (Cell *cell, int halign, int valign, int orientation, int auto_return);
void cell_set_halign (Cell *cell, StyleHAlignFlags halign);
void cell_set_rendered_text (Cell *cell, char *rendered_text);
void cell_formula_relocate (Cell *cell, int target_col, int target_row);
void cell_relocate (Cell *cell, int target_col, int target_row);
void cell_get_span (Cell *cell, int *col1, int *col2);
void cell_make_value (Cell *cell);
void cell_render_value (Cell *cell);
......
......@@ -47,7 +47,7 @@ paste_cell (Sheet *dest_sheet, Cell *new_cell, int target_col, int target_row, i
if (new_cell->parsed_node){
if (paste_flags & PASTE_FORMULAS)
cell_formula_relocate (new_cell, target_col, target_row);
cell_relocate (new_cell, target_col, target_row);
else
cell_make_value (new_cell);
}
......
......@@ -617,3 +617,39 @@ sheet_view_show_cursor (SheetView *sheet_view)
item_cursor_set_visibility (gsheet->item_cursor, TRUE);
}
#define TRIANGLE_WIDTH 6
GnomeCanvasItem *
sheet_view_create_comment_marker (SheetView *sheet_view, int col, int row)
{
GnomeCanvasPoints *points;
GnomeCanvasGroup *group;
GnomeCanvasItem *i;
int x, y;
g_return_val_if_fail (sheet_view != NULL, NULL);
g_return_val_if_fail (IS_SHEET_VIEW (sheet_view), NULL);
group = GNOME_CANVAS_GROUP (GNOME_CANVAS (sheet_view->sheet_view)->root);
points = gnome_canvas_points_new (3);
x = sheet_col_get_distance (sheet_view->sheet, 0, col+1);
y = 1+sheet_row_get_distance (sheet_view->sheet, 0, row);
points->coords [0] = x - TRIANGLE_WIDTH;
points->coords [1] = y;
points->coords [2] = x;
points->coords [3] = y;
points->coords [4] = x;
points->coords [5] = y + TRIANGLE_WIDTH;
i = gnome_canvas_item_new (
group, gnome_canvas_polygon_get_type (),
"points", points,
"fill_color", "red",
NULL);
return i;
}
......@@ -38,23 +38,28 @@ typedef struct {
GtkWidget *tip;
} SheetView;
GtkType sheet_view_get_type (void);
GtkWidget *sheet_view_new (Sheet *sheet);
GtkType sheet_view_get_type (void);
GtkWidget *sheet_view_new (Sheet *sheet);
void sheet_view_set_zoom_factor (SheetView *sheet_view, double factor);
void sheet_view_set_zoom_factor (SheetView *sheet_view,
double factor);
void sheet_view_redraw_all (SheetView *sheet_view);
void sheet_view_redraw_cell_region (SheetView *sheet_view,
int start_col, int start_row,
int end_col, int end_row);
void sheet_view_redraw_rows (SheetView *sheet_view);
void sheet_view_redraw_columns (SheetView *sheet_view);
void sheet_view_redraw_all (SheetView *sheet_view);
void sheet_view_redraw_cell_region (SheetView *sheet_view,
int start_col, int start_row,
int end_col, int end_row);
void sheet_view_redraw_rows (SheetView *sheet_view);
void sheet_view_redraw_columns (SheetView *sheet_view);
void sheet_view_hide_cursor (SheetView *sheet_view);
void sheet_view_show_cursor (SheetView *sheet_view);
void sheet_view_hide_cursor (SheetView *sheet_view);
void sheet_view_show_cursor (SheetView *sheet_view);
GnomeCanvasItem *sheet_view_create_comment_marker (SheetView *sheet_view,
int col, int row);
typedef struct {
GtkTableClass parent_class;
} SheetViewClass;
#endif /* GNUMERIC_SHEET_VIEW_H */
......@@ -617,3 +617,39 @@ sheet_view_show_cursor (SheetView *sheet_view)
item_cursor_set_visibility (gsheet->item_cursor, TRUE);
}
#define TRIANGLE_WIDTH 6
GnomeCanvasItem *
sheet_view_create_comment_marker (SheetView *sheet_view, int col, int row)
{
GnomeCanvasPoints *points;
GnomeCanvasGroup *group;
GnomeCanvasItem *i;
int x, y;
g_return_val_if_fail (sheet_view != NULL, NULL);
g_return_val_if_fail (IS_SHEET_VIEW (sheet_view), NULL);
group = GNOME_CANVAS_GROUP (GNOME_CANVAS (sheet_view->sheet_view)->root);
points = gnome_canvas_points_new (3);
x = sheet_col_get_distance (sheet_view->sheet, 0, col+1);
y = 1+sheet_row_get_distance (sheet_view->sheet, 0, row);
points->coords [0] = x - TRIANGLE_WIDTH;
points->coords [1] = y;
points->coords [2] = x;
points->coords [3] = y;
points->coords [4] = x;
points->coords [5] = y + TRIANGLE_WIDTH;
i = gnome_canvas_item_new (
group, gnome_canvas_polygon_get_type (),
"points", points,
"fill_color", "red",
NULL);
return i;
}
......@@ -38,23 +38,28 @@ typedef struct {
GtkWidget *tip;
} SheetView;
GtkType sheet_view_get_type (void);
GtkWidget *sheet_view_new (Sheet *sheet);
GtkType sheet_view_get_type (void);
GtkWidget *sheet_view_new (Sheet *sheet);
void sheet_view_set_zoom_factor (SheetView *sheet_view, double factor);
void sheet_view_set_zoom_factor (SheetView *sheet_view,
double factor);
void sheet_view_redraw_all (SheetView *sheet_view);
void sheet_view_redraw_cell_region (SheetView *sheet_view,
int start_col, int start_row,
int end_col, int end_row);
void sheet_view_redraw_rows (SheetView *sheet_view);
void sheet_view_redraw_columns (SheetView *sheet_view);
void sheet_view_redraw_all (SheetView *sheet_view);
void sheet_view_redraw_cell_region (SheetView *sheet_view,
int start_col, int start_row,
int end_col, int end_row);
void sheet_view_redraw_rows (SheetView *sheet_view);
void sheet_view_redraw_columns (SheetView *sheet_view);
void sheet_view_hide_cursor (SheetView *sheet_view);
void sheet_view_show_cursor (SheetView *sheet_view);
void sheet_view_hide_cursor (SheetView *sheet_view);
void sheet_view_show_cursor (SheetView *sheet_view);
GnomeCanvasItem *sheet_view_create_comment_marker (SheetView *sheet_view,
int col, int row);
typedef struct {
GtkTableClass parent_class;
} SheetViewClass;
#endif /* GNUMERIC_SHEET_VIEW_H */
......@@ -2276,8 +2276,7 @@ sheet_move_column (Sheet *sheet, ColRowInfo *ci, int new_column)
sheet_cell_add_to_hash (sheet, cell);
/* If there is a formula, re-render the entered text*/
if (cell->parsed_node)
cell_formula_relocate (cell, new_column, cell->row->pos);
cell_relocate (cell, new_column, cell->row->pos);
}
g_list_free (column_cells);
}
......@@ -2504,8 +2503,7 @@ sheet_shift_row (Sheet *sheet, int col, int row, int count)
/* Relocate the cell */
sheet_cell_remove (sheet, cell);
sheet_cell_add (sheet, cell, new_column, row);
if (cell->parsed_node)
cell_formula_relocate (cell, new_column, row);
cell_relocate (cell, new_column, row);
}
g_list_free (l);
......@@ -2609,8 +2607,7 @@ sheet_insert_row (Sheet *sheet, int row, int count)
sheet_cell_add_to_hash (sheet, cell);
if (cell->parsed_node)
cell_formula_relocate (cell, cell->col->pos, cell->row->pos);
cell_relocate (cell, cell->col->pos, cell->row->pos);
}
g_list_free (cell_store);
......@@ -2700,8 +2697,7 @@ sheet_delete_row (Sheet *sheet, int row, int count)
sheet_cell_add_to_hash (sheet, cell);
if (cell->parsed_node)