Commit b23d8630 authored by Jody Goldberg's avatar Jody Goldberg Committed by Jody Goldberg

Support underlining of text.

2000-02-29  Jody Goldberg <jgoldberg@home.com>

	* src/workbook-format-toolbar.c (change_selection_font) : Add underline.
	(underline_cmd) : New function.
	(workbook_format_toolbar) : Add underline.
	(workbook_feedback_set) : Ditto.

	* src/xml-io.c (xml_read_style) : Restore underline style.
	(xml_write_style) : Save the underline style.

	* src/pattern.c (gnumeric_background_set_pc) : suppress warning.

	* src/mstyle.[ch] : Add MSTYLE_FONT_UNDERLINE.
	(mstyle_get_font_uline) : New function.
	(mstyle_set_font_uline) : New function.

	* src/cell-draw.c (draw_text) : new function to add underlines.
	(draw_overflow) : Use draw_text.
	(cell_draw) : Ditto.

	* src/gnumeric.h : Add StyleUnderlineType.

	* gnumeric.spec.in : Update the requirements.
parent 3c5bb487
2000-02-29 Jody Goldberg <jgoldberg@home.com>
* src/workbook-format-toolbar.c (change_selection_font) : Add underline.
(underline_cmd) : New function.
(workbook_format_toolbar) : Add underline.
(workbook_feedback_set) : Ditto.
* src/xml-io.c (xml_read_style) : Restore underline style.
(xml_write_style) : Save the underline style.
* src/pattern.c (gnumeric_background_set_pc) : suppress warning.
* src/mstyle.[ch] : Add MSTYLE_FONT_UNDERLINE.
(mstyle_get_font_uline) : New function.
(mstyle_set_font_uline) : New function.
* src/cell-draw.c (draw_text) : new function to add underlines.
(draw_overflow) : Use draw_text.
(cell_draw) : Ditto.
* src/gnumeric.h : Add StyleUnderlineType.
* gnumeric.spec.in : Update the requirements.
2000-03-01 Jon K Hellan <hellan@acm.org>
* doc/python-gnumeric.txt: Clarified mapping of arrays.
......
2000-02-29 Jody Goldberg <jgoldberg@home.com>
* src/workbook-format-toolbar.c (change_selection_font) : Add underline.
(underline_cmd) : New function.
(workbook_format_toolbar) : Add underline.
(workbook_feedback_set) : Ditto.
* src/xml-io.c (xml_read_style) : Restore underline style.
(xml_write_style) : Save the underline style.
* src/pattern.c (gnumeric_background_set_pc) : suppress warning.
* src/mstyle.[ch] : Add MSTYLE_FONT_UNDERLINE.
(mstyle_get_font_uline) : New function.
(mstyle_set_font_uline) : New function.
* src/cell-draw.c (draw_text) : new function to add underlines.
(draw_overflow) : Use draw_text.
(cell_draw) : Ditto.
* src/gnumeric.h : Add StyleUnderlineType.
* gnumeric.spec.in : Update the requirements.
2000-03-01 Jon K Hellan <hellan@acm.org>
* doc/python-gnumeric.txt: Clarified mapping of arrays.
......
2000-02-29 Jody Goldberg <jgoldberg@home.com>
* src/workbook-format-toolbar.c (change_selection_font) : Add underline.
(underline_cmd) : New function.
(workbook_format_toolbar) : Add underline.
(workbook_feedback_set) : Ditto.
* src/xml-io.c (xml_read_style) : Restore underline style.
(xml_write_style) : Save the underline style.
* src/pattern.c (gnumeric_background_set_pc) : suppress warning.
* src/mstyle.[ch] : Add MSTYLE_FONT_UNDERLINE.
(mstyle_get_font_uline) : New function.
(mstyle_set_font_uline) : New function.
* src/cell-draw.c (draw_text) : new function to add underlines.
(draw_overflow) : Use draw_text.
(cell_draw) : Ditto.
* src/gnumeric.h : Add StyleUnderlineType.
* gnumeric.spec.in : Update the requirements.
2000-03-01 Jon K Hellan <hellan@acm.org>
* doc/python-gnumeric.txt: Clarified mapping of arrays.
......
2000-02-29 Jody Goldberg <jgoldberg@home.com>
* src/workbook-format-toolbar.c (change_selection_font) : Add underline.
(underline_cmd) : New function.
(workbook_format_toolbar) : Add underline.
(workbook_feedback_set) : Ditto.
* src/xml-io.c (xml_read_style) : Restore underline style.
(xml_write_style) : Save the underline style.
* src/pattern.c (gnumeric_background_set_pc) : suppress warning.
* src/mstyle.[ch] : Add MSTYLE_FONT_UNDERLINE.
(mstyle_get_font_uline) : New function.
(mstyle_set_font_uline) : New function.
* src/cell-draw.c (draw_text) : new function to add underlines.
(draw_overflow) : Use draw_text.
(cell_draw) : Ditto.
* src/gnumeric.h : Add StyleUnderlineType.
* gnumeric.spec.in : Update the requirements.
2000-03-01 Jon K Hellan <hellan@acm.org>
* doc/python-gnumeric.txt: Clarified mapping of arrays.
......
2000-02-29 Jody Goldberg <jgoldberg@home.com>
* src/workbook-format-toolbar.c (change_selection_font) : Add underline.
(underline_cmd) : New function.
(workbook_format_toolbar) : Add underline.
(workbook_feedback_set) : Ditto.
* src/xml-io.c (xml_read_style) : Restore underline style.
(xml_write_style) : Save the underline style.
* src/pattern.c (gnumeric_background_set_pc) : suppress warning.
* src/mstyle.[ch] : Add MSTYLE_FONT_UNDERLINE.
(mstyle_get_font_uline) : New function.
(mstyle_set_font_uline) : New function.
* src/cell-draw.c (draw_text) : new function to add underlines.
(draw_overflow) : Use draw_text.
(cell_draw) : Ditto.
* src/gnumeric.h : Add StyleUnderlineType.
* gnumeric.spec.in : Update the requirements.
2000-03-01 Jon K Hellan <hellan@acm.org>
* doc/python-gnumeric.txt: Clarified mapping of arrays.
......
2000-02-29 Jody Goldberg <jgoldberg@home.com>
* src/workbook-format-toolbar.c (change_selection_font) : Add underline.
(underline_cmd) : New function.
(workbook_format_toolbar) : Add underline.
(workbook_feedback_set) : Ditto.
* src/xml-io.c (xml_read_style) : Restore underline style.
(xml_write_style) : Save the underline style.
* src/pattern.c (gnumeric_background_set_pc) : suppress warning.
* src/mstyle.[ch] : Add MSTYLE_FONT_UNDERLINE.
(mstyle_get_font_uline) : New function.
(mstyle_set_font_uline) : New function.
* src/cell-draw.c (draw_text) : new function to add underlines.
(draw_overflow) : Use draw_text.
(cell_draw) : Ditto.
* src/gnumeric.h : Add StyleUnderlineType.
* gnumeric.spec.in : Update the requirements.
2000-03-01 Jon K Hellan <hellan@acm.org>
* doc/python-gnumeric.txt: Clarified mapping of arrays.
......
2000-02-29 Jody Goldberg <jgoldberg@home.com>
* src/workbook-format-toolbar.c (change_selection_font) : Add underline.
(underline_cmd) : New function.
(workbook_format_toolbar) : Add underline.
(workbook_feedback_set) : Ditto.
* src/xml-io.c (xml_read_style) : Restore underline style.
(xml_write_style) : Save the underline style.
* src/pattern.c (gnumeric_background_set_pc) : suppress warning.
* src/mstyle.[ch] : Add MSTYLE_FONT_UNDERLINE.
(mstyle_get_font_uline) : New function.
(mstyle_set_font_uline) : New function.
* src/cell-draw.c (draw_text) : new function to add underlines.
(draw_overflow) : Use draw_text.
(cell_draw) : Ditto.
* src/gnumeric.h : Add StyleUnderlineType.
* gnumeric.spec.in : Update the requirements.
2000-03-01 Jon K Hellan <hellan@acm.org>
* doc/python-gnumeric.txt: Clarified mapping of arrays.
......
......@@ -15,8 +15,8 @@ BuildRoot: /var/tmp/gnumeric-%{PACKAGE_VERSION}-root
Docdir: %{prefix}/doc
Requires: gtk+ >= 1.2.2
Requires: gnome-libs >= 1.0.0
Requires: gnome-print >= 0.10
Requires: gnome-libs >= 1.0.56
Requires: gnome-print >= 0.12
Requires: libglade >= 0.11
Requires: libxml >= 1.8.5
......@@ -94,6 +94,9 @@ fi
%doc HACKING AUTHORS ChangeLog NEWS README COPYING TODO
%changelog
* Mon Feb 29 2000 Jody Goldberg <jgolbderg@home.com>
- Updated version requirements for gnome-print, and gnome-libs.
* Sun Jan 30 2000 Gregory McLean <gregm@comstar.net>
- Added in some auto-detect the language files logic (rpm 3.0.xx only)
......
2000-02-29 Jody Goldberg <jgoldberg@home.com>
* ms-excel-read.c (ms_excel_get_style_from_xf) : Add support for
importing underlines.
2000-02-18 Jody Goldberg <jgoldberg@home.com>
* ms-excel-read.c (ms_excel_get_style_from_xf) : Hard code 'auto'
......
......@@ -1085,6 +1085,7 @@ ms_excel_get_style_from_xf (ExcelSheet *sheet, guint16 xfidx)
/* Font */
fd = ms_excel_get_font (sheet, xf->font_idx);
if (fd != NULL) {
StyleUnderlineType underline = UNDERLINE_NONE;
subs_fontname = get_substitute_font (fd->fontname);
if (subs_fontname)
mstyle_set_font_name (mstyle, subs_fontname);
......@@ -1093,6 +1094,23 @@ ms_excel_get_style_from_xf (ExcelSheet *sheet, guint16 xfidx)
mstyle_set_font_size (mstyle, fd->height / 20.0);
mstyle_set_font_bold (mstyle, fd->boldness >= 0x2bc);
mstyle_set_font_italic (mstyle, fd->italic);
switch (fd->underline) {
case eBiffFUSingle :
case eBiffFUSingleAcc :
underline = UNDERLINE_SINGLE;
break;
case eBiffFUDouble :
case eBiffFUDoubleAcc :
underline = UNDERLINE_DOUBLE;
break;
case eBiffFUNone :
default :
underline = UNDERLINE_NONE;
}
mstyle_set_font_uline (mstyle, underline);
font_index = fd->color_idx;
} else
font_index = 127; /* Default to White */
......
......@@ -18,7 +18,23 @@
#include "cell-draw.h"
static void
draw_overflow (GdkDrawable *drawable, GdkGC *gc, GdkFont *font,
draw_text (GdkDrawable *drawable, GdkFont *font, StyleUnderlineType const uline,
GdkGC *gc, int x1, int text_base, char const * text, int n, int len_pixels)
{
gdk_draw_text (drawable, font, gc, x1, text_base, text, n);
/* FIXME how to handle small fonts ?
* the text_base should be at least 4 pixels above the bottom */
if (uline != UNDERLINE_NONE) {
gdk_draw_line (drawable, gc, x1, text_base+1, x1+len_pixels, text_base+1);
if (uline == UNDERLINE_DOUBLE)
gdk_draw_line (drawable, gc, x1, text_base+3, x1+len_pixels, text_base+3);
}
}
static void
draw_overflow (GdkDrawable *drawable, GdkGC *gc,
GdkFont *font, StyleUnderlineType const uline,
int x1, int text_base, int width)
{
int const len = gdk_string_width (font, "#");
......@@ -26,7 +42,7 @@ draw_overflow (GdkDrawable *drawable, GdkGC *gc, GdkFont *font,
/* Center */
for (x1 += (width - count*len) / 2; --count >= 0 ; x1 += len )
gdk_draw_text (drawable, font, gc, x1, text_base, "#", 1);
draw_text (drawable, font, uline, gc, x1, text_base, "#", 1, len);
}
/*
......@@ -122,6 +138,7 @@ cell_draw (Cell *cell, MStyle *mstyle,
SheetView *sheet_view, GdkGC *gc, GdkDrawable *drawable,
int x1, int y1)
{
StyleUnderlineType const uline = mstyle_get_font_uline (mstyle);
StyleFont *style_font = sheet_view_get_style_font (cell->sheet, mstyle);
GdkFont *font = style_font_gdk_font (style_font);
GdkRectangle rect;
......@@ -244,7 +261,7 @@ cell_draw (Cell *cell, MStyle *mstyle,
/* if a number overflows, do special drawing */
if (width < cell->width_pixel && cell_is_number (cell)) {
draw_overflow (drawable, gc, font,
draw_overflow (drawable, gc, font, uline,
x1 + cell->col->margin_a + 1,
text_base, width);
style_font_unref (style_font);
......@@ -254,11 +271,12 @@ cell_draw (Cell *cell, MStyle *mstyle,
if (is_single_line) {
int total, len;
len = 0;
len = (uline != UNDERLINE_NONE || halign == HALIGN_FILL)
? gdk_string_width (font, text) : 0;
switch (halign) {
case HALIGN_FILL:
printf ("FILL!\n");
len = gdk_string_width (font, text);
/* fall through */
case HALIGN_LEFT:
......@@ -280,8 +298,8 @@ cell_draw (Cell *cell, MStyle *mstyle,
total = 0;
do {
gdk_draw_text (drawable, font, gc, x1,
text_base, text, strlen (text));
draw_text (drawable, font, uline, gc, x1,
text_base, text, strlen (text), len);
x1 += len;
total += len;
} while (halign == HALIGN_FILL && total < rect.width && len > 0);
......@@ -326,30 +344,34 @@ cell_draw (Cell *cell, MStyle *mstyle,
y_offset += font_height - 1;
for (l = lines; l; l = l->next) {
char const * const str = l->data;
int len = 0;
switch (halign){
default:
g_warning ("Multi-line justification style not supported\n");
/* fall through */
case HALIGN_LEFT:
case HALIGN_JUSTIFY:
x_offset = cell->col->margin_a;
if (uline != UNDERLINE_NONE)
len = gdk_string_width (font, text);
break;
case HALIGN_RIGHT:
x_offset = cell->col->size_pixels - cell->col->margin_b -
gdk_string_width (font, str);
len = gdk_string_width (font, str);
x_offset = cell->col->size_pixels - cell->col->margin_b - len;
break;
case HALIGN_CENTER:
x_offset = (cell->col->size_pixels -
gdk_string_width (font, str)) / 2;
break;
default:
g_warning ("Multi-line justification style not supported\n");
x_offset = cell->col->margin_a;
len = gdk_string_width (font, str);
x_offset = (cell->col->size_pixels - len) / 2;
}
/* Advance one pixel for the border */
x_offset++;
gdk_draw_text (drawable, font, gc, x1 + x_offset,
y1 + y_offset, str, strlen (str));
draw_text (drawable, font, uline, gc, x1 + x_offset,
y1 + y_offset, str, strlen (str), len);
y_offset += inter_space;
g_free (l->data);
......
......@@ -52,6 +52,7 @@ typedef enum _StyleHAlignFlags StyleHAlignFlags;
typedef enum _StyleVAlignFlags StyleVAlignFlags;
typedef enum _StyleOrientation StyleOrientation;
typedef enum _StyleBorderLocation StyleBorderLocation;
typedef enum _StyleUnderlineType StyleUnderlineType;
typedef struct _StyleFormat StyleFormat;
typedef struct _StyleFormatEntry StyleFormatEntry;
......
......@@ -41,6 +41,7 @@ typedef struct {
String *name;
gboolean bold;
gboolean italic;
StyleUnderlineType underline;
float size;
} font;
StyleFormat *format;
......@@ -109,6 +110,7 @@ const char *mstyle_names [MSTYLE_ELEMENT_MAX] = {
"Font.Name",
"Font.Bold",
"Font.Italic",
"Font.Underline",
"Font.Size",
"Format",
"Align.v",
......@@ -155,6 +157,9 @@ mstyle_hash (gconstpointer st)
case MSTYLE_ORIENTATION:
hash = hash ^ e->u.orientation;
break;
case MSTYLE_FONT_UNDERLINE:
hash = hash ^ e->u.font.underline;
break;
default:
g_warning ("Unimplemented hash item");
break;
......@@ -200,6 +205,17 @@ mstyle_element_dump (const MStyleElement *e)
else
g_string_sprintf (ans, "not italic");
break;
case MSTYLE_FONT_UNDERLINE:
switch (e->u.font.underline) {
default :
case UNDERLINE_NONE :
g_string_sprintf (ans, "not underline");
case UNDERLINE_SINGLE :
g_string_sprintf (ans, "single underline");
case UNDERLINE_DOUBLE :
g_string_sprintf (ans, "double underline");
};
break;
case MSTYLE_FONT_SIZE:
g_string_sprintf (ans, "size %f", e->u.font.size);
break;
......@@ -266,6 +282,10 @@ mstyle_element_equal (const MStyleElement a,
if (a.u.font.italic == b.u.font.italic)
return TRUE;
break;
case MSTYLE_FONT_UNDERLINE:
if (a.u.font.underline == b.u.font.underline)
return TRUE;
break;
case MSTYLE_FONT_SIZE:
if (a.u.font.size == b.u.font.size)
return TRUE;
......@@ -509,10 +529,11 @@ mstyle_new_default (void)
mstyle_set_align_v (mstyle, VALIGN_BOTTOM);
mstyle_set_align_h (mstyle, HALIGN_GENERAL);
mstyle_set_orientation (mstyle, ORIENT_HORIZ);
mstyle_set_fit_in_cell (mstyle, 0);
mstyle_set_fit_in_cell (mstyle, FALSE);
mstyle_set_font_name (mstyle, DEFAULT_FONT);
mstyle_set_font_bold (mstyle, 0);
mstyle_set_font_italic (mstyle, 0);
mstyle_set_font_bold (mstyle, FALSE);
mstyle_set_font_italic (mstyle, FALSE);
mstyle_set_font_uline (mstyle, UNDERLINE_NONE);
mstyle_set_font_size (mstyle, DEFAULT_SIZE);
mstyle_set_color (mstyle, MSTYLE_COLOR_FORE,
......@@ -856,7 +877,7 @@ mstyle_get_font (const MStyle *style, double zoom)
{
StyleFont *font;
const gchar *name;
int bold, italic;
gboolean bold, italic;
double size;
g_return_val_if_fail (style != NULL, NULL);
......@@ -868,11 +889,11 @@ mstyle_get_font (const MStyle *style, double zoom)
if (mstyle_is_element_set (style, MSTYLE_FONT_BOLD))
bold = mstyle_get_font_bold (style);
else
bold = 0;
bold = FALSE;
if (mstyle_is_element_set (style, MSTYLE_FONT_ITALIC))
italic = mstyle_get_font_italic (style);
else
italic = 0;
italic = FALSE;
if (mstyle_is_element_set (style, MSTYLE_FONT_SIZE))
size = mstyle_get_font_size (style);
else
......@@ -940,6 +961,24 @@ mstyle_get_font_italic (const MStyle *style)
return style->elements [MSTYLE_FONT_ITALIC].u.font.italic;
}
void
mstyle_set_font_uline (MStyle *style, StyleUnderlineType const underline)
{
g_return_if_fail (style != NULL);
style->elements [MSTYLE_FONT_UNDERLINE].type = MSTYLE_FONT_UNDERLINE;
style->elements [MSTYLE_FONT_UNDERLINE].u.font.underline = underline;
}
StyleUnderlineType
mstyle_get_font_uline (const MStyle *style)
{
g_return_val_if_fail (style != NULL, FALSE);
g_return_val_if_fail (mstyle_is_element_set (style, MSTYLE_FONT_UNDERLINE), FALSE);
return style->elements [MSTYLE_FONT_UNDERLINE].u.font.underline;
}
void
mstyle_set_font_size (MStyle *style, double size)
{
......
......@@ -30,6 +30,7 @@ enum _MStyleElementType {
MSTYLE_FONT_NAME,
MSTYLE_FONT_BOLD,
MSTYLE_FONT_ITALIC,
MSTYLE_FONT_UNDERLINE,
MSTYLE_FONT_SIZE,
MSTYLE_FORMAT,
......@@ -82,6 +83,8 @@ void mstyle_set_font_bold (MStyle *st, gboolean bold);
gboolean mstyle_get_font_bold (const MStyle *st);
void mstyle_set_font_italic (MStyle *st, gboolean italic);
gboolean mstyle_get_font_italic (const MStyle *st);
void mstyle_set_font_uline (MStyle *st, StyleUnderlineType const t);
StyleUnderlineType mstyle_get_font_uline (const MStyle *st);
void mstyle_set_font_size (MStyle *st, double size);
double mstyle_get_font_size (const MStyle *st);
/* this font must be unrefd after use */
......
......@@ -146,7 +146,6 @@ gnumeric_background_set_pc (MStyle *mstyle, GnomePrintContext *context)
return FALSE;
pattern = mstyle_get_pattern (mstyle);
if (pattern > 0) {
GdkColor *back;
StyleColor *back_col =
mstyle_get_color (mstyle, MSTYLE_COLOR_BACK);
......@@ -157,6 +156,7 @@ gnumeric_background_set_pc (MStyle *mstyle, GnomePrintContext *context)
back_col->green / (double) 0xffff,
back_col->blue / (double) 0xffff);
#if 0
/* Support grey scale patterns. FIXME how to do the rest ? */
if (pattern >= 1 && pattern <= 5) {
static double const gray[] = { 1., .75, .50, .25, .125, .0625 };
......@@ -164,7 +164,6 @@ gnumeric_background_set_pc (MStyle *mstyle, GnomePrintContext *context)
/* FIXME : why no support for setgray in gnome-print ? */
}
#if 0
if (pattern > 1) {
StyleColor *pat_col =
mstyle_get_color (mstyle, MSTYLE_COLOR_PATTERN);
......
......@@ -97,7 +97,8 @@ my_gdk_actual_font_name (GdkFont *font)
#endif
StyleFont *
style_font_new_simple (const char *font_name, double size, double scale, int bold, int italic)
style_font_new_simple (const char *font_name, double size, double scale,
gboolean bold, gboolean italic)
{
StyleFont *font;
StyleFont key;
......@@ -164,7 +165,8 @@ style_font_new_simple (const char *font_name, double size, double scale, int bol
}
StyleFont *
style_font_new (const char *font_name, double size, double scale, int bold, int italic)
style_font_new (const char *font_name, double size, double scale,
gboolean bold, gboolean italic)
{
StyleFont *font;
......@@ -197,7 +199,8 @@ style_font_new_from (StyleFont *sf, double scale)
g_return_val_if_fail (sf != NULL, NULL);
g_return_val_if_fail (scale != 0.0, NULL);
new_sf = style_font_new_simple (sf->font_name, sf->size, scale, sf->is_bold, sf->is_italic);
new_sf = style_font_new_simple (sf->font_name, sf->size, scale,
sf->is_bold, sf->is_italic);
if (!new_sf){
new_sf = gnumeric_default_font;
style_font_ref (new_sf);
......
......@@ -25,6 +25,12 @@ enum _StyleVAlignFlags {
VALIGN_JUSTIFY = 8
};
enum _StyleUnderlineType {
UNDERLINE_NONE = 0,
UNDERLINE_SINGLE = 1,
UNDERLINE_DOUBLE = 2,
};
enum _StyleOrientation {
ORIENT_HORIZ = 1,
ORIENT_VERT_HORIZ_TEXT = 2,
......@@ -92,11 +98,11 @@ void style_format_unref (StyleFormat *sf);
StyleFont *style_font_new (const char *font_name,
double size, double scale,
int bold, int italic);
gboolean bold, gboolean italic);
StyleFont *style_font_new_from (StyleFont *sf, double scale);
StyleFont *style_font_new_simple (const char *font_name,
double size, double scale,
int bold, int italic);
gboolean bold, gboolean italic);
GdkFont *style_font_gdk_font (StyleFont *sf);
GnomeFont *style_font_gnome_font (StyleFont *sf);
int style_font_get_height (StyleFont *sf);
......
......@@ -82,10 +82,11 @@ center_cmd (GtkWidget *widget, Workbook *wb)
* @wb: The workbook to operate on
* @bold: -1 to leave unchanged, 0 to clear, 1 to set
* @italic: -1 to leave unchanged, 0 to clear, 1 to set
* @underline: -1 to leave unchanged, 0 to clear, 1 to set
*
*/
static void
change_selection_font (Workbook *wb, int bold, int italic)
change_selection_font (Workbook *wb, int bold, int italic, int underline)
{
MStyle *mstyle;
Sheet *sheet;
......@@ -100,8 +101,13 @@ change_selection_font (Workbook *wb, int bold, int italic)
if (italic >= 0)
mstyle_set_font_italic (mstyle, italic);
if (underline >= 0)
mstyle_set_font_uline (mstyle,
underline ? UNDERLINE_SINGLE : UNDERLINE_NONE);
if (bold >= 0 ||
italic >= 0)
italic >= 0 ||
underline >= 0)
cmd_format (workbook_command_context_gui (wb),
sheet, mstyle, NULL);
else
......@@ -111,13 +117,19 @@ change_selection_font (Workbook *wb, int bold, int italic)
static void
bold_cmd (GtkToggleButton *t, Workbook *wb)
{
change_selection_font (wb, t->active, -1);
change_selection_font (wb, t->active, -1, -1);
}
static void
italic_cmd (GtkToggleButton *t, Workbook *wb)
{
change_selection_font (wb, -1, t->active);
change_selection_font (wb, -1, t->active, -1);
}
static void
underline_cmd (GtkToggleButton *t, Workbook *wb)
{
change_selection_font (wb, -1, -1, t->active);
}
static void
......@@ -276,6 +288,9 @@ static GnomeUIInfo workbook_format_toolbar [] = {
{ GNOME_APP_UI_TOGGLEITEM, N_("Italic"), N_("Makes the font italic"),
italic_cmd, NULL, NULL, GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_PIXMAP_TEXT_ITALIC },
{ GNOME_APP_UI_TOGGLEITEM, N_("Underline"), N_("Underlines the font"),
underline_cmd, NULL, NULL, GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_PIXMAP_TEXT_UNDERLINE },
GNOMEUIINFO_SEPARATOR,
{ GNOME_APP_UI_TOGGLEITEM, N_("Left align"), N_("Left justifies the cell contents"),
......@@ -667,6 +682,13 @@ workbook_feedback_set (Workbook *workbook, MStyle *style)
(GtkSignalFunc)&italic_cmd,
mstyle_get_font_italic (style));
/* Handle font underlining */
g_return_if_fail (mstyle_is_element_set (style, MSTYLE_FONT_UNDERLINE));
workbook_format_toolbutton_update (workbook, toolbar,
TOOLBAR_UNDERLINE_BUTTON_INDEX,
(GtkSignalFunc)&underline_cmd,
mstyle_get_font_uline (style) != UNDERLINE_NONE);
/* horizontal alignment */
g_return_if_fail (mstyle_is_element_set (style, MSTYLE_ALIGN_H));
workbook_format_halign_feedback_set (workbook, mstyle_get_align_h (style));
......
......@@ -3,9 +3,10 @@
#define TOOLBAR_BOLD_BUTTON_INDEX 2
#define TOOLBAR_ITALIC_BUTTON_INDEX 3
#define TOOLBAR_ALIGN_LEFT_BUTTON_INDEX 4
#define TOOLBAR_ALIGN_CENTER_BUTTON_INDEX 5
#define TOOLBAR_ALIGN_RIGHT_BUTTON_INDEX 6
#define TOOLBAR_UNDERLINE_BUTTON_INDEX 4
#define TOOLBAR_ALIGN_LEFT_BUTTON_INDEX 5
#define TOOLBAR_ALIGN_CENTER_BUTTON_INDEX 6
#define TOOLBAR_ALIGN_RIGHT_BUTTON_INDEX 7
GtkWidget *workbook_create_format_toolbar (Workbook *wb);
......
......@@ -816,6 +816,9 @@ xml_write_style (parse_xml_context_t *ctxt,
if (mstyle_is_element_set (style, MSTYLE_FONT_ITALIC))
xml_set_value_int (child, "Italic",
mstyle_get_font_italic (style));
if (mstyle_is_element_set (style, MSTYLE_FONT_UNDERLINE))
xml_set_value_int (child, "Underline",
(int)mstyle_get_font_uline (style));
}
child = xml_write_style_border (ctxt, style);
......@@ -1302,6 +1305,9 @@ xml_read_style (parse_xml_context_t *ctxt, xmlNodePtr tree)
if (xml_get_value_int (child, "Italic", &t))
mstyle_set_font_italic (mstyle, t);
if (xml_get_value_int (child, "Underline", &t))
mstyle_set_font_uline (mstyle, (StyleOrientation)t);
font = xmlNodeGetContent (child);
if (font) {
if (*font == '-')
......
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