Commit beff1ee5 authored by Miguel de Icaza's avatar Miguel de Icaza Committed by Arturo Espinosa

Save colors. Save pattern. (readXmlStyle): return the value. Start with an

1998-09-22  Miguel de Icaza  <miguel@nuclecu.unam.mx>

	* src/xml-io.c (writeXmlStyle): Save colors.  Save pattern.
	(readXmlStyle): return the value.  Start with an empty style. Load
	font.
	(xmlGetColorValue): Use the style color allocation routines.
	(readXmlCell): Load style. Merge styles if an element is missing.
	Trim the cell tail content (spaces and newlines at the end).
	Changed the use of all hash tables to use strings instead of
	pointers.
	(readXmlObject); Call sheet_object_realize on the object loaded.

	* src/item-cursor.c (item_cursor_autofill_event): Commted out
	debugging code.

	* src/sheet-autofill.c (string_has_number): Bug fix: it was
	assuming every string had a number at the end.

	* src/workbook.c (workbook_new): Handle to destroy signal.  Add
	Close option to file menu.

	* src/style.c, src/style.h (border_equal): Colors in the
	BorderStyler are now stored as StyleColors.

	* src/sheet.c (sheet_shift_col): Small buglette fixes: we need to
	advance our row walker here ;-)
	(sheet_shift_row): Same error was here.
parent 3659f22d
1998-09-22 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/xml-io.c (writeXmlStyle): Save colors. Save pattern.
(readXmlStyle): return the value. Start with an empty style. Load
font.
(xmlGetColorValue): Use the style color allocation routines.
(readXmlCell): Load style. Merge styles if an element is missing.
Trim the cell tail content (spaces and newlines at the end).
Changed the use of all hash tables to use strings instead of
pointers.
(readXmlObject); Call sheet_object_realize on the object loaded.
* src/item-cursor.c (item_cursor_autofill_event): Commted out
debugging code.
* src/sheet-autofill.c (string_has_number): Bug fix: it was
assuming every string had a number at the end.
* src/workbook.c (workbook_new): Handle to destroy signal. Add
Close option to file menu.
* src/style.c, src/style.h (border_equal): Colors in the
BorderStyler are now stored as StyleColors.
* src/sheet.c (sheet_shift_col): Small buglette fixes: we need to
advance our row walker here ;-)
(sheet_shift_row): Same error was here.
* src/format.c (format_value): Handle NaN/infinite numbers
* src/gnumeric-sheet.c (gnumeric_sheet_key): Last fix was a little
too good: Forward the keystroke events if the user is already
editing a cell.
* src/gnumeric-sheet.c (gnumeric_sheet_key): Do not process events
that might be catched by the menubar.
......
1998-09-22 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/xml-io.c (writeXmlStyle): Save colors. Save pattern.
(readXmlStyle): return the value. Start with an empty style. Load
font.
(xmlGetColorValue): Use the style color allocation routines.
(readXmlCell): Load style. Merge styles if an element is missing.
Trim the cell tail content (spaces and newlines at the end).
Changed the use of all hash tables to use strings instead of
pointers.
(readXmlObject); Call sheet_object_realize on the object loaded.
* src/item-cursor.c (item_cursor_autofill_event): Commted out
debugging code.
* src/sheet-autofill.c (string_has_number): Bug fix: it was
assuming every string had a number at the end.
* src/workbook.c (workbook_new): Handle to destroy signal. Add
Close option to file menu.
* src/style.c, src/style.h (border_equal): Colors in the
BorderStyler are now stored as StyleColors.
* src/sheet.c (sheet_shift_col): Small buglette fixes: we need to
advance our row walker here ;-)
(sheet_shift_row): Same error was here.
* src/format.c (format_value): Handle NaN/infinite numbers
* src/gnumeric-sheet.c (gnumeric_sheet_key): Last fix was a little
too good: Forward the keystroke events if the user is already
editing a cell.
* src/gnumeric-sheet.c (gnumeric_sheet_key): Do not process events
that might be catched by the menubar.
......
1998-09-22 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/xml-io.c (writeXmlStyle): Save colors. Save pattern.
(readXmlStyle): return the value. Start with an empty style. Load
font.
(xmlGetColorValue): Use the style color allocation routines.
(readXmlCell): Load style. Merge styles if an element is missing.
Trim the cell tail content (spaces and newlines at the end).
Changed the use of all hash tables to use strings instead of
pointers.
(readXmlObject); Call sheet_object_realize on the object loaded.
* src/item-cursor.c (item_cursor_autofill_event): Commted out
debugging code.
* src/sheet-autofill.c (string_has_number): Bug fix: it was
assuming every string had a number at the end.
* src/workbook.c (workbook_new): Handle to destroy signal. Add
Close option to file menu.
* src/style.c, src/style.h (border_equal): Colors in the
BorderStyler are now stored as StyleColors.
* src/sheet.c (sheet_shift_col): Small buglette fixes: we need to
advance our row walker here ;-)
(sheet_shift_row): Same error was here.
* src/format.c (format_value): Handle NaN/infinite numbers
* src/gnumeric-sheet.c (gnumeric_sheet_key): Last fix was a little
too good: Forward the keystroke events if the user is already
editing a cell.
* src/gnumeric-sheet.c (gnumeric_sheet_key): Do not process events
that might be catched by the menubar.
......
1998-09-22 Miguel de Icaza <miguel@nuclecu.unam.mx>
* src/xml-io.c (writeXmlStyle): Save colors. Save pattern.
(readXmlStyle): return the value. Start with an empty style. Load
font.
(xmlGetColorValue): Use the style color allocation routines.
(readXmlCell): Load style. Merge styles if an element is missing.
Trim the cell tail content (spaces and newlines at the end).
Changed the use of all hash tables to use strings instead of
pointers.
(readXmlObject); Call sheet_object_realize on the object loaded.
* src/item-cursor.c (item_cursor_autofill_event): Commted out
debugging code.
* src/sheet-autofill.c (string_has_number): Bug fix: it was
assuming every string had a number at the end.
* src/workbook.c (workbook_new): Handle to destroy signal. Add
Close option to file menu.
* src/style.c, src/style.h (border_equal): Colors in the
BorderStyler are now stored as StyleColors.
* src/sheet.c (sheet_shift_col): Small buglette fixes: we need to
advance our row walker here ;-)
(sheet_shift_row): Same error was here.
* src/format.c (format_value): Handle NaN/infinite numbers
* src/gnumeric-sheet.c (gnumeric_sheet_key): Last fix was a little
too good: Forward the keystroke events if the user is already
editing a cell.
* src/gnumeric-sheet.c (gnumeric_sheet_key): Do not process events
that might be catched by the menubar.
......
......@@ -648,10 +648,12 @@ item_cursor_autofill_event (GnomeCanvasItem *item, GdkEvent *event)
gnome_canvas_item_ungrab (item, event->button.time);
#if DEBUG_AUTOFILL
g_warning ("Temporary flush after ungrap here\n");
gnome_canvas_update_now (canvas);
gdk_flush ();
#endif
if (!((item_cursor->end_col == item_cursor->base_col + item_cursor->base_cols) &&
(item_cursor->end_row == item_cursor->base_row + item_cursor->base_rows))){
......
......@@ -159,6 +159,8 @@ string_has_number (String *str, int *num, int *pos)
if (p == str->str)
return FALSE;
if (!isdigit (*p))
return FALSE;
p++;
*num = atoi (p);
*pos = p - str->str;
......
......@@ -109,10 +109,10 @@ style_font_unref (StyleFont *sf)
}
StyleBorder *
style_border_new (StyleBorderType left, StyleBorderType right,
StyleBorderType top, StyleBorderType bottom,
GdkColor *left_color, GdkColor *right_color,
GdkColor *top_color, GdkColor *bottom_color)
style_border_new (StyleBorderType left, StyleBorderType right,
StyleBorderType top, StyleBorderType bottom,
StyleColor *left_color, StyleColor *right_color,
StyleColor *top_color, StyleColor *bottom_color)
{
StyleBorder key, *border;
......@@ -121,13 +121,13 @@ style_border_new (StyleBorderType left, StyleBorderType right,
key.top = top;
key.bottom = bottom;
if (left_color)
key.left_color = *left_color;
key.left_color = left_color;
if (right_color)
key.right_color = *right_color;
key.right_color = right_color;
if (top_color)
key.top_color = *top_color;
key.top_color = top_color;
if (bottom_color)
key.bottom_color = *bottom_color;
key.bottom_color = bottom_color;
border = (StyleBorder *) g_hash_table_lookup (style_border_hash, &key);
if (!border){
......@@ -357,16 +357,16 @@ border_equal (gconstpointer v, gconstpointer v2)
if (k1->bottom != k2->bottom)
return 0;
if (k1->left != BORDER_NONE)
if (!gdk_color_equal (&k1->left_color, &k2->left_color))
if (k1->left_color != k2->left_color)
return 0;
if (k1->right != BORDER_NONE)
if (!gdk_color_equal (&k1->right_color, &k2->right_color))
if (k1->right_color != k2->right_color)
return 0;
if (k1->top != BORDER_NONE)
if (gdk_color_equal (&k1->top_color, &k2->top_color))
if (k1->top_color != k2->top_color)
return 0;
if (k1->bottom != BORDER_NONE)
if (gdk_color_equal (&k1->bottom_color, &k2->bottom_color))
if (k1->bottom_color != k2->bottom_color)
return 0;
return 1;
}
......
......@@ -22,6 +22,12 @@ typedef struct {
GdkFont *font;
} StyleFont;
typedef struct {
int ref_count;
GdkColor color;
char *name;
} StyleColor;
typedef enum {
BORDER_NONE,
BORDER_SOLID
......@@ -40,18 +46,12 @@ typedef struct {
unsigned int top:4;
unsigned int bottom:4;
GdkColor left_color;
GdkColor right_color;
GdkColor top_color;
GdkColor bottom_color;
StyleColor *left_color;
StyleColor *right_color;
StyleColor *top_color;
StyleColor *bottom_color;
} StyleBorder;
typedef struct {
int ref_count;
GdkColor color;
char *name;
} StyleColor;
/* Alignment definitions */
typedef enum {
HALIGN_GENERAL = 1,
......@@ -131,9 +131,9 @@ StyleBorder *style_border_new (StyleBorderType left,
StyleBorderType right,
StyleBorderType top,
StyleBorderType bottom,
GdkColor *left_color,
GdkColor *right_color,
GdkColor *top_color,
GdkColor *bottom_color);
StyleColor *left_color,
StyleColor *right_color,
StyleColor *top_color,
StyleColor *bottom_color);
#endif /* GNUMERIC_STYLE_H */
......@@ -24,6 +24,7 @@
#define WB_COLS 1
Workbook *current_workbook;
static int workbook_count;
static void
new_cmd (void)
......@@ -143,6 +144,12 @@ quit_cmd (void)
gtk_main_quit ();
}
static void
close_cmd (GtkWidget *widget, Workbook *wb)
{
gtk_widget_destroy (wb->toplevel);
}
static void
paste_cmd (GtkWidget *widget, Workbook *wb)
{
......@@ -290,6 +297,7 @@ static GnomeUIInfo workbook_menu_file [] = {
{ GNOME_APP_UI_ITEM, N_("S_ave as..."), NULL, save_as_cmd, NULL, NULL,
GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_SAVE },
{ GNOME_APP_UI_ITEM, N_("_Plugins..."), NULL, plugins_cmd },
{ GNOME_APP_UI_ITEM, N_("_Close"), NULL, close_cmd },
{ GNOME_APP_UI_ITEM, N_("_Exit"), NULL, quit_cmd, NULL, NULL,
GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_EXIT },
GNOMEUIINFO_END
......@@ -688,6 +696,14 @@ workbook_set_focus (GtkWindow *window, GtkWidget *focus, Workbook *wb)
workbook_focus_current_sheet (wb);
}
static void
workbook_close (void)
{
workbook_count--;
if (workbook_count == 0)
gtk_main_quit ();
}
/*
* Sets up the workbook.
* Right now it is adding some decorations to the window,
......@@ -720,10 +736,15 @@ workbook_new (void)
GTK_OBJECT (wb->toplevel), "set_focus",
GTK_SIGNAL_FUNC (workbook_set_focus), wb);
gtk_signal_connect (
GTK_OBJECT (wb->toplevel), "destroy",
GTK_SIGNAL_FUNC (workbook_close), wb);
/* Set the default operation to be performed over selections */
workbook_set_auto_expr (wb, "SUM", "SUM(SELECTION())");
workbook_count++;
gtk_widget_show_all (wb->table);
return wb;
}
......
......@@ -64,7 +64,7 @@ static const char *xmlGetValue(xmlNodePtr node, const char *name) {
* Get a String value for a node either carried as an attibute or as
* the content of a child.
*/
String *xmlGetStringValue(xmlNodePtr node, const char *name) {
static String *xmlGetStringValue(xmlNodePtr node, const char *name) {
const char *val;
String *ret;
xmlNodePtr child;
......@@ -115,7 +115,7 @@ static int xmlGetIntValue(xmlNodePtr node, const char *name, int *val) {
* Get a float value for a node either carried as an attibute or as
* the content of a child.
*/
int xmlGetFloatValue(xmlNodePtr node, const char *name, float *val) {
static int xmlGetFloatValue(xmlNodePtr node, const char *name, float *val) {
const char *ret;
xmlNodePtr child;
float f;
......@@ -167,8 +167,8 @@ static int xmlGetDoubleValue(xmlNodePtr node, const char *name, double *val) {
* Get a set of coodinates for a node, carried as the content of a child.
*/
int xmlGetCoordinate(xmlNodePtr node, const char *name,
double *x, double *y) {
static int xmlGetCoordinate(xmlNodePtr node, const char *name,
double *x, double *y) {
xmlNodePtr child;
float X, Y;
......@@ -218,7 +218,7 @@ static int xmlGetCoordinates(xmlNodePtr node, const char *name,
* Get a GnomeCanvasPoints for a node, carried as the content of a child.
*/
GnomeCanvasPoints *xmlGetGnomeCanvasPoints(xmlNodePtr node,
static GnomeCanvasPoints *xmlGetGnomeCanvasPoints(xmlNodePtr node,
const char *name) {
GnomeCanvasPoints *ret = NULL;
int res;
......@@ -362,7 +362,7 @@ static void xmlSetIntValue(xmlNodePtr node, const char *name, int val) {
* Set a float value for a node either carried as an attibute or as
* the content of a child.
*/
void xmlSetFloatValue(xmlNodePtr node, const char *name, float val) {
static void xmlSetFloatValue(xmlNodePtr node, const char *name, float val) {
const char *ret;
xmlNodePtr child;
char str[101];
......@@ -388,7 +388,7 @@ void xmlSetFloatValue(xmlNodePtr node, const char *name, float val) {
* Set a double value for a node either carried as an attibute or as
* the content of a child.
*/
void xmlSetDoubleValue(xmlNodePtr node, const char *name, double val) {
static void xmlSetDoubleValue(xmlNodePtr node, const char *name, double val) {
const char *ret;
xmlNodePtr child;
char str[101];
......@@ -441,36 +441,22 @@ static xmlNodePtr xmlSearchChild(xmlNodePtr node, const char *name) {
* option ...
*/
static int xmlGetColorValue(xmlNodePtr node, const char *name,
GdkColor **val) {
StyleColor **color) {
const char *ret;
xmlNodePtr child;
GdkColormap *colormap;
int red, green, blue;
colormap = gtk_widget_get_default_colormap();
if (colormap == NULL) {
fprintf(stderr, "xmlGetColorValue : cannot get default_colormap\n");
return(0);
}
ret = xmlGetProp(node, name);
if ((ret != NULL) &&
(sscanf(ret, "%X:%X:%X", &red, &green, &blue) == 3)) {
(*val)->red = red;
(*val)->green = green;
(*val)->red = blue;
color_alloc_gdk (*val);
*color = style_color_new (red, green, blue);
return(1);
}
child = node->childs;
while (child != NULL) {
if ((!strcmp(child->name, name)) && (child->content != NULL) &&
(sscanf(ret, "%X:%X:%X", &red, &green, &blue) == 3)) {
(*val)->red = red;
(*val)->green = green;
(*val)->red = blue;
color_alloc_gdk (*val);
*color = style_color_new (red, green, blue);
return(1);
}
child = child->next;
......@@ -483,12 +469,12 @@ static int xmlGetColorValue(xmlNodePtr node, const char *name,
* the content of a child.
*/
static void xmlSetColorValue(xmlNodePtr node, const char *name,
GdkColor *val) {
StyleColor *val) {
const char *ret;
xmlNodePtr child;
char str[101];
snprintf(str, 100, "%X:%X:%X", val->red, val->green, val->blue);
snprintf(str, 100, "%X:%X:%X", val->color.red, val->color.green, val->color.blue);
ret = xmlGetProp(node, name);
if (ret != NULL) {
xmlSetProp(node, name, str);
......@@ -549,7 +535,7 @@ Sheet *gnumericReadXmlSheet(const char *filename) {
ctxt.doc = res;
ctxt.ns = gmr;
ctxt.nameTable = g_hash_table_new(ptrHash, ptrCompare);
ctxt.nameTable = g_hash_table_new(g_str_hash, g_str_equal);
ctxt.fontIdx = 1;
sheet = readXmlSheet(&ctxt, res->root);
g_hash_table_foreach(ctxt.nameTable, nameFree, NULL);
......@@ -596,7 +582,7 @@ int gnumericWriteXmlSheet(Sheet *sheet, const char *filename) {
gmr = xmlNewGlobalNs(xml, "http://www.gnome.org/gnumeric/", "gmr");
ctxt.doc = xml;
ctxt.ns = gmr;
ctxt.nameTable = g_hash_table_new(ptrHash, ptrCompare);
ctxt.nameTable = g_hash_table_new(g_str_hash, g_str_equal);
ctxt.fontIdx = 1;
xml->root = writeXmlSheet(&ctxt, sheet);
g_hash_table_foreach(ctxt.nameTable, nameFree, NULL);
......@@ -649,7 +635,7 @@ Workbook *gnumericReadXmlWorkbook(const char *filename) {
ctxt.doc = res;
ctxt.ns = gmr;
ctxt.nameTable = g_hash_table_new(ptrHash, ptrCompare);
ctxt.nameTable = g_hash_table_new(g_str_hash, g_str_equal);
ctxt.fontIdx = 1;
wb = readXmlWorkbook(&ctxt, res->root);
workbook_recalc(wb);
......@@ -697,7 +683,7 @@ int gnumericWriteXmlWorkbook(Workbook *wb, const char *filename) {
gmr = xmlNewGlobalNs(xml, "http://www.gnome.org/gnumeric/", "gmr");
ctxt.doc = xml;
ctxt.ns = gmr;
ctxt.nameTable = g_hash_table_new(ptrHash, ptrCompare);
ctxt.nameTable = g_hash_table_new(g_str_hash, g_str_equal);
ctxt.fontIdx = 1;
xml->root = writeXmlWorkbook(&ctxt, wb);
g_hash_table_foreach(ctxt.nameTable, nameFree, NULL);
......@@ -723,34 +709,31 @@ int gnumericWriteXmlWorkbook(Workbook *wb, const char *filename) {
*/
static void nameFree(gpointer key, gpointer value, gpointer user_data)
{
/* g_free(value); */
g_free (key);
}
/*
* Hash functions for pointers.
*/
static guint ptrHash(gconstpointer a)
static int
style_is_default_fore (StyleColor *color)
{
guint res = (guint) a;
res >>= 2;
res &= 0xFFFF;
return(res);
if (!color)
return TRUE;
if (color->color.red == 0 && color->color.green == 0 && color->color.blue == 0)
return TRUE;
else
return FALSE;
}
/*
* Comparison functions for pointers.
*/
static gint ptrCompare(gconstpointer a, gconstpointer b)
static int
style_is_default_back (StyleColor *color)
{
char *ca, *cb;
ca = (char *) a;
cb = (char *) b;
if (ca != cb)
return 0;
return 1;
if (!color)
return TRUE;
if (color->color.red == 0xffff && color->color.green == 0xffff && color->color.blue == 0xffff)
return TRUE;
else
return FALSE;
}
/*
......@@ -769,19 +752,19 @@ static xmlNodePtr writeXmlStyleBorder(parseXmlContextPtr ctxt,
cur = xmlNewNode(ctxt->ns, "StyleBorder", NULL);
if (border->left != BORDER_NONE) {
side = xmlNewChild(cur, ctxt->ns,"Left", BorderTypes[border->left]);
xmlSetColorValue(side, "Color", &border->left_color);
xmlSetColorValue(side, "Color", border->left_color);
}
if (border->right != BORDER_NONE) {
side = xmlNewChild(cur, ctxt->ns,"Right", BorderTypes[border->right]);
xmlSetColorValue(side, "Color", &border->right_color);
xmlSetColorValue(side, "Color", border->right_color);
}
if (border->top != BORDER_NONE) {
side = xmlNewChild(cur, ctxt->ns,"Top", BorderTypes[border->top]);
xmlSetColorValue(side, "Color", &border->top_color);
xmlSetColorValue(side, "Color", border->top_color);
}
if (border->bottom != BORDER_NONE) {
side = xmlNewChild(cur, ctxt->ns,"Bottom", BorderTypes[border->bottom]);
xmlSetColorValue(side, "Color", &border->bottom_color);
xmlSetColorValue(side, "Color", border->bottom_color);
}
return(cur);
}
......@@ -796,10 +779,10 @@ static StyleBorder *readXmlStyleBorder(parseXmlContextPtr ctxt,
StyleBorderType right = BORDER_NONE;
StyleBorderType top = BORDER_NONE;
StyleBorderType bottom = BORDER_NONE;
GdkColor *left_color = NULL;
GdkColor *right_color = NULL;
GdkColor *top_color = NULL;
GdkColor *bottom_color = NULL;
StyleColor *left_color = NULL;
StyleColor *right_color = NULL;
StyleColor *top_color = NULL;
StyleColor *bottom_color = NULL;
xmlNodePtr side;
if (strcmp(tree->name, "StyleBorder")) {
......@@ -845,8 +828,16 @@ static xmlNodePtr writeXmlStyle(parseXmlContextPtr ctxt, Style *style) {
cur = xmlNewNode(ctxt->ns, "Style", NULL);
xmlSetIntValue(cur, "HAlign", style->halign);
xmlSetIntValue(cur, "VAlign", style->valign);
xmlSetIntValue(cur, "Fit", style->fit_in_cell);
xmlSetIntValue(cur, "Orient", style->orientation);
xmlSetIntValue(cur, "Shade", style->pattern);
if (!style_is_default_fore (style->fore_color))
xmlSetColorValue(cur, "Fore", style->fore_color);
if (!style_is_default_back (style->back_color))
xmlSetColorValue(cur, "Back", style->back_color);
if (style->format != NULL) {
xmlSetValue(cur, "Format", style->format->format);
}
......@@ -861,7 +852,7 @@ static xmlNodePtr writeXmlStyle(parseXmlContextPtr ctxt, Style *style) {
xmlSetIntValue(child, "Unit", style->font->units);
sprintf(str, "FontDef%d", ctxt->fontIdx++);
xmlNewProp(child, "NAME", str);
g_hash_table_insert(ctxt->nameTable, style->font, g_strdup(str));
g_hash_table_insert(ctxt->nameTable, g_strdup (str), style->font);
}
}
......@@ -869,10 +860,6 @@ static xmlNodePtr writeXmlStyle(parseXmlContextPtr ctxt, Style *style) {
child = writeXmlStyleBorder(ctxt, style->border);
if (child) xmlAddChild(cur, child);
}
if (style->valid_flags & STYLE_PATTERN != NULL) {
sprintf(str, "%d", style->pattern);
xmlNewChild(cur, ctxt->ns, "Shade", str);
}
return(cur);
}
......@@ -884,6 +871,7 @@ static Style *readXmlStyle(parseXmlContextPtr ctxt, xmlNodePtr tree,
xmlNodePtr child;
const char *prop;
int val;
StyleColor *c;
if (strcmp(tree->name, "Style")) {
fprintf(stderr,
......@@ -891,38 +879,87 @@ static Style *readXmlStyle(parseXmlContextPtr ctxt, xmlNodePtr tree,
tree->name);
}
if (ret == NULL) {
ret = style_new();
ret = style_new_empty();
}
if (ret == NULL) return(NULL);
if (xmlGetIntValue(tree, "HAlign", &val)) ret->halign = val;
if (xmlGetIntValue(tree, "VAlign", &val)) ret->valign = val;
if (xmlGetIntValue(tree, "Orient", &val)) ret->orientation = val;
if (xmlGetIntValue(tree, "HAlign", &val)){
ret->halign = val;
ret->valid_flags |= STYLE_ALIGN;
}
if (xmlGetIntValue(tree, "Fit", &val)){
ret->fit_in_cell = val;
ret->valid_flags |= STYLE_ALIGN;
}
if (xmlGetIntValue(tree, "VAlign", &val)){
ret->valign = val;
ret->valid_flags |= STYLE_ALIGN;
}
if (xmlGetIntValue(tree, "Orient", &val)){
ret->orientation = val;
ret->valid_flags |= STYLE_ALIGN;
}
if (xmlGetIntValue(tree, "Shade", &val)){
ret->pattern = val;
ret->valid_flags |= STYLE_PATTERN;
}
if (xmlGetColorValue(tree, "Fore", &c)){
ret->fore_color = c;
ret->valid_flags |= STYLE_FORE_COLOR;
}
if (xmlGetColorValue(tree, "Back", &c)){
ret->back_color = c;
ret->valid_flags |= STYLE_BACK_COLOR;
}
prop = xmlGetValue(tree, "Format");
if (prop != NULL) {
if (ret->format == NULL)
ret->format = style_format_new((char *) prop);
if (ret->format == NULL){
ret->format = style_format_new((char *) prop);
ret->valid_flags |= STYLE_FORMAT;
}
}
child = tree->childs;
while (child != NULL) {
if (!strcmp(child->name, "Font")) {
/* TODO */
const char *v;
v = xmlGetValue (child, "NAME");
if (v){
int units = 14;
xmlGetIntValue (child, "Unit", &units);
ret->font = style_font_new (child->content, units);
if (ret->font){
g_hash_table_insert (ctxt->nameTable, g_strdup (v), ret->font);
ret->valid_flags |= STYLE_FONT;
}
} else {
StyleFont *font;
v = xmlGetValue (child, "HREF");
if (v){
font = g_hash_table_lookup (ctxt->nameTable, v+1);
if (font){
ret->font = font;
style_font_ref (font);
ret->valid_flags |= STYLE_FONT;
}
}
}
} else if (!strcmp(child->name, "StyleBorder")) {
StyleBorder *sb;