Commit 1da26dd1 authored by Michael Meeks's avatar Michael Meeks

Begginings of summary information,

Some Excel fixups,
More debug in obscure places,
parent 9a688898
1999-07-13 Michael Meeks <michael@edenproject.org>
* src/Makefile.am (GNUMERIC_BASE_SOURCES): add summary.[ch]
* src/workbook.c (workbook_core_new): Hook in summary info.
(workbook_do_destroy): ditto.
(deps_output): debugging hook.
* src/sheet.h: Added SummaryInfo to Workbook.
* src/summary.[ch]: Added.
1999-07-11 Michael Meeks <michael@edenproject.org>
* src/cell-draw.c (cell_draw): Added handy debug for when
cell->text is duff.
1999-07-13 Morten Welinder <terra@diku.dk>
* src/fn-string.c (gnumeric_search): Actually start search where
......
1999-07-13 Michael Meeks <michael@edenproject.org>
* src/Makefile.am (GNUMERIC_BASE_SOURCES): add summary.[ch]
* src/workbook.c (workbook_core_new): Hook in summary info.
(workbook_do_destroy): ditto.
(deps_output): debugging hook.
* src/sheet.h: Added SummaryInfo to Workbook.
* src/summary.[ch]: Added.
1999-07-11 Michael Meeks <michael@edenproject.org>
* src/cell-draw.c (cell_draw): Added handy debug for when
cell->text is duff.
1999-07-13 Morten Welinder <terra@diku.dk>
* src/fn-string.c (gnumeric_search): Actually start search where
......
1999-07-11 Michael Meeks <michael@edenproject.org>
* ms-excel-read.c (ms_excel_read_formula): Catch NULL cell->text
(ms_excel_formula_shared): Check on cell... & add position to debug.
(ms_excel_sheet_append_comment): Add paranoid blank text setting.
1999-07-13 Jody Goldberg <jgoldberg@home.com>
* ms-excel-read.c (ms_excel_read_workbook SST) : Zero sized strings use
......
......@@ -10,16 +10,21 @@ Michael
* New style support so we can do
* Colours
* Fonts etc.
* Move workbook name lists into Workbook structure.
* Sort out biff padding =>
* Sort out better versioning scheme & helper macros.
* Rationalise Missing Argument stuff ... a new value ?
* Remove silly name record in writing ( after debugging is done )
* Lookup Harvest and see if we can help with doc summary info for
searches.
* Split panes.
* Use the document summary information
* Use same XML as Office for elegance (?)
* Get font / layout sizes correct for new Print-stuff.
* Investigate VB streams, and their lengths.
* glib
* g_get_double ( instead of biff_getdouble )
* g_str_case_hash ( case insensitive g_str_hash )
Jody
* BIFF_COLINFO : Assuming a width of 36 seems to give reasonable
......
......@@ -951,10 +951,13 @@ ms_excel_set_cell_xf (ExcelSheet *sheet, Cell *cell, guint16 xfidx)
BiffXFData const *xf = ms_excel_get_xf (sheet, xfidx);
StyleColor *fore, *back, *basefore;
int back_index;
/* IF this was an error, the message was already printed. */
if (xf == NULL)
g_return_if_fail (cell->value);
if (xfidx == 0) {
/* printf ("Normal cell formatting\n"); */
return;
}
g_return_if_fail (cell->value);
......@@ -984,7 +987,7 @@ ms_excel_set_cell_xf (ExcelSheet *sheet, Cell *cell, guint16 xfidx)
xf->fill_pattern_idx);
}
#endif
if (!basefore) {
#ifndef NO_DEBUG_EXCEL
if (ms_excel_color_debug > 2) {
......@@ -1007,7 +1010,7 @@ ms_excel_set_cell_xf (ExcelSheet *sheet, Cell *cell, guint16 xfidx)
fore = basefore;
back_index = xf->pat_foregnd_col;
}
/* Use contrasting colour for background if the fill pattern is
* 0 (transparent)
*/
......@@ -1313,8 +1316,7 @@ ms_excel_sheet_insert (ExcelSheet *sheet, int xfidx,
if (text) {
sheet->blank = FALSE;
cell_set_text_simple (cell, text);
}
else
} else
cell_set_text_simple (cell, "");
ms_excel_set_cell_xf (sheet, cell, xfidx);
}
......@@ -1348,8 +1350,8 @@ ms_excel_formula_shared (BiffQuery *q, ExcelSheet *sheet, Cell *cell)
{
g_return_val_if_fail (ms_biff_query_next (q), FALSE);
if (q->ls_op != BIFF_SHRFMLA && q->ls_op != BIFF_ARRAY) {
printf ("EXCEL : unexpected record after a formula %x\n",
q->opcode);
printf ("EXCEL : unexpected record after a formula %x in '%s'\n",
q->opcode, cell_name (cell->col->pos, cell->row->pos));
return FALSE;
} else {
gboolean const is_array = (q->ls_op == BIFF_ARRAY);
......@@ -1510,8 +1512,14 @@ ms_excel_read_formula (BiffQuery *q, ExcelSheet *sheet)
* when the flag is set.
*/
cell_set_formula_tree_simple (cell, expr);
} else if (!array_elem && !ms_excel_formula_shared (q, sheet, cell))
} else if (!array_elem && !ms_excel_formula_shared (q, sheet, cell)) {
cell_set_text (cell, "Broken expr a");
g_warning ("NULL expr a");
return;
} else { /* Expr is NULL */
cell_set_text (cell, "Broken expr b");
g_warning ("NULL expr b");
}
if (is_string)
{
......@@ -1639,6 +1647,8 @@ ms_excel_sheet_append_comment (ExcelSheet *sheet, int col, int row, char *text)
{
if (text) {
Cell *cell = sheet_cell_fetch (sheet->gnum_sheet, col, row);
if (!cell->value)
cell_set_text (cell, "");
if (cell->comment && cell->comment->comment &&
cell->comment->comment->str) {
char *txt = g_strconcat (cell->comment->comment->str, text, NULL);
......
No preview for this file type
No preview for this file type
......@@ -160,6 +160,8 @@ GNUMERIC_BASE_SOURCES = \
str.h \
style.c \
style.h \
summary.c \
summary.h \
symbol.h \
symbol.c \
utils.c \
......
......@@ -147,7 +147,13 @@ cell_draw (Cell *cell, SheetView *sheet_view, GdkGC *gc, GdkDrawable *drawable,
else
do_multi_line = FALSE;
text = cell->text->str;
if (cell && cell->text && cell->text->str)
text = cell->text->str;
else {
printf ("Serious cell error at '%s'\n", cell_name (cell->col->pos,
cell->row->pos));
text = "FATAL ERROR";
}
/*
* To draw the background of the cell, we need to
......
......@@ -14,6 +14,7 @@ typedef struct _Sheet Sheet;
#include "str.h"
#include "symbol.h"
#include "cell.h"
#include "summary.h"
#define SHEET_MAX_ROWS (16 * 1024)
#define SHEET_MAX_COLS 256
......@@ -79,7 +80,10 @@ struct _Workbook {
/* The Symbol table used for naming cell ranges in the workbook */
SymbolTable *symbol_names;
/* Attached summary information */
SummaryInfo *sin;
/*
* This is used during the clipboard paste command to pass information
* to the asyncronous paste callback
......
/*
* summary.c: Summary Information management
*
* Author:
* Michael Meeks (michael@imaginator.com)
*
* (C) 1999 Michael Meeks
*/
#include <config.h>
#include <ctype.h>
#include <glib.h>
#include "summary.h"
gchar *summary_item_name[] = {
"Title",
"Subject",
"Author",
"Keywords",
"Comments",
"Saving App"
};
static SummaryItem *
summary_item_new (const gchar *name, SummaryItemType t)
{
SummaryItem *sit = g_new (SummaryItem, 1);
sit->name = g_strdup (name);
sit->type = t;
return sit;
}
SummaryItem *
summary_item_new_int (const gchar *name, gint i)
{
SummaryItem *sit = summary_item_new (name, SUMMARY_INT);
sit->v.i = i;
return sit;
}
SummaryItem *
summary_item_new_time (const gchar *name, GTimeVal t)
{
SummaryItem *sit = summary_item_new (name, SUMMARY_TIME);
sit->v.time = t;
return sit;
}
SummaryItem *
summary_item_new_string (const gchar *name, const gchar *string)
{
SummaryItem *sit = summary_item_new (name, SUMMARY_STRING);
sit->v.txt = g_strdup (string);
return sit;
}
void
summary_item_free (SummaryItem *sit)
{
g_return_if_fail (sit);
switch (sit->type)
{
case SUMMARY_STRING:
g_free (sit->v.txt);
sit->v.txt = NULL;
break;
case SUMMARY_INT:
case SUMMARY_TIME:
break;
default:
g_warning ("unknown / unimplemented summary type");
break;
}
g_free (sit);
}
void
summary_item_dump (SummaryItem *sit)
{
g_return_if_fail (sit);
g_return_if_fail (sit->name);
printf (" '%s' = ", sit->name);
switch (sit->type)
{
case SUMMARY_STRING:
printf (" '%s'\n", sit->v.txt);
break;
case SUMMARY_INT:
printf (" %d\n", sit->v.i);
break;
case SUMMARY_TIME:
printf (" Unimplemented\n");
break;
default:
g_warning ("unknown / unimplemented summary type");
break;
}
}
static gint
g_str_case_equal (gconstpointer v, gconstpointer v2)
{
return g_strcasecmp ((const gchar*) v, (const gchar*)v2) == 0;
}
/* a char* hash function from ASU */
static guint
g_str_case_hash (gconstpointer v)
{
const char *s = (char*)v;
const char *p;
guint h=0, g;
for(p = s; *p != '\0'; p += 1) {
h = ( h << 4 ) + tolower (*p);
if ( ( g = h & 0xf0000000 ) ) {
h = h ^ (g >> 24);
h = h ^ g;
}
}
return h /* % M */;
}
SummaryInfo *
summary_info_new (void)
{
SummaryInfo *sin = g_new (SummaryInfo, 1);
sin->names = g_hash_table_new (g_str_case_hash,
g_str_case_equal);
return sin;
}
SummaryItem *
summary_info_get (SummaryInfo *sin, char *name)
{
g_return_val_if_fail (sin != NULL, NULL);
g_return_val_if_fail (name != NULL, NULL);
g_return_val_if_fail (sin->names != NULL, NULL);
return g_hash_table_lookup (sin->names, name);
}
void
summary_info_add (SummaryInfo *sin, SummaryItem *sit)
{
g_return_if_fail (sin != NULL);
g_return_if_fail (sit != NULL);
g_return_if_fail (sit->name != NULL);
g_return_if_fail (sin->names != NULL);
g_hash_table_insert (sin->names, sit->name, sit);
}
void
summary_info_default (SummaryInfo *sin)
{
SummaryItem *sit;
g_return_if_fail (sin != NULL);
sit = summary_item_new_string (summary_item_name [SUMMARY_I_AUTHOR],
g_get_real_name ());
summary_info_add (sin, sit);
sit = summary_item_new_string (summary_item_name [SUMMARY_I_APP],
g_get_prgname ());
summary_info_add (sin, sit);
}
static void
free_item (gchar *key, SummaryItem *item, void *dummy)
{
g_return_if_fail (item);
summary_item_free (item);
}
void
summary_info_free (SummaryInfo *sin)
{
g_return_if_fail (sin != NULL);
g_return_if_fail (sin->names != NULL);
g_hash_table_foreach (sin->names, (GHFunc)free_item,
NULL);
g_hash_table_destroy (sin->names);
sin->names = NULL;
}
static void
dump_item (gchar *key, SummaryItem *item, void *dummy)
{
summary_item_dump (item);
}
void
summary_info_dump (SummaryInfo *sin)
{
g_return_if_fail (sin != NULL);
g_return_if_fail (sin->names != NULL);
printf ("summary information ...\n");
g_hash_table_foreach (sin->names, (GHFunc)dump_item,
NULL);
printf ("... end of summary information\n");
}
/*
* summary.h: Summary Information management
*
* Author:
* Michael Meeks (michael@imaginator.com)
*
* (C) 1999 Michael Meeks
*/
typedef struct _SummaryItem SummaryItem;
typedef struct _SummaryInfo SummaryInfo;
typedef enum { SUMMARY_STRING, SUMMARY_INT, SUMMARY_TIME } SummaryItemType;
typedef enum { SUMMARY_I_TITLE,
SUMMARY_I_SUBJECT,
SUMMARY_I_AUTHOR,
SUMMARY_I_KEYWORDS,
SUMMARY_I_COMMENTS,
SUMMARY_I_APP,
SUMMARY_I_MAX } SummaryItemBuiltin;
/* Builtin names: use summary_item_name[SUMMARY_I_TITLE] */
gchar *summary_item_name[SUMMARY_I_MAX];
/*
* Each Summary Item has a name it is hashed on,
* and a value.
*/
struct _SummaryItem {
SummaryItemType type;
gchar *name;
union {
gchar *txt;
GTimeVal time;
gint i;
} v;
};
SummaryItem *summary_item_new_int (const gchar *name, gint i);
SummaryItem *summary_item_new_time (const gchar *name, GTimeVal t);
SummaryItem *summary_item_new_string (const gchar *name, const gchar *string);
void summary_item_free (SummaryItem *sit);
struct _SummaryInfo {
GHashTable *names;
};
SummaryInfo *summary_info_new (void);
SummaryItem *summary_info_get (SummaryInfo *sin, char *name);
void summary_info_add (SummaryInfo *sin, SummaryItem *sit);
void summary_info_default (SummaryInfo *sin);
void summary_info_dump (SummaryInfo *sin);
void summary_info_free (SummaryInfo *sin);
......@@ -244,6 +244,9 @@ workbook_do_destroy (Workbook *wb)
/* First do all deletions that leave the workbook in a working
order. */
summary_info_free (wb->sin);
wb->sin = NULL;
/*
* Erase all cells. In particular this removes all links between
* sheets.
......@@ -1307,6 +1310,8 @@ deps_output (GtkWidget *widget, Workbook *wb)
Cell *cell;
GList *list;
summary_info_dump (wb->sin);
if (!sheet_selection_first_range (
sheet, &dummy, &dummy, &col, &row, &dummy, &dummy)){
gnumeric_notice (
......@@ -1600,6 +1605,8 @@ workbook_core_new (void)
wb->print_info = print_info_new ();
wb->symbol_names = symbol_table_new ();
wb->max_iterations = 1;
wb->sin = summary_info_new ();
summary_info_default (wb->sin);
/* Set the default operation to be performed over selections */
wb->auto_expr = NULL;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment