[gnumeric] Improve xl import of underlines.
- From: Andreas J. Guelzow <guelzow src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] Improve xl import of underlines.
- Date: Wed, 28 Jul 2010 18:26:16 +0000 (UTC)
commit 86dd9be62f296580fb45678764ca3a61e700787b
Author: Andreas J Guelzow <aguelzow pyrshep ca>
Date: Wed Jul 28 12:18:17 2010 -0600
Improve xl import of underlines.
2010-07-28 Andreas J. Guelzow <aguelzow pyrshep ca>
* src/mstyle.c (gnm_style_get_pango_attrs): use
gnm_translate_underline_to_pango
(gnm_style_generate_attrs_full): use gnm_translate_underline_to_pango
(gnm_style_set_from_pango_attribute): use
gnm_translate_underline_from_pango
* src/style.c (gnm_translate_underline_to_pango): new
(gnm_translate_underline_from_pango): new
* src/style.h (gnm_translate_underline_to_pango): new
(gnm_translate_underline_from_pango): new
* src/wbc-gtk-actions.c (FontSingleLowUnderline): new actions
(FontDoubleLowUnderline): new actions
(cb_font_underline_low): new
(cb_font_double_underline_low): new
* src/wbc-gtk-impl.h (_WBCGtk): add toggle action fields
* src/wbc-gtk.c (wbc_gtk_style_feedback_real): handle
UNDERLINE_*_LOW
(wbc_gtk_init): add Font*LowUnderline
2010-07-28 Andreas J. Guelzow <aguelzow pyrshep ca>
* dialog-cell-format.c (underline_types): add low underlines
2010-07-28 Andreas J. Guelzow <aguelzow pyrshep ca>
* openoffice-read.c (oo_style_prop_cell): handle
style:text-underline-type
* openoffice-write.c (odf_write_style_text_properties): add
UNDERLINE_*_LOW
2010-07-28 Andreas J. Guelzow <aguelzow pyrshep ca>
* excel-xml-read.c (xl_xml_font): add UNDERLINE_*_LOW
* ms-excel-read.c (xls_uline_to_gnm_underline): new
(excel_get_style_from_xf): use xls_uline_to_gnm_underline
(ms_wb_get_font_markup): use gnm_translate_underline_to_pango
(excel_read_CF): use xls_uline_to_gnm_underline
* ms-excel-write.c (map_underline_to_xl) rename
to map_style_underline_to_xl and use new map_underline_to_xl,
change all callers
(map_underline_to_xl): new
(excel_font_to_string): add UNDERLINE_*_LOW
(excel_font_overlay_pango): use gnm_translate_underline_from_pango
(excel_font_from_go_font): fix typo
(excel_write_FONT): use map_underline_to_xl
* xlsx-read.c (xlsx_font_uline): add UNDERLINE_*_LOW
(xlsx_font_valign): fix typo
ChangeLog | 20 ++++++++
NEWS | 1 +
plugins/excel/ChangeLog | 18 +++++++
plugins/excel/excel-xml-read.c | 4 +-
plugins/excel/ms-excel-read.c | 83 +++++++++++++++++---------------
plugins/excel/ms-excel-write.c | 40 +++++++++-------
plugins/excel/xlsx-read.c | 6 +-
plugins/openoffice/ChangeLog | 7 +++
plugins/openoffice/openoffice-read.c | 17 ++++---
plugins/openoffice/openoffice-write.c | 6 ++
src/dialogs/ChangeLog | 4 ++
src/dialogs/dialog-cell-format.c | 6 ++-
src/mstyle.c | 50 ++++++-------------
src/style.c | 40 ++++++++++++++++
src/style.h | 6 ++-
src/wbc-gtk-actions.c | 20 ++++++--
src/wbc-gtk-impl.h | 3 +-
src/wbc-gtk.c | 6 ++
18 files changed, 226 insertions(+), 111 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index f0486be..686a8d2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,23 @@
+2010-07-28 Andreas J. Guelzow <aguelzow pyrshep ca>
+
+ * src/mstyle.c (gnm_style_get_pango_attrs): use
+ gnm_translate_underline_to_pango
+ (gnm_style_generate_attrs_full): use gnm_translate_underline_to_pango
+ (gnm_style_set_from_pango_attribute): use
+ gnm_translate_underline_from_pango
+ * src/style.c (gnm_translate_underline_to_pango): new
+ (gnm_translate_underline_from_pango): new
+ * src/style.h (gnm_translate_underline_to_pango): new
+ (gnm_translate_underline_from_pango): new
+ * src/wbc-gtk-actions.c (FontSingleLowUnderline): new actions
+ (FontDoubleLowUnderline): new actions
+ (cb_font_underline_low): new
+ (cb_font_double_underline_low): new
+ * src/wbc-gtk-impl.h (_WBCGtk): add toggle action fields
+ * src/wbc-gtk.c (wbc_gtk_style_feedback_real): handle
+ UNDERLINE_*_LOW
+ (wbc_gtk_init): add Font*LowUnderline
+
2010-07-27 Andreas J. Guelzow <aguelzow pyrshep ca>
* src/dead-kittens.h (gtk_dialog_get_content_area): new
diff --git a/NEWS b/NEWS
index b707c7f..2e6890e 100644
--- a/NEWS
+++ b/NEWS
@@ -53,6 +53,7 @@ Andreas:
* Reduce the size of the text import dialog. [#625281]
* Fix import of underlined/double underlined comments from xls.
Part of [#405951]
+ * Improve xl import of underlines.
Jean:
* Fix strong/weak cursor display. [#623241]
diff --git a/plugins/excel/ChangeLog b/plugins/excel/ChangeLog
index 62b4466..2df4e08 100644
--- a/plugins/excel/ChangeLog
+++ b/plugins/excel/ChangeLog
@@ -1,3 +1,21 @@
+2010-07-28 Andreas J. Guelzow <aguelzow pyrshep ca>
+
+ * excel-xml-read.c (xl_xml_font): add UNDERLINE_*_LOW
+ * ms-excel-read.c (xls_uline_to_gnm_underline): new
+ (excel_get_style_from_xf): use xls_uline_to_gnm_underline
+ (ms_wb_get_font_markup): use gnm_translate_underline_to_pango
+ (excel_read_CF): use xls_uline_to_gnm_underline
+ * ms-excel-write.c (map_underline_to_xl) rename
+ to map_style_underline_to_xl and use new map_underline_to_xl,
+ change all callers
+ (map_underline_to_xl): new
+ (excel_font_to_string): add UNDERLINE_*_LOW
+ (excel_font_overlay_pango): use gnm_translate_underline_from_pango
+ (excel_font_from_go_font): fix typo
+ (excel_write_FONT): use map_underline_to_xl
+ * xlsx-read.c (xlsx_font_uline): add UNDERLINE_*_LOW
+ (xlsx_font_valign): fix typo
+
2010-07-27 Andreas J. Guelzow <aguelzow pyrshep ca>
* ms-excel-read.h (ExcelFont): change underline field from PangoUnderline
diff --git a/plugins/excel/excel-xml-read.c b/plugins/excel/excel-xml-read.c
index 97db7a0..7669b1d 100644
--- a/plugins/excel/excel-xml-read.c
+++ b/plugins/excel/excel-xml-read.c
@@ -502,9 +502,9 @@ xl_xml_font (GsfXMLIn *xin, xmlChar const **attrs)
static EnumVal const underlines[] = {
{ "None", UNDERLINE_NONE },
{ "Single", UNDERLINE_SINGLE },
- { "SingleAccounting", UNDERLINE_SINGLE },
+ { "SingleAccounting", UNDERLINE_SINGLE_LOW },
{ "Double", UNDERLINE_DOUBLE },
- { "DoubleAccounting", UNDERLINE_DOUBLE },
+ { "DoubleAccounting", UNDERLINE_DOUBLE_LOW },
{ NULL, 0 }
};
static EnumVal const scripts[] = {
diff --git a/plugins/excel/ms-excel-read.c b/plugins/excel/ms-excel-read.c
index 9cc3c56..f4ff80b 100644
--- a/plugins/excel/ms-excel-read.c
+++ b/plugins/excel/ms-excel-read.c
@@ -1617,6 +1617,9 @@ excel_read_FONT (BiffQuery *q, GnmXLImporter *importer)
case 2: fd->underline = XLS_ULINE_DOUBLE; break;
case 0x21: fd->underline = XLS_ULINE_SINGLE_ACC; break; /* single accounting */
case 0x22: fd->underline = XLS_ULINE_DOUBLE_ACC; break; /* double accounting */
+ default:
+ g_printerr ("Unknown uline %#x\n", (int)data1);
+ break;
}
fd->fontname = excel_biff_text_1 (importer, q, 14);
}
@@ -1925,6 +1928,28 @@ excel_get_xf (ExcelReadSheet *esheet, unsigned xfidx)
return g_ptr_array_index (p, xfidx);
}
+static GnmUnderline
+xls_uline_to_gnm_underline (MsBiffFontUnderline mul)
+{
+ g_return_val_if_fail (mul >= XLS_ULINE_NONE, UNDERLINE_NONE);
+ g_return_val_if_fail (mul <= XLS_ULINE_DOUBLE_ACC, UNDERLINE_NONE);
+
+ switch (mul) {
+ case XLS_ULINE_SINGLE:
+ return UNDERLINE_SINGLE;
+ case XLS_ULINE_DOUBLE:
+ return UNDERLINE_DOUBLE;
+ case XLS_ULINE_SINGLE_ACC:
+ return UNDERLINE_SINGLE_LOW;
+ case XLS_ULINE_DOUBLE_ACC:
+ return UNDERLINE_DOUBLE_LOW;
+ case XLS_ULINE_NONE:
+ default:
+ return UNDERLINE_NONE;
+ }
+
+}
+
/* Adds a ref the result */
static GnmStyle *
excel_get_style_from_xf (ExcelReadSheet *esheet, BiffXFData const *xf)
@@ -1967,28 +1992,14 @@ excel_get_style_from_xf (ExcelReadSheet *esheet, BiffXFData const *xf)
/* Font */
fd = excel_font_get (esheet->container.importer, xf->font_idx);
if (fd != NULL) {
- GnmUnderline underline = UNDERLINE_NONE;
-
gnm_style_set_font_name (mstyle, fd->fontname);
gnm_style_set_font_size (mstyle, fd->height / 20.0);
gnm_style_set_font_bold (mstyle, fd->boldness >= 0x2bc);
gnm_style_set_font_italic (mstyle, fd->italic);
gnm_style_set_font_strike (mstyle, fd->struck_out);
gnm_style_set_font_script (mstyle, fd->script);
-
- switch (fd->underline) {
- case XLS_ULINE_SINGLE:
- case XLS_ULINE_SINGLE_ACC:
- underline = UNDERLINE_SINGLE;
- break;
- case XLS_ULINE_DOUBLE:
- case XLS_ULINE_DOUBLE_ACC:
- underline = UNDERLINE_DOUBLE;
- break;
- default: break;
- }
- gnm_style_set_font_uline (mstyle, underline);
-
+ gnm_style_set_font_uline
+ (mstyle, xls_uline_to_gnm_underline (fd->underline));
font_index = fd->color_idx;
} else
font_index = 127; /* Default to Black */
@@ -3062,21 +3073,8 @@ ms_wb_get_font_markup (MSContainer const *c, unsigned indx)
if (fd->attrs == NULL) {
PangoAttrList *attrs;
- PangoUnderline underline = PANGO_UNDERLINE_NONE;
-
- switch (fd->underline) {
- case XLS_ULINE_SINGLE:
- case XLS_ULINE_SINGLE_ACC:
- underline = PANGO_UNDERLINE_SINGLE;
- break;
-
- case XLS_ULINE_DOUBLE:
- case XLS_ULINE_DOUBLE_ACC:
- underline = PANGO_UNDERLINE_DOUBLE;
- break;
-
- default: break;
- }
+ PangoUnderline underline = gnm_translate_underline_to_pango
+ (xls_uline_to_gnm_underline (fd->underline));
attrs = pango_attr_list_new ();
add_attr (attrs, pango_attr_family_new (fd->fontname));
@@ -5050,21 +5048,28 @@ excel_read_CF (BiffQuery *q, ExcelReadSheet *esheet, GnmStyleConditions *sc)
}
}
if (0 == GSF_LE_GET_GUINT8 (data + 32)) {
+ MsBiffFontUnderline mul;
switch (GSF_LE_GET_GUINT8 (data + 12)) {
default :
case 0:
- gnm_style_set_font_uline (cond.overlay,
- UNDERLINE_NONE);
+ mul = XLS_ULINE_NONE;
+ break;
+ case 1:
+ mul = XLS_ULINE_SINGLE;
+ break;
+ case 2:
+ mul = XLS_ULINE_DOUBLE;
break;
- case 1: case 0x21:
- gnm_style_set_font_uline (cond.overlay,
- UNDERLINE_SINGLE);
+ case 0x21:
+ mul = XLS_ULINE_SINGLE_ACC;
break;
- case 2: case 0x22:
- gnm_style_set_font_uline (cond.overlay,
- UNDERLINE_DOUBLE);
+ case 0x22:
+ mul = XLS_ULINE_DOUBLE_ACC;
break;
}
+ gnm_style_set_font_uline
+ (cond.overlay,
+ xls_uline_to_gnm_underline (mul));
}
d (3, {
diff --git a/plugins/excel/ms-excel-write.c b/plugins/excel/ms-excel-write.c
index 574936c..1aa9d46 100644
--- a/plugins/excel/ms-excel-write.c
+++ b/plugins/excel/ms-excel-write.c
@@ -886,17 +886,27 @@ write_border (ExcelWriteSheet const *esheet,
}
static int
-map_underline_to_xl (GnmStyle const *style)
+map_underline_to_xl (GnmUnderline const ul)
{
- switch (gnm_style_get_font_uline (style)) {
+ switch (ul) {
default :
case UNDERLINE_NONE : return 0;
case UNDERLINE_SINGLE : return 1;
case UNDERLINE_DOUBLE : return 2;
+ case UNDERLINE_SINGLE_LOW : return 0x21;
+ case UNDERLINE_DOUBLE_LOW : return 0x22;
}
}
static int
+map_style_underline_to_xl (GnmStyle const *style)
+{
+ return map_underline_to_xl (gnm_style_get_font_uline (style));
+}
+
+
+
+static int
map_script_to_xl (GnmStyle const *style)
{
switch (gnm_style_get_font_script (style)) {
@@ -988,7 +998,7 @@ cb_write_condition (GnmStyleConditions const *sc, CondDetails *cd,
GSF_LE_SET_GUINT32 (fbuf+68, tmp);
if (gnm_style_is_element_set (s, MSTYLE_FONT_UNDERLINE)) {
- tmp = map_underline_to_xl (s);
+ tmp = map_style_underline_to_xl (s);
GSF_LE_SET_GUINT32 (fbuf+76, tmp);
} else
GSF_LE_SET_GUINT32 (fbuf+96, 1); /* flag as unused */
@@ -1917,6 +1927,12 @@ excel_font_to_string (ExcelWriteFont const *f)
else if ((GnmUnderline) f->underline == UNDERLINE_DOUBLE)
nused += snprintf (buf + nused, sizeof buf - nused,
", %s", "double underline");
+ else if ((GnmUnderline) f->underline == UNDERLINE_SINGLE_LOW)
+ nused += snprintf (buf + nused, sizeof buf - nused,
+ ", %s", "single low underline");
+ else if ((GnmUnderline) f->underline == UNDERLINE_DOUBLE_LOW)
+ nused += snprintf (buf + nused, sizeof buf - nused,
+ ", %s", "double low underline");
}
if (nused < sizeof buf && f->strikethrough)
nused += snprintf (buf + nused, sizeof buf - nused, ", %s",
@@ -2001,17 +2017,8 @@ excel_font_overlay_pango (ExcelWriteFont *efont, GSList *pango)
break;
case PANGO_ATTR_UNDERLINE :
- switch (((PangoAttrInt *)attr)->value) {
- case PANGO_UNDERLINE_NONE :
- efont->underline = UNDERLINE_NONE;
- break;
- case PANGO_UNDERLINE_SINGLE :
- efont->underline = UNDERLINE_SINGLE;
- break;
- case PANGO_UNDERLINE_DOUBLE :
- efont->underline = UNDERLINE_DOUBLE;
- break;
- }
+ efont->underline = gnm_translate_underline_from_pango
+ (((PangoAttrInt *)attr)->value);
break;
case PANGO_ATTR_FOREGROUND :
@@ -2126,7 +2133,7 @@ excel_font_from_go_font (XLExportBase *ewb, GOFont const *font)
efont->is_bold = pango_font_description_get_weight (font->desc) > PANGO_WEIGHT_NORMAL;
efont->is_italic = pango_font_description_get_style (font->desc) != PANGO_STYLE_NORMAL;
/* FIXME: implement when supported */
- efont->underline = FALSE;
+ efont->underline = UNDERLINE_NONE;
efont->strikethrough = FALSE;
efont->script = 0;
efont->color = go_color_to_bgr (GO_COLOR_BLACK);
@@ -2154,8 +2161,7 @@ excel_write_FONT (ExcelWriteState *ewb, ExcelWriteFont const *f)
/* 0: Normal, 1; Super, 2: Sub script*/
guint16 subsuper = f->script;
- /* 0: None, 1: Single, 2: Double */
- guint8 underline = (guint8) f->underline;
+ guint8 underline = (guint8) map_underline_to_xl (f->underline);
guint8 family = 0;
guint8 charset = 0; /* Seems OK. */
diff --git a/plugins/excel/xlsx-read.c b/plugins/excel/xlsx-read.c
index 0bb81af..0733e3b 100644
--- a/plugins/excel/xlsx-read.c
+++ b/plugins/excel/xlsx-read.c
@@ -4563,8 +4563,8 @@ xlsx_font_uline (GsfXMLIn *xin, xmlChar const **attrs)
static EnumVal const types[] = {
{ "single", UNDERLINE_SINGLE },
{ "double", UNDERLINE_DOUBLE },
- { "singleAccounting", UNDERLINE_SINGLE },
- { "doubleAccounting", UNDERLINE_DOUBLE },
+ { "singleAccounting", UNDERLINE_SINGLE_LOW },
+ { "doubleAccounting", UNDERLINE_DOUBLE_LOW },
{ "none", UNDERLINE_NONE },
{ NULL, 0 }
};
@@ -4587,7 +4587,7 @@ xlsx_font_valign (GsfXMLIn *xin, xmlChar const **attrs)
{ NULL, 0 }
};
XLSXReadState *state = (XLSXReadState *)xin->user_state;
- int val = UNDERLINE_SINGLE;
+ int val = GO_FONT_SCRIPT_STANDARD;
for (; attrs != NULL && attrs[0] && attrs[1] ; attrs += 2)
if (attr_enum (xin, attrs, "val", types, &val))
diff --git a/plugins/openoffice/ChangeLog b/plugins/openoffice/ChangeLog
index 375541b..34dca85 100644
--- a/plugins/openoffice/ChangeLog
+++ b/plugins/openoffice/ChangeLog
@@ -1,3 +1,10 @@
+2010-07-28 Andreas J. Guelzow <aguelzow pyrshep ca>
+
+ * openoffice-read.c (oo_style_prop_cell): handle
+ style:text-underline-type
+ * openoffice-write.c (odf_write_style_text_properties): add
+ UNDERLINE_*_LOW
+
2010-07-26 Andreas J. Guelzow <aguelzow pyrshep ca>
* openoffice-read.c (oo_db_range_start): If this filter range
diff --git a/plugins/openoffice/openoffice-read.c b/plugins/openoffice/openoffice-read.c
index b77c376..6bc91b0 100644
--- a/plugins/openoffice/openoffice-read.c
+++ b/plugins/openoffice/openoffice-read.c
@@ -2564,14 +2564,15 @@ oo_style_prop_cell (GsfXMLIn *xin, xmlChar const **attrs)
gnm_float size;
if (1 == sscanf (CXML2C (attrs[1]), "%" GNM_SCANF_g "pt", &size))
gnm_style_set_font_size (style, size);
-
- /* TODO : get specs on how these relate */
- } else if (gsf_xml_in_namecmp (xin, CXML2C (attrs[0]), OO_NS_STYLE, "text-underline-style") ||
- gsf_xml_in_namecmp (xin, CXML2C (attrs[0]), OO_NS_STYLE, "text-underline-type") ||
- gsf_xml_in_namecmp (xin, CXML2C (attrs[0]), OO_NS_STYLE, "text-underline"))
- /* cheesy simple support for now */
- gnm_style_set_font_uline (style, attr_eq (attrs[1], "none") ? UNDERLINE_NONE : UNDERLINE_SINGLE);
- else if (gsf_xml_in_namecmp (xin, CXML2C (attrs[0]), OO_NS_FO, "font-style"))
+ } else if (gsf_xml_in_namecmp (xin, CXML2C (attrs[0]), OO_NS_STYLE, "text-underline-type") ||
+ gsf_xml_in_namecmp (xin, CXML2C (attrs[0]), OO_NS_STYLE, "text-underline")) {
+ if (attr_eq (attrs[1], "none"))
+ gnm_style_set_font_uline (style, UNDERLINE_NONE);
+ else if (attr_eq (attrs[1], "single"))
+ gnm_style_set_font_uline (style, UNDERLINE_SINGLE);
+ else if (attr_eq (attrs[1], "double"))
+ gnm_style_set_font_uline (style, UNDERLINE_DOUBLE);
+ } else if (gsf_xml_in_namecmp (xin, CXML2C (attrs[0]), OO_NS_FO, "font-style"))
gnm_style_set_font_italic (style, attr_eq (attrs[1], "italic"));
else if (gsf_xml_in_namecmp (xin, CXML2C (attrs[0]), OO_NS_FO, "font-weight")) {
int weight = atoi (CXML2C (attrs[1]));
diff --git a/plugins/openoffice/openoffice-write.c b/plugins/openoffice/openoffice-write.c
index 7a15e4a..a821b38 100644
--- a/plugins/openoffice/openoffice-write.c
+++ b/plugins/openoffice/openoffice-write.c
@@ -922,6 +922,12 @@ odf_write_style_text_properties (GnmOOExport *state, GnmStyle const *style)
case UNDERLINE_DOUBLE:
UNDERLINESPECS("double", "solid", "auto");
break;
+ case UNDERLINE_SINGLE_LOW:
+ UNDERLINESPECS("single", "solid", "auto");
+ break;
+ case UNDERLINE_DOUBLE_LOW:
+ UNDERLINESPECS("double", "solid", "auto");
+ break;
}
/* Superscript/Subscript */
if (gnm_style_is_element_set (style, MSTYLE_FONT_SCRIPT))
diff --git a/src/dialogs/ChangeLog b/src/dialogs/ChangeLog
index 2c16527..87ba85f 100644
--- a/src/dialogs/ChangeLog
+++ b/src/dialogs/ChangeLog
@@ -1,3 +1,7 @@
+2010-07-28 Andreas J. Guelzow <aguelzow pyrshep ca>
+
+ * dialog-cell-format.c (underline_types): add low underlines
+
2010-07-28 Morten Welinder <terra gnome org>
* dialog-about.c (text_item_renderer): Draw with pango.
diff --git a/src/dialogs/dialog-cell-format.c b/src/dialogs/dialog-cell-format.c
index 82064ab..d8abced 100644
--- a/src/dialogs/dialog-cell-format.c
+++ b/src/dialogs/dialog-cell-format.c
@@ -72,7 +72,11 @@ static struct {
} const underline_types[] = {
{ N_("None"), UNDERLINE_NONE },
{ N_("Single"), UNDERLINE_SINGLE },
- { N_("Double"), UNDERLINE_DOUBLE }
+ { N_("Double"), UNDERLINE_DOUBLE },
+ /* xgettext: This refers to a "single low underline" */
+ { N_("Single Low"), UNDERLINE_SINGLE_LOW },
+ /* xgettext: This refers to a "double low underline" */
+ { N_("Double Low"), UNDERLINE_DOUBLE_LOW }
};
/* The order corresponds to border_preset_buttons */
diff --git a/src/mstyle.c b/src/mstyle.c
index 092a88f..3b34584 100644
--- a/src/mstyle.c
+++ b/src/mstyle.c
@@ -1648,6 +1648,7 @@ gnm_style_get_pango_attrs (GnmStyle const *style,
double zoom)
{
PangoAttrList *l;
+ GnmUnderline ul;
if (style->pango_attrs) {
if (zoom == style->pango_attrs_zoom) {
@@ -1669,19 +1670,16 @@ gnm_style_get_pango_attrs (GnmStyle const *style,
}
/* Handle underlining. */
- switch (gnm_style_get_font_uline (style)) {
- case UNDERLINE_SINGLE :
- add_attr (l, pango_attr_underline_new (PANGO_UNDERLINE_SINGLE));
- break;
- case UNDERLINE_DOUBLE :
- add_attr (l, pango_attr_underline_new (PANGO_UNDERLINE_DOUBLE));
- break;
- default :
- break;
- }
+ ul = gnm_style_get_font_uline (style);
+ if (ul != UNDERLINE_NONE)
+ add_attr (l,
+ pango_attr_underline_new (gnm_translate_underline_to_pango (ul)));
+ /* Handle strikethrough. */
if (gnm_style_get_font_strike (style))
add_attr (l, pango_attr_strikethrough_new (TRUE));
+
+ /* Handle script. */
switch (gnm_style_get_font_script (style)) {
default :
case GO_FONT_SCRIPT_STANDARD :
@@ -1720,19 +1718,11 @@ gnm_style_generate_attrs_full (GnmStyle const *style)
add_attr (l, pango_attr_weight_new (gnm_style_get_font_bold (style)
? PANGO_WEIGHT_BOLD : PANGO_WEIGHT_NORMAL));
add_attr (l, go_color_to_pango (fore->go_color, TRUE));
- add_attr (l, pango_attr_strikethrough_new (gnm_style_get_font_strike (style)));
- switch (gnm_style_get_font_uline (style)) {
- case UNDERLINE_SINGLE :
- add_attr (l, pango_attr_underline_new (PANGO_UNDERLINE_SINGLE));
- break;
- case UNDERLINE_DOUBLE :
- add_attr (l, pango_attr_underline_new (PANGO_UNDERLINE_DOUBLE));
- break;
- default :
- add_attr (l, pango_attr_underline_new (PANGO_UNDERLINE_NONE));
- break;
- }
-
+ add_attr (l, pango_attr_strikethrough_new
+ (gnm_style_get_font_strike (style)));
+ add_attr (l, pango_attr_underline_new
+ (gnm_translate_underline_to_pango
+ (gnm_style_get_font_uline (style))));
return l;
}
@@ -1782,17 +1772,9 @@ gnm_style_set_from_pango_attribute (GnmStyle *style, PangoAttribute const *attr)
&((PangoAttrColor *)attr)->color));
break;
case PANGO_ATTR_UNDERLINE :
- switch (((PangoAttrInt *)attr)->value) {
- case PANGO_UNDERLINE_NONE :
- gnm_style_set_font_uline (style, UNDERLINE_NONE);
- break;
- case PANGO_UNDERLINE_SINGLE :
- gnm_style_set_font_uline (style, UNDERLINE_SINGLE);
- break;
- case PANGO_UNDERLINE_DOUBLE :
- gnm_style_set_font_uline (style, UNDERLINE_DOUBLE);
- break;
- }
+ gnm_style_set_font_uline
+ (style, gnm_translate_underline_from_pango
+ (((PangoAttrInt *)attr)->value));
break;
case PANGO_ATTR_STRIKETHROUGH :
gnm_style_set_font_strike (style,
diff --git a/src/style.c b/src/style.c
index 68e56de..c4c266e 100644
--- a/src/style.c
+++ b/src/style.c
@@ -513,3 +513,43 @@ gnm_style_default_halign (GnmStyle const *mstyle, GnmCell const *c)
}
return HALIGN_RIGHT;
}
+
+PangoUnderline
+gnm_translate_underline_to_pango (GnmUnderline ul)
+{
+ g_return_val_if_fail (ul >= UNDERLINE_NONE, PANGO_UNDERLINE_NONE);
+ g_return_val_if_fail (ul <= UNDERLINE_DOUBLE_LOW, PANGO_UNDERLINE_NONE);
+
+ switch (ul) {
+ case UNDERLINE_SINGLE:
+ return PANGO_UNDERLINE_SINGLE;
+ case UNDERLINE_DOUBLE:
+ case UNDERLINE_DOUBLE_LOW:
+ return PANGO_UNDERLINE_DOUBLE;
+ case UNDERLINE_SINGLE_LOW:
+ return PANGO_UNDERLINE_LOW;
+ case UNDERLINE_NONE:
+ default:
+ return PANGO_UNDERLINE_NONE;
+ }
+}
+
+GnmUnderline
+gnm_translate_underline_from_pango (PangoUnderline pul)
+{
+ g_return_val_if_fail (pul >= PANGO_UNDERLINE_NONE, UNDERLINE_NONE);
+ g_return_val_if_fail (pul <= PANGO_UNDERLINE_LOW, UNDERLINE_NONE);
+
+ switch (pul) {
+ case PANGO_UNDERLINE_SINGLE:
+ return UNDERLINE_SINGLE;
+ case PANGO_UNDERLINE_DOUBLE:
+ return UNDERLINE_DOUBLE;
+ case PANGO_UNDERLINE_LOW:
+ return UNDERLINE_SINGLE_LOW;
+ case PANGO_UNDERLINE_NONE:
+ default:
+ return UNDERLINE_NONE;
+ }
+
+}
diff --git a/src/style.h b/src/style.h
index af218a1..cb09cde 100644
--- a/src/style.h
+++ b/src/style.h
@@ -35,7 +35,9 @@ typedef enum {
typedef enum {
UNDERLINE_NONE = 0,
UNDERLINE_SINGLE = 1,
- UNDERLINE_DOUBLE = 2
+ UNDERLINE_DOUBLE = 2,
+ UNDERLINE_SINGLE_LOW = 3,
+ UNDERLINE_DOUBLE_LOW = 4
} GnmUnderline;
typedef enum {
@@ -55,6 +57,8 @@ typedef enum {
GnmSpanCalcFlags gnm_style_required_spanflags (GnmStyle const *style);
GnmHAlign gnm_style_default_halign (GnmStyle const *style,
GnmCell const *c);
+PangoUnderline gnm_translate_underline_to_pango (GnmUnderline ul);
+GnmUnderline gnm_translate_underline_from_pango (PangoUnderline pul);
G_END_DECLS
diff --git a/src/wbc-gtk-actions.c b/src/wbc-gtk-actions.c
index 05aeb9b..8f97648 100644
--- a/src/wbc-gtk-actions.c
+++ b/src/wbc-gtk-actions.c
@@ -1441,8 +1441,8 @@ toggle_font_attr (WBCGtk *wbcg, GtkToggleAction *act,
attr = pango_attr_style_new (val ? PANGO_STYLE_ITALIC : PANGO_STYLE_NORMAL);
break;
case MSTYLE_FONT_UNDERLINE:
- attr = pango_attr_underline_new ((val == UNDERLINE_SINGLE) ? PANGO_UNDERLINE_SINGLE
- : ((val == UNDERLINE_DOUBLE) ? PANGO_UNDERLINE_DOUBLE : PANGO_UNDERLINE_NONE));
+ attr = pango_attr_underline_new
+ (gnm_translate_underline_to_pango (val));
break;
case MSTYLE_FONT_STRIKETHROUGH:
attr = pango_attr_strikethrough_new (val);
@@ -1480,6 +1480,10 @@ static void cb_font_underline (GtkToggleAction *act, WBCGtk *wbcg)
{ toggle_font_attr (wbcg, act, MSTYLE_FONT_UNDERLINE, UNDERLINE_SINGLE, UNDERLINE_NONE); }
static void cb_font_double_underline (GtkToggleAction *act, WBCGtk *wbcg)
{ toggle_font_attr (wbcg, act, MSTYLE_FONT_UNDERLINE, UNDERLINE_DOUBLE, UNDERLINE_NONE); }
+static void cb_font_underline_low (GtkToggleAction *act, WBCGtk *wbcg)
+ { toggle_font_attr (wbcg, act, MSTYLE_FONT_UNDERLINE, UNDERLINE_SINGLE_LOW, UNDERLINE_NONE); }
+static void cb_font_double_underline_low (GtkToggleAction *act, WBCGtk *wbcg)
+ { toggle_font_attr (wbcg, act, MSTYLE_FONT_UNDERLINE, UNDERLINE_DOUBLE_LOW, UNDERLINE_NONE); }
static void cb_font_strikethrough (GtkToggleAction *act, WBCGtk *wbcg)
{ toggle_font_attr (wbcg, act, MSTYLE_FONT_STRIKETHROUGH, TRUE, FALSE); }
static void cb_font_subscript (GtkToggleAction *act, WBCGtk *wbcg)
@@ -2689,12 +2693,18 @@ static GtkToggleActionEntry const font_toggle_actions[] = {
{ "FontUnderline", GTK_STOCK_UNDERLINE,
N_("_Underline"), "<control>u", /* ALSO "<control>4" */
N_("Underline"), G_CALLBACK (cb_font_underline), FALSE },
- { "FontStrikeThrough", GTK_STOCK_STRIKETHROUGH,
- N_("_Strike Through"), "<control>5",
- N_("Strike Through"), G_CALLBACK (cb_font_strikethrough), FALSE },
{ "FontDoubleUnderline", "stock_text_underlined-double", /* from icon theme */
N_("_Double Underline"), "<control><shift>d",
N_("Double Underline"), G_CALLBACK (cb_font_double_underline), FALSE },
+ { "FontSingleLowUnderline", NULL, /* from icon theme */
+ N_("_Single Low Underline"), "<control><shift>l",
+ N_("Single Low Underline"), G_CALLBACK (cb_font_underline_low), FALSE },
+ { "FontDoubleLowUnderline", NULL, /* from icon theme */
+ N_("_Double Low Underline"), NULL,
+ N_("Double Low Underline"), G_CALLBACK (cb_font_double_underline_low), FALSE },
+ { "FontStrikeThrough", GTK_STOCK_STRIKETHROUGH,
+ N_("_Strike Through"), "<control>5",
+ N_("Strike Through"), G_CALLBACK (cb_font_strikethrough), FALSE },
{ "FontSuperscript", "stock_superscript", /* from icon theme */
N_("Su_perscript"), "<control>asciicircum",
N_("Superscript"), G_CALLBACK (cb_font_superscript), FALSE },
diff --git a/src/wbc-gtk-impl.h b/src/wbc-gtk-impl.h
index 989655e..a5fe235 100644
--- a/src/wbc-gtk-impl.h
+++ b/src/wbc-gtk-impl.h
@@ -121,7 +121,8 @@ struct _WBCGtk {
GtkAction *zoom_vaction;
GOActionComboPixmaps *borders, *halignment, *valignment;
struct {
- GtkToggleAction *bold, *italic, *underline, *d_underline;
+ GtkToggleAction *bold, *italic, *underline, *d_underline,
+ *sl_underline, *dl_underline;
GtkToggleAction *superscript, *subscript, *strikethrough;
} font;
struct {
diff --git a/src/wbc-gtk.c b/src/wbc-gtk.c
index b119e51..767bd63 100644
--- a/src/wbc-gtk.c
+++ b/src/wbc-gtk.c
@@ -3338,6 +3338,10 @@ wbc_gtk_style_feedback_real (WorkbookControl *wbc, GnmStyle const *changes)
gnm_style_get_font_uline (changes) == UNDERLINE_SINGLE);
gtk_toggle_action_set_active (wbcg->font.d_underline,
gnm_style_get_font_uline (changes) == UNDERLINE_DOUBLE);
+ gtk_toggle_action_set_active (wbcg->font.sl_underline,
+ gnm_style_get_font_uline (changes) == UNDERLINE_SINGLE_LOW);
+ gtk_toggle_action_set_active (wbcg->font.dl_underline,
+ gnm_style_get_font_uline (changes) == UNDERLINE_DOUBLE_LOW);
}
if (gnm_style_is_element_set (changes, MSTYLE_FONT_STRIKETHROUGH))
gtk_toggle_action_set_active (wbcg->font.strikethrough,
@@ -5370,6 +5374,8 @@ wbc_gtk_init (GObject *obj)
{ "FontItalic", TRUE, G_STRUCT_OFFSET (WBCGtk, font.italic) },
{ "FontUnderline", TRUE, G_STRUCT_OFFSET (WBCGtk, font.underline) },
{ "FontDoubleUnderline", TRUE, G_STRUCT_OFFSET (WBCGtk, font.d_underline) },
+ { "FontSingleLowUnderline",TRUE, G_STRUCT_OFFSET (WBCGtk, font.sl_underline) },
+ { "FontDoubleLowUnderline",TRUE, G_STRUCT_OFFSET (WBCGtk, font.dl_underline) },
{ "FontSuperscript", TRUE, G_STRUCT_OFFSET (WBCGtk, font.superscript) },
{ "FontSubscript", TRUE, G_STRUCT_OFFSET (WBCGtk, font.subscript) },
{ "FontStrikeThrough", TRUE, G_STRUCT_OFFSET (WBCGtk, font.strikethrough) },
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]