Commit f92031a3 authored by Michael Meeks's avatar Michael Meeks

Silly bits I forgot and some more heavy duty mangling

parent c399543d
......@@ -137,9 +137,9 @@ BC_R(ai)(ExcelChartHandler const *handle,
guint16 const flags = MS_OLE_GET_GUINT16 (q->data + 2);
guint16 const fmt_index = MS_OLE_GET_GUINT16 (q->data + 4);
guint16 const length = MS_OLE_GET_GUINT16 (q->data + 6);
StyleFormat * fmt = biff_format_data_lookup (s->wb, fmt_index);
/* StyleFormat * fmt = biff_format_data_lookup (s->wb, fmt_index);*/
printf ("Format = '%s';\n", fmt->format);
/* printf ("Format = '%s';\n", fmt->format);*/
switch (id) {
case 0 : puts ("Linking title or text"); break;
......@@ -858,9 +858,9 @@ BC_R(ifmt)(ExcelChartHandler const *handle,
ExcelChartState *s, BiffQuery *q)
{
guint16 const fmt_index = MS_OLE_GET_GUINT16 (q->data);
StyleFormat * fmt = biff_format_data_lookup (s->wb, fmt_index);
/* StyleFormat * fmt = biff_format_data_lookup (s->wb, fmt_index);
printf ("Format = '%s';\n", fmt->format);
printf ("Format = '%s';\n", fmt->format);*/
return FALSE;
}
......
......@@ -527,7 +527,7 @@ char *excel_builtin_formats[EXCEL_BUILTIN_FORMAT_LEN] = {
/* 0x31 */ "@"
};
StyleFormat *
/*StyleFormat *
biff_format_data_lookup (ExcelWorkbook *wb, guint16 idx)
{
char *ans = NULL;
......@@ -550,7 +550,7 @@ biff_format_data_lookup (ExcelWorkbook *wb, guint16 idx)
return style_format_new (ans);
else
return NULL;
}
}*/
static gboolean
biff_format_data_destroy (gpointer key, BiffFormatData *d, gpointer userdata)
......@@ -872,7 +872,7 @@ ms_excel_palette_destroy (ExcelPalette *pal)
typedef struct _BiffXFData {
guint16 font_idx;
guint16 format_idx;
StyleFormat *style_format;
/* StyleFormat *style_format;*/
eBiff_hidden hidden;
eBiff_locked locked;
eBiff_xftype xftype; /* -- Very important field... */
......@@ -1074,8 +1074,8 @@ biff_xf_data_new (ExcelWorkbook *wb, BiffQuery *q, eBiff_version ver)
xf->font_idx = MS_OLE_GET_GUINT16 (q->data);
xf->format_idx = MS_OLE_GET_GUINT16 (q->data + 2);
xf->style_format = (xf->format_idx > 0)
? biff_format_data_lookup (wb, xf->format_idx) : NULL;
xf->style_format = NULL; /*(xf->format_idx > 0)
? biff_format_data_lookup (wb, xf->format_idx) : NULL;*/
data = MS_OLE_GET_GUINT16 (q->data + 4);
xf->locked = (data & 0x0001) ? eBiffLLocked : eBiffLUnlocked;
......
......@@ -112,8 +112,8 @@ extern ExprTree* biff_name_data_get_name (ExcelSheet *sheet, int idx);
extern BIFF_BOF_DATA * ms_biff_bof_data_new (BiffQuery * q);
extern void ms_biff_bof_data_destroy (BIFF_BOF_DATA * data);
extern StyleFormat * biff_format_data_lookup (ExcelWorkbook *wb, guint16 idx);
extern StyleColor * ms_excel_palette_get (ExcelPalette *pal, guint idx,
/*extern StyleFormat *biff_format_data_lookup (ExcelWorkbook *wb, guint16 idx); */
extern StyleColor *ms_excel_palette_get (ExcelPalette *pal, guint idx,
StyleColor *contrast);
/* A utility routine to handle unexpected BIFF records */
......
......@@ -81,8 +81,8 @@ paste_cell_flags (Sheet *dest_sheet, int target_col, int target_row,
cell = sheet_cell_get (dest_sheet,
target_col,
target_row);
if (cell && c_copy->u.cell)
cell_set_style (cell, c_copy->u.cell->style);
/* if (cell && c_copy->u.cell)
cell_set_style (cell, c_copy->u.cell->style); */
} else {
Cell *new_cell;
......
......@@ -586,7 +586,7 @@ create_background_radio (GtkWidget *prop_win)
static GtkWidget *
create_coloring_page (GtkWidget *prop_win, CellList *cells)
{
GtkTable *t;
/* GtkTable *t;
GtkWidget *fore, *back;
int e = GTK_FILL | GTK_EXPAND;
......@@ -600,14 +600,14 @@ create_coloring_page (GtkWidget *prop_win, CellList *cells)
fore = create_foreground_radio (prop_win);
back = create_background_radio (prop_win);
*/
/* Check if all cells have the same properties */
/*
* FIXME: This should check the cells *AND* the
* style regions to figure out what to check and what
* not, right now this is broken in that regard
*/
if (cells){
/* if (cells){
Cell *cell = (Cell *) cells->data;
fore_red = cell->style->fore_color->color.red;
......@@ -617,7 +617,7 @@ create_coloring_page (GtkWidget *prop_win, CellList *cells)
back_red = cell->style->back_color->color.red;
back_green = cell->style->back_color->color.green;
back_blue = cell->style->back_color->color.blue;
*/
/*
* What follows is ugly: I believe we should use the method illustrated
* in the following two lines:
......@@ -626,7 +626,7 @@ create_coloring_page (GtkWidget *prop_win, CellList *cells)
* instead of what we are using, but it just does not work (even though the
* flag is being set/cleared cell by cell and style-wise in function apply_coloring_format)
*/
if (fore_red == 0 &&
/* if (fore_red == 0 &&
fore_green == 0 &&
fore_blue == 0){
foreground_flag = 0;
......@@ -639,13 +639,13 @@ create_coloring_page (GtkWidget *prop_win, CellList *cells)
background_flag = 0;
} else {
background_flag = STYLE_BACK_COLOR;
}
}*/
/*
* First scan is to find out whether all cells have the same foreground color,
* second one is the equivalent for background
*/
for (ok_fore = 1, l = cells; l; l = l->next){
/* for (ok_fore = 1, l = cells; l; l = l->next){
Cell *cell = l->data;
if (cell->style->fore_color->color.red != fore_red ||
......@@ -706,7 +706,8 @@ create_coloring_page (GtkWidget *prop_win, CellList *cells)
gtk_widget_show_all (GTK_WIDGET (t));
return GTK_WIDGET (t);
return GTK_WIDGET (t); */
return NULL;
}
static void
......@@ -840,7 +841,7 @@ static struct {
static void
cell_properties_apply (GtkObject *w, int page, CellList *cells)
{
Sheet *sheet;
/* Sheet *sheet;
Style *style;
GList *l;
int i;
......@@ -850,7 +851,7 @@ cell_properties_apply (GtkObject *w, int page, CellList *cells)
sheet = (Sheet *) gtk_object_get_data (w, "Sheet");
/* Now, let each property page apply their style */
* Now, let each property page apply their style *
style = style_new_empty ();
style->valid_flags = 0;
......@@ -867,7 +868,7 @@ cell_properties_apply (GtkObject *w, int page, CellList *cells)
cell_thaw_redraws ();
/* Attach this style to all of the selections */
* Attach this style to all of the selections *
for (l = sheet->selections; l; l = l->next){
SheetSelection *ss = l->data;
......@@ -876,7 +877,7 @@ cell_properties_apply (GtkObject *w, int page, CellList *cells)
ss->start_col, ss->start_row,
ss->end_col, ss->end_row,
style);
}
}*/
}
static void
......
......@@ -586,7 +586,7 @@ create_background_radio (GtkWidget *prop_win)
static GtkWidget *
create_coloring_page (GtkWidget *prop_win, CellList *cells)
{
GtkTable *t;
/* GtkTable *t;
GtkWidget *fore, *back;
int e = GTK_FILL | GTK_EXPAND;
......@@ -600,14 +600,14 @@ create_coloring_page (GtkWidget *prop_win, CellList *cells)
fore = create_foreground_radio (prop_win);
back = create_background_radio (prop_win);
*/
/* Check if all cells have the same properties */
/*
* FIXME: This should check the cells *AND* the
* style regions to figure out what to check and what
* not, right now this is broken in that regard
*/
if (cells){
/* if (cells){
Cell *cell = (Cell *) cells->data;
fore_red = cell->style->fore_color->color.red;
......@@ -617,7 +617,7 @@ create_coloring_page (GtkWidget *prop_win, CellList *cells)
back_red = cell->style->back_color->color.red;
back_green = cell->style->back_color->color.green;
back_blue = cell->style->back_color->color.blue;
*/
/*
* What follows is ugly: I believe we should use the method illustrated
* in the following two lines:
......@@ -626,7 +626,7 @@ create_coloring_page (GtkWidget *prop_win, CellList *cells)
* instead of what we are using, but it just does not work (even though the
* flag is being set/cleared cell by cell and style-wise in function apply_coloring_format)
*/
if (fore_red == 0 &&
/* if (fore_red == 0 &&
fore_green == 0 &&
fore_blue == 0){
foreground_flag = 0;
......@@ -639,13 +639,13 @@ create_coloring_page (GtkWidget *prop_win, CellList *cells)
background_flag = 0;
} else {
background_flag = STYLE_BACK_COLOR;
}
}*/
/*
* First scan is to find out whether all cells have the same foreground color,
* second one is the equivalent for background
*/
for (ok_fore = 1, l = cells; l; l = l->next){
/* for (ok_fore = 1, l = cells; l; l = l->next){
Cell *cell = l->data;
if (cell->style->fore_color->color.red != fore_red ||
......@@ -706,7 +706,8 @@ create_coloring_page (GtkWidget *prop_win, CellList *cells)
gtk_widget_show_all (GTK_WIDGET (t));
return GTK_WIDGET (t);
return GTK_WIDGET (t); */
return NULL;
}
static void
......@@ -840,7 +841,7 @@ static struct {
static void
cell_properties_apply (GtkObject *w, int page, CellList *cells)
{
Sheet *sheet;
/* Sheet *sheet;
Style *style;
GList *l;
int i;
......@@ -850,7 +851,7 @@ cell_properties_apply (GtkObject *w, int page, CellList *cells)
sheet = (Sheet *) gtk_object_get_data (w, "Sheet");
/* Now, let each property page apply their style */
* Now, let each property page apply their style *
style = style_new_empty ();
style->valid_flags = 0;
......@@ -867,7 +868,7 @@ cell_properties_apply (GtkObject *w, int page, CellList *cells)
cell_thaw_redraws ();
/* Attach this style to all of the selections */
* Attach this style to all of the selections *
for (l = sheet->selections; l; l = l->next){
SheetSelection *ss = l->data;
......@@ -876,7 +877,7 @@ cell_properties_apply (GtkObject *w, int page, CellList *cells)
ss->start_col, ss->start_row,
ss->end_col, ss->end_row,
style);
}
}*/
}
static void
......
......@@ -653,14 +653,14 @@ static char *help_text = {
static Value *
gnumeric_text (FunctionEvalInfo *ei, Value **args)
{
StyleFormat *format = style_format_new (args[1]->v.str->str);
/* StyleFormat *format = style_format_new (args[1]->v.str->str);
Value *res, *tmp = NULL;
Value const *arg = args[0];
gboolean ok = FALSE;
/* FIXME FIXME FIXME : All this should really be moved
* FIXME FIXME FIXME : All this should really be moved
* into value_get_as_float
*/
*
if (arg->type == VALUE_CELLRANGE || arg->type == VALUE_ARRAY) {
if (value_area_get_height (&ei->pos, arg) == 1 &&
value_area_get_width (&ei->pos, arg) == 1)
......@@ -686,8 +686,8 @@ gnumeric_text (FunctionEvalInfo *ei, Value **args)
if (tmp != NULL)
value_release (tmp);
style_format_unref (format);
return res;
style_format_unref (format);*/
return value_new_string ("Wibble");
}
......
......@@ -37,6 +37,8 @@
#include "dates.h"
#include "utils.h"
#if 0
/* Points to the locale information for number display */
static struct lconv *lc;
......@@ -1084,3 +1086,7 @@ format_value (StyleFormat *format, const Value *value, StyleColor **color)
return v;
}
#endif
......@@ -4,10 +4,10 @@
#include "style.h"
#include "expr.h"
void format_destroy (StyleFormat *format);
/*void format_destroy (StyleFormat *format);
void format_compile (StyleFormat *format);
gchar *format_value (StyleFormat *format, const Value *value, StyleColor **color);
*/
void format_color_init (void);
void format_color_shutdown (void);
#endif /* GNUMERIC_FORMAT_H */
......@@ -653,14 +653,14 @@ static char *help_text = {
static Value *
gnumeric_text (FunctionEvalInfo *ei, Value **args)
{
StyleFormat *format = style_format_new (args[1]->v.str->str);
/* StyleFormat *format = style_format_new (args[1]->v.str->str);
Value *res, *tmp = NULL;
Value const *arg = args[0];
gboolean ok = FALSE;
/* FIXME FIXME FIXME : All this should really be moved
* FIXME FIXME FIXME : All this should really be moved
* into value_get_as_float
*/
*
if (arg->type == VALUE_CELLRANGE || arg->type == VALUE_ARRAY) {
if (value_area_get_height (&ei->pos, arg) == 1 &&
value_area_get_width (&ei->pos, arg) == 1)
......@@ -686,8 +686,8 @@ gnumeric_text (FunctionEvalInfo *ei, Value **args)
if (tmp != NULL)
value_release (tmp);
style_format_unref (format);
return res;
style_format_unref (format);*/
return value_new_string ("Wibble");
}
......
......@@ -24,7 +24,7 @@ typedef struct {
int col, row, col_span;
int pixel_span;
Style *style;
RenderInfo *style;
} ItemEdit;
GtkType item_edit_get_type (void);
......
......@@ -220,15 +220,15 @@ item_grid_draw_cell (GdkDrawable *drawable, ItemGrid *item_grid, Cell *cell, int
if (cell->render_color)
gdk_gc_set_foreground (gc, &cell->render_color->color);
else {
if (cell->style->valid_flags & STYLE_FORE_COLOR)
/* if (cell->style->valid_flags & STYLE_FORE_COLOR)*/
gdk_gc_set_foreground (gc, &cell->style->fore_color->color);
}
if (cell->style->valid_flags & STYLE_BACK_COLOR){
/* if (cell->style->valid_flags & STYLE_BACK_COLOR)*/{
gdk_gc_set_background (gc, &cell->style->back_color->color);
}
#if 0
if ((cell->style->valid_flags & STYLE_PATTERN) && cell->style->pattern){
#if 0
GnomeCanvasItem *item = GNOME_CANVAS_ITEM (item_grid);
......@@ -248,7 +248,7 @@ item_grid_draw_cell (GdkDrawable *drawable, ItemGrid *item_grid, Cell *cell, int
gdk_gc_set_fill (gc, GDK_SOLID);
gdk_gc_set_stipple (gc, NULL);
}
#endif
count = cell_draw (cell, item_grid->sheet_view, gc, drawable, x1, y1);
return count;
......
......@@ -75,7 +75,7 @@ gnumeric_main (void *closure, int argc, char *argv [])
string_init ();
format_match_init ();
style_init ();
render_init ();
format_color_init ();
cursors_init ();
global_symbol_init ();
......@@ -119,7 +119,7 @@ gnumeric_main (void *closure, int argc, char *argv [])
cursors_shutdown ();
format_match_finish ();
format_color_shutdown ();
style_shutdown ();
render_shutdown ();
gnome_config_drop_all ();
}
......
......@@ -20,6 +20,8 @@
#define CELL_HEIGHT(cell) CELL_DIM(cell,row)
#define CELL_WIDTH(cell) CELL_DIM(cell,col)
#if 0
static void
print_border (GnomePrintContext *pc, double x1, double y1, double x2, double y2, StyleBorder *b, int idx)
{
......@@ -356,6 +358,7 @@ print_cell (GnomePrintContext *context, Cell *cell, double x, double y)
x + cell->col->margin_a_pt,
y + cell->row->margin_b_pt);
}
#endif
void
print_cell_range (GnomePrintContext *context,
......@@ -364,6 +367,7 @@ print_cell_range (GnomePrintContext *context,
int end_col, int end_row,
double base_x, double base_y)
{
#if 0
ColRowInfo *ci, *ri;
int row, col;
double x, y;
......@@ -403,8 +407,10 @@ vline (GnomePrintContext *context, double x, double y1, double y2)
gnome_print_moveto (context, x, y1);
gnome_print_lineto (context, x, y2);
gnome_print_stroke (context);
#endif
}
#if 0
static void
hline (GnomePrintContext *context, double x1, double x2, double y)
{
......@@ -412,6 +418,7 @@ hline (GnomePrintContext *context, double x1, double x2, double y)
gnome_print_lineto (context, x2, y);
gnome_print_stroke (context);
}
#endif
void
print_cell_grid (GnomePrintContext *context,
......@@ -421,6 +428,7 @@ print_cell_grid (GnomePrintContext *context,
double base_x, double base_y,
double width, double height)
{
#if 0
int col, row;
double x, y;
......@@ -451,6 +459,7 @@ print_cell_grid (GnomePrintContext *context,
hline (context, base_x, base_x + width, y);
y -= ri->units + ri->margin_a_pt + ri->margin_b_pt;
}
#endif
}
......
......@@ -193,7 +193,7 @@ sheet_new (Workbook *wb, const char *name)
sheet->cell_hash = g_hash_table_new (cell_hash, cell_compare);
sheet_style = style_new ();
sheet_style = style_new (NULL);
sheet_style_attach (sheet, 0, 0, SHEET_MAX_COLS-1, SHEET_MAX_ROWS-1, sheet_style);
sheet_init_default_styles (sheet);
......@@ -280,8 +280,10 @@ zoom_cell_style (Sheet *sheet, int col, int row, Cell *cell, void *user_data)
if (cell->style->font->scale == sheet->last_zoom_factor_used)
return NULL;
/* HACK.
sf = style_font_new_from (cell->style->font, sheet->last_zoom_factor_used);
cell_set_font_from_style (cell, sf);
*/
return NULL;
}
......@@ -324,17 +326,22 @@ sheet_set_zoom_factor (Sheet *sheet, double factor)
/*
* Scale the internal font styles
*/
/* HACK: Should be the RenderInfo hash */
for (l = sheet->style_list; l; l = l->next){
StyleRegion *sr = l->data;
Style *style = sr->style;
StyleFont *scaled;
StyleElement e;
e.type = STYLE_FONT_SCALE;
e.u.font.scale = factor;
if (!(style->valid_flags & STYLE_FONT))
style_set (style, e);
/* if (!(style->valid_flags & STYLE_FONT))
continue;
scaled = style_font_new_from (style->font, factor);
style_font_unref (style->font);
style->font = scaled;
style->font = scaled;*/
}
}
......@@ -893,12 +900,12 @@ sheet_set_text (Sheet *sheet, int col, int row, const char *str)
* that we would other wise actually set a "0" format
* for integers and that it would stick.
*/
} else if (format_match (text, &v, &format)) {
} /* HACK else if (format_match (text, &v, &format)) {
if (!CELL_IS_FORMAT_SET (cell))
cell_set_format_simple (cell, format);
cell_set_value (cell, value_new_float (v));
text_set = TRUE;
}
}*/
}
if (!text_set)
......@@ -1083,12 +1090,12 @@ sheet_update_controls (Sheet *sheet)
* in the range to compute the values
*/
SheetSelection *ss = sheet->selections->data;
Style *style;
RenderInfo *style;
style = sheet_style_compute (sheet, ss->start_col, ss->start_row, NULL);
bold_first = style->font->is_bold;
italic_first = style->font->is_italic;
style_destroy (style);
/* style_destroy (style);*/
/* Initialize the pointer that is going to be used next */
l = cells;
......@@ -2288,8 +2295,8 @@ sheet_cell_add (Sheet *sheet, Cell *cell, int col, int row)
cell->style = sheet_style_compute (sheet, col, row, &flags);
if (flags & STYLE_FORMAT)
cell->flags |= CELL_FORMAT_SET;
/* if (flags & STYLE_FORMAT)
cell->flags |= CELL_FORMAT_SET;*/
}
cell_calc_dimensions (cell);
......@@ -2783,7 +2790,7 @@ sheet_selection_clear_comments (Sheet *sheet)
static Value *
clear_cell_format (Sheet *sheet, int col, int row, Cell *cell, void *user_data)
{
cell_set_format (cell, "General");
/* cell_set_format (cell, "General");*/
return NULL;
}
......@@ -3614,6 +3621,13 @@ sheet_style_attach (Sheet *sheet, int start_col, int start_row, int end_col, int
sheet->style_list = g_list_prepend (sheet->style_list, sr);
}
void
sheet_style_attach_cell (Cell *cell, Style *style)
{
sheet_style_attach (cell->sheet, cell->col->pos, cell->row->pos,
cell->col->pos, cell->row->pos, style);
}
/**
* sheet_style_compute:
* @sheet: Which sheet we are looking up
......@@ -3623,10 +3637,10 @@ sheet_style_attach (Sheet *sheet, int start_col, int start_row, int end_col, int
* the cell has which are not part of the
* default style.
*/
Style *
RenderInfo *
sheet_style_compute (Sheet *sheet, int col, int row, int *non_default)
{
GList *l;
GList *l, *a=NULL;
Style *style;
g_return_val_if_fail (sheet != NULL, NULL);
g_return_val_if_fail (IS_SHEET (sheet), NULL);
......@@ -3634,7 +3648,14 @@ sheet_style_compute (Sheet *sheet, int col, int row, int *non_default)
style = style_new_empty ();
/* Look in the styles applied to the sheet */
for (l = sheet->style_list; l; l = l->next){
for (l = sheet->style_list; l; l = l->next) {
StyleRegion *sr = l->data;
if (range_contains (&sr->range, col, row))
a = g_list_append (a, l);
l = g_list_next (l);
}
return render_merge (a);
/* for (l = sheet->style_list; l; l = l->next){
StyleRegion *sr = l->data;
int is_default_style = l->next == NULL;
int flags;
......@@ -3656,7 +3677,7 @@ sheet_style_compute (Sheet *sheet, int col, int row, int *non_default)
}
g_warning ("Strange, no style available here\n");
return style_new ();
return style_new ();*/
}
void
......
......@@ -4,11 +4,6 @@
typedef struct _Workbook Workbook;
typedef struct _Sheet Sheet;
typedef struct {
int start_col, start_row;
int end_col, end_row;
} Range;
typedef struct {
Sheet *sheet;
int col, row;
......@@ -41,19 +36,13 @@ typedef struct {
#include "symbol.h"
#include "cell.h"
#include "summary.h"
#include "style.h"
#define SHEET_MAX_ROWS (16 * 1024)
#define SHEET_MAX_COLS 256
typedef GList ColStyleList;
gboolean range_contains (Range *range, int col, int row);
typedef struct {
Range range;
Style *style;
} StyleRegion;
/* Forward declaration */
struct _PrintInformation;
typedef struct _PrintInformation PrintInformation;
......@@ -78,9 +67,6 @@ struct _Workbook {
String *auto_expr_desc;
GnomeCanvasItem *auto_expr_label;
/* Styles */
Style style;
/* The sheets */