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

merge in format_destroy there was no utility in keeping them distinct. Do

2005-09-26  Jody Goldberg <jody@gnome.org>

	* goffice/utils/format.c (go_format_unref) : merge in format_destroy
	  there was no utility in keeping them distinct.  Do not warn about
	  the final unref of a markup style, they are not kept in the global
	  cache.
	(go_format_new_markup) : do not put markup formats in the global
	  cache.  We do not really want to share them, and the old code would
	  replace existing formats in the rare situation where some rich text
	  formating happened to be used in the same way in two places
	  eg C sub 1  vs C sub 2
	(go_format_parse_markup) : support rise.
	(cb_attrs_as_string) : ditto.

2005-09-28  Jody Goldberg <jody@gnome.org>

	* ms-chart.c (xl_chart_import_reg_curve) : split out from
	  ms_excel_chart_read.
	(xl_chart_import_error_bar) : ditto.

	* ms-excel-write.c (excel_font_overlay_pango) : check super/sub scripts.
	(excel_font_hash) : ditto.
	(excel_font_equal) : ditto.
	(excel_font_new) : init the super/sub status
	(map_underline_to_xl) : new.
	(map_script_to_xl) : new.
	(cb_write_condition) : handle super/sub script.
	(excel_write_FONT) : ditto.
	(excel_font_new) : ditto.

	* ms-excel-read.c (ms_wb_get_font_markup) : The super/subscript
	  distances were broken.  Use 5000 not 500.  Seems like we may want a
	  scale in there too.
	(excel_read_FONT) : Use GOFontScript
	(excel_get_style_from_xf) : store the script (super/sub)
	(excel_read_CF) : handle scripts.

2005-09-26  Jody Goldberg <jody@gnome.org>

	* cell-format.glade : give the super/sub script buttons names and
	  enable them.
	* dialog-cell-format.c (cb_font_changed) : watch for script changes.
	(cb_font_script_toggle) : new.
	(fmt_dialog_init_font_page) : setup super/sub script buttons.

2005-09-26  Jody Goldberg <jody@gnome.org>

	* src/gnm-style-impl.h : Add a script element to GnmStyle
	* src/mstyle.c (elem_is_eq) : support scripts
	(elem_assign_content) : support scripts
	(gnm_style_new_default) : support scripts
	(gnm_style_get_pango_attrs) : support scripts
	(gnm_style_dump) : support scripts
	(gnm_style_set_font_script) : new.
	(gnm_style_get_font_script) : new.

	* src/GNOME_Gnumeric-gtk.xml.in  : Add the super/sub script
	  accelerators

	* gnumeric.xsd : update to include the new h/v alignments and to add
	  Script.

	* src/wbc-gtk.c (wbc_gtk_style_feedback) : support super/sub script
	  and fix support for double underline

	* src/wbcg-actions.c (toggle_font_attr) : support super/sub script
	(cb_font_subscript) : new.
	(cb_font_superscript) : new.

	* src/xml-io.c (xml_write_style) : ditto.
	(xml_read_style) : ditto.
	* src/xml-sax-read.c (xml_sax_styleregion_font) : ditto.
	* src/xml-sax-write.c (xml_write_gnmstyle) : ditto.
parent 25c70456
......@@ -8,9 +8,6 @@ release, and longer term bugs.
Release Critical
----------------
** (lt-gnumeric:23623): WARNING **: Probable ref counting problem. fmt 0x11977118 '@[family=Arial:4:2147483647][size=10240:4:2147483647][bold=1:4:2147483647][italic=1:4:2147483647][strikthrough=0:4:2147483647][underline=none:4:2147483647][color=00x00x00:4:2147483647]' is being unrefed while still in the global cache
: Some sort of rich text ref counting oddness.
Pending Patches
---------------
- Patch for non-gconf gnm-config {bugzilla}
......
2005-09-26 Jody Goldberg <jody@gnome.org>
* src/gnm-style-impl.h : Add a script element to GnmStyle
* src/mstyle.c (elem_is_eq) : support scripts
(elem_assign_content) : support scripts
(gnm_style_new_default) : support scripts
(gnm_style_get_pango_attrs) : support scripts
(gnm_style_dump) : support scripts
(gnm_style_set_font_script) : new.
(gnm_style_get_font_script) : new.
* src/GNOME_Gnumeric-gtk.xml.in : Add the super/sub script
accelerators
* gnumeric.xsd : update to include the new h/v alignments and to add
Script.
* src/wbc-gtk.c (wbc_gtk_style_feedback) : support super/sub script
and fix support for double underline
* src/wbcg-actions.c (toggle_font_attr) : support super/sub script
(cb_font_subscript) : new.
(cb_font_superscript) : new.
* src/xml-io.c (xml_write_style) : ditto.
(xml_read_style) : ditto.
* src/xml-sax-read.c (xml_sax_styleregion_font) : ditto.
* src/xml-sax-write.c (xml_write_gnmstyle) : ditto.
2005-09-27 Morten Welinder <terra@gnome.org>
* src/position.c (eval_pos_init_dep): Fix typo.
......
......@@ -11,6 +11,7 @@ Jody:
* Fix rotated text with pango-1.10 [#316597]
* Update auto-expr after a recalc [#314867]
* Use Emmanuel's ideas to improve the frozen pane drag handles.
* Enable super/subscripts.
Morten:
* Fix C99ism.
......
2005-09-26 Jody Goldberg <jody@gnome.org>
* src/gnm-style-impl.h : Add a script element to GnmStyle
* src/mstyle.c (elem_is_eq) : support scripts
(elem_assign_content) : support scripts
(gnm_style_new_default) : support scripts
(gnm_style_get_pango_attrs) : support scripts
(gnm_style_dump) : support scripts
(gnm_style_set_font_script) : new.
(gnm_style_get_font_script) : new.
* src/GNOME_Gnumeric-gtk.xml.in : Add the super/sub script
accelerators
* gnumeric.xsd : update to include the new h/v alignments and to add
Script.
* src/wbc-gtk.c (wbc_gtk_style_feedback) : support super/sub script
and fix support for double underline
* src/wbcg-actions.c (toggle_font_attr) : support super/sub script
(cb_font_subscript) : new.
(cb_font_superscript) : new.
* src/xml-io.c (xml_write_style) : ditto.
(xml_read_style) : ditto.
* src/xml-sax-read.c (xml_sax_styleregion_font) : ditto.
* src/xml-sax-write.c (xml_write_gnmstyle) : ditto.
2005-09-27 Morten Welinder <terra@gnome.org>
* src/position.c (eval_pos_init_dep): Fix typo.
......
......@@ -8,7 +8,9 @@
<xsd:annotation>
<xsd:documentation xml:lang="en">
Schema for gnumeric spreadsheet documents
Assumes Gnumeric 1.2.2, updated for 1.4.2 in Feb 2005
Assumes Gnumeric 1.2.2,
updated for 1.4.2 in Feb 2005
updated for 1.6.0 in Sept 2005
Based on gnumeric source code and sample gnumeric documents
Author: Marc Johnson (marc_johnson27591@hotmail.com)
</xsd:documentation>
......@@ -223,7 +225,9 @@
<xsd:attribute name="DisplayOutlines" type="xsd:boolean" use="required"/>
<xsd:attribute name="OutlineSymbolsBelow" type="xsd:boolean" use="required"/>
<xsd:attribute name="OutlineSymbolsRight" type="xsd:boolean" use="required"/>
<xsd:attribute name="RTL_Layout" type="xsd:boolean" use="optional"/>
<xsd:attribute name="TabColor" type="gmr:color" use="optional"/>
<xsd:attribute name="TabTextColor" type="gmr:color" use="optional"/>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
......@@ -387,6 +391,7 @@
<xsd:attribute name="Italic" type="xsd:boolean" use="required"/>
<xsd:attribute name="Underline" type="gmr:underline" use="required"/>
<xsd:attribute name="StrikeThrough" type="xsd:boolean" use="required"/>
<xsd:attribute name="Script" type="gmr:script" use="required"/>
</xsd:extension>
</xsd:simpleContent>
</xsd:complexType>
......@@ -493,6 +498,17 @@
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="script">
<xsd:restriction base="xsd:integer">
<!-- GO_FONT_SCRIPT_SUB = -1,
GO_FONT_SCRIPT_STANDARD = 0,
GO_FONT_SCRIPT_SUPER = 1
-->
<xsd:minInclusive value="-1"/>
<xsd:maxInclusive value="1"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="horizontal_alignment">
<xsd:restriction base="xsd:integer">
<!-- this is a bit map as follows:
......@@ -503,9 +519,10 @@
16 = FILL
32 = JUSTIFY
64 = CENTER ACROSS SELECTION
128 = DISTRIBUTED
-->
<xsd:minInclusive value="0"/>
<xsd:maxInclusive value="127"/>
<xsd:minInclusive value="1"/>
<xsd:maxInclusive value="128"/>
</xsd:restriction>
</xsd:simpleType>
......@@ -516,9 +533,10 @@
2 = BOTTOM
4 = CENTER
8 = JUSTIFY
16 = DISTRIBUTED
-->
<xsd:minInclusive value="0"/>
<xsd:maxInclusive value="15"/>
<xsd:minInclusive value="1"/>
<xsd:maxInclusive value="16"/>
</xsd:restriction>
</xsd:simpleType>
......
2005-09-28 Jody Goldberg <jody@gnome.org>
* ms-chart.c (xl_chart_import_reg_curve) : split out from
ms_excel_chart_read.
(xl_chart_import_error_bar) : ditto.
* ms-excel-write.c (excel_font_overlay_pango) : check super/sub scripts.
(excel_font_hash) : ditto.
(excel_font_equal) : ditto.
(excel_font_new) : init the super/sub status
(map_underline_to_xl) : new.
(map_script_to_xl) : new.
(cb_write_condition) : handle super/sub script.
(excel_write_FONT) : ditto.
(excel_font_new) : ditto.
* ms-excel-read.c (ms_wb_get_font_markup) : The super/subscript
distances were broken. Use 5000 not 500. Seems like we may want a
scale in there too.
(excel_read_FONT) : Use GOFontScript
(excel_get_style_from_xf) : store the script (super/sub)
(excel_read_CF) : handle scripts.
2005-09-26 Jean Brefort <jean.brefort@normalesup.org>
* ms-chart.c: (axislineformat): read the areaformat for type 3
......
......@@ -1912,15 +1912,15 @@ BC_R(text)(XLChartHandler const *handle,
if (s->prev_opcode == BIFF_CHART_defaulttext) {
fputs ("Text follows defaulttext;\n", stderr);
} else switch (BC_R(top_state) (s, 0)) {
case BIFF_CHART_chart :
fputs ("Text follows chart;\n", stderr);
break;
case BIFF_CHART_legend :
fputs ("Text follows legend;\n", stderr);
break;
default :
fprintf (stderr, "BIFF ERROR : A Text record follows a %x\n",
s->prev_opcode);
case BIFF_CHART_chart :
fputs ("Text follows chart;\n", stderr);
break;
case BIFF_CHART_legend :
fputs ("Text follows legend;\n", stderr);
break;
default :
fprintf (stderr, "BIFF ERROR : A Text record follows a %x\n",
s->prev_opcode);
}};);
return FALSE;
......@@ -2725,6 +2725,140 @@ chart_get_sheet (MSContainer const *container)
return ms_container_sheet (container->parent);
}
static void
xl_chart_import_reg_curve (XLChartReadState *state, XLChartSeries *series)
{
GogRegCurve *rc;
XLChartSeries *parent = g_ptr_array_index (state->series, series->reg_parent);
if (NULL == parent)
return;
switch (series->reg_type) {
case 0:
if (series->reg_order == 1)
rc = gog_reg_curve_new_by_name ("GogLinRegCurve");
else {
rc = gog_reg_curve_new_by_name ("GogPolynomRegCurve");
g_object_set (G_OBJECT (rc), "dims", series->reg_order, NULL);
}
break;
case 1:
rc = gog_reg_curve_new_by_name ("GogExpRegCurve");
break;
case 2:
rc = gog_reg_curve_new_by_name ("GogLogRegCurve");
break;
case 3:
rc = NULL; /*Power: not yet supported*/
break;
default: /* moving average is 4 and not supported */
rc = NULL;
break;
}
if (rc) {
if (series->reg_intercept == 0.)
g_object_set (G_OBJECT (rc),
"affine", series->reg_order,
NULL);
gog_object_add_by_name (GOG_OBJECT (parent->series),
"Regression curve", GOG_OBJECT (rc));
if (series->reg_show_eq || series->reg_show_R2) {
GogObject *obj = gog_object_add_by_name (
GOG_OBJECT (rc), "Equation", NULL);
g_object_set (G_OBJECT (obj),
"show_eq", series->reg_show_eq,
"show_r2", series->reg_show_R2,
NULL);
}
}
}
static void
xl_chart_import_error_bar (XLChartReadState *state, XLChartSeries *series)
{
XLChartSeries *parent = g_ptr_array_index (state->series, series->err_parent);
Sheet *sheet;
int orig_dim;
GogMSDimType msdim;
char const *prop_name = (series->err_type < 3)
? "x-errors" : "y-errors";
GParamSpec *pspec = g_object_class_find_property (
G_OBJECT_GET_CLASS (parent->series),
prop_name);
state->plot = parent->series->plot;
if (pspec == NULL) {
pspec = g_object_class_find_property (
G_OBJECT_GET_CLASS (parent->series), "errors");
prop_name = (pspec)? "errors": NULL;
msdim = (series->err_type < 3)
? GOG_MS_DIM_TYPES + series->err_type
: GOG_MS_DIM_TYPES + series->err_type - 2;
} else
msdim = (series->err_type < 3)
? GOG_MS_DIM_TYPES + series->err_type + 2
: GOG_MS_DIM_TYPES + series->err_type - 2;
sheet = ms_container_sheet (state->container.parent);
if (sheet && parent && prop_name) {
GnmExpr const *expr;
GogErrorBar *error_bar = g_object_new (GOG_ERROR_BAR_TYPE, NULL);
GOData *data;
error_bar->display |= (series->err_type & 1)
? GOG_ERROR_BAR_DISPLAY_POSITIVE
: GOG_ERROR_BAR_DISPLAY_NEGATIVE;
if (!series->err_teetop)
error_bar->width = 0;
error_bar->style = gog_style_dup (series->style);
switch (series->err_src) {
case 1:
/* percentage */
error_bar->type = GOG_ERROR_BAR_TYPE_PERCENT;
expr = gnm_expr_new_constant (
value_new_float (series->err_val));
data = gnm_go_data_vector_new_expr (sheet, expr);
XL_gog_series_set_dim (parent->series, msdim, data);
break;
case 2:
/* fixed value */
error_bar->type = GOG_ERROR_BAR_TYPE_ABSOLUTE;
expr = gnm_expr_new_constant (
value_new_float (series->err_val));
data = gnm_go_data_vector_new_expr (sheet, expr);
XL_gog_series_set_dim (parent->series, msdim, data);
break;
case 3:
/* not supported */
break;
case 4:
orig_dim = (series->err_type < 3)
? GOG_MS_DIM_CATEGORIES
: GOG_MS_DIM_VALUES;
error_bar->type = GOG_ERROR_BAR_TYPE_ABSOLUTE;
if (series->data[orig_dim].data) {
XL_gog_series_set_dim (parent->series, msdim,
series->data[orig_dim].data);
series->data[orig_dim].data = NULL;
} else if (series->data [orig_dim].value) {
expr = gnm_expr_new_constant ((GnmValue *)
series->data[orig_dim].value);
data = gnm_go_data_vector_new_expr (sheet, expr);
XL_gog_series_set_dim (parent->series, msdim, data);
}
break;
default:
/* type 5, standard error is not supported */
break;
}
g_object_set (G_OBJECT (parent->series),
prop_name, error_bar,
NULL);
g_object_unref (error_bar);
}
}
gboolean
ms_excel_chart_read (BiffQuery *q, MSContainer *container,
SheetObject *sog, Sheet *full_page)
......@@ -2915,7 +3049,7 @@ ms_excel_chart_read (BiffQuery *q, MSContainer *container,
case BIFF_PRINTSIZE: {
#if 0
/* Undocumented, seems like an enum ??? */
/* Undocumented, seems like an enum ?? */
gint16 const v = GSF_LE_GET_GUINT16 (q->data);
#endif
}
......@@ -2937,149 +3071,33 @@ ms_excel_chart_read (BiffQuery *q, MSContainer *container,
}
for (i = state.series->len; i-- > 0 ; ) {
Sheet *sheet = ms_container_sheet (state.container.parent);
int j;
XLChartSeries *series = g_ptr_array_index (state.series, i), *parent;
GOData *data;
GnmExpr const * expr;
GParamSpec *pspec;
GogErrorBar *error_bar;
char const *prop_name;
GogMSDimType msdim;
XLChartSeries *series = g_ptr_array_index (state.series, i);
if (series != NULL) {
Sheet *sheet = ms_container_sheet (state.container.parent);
GnmExpr const *expr;
GOData *data;
if (series->chart_group < 0) {
/* might be a error bar series or a regression curve */
if (series->err_type == 0) {
/* it is a regression curve */
GogRegCurve *rc;
parent = g_ptr_array_index (state.series, series->reg_parent);
if (parent) {
switch (series->reg_type) {
case 0:
if (series->reg_order == 1)
rc = gog_reg_curve_new_by_name ("GogLinRegCurve");
else {
rc = gog_reg_curve_new_by_name ("GogPolynomRegCurve");
g_object_set (G_OBJECT (rc), "dims", series->reg_order, NULL);
}
break;
case 1:
rc = gog_reg_curve_new_by_name ("GogExpRegCurve");
break;
case 2:
rc = gog_reg_curve_new_by_name ("GogLogRegCurve");
break;
case 3:
rc = NULL; /*Power: not yet supported*/
break;
default: /* moving average is 4 and not supported */
rc = NULL;
break;
}
if (rc) {
if (series->reg_intercept == 0.)
g_object_set (G_OBJECT (rc), "affine", series->reg_order, FALSE);
gog_object_add_by_name (GOG_OBJECT (parent->series),
"Regression curve", GOG_OBJECT (rc));
if (series->reg_show_eq || series->reg_show_R2) {
GogObject *obj = gog_object_add_by_name (
GOG_OBJECT (rc), "Equation", NULL);
g_object_set (G_OBJECT (obj),
"show_eq", series->reg_show_eq,
"show_r2", series->reg_show_R2,
NULL);
}
}
}
} else {
int orig_dim;
prop_name = NULL;
parent = g_ptr_array_index (state.series, series->err_parent);
state.plot = parent->series->plot;
prop_name = (series->err_type < 3)? "x-errors": "y-errors";
pspec = g_object_class_find_property (
G_OBJECT_GET_CLASS (parent->series),
prop_name);
if (pspec == NULL) {
pspec = g_object_class_find_property (
G_OBJECT_GET_CLASS (parent->series), "errors");
prop_name = (pspec)? "errors": NULL;
msdim = (series->err_type < 3)?
GOG_MS_DIM_TYPES + series->err_type:
GOG_MS_DIM_TYPES + series->err_type - 2;
} else {
msdim = (series->err_type < 3)?
GOG_MS_DIM_TYPES + series->err_type + 2:
GOG_MS_DIM_TYPES + series->err_type - 2;
}
if (sheet && parent && prop_name) {
error_bar = g_object_new (GOG_ERROR_BAR_TYPE, NULL);
error_bar->display |= (series->err_type & 1)?
GOG_ERROR_BAR_DISPLAY_POSITIVE:
GOG_ERROR_BAR_DISPLAY_NEGATIVE;
if (!series->err_teetop)
error_bar->width = 0;
error_bar->style = gog_style_dup (series->style);
switch (series->err_src) {
case 1:
/* percentage */
error_bar->type = GOG_ERROR_BAR_TYPE_PERCENT;
expr = gnm_expr_new_constant (
value_new_float (series->err_val));
data = gnm_go_data_vector_new_expr (sheet, expr);
XL_gog_series_set_dim (parent->series, msdim, data);
break;
case 2:
/* fixed value */
error_bar->type = GOG_ERROR_BAR_TYPE_ABSOLUTE;
expr = gnm_expr_new_constant (
value_new_float (series->err_val));
data = gnm_go_data_vector_new_expr (sheet, expr);
XL_gog_series_set_dim (parent->series, msdim, data);
break;
case 3:
/* not supported */
break;
case 4:
orig_dim = (series->err_type < 3)? GOG_MS_DIM_CATEGORIES: GOG_MS_DIM_VALUES;
error_bar->type = GOG_ERROR_BAR_TYPE_ABSOLUTE;
if (series->data[orig_dim].data) {
XL_gog_series_set_dim (parent->series, msdim,
series->data[orig_dim].data);
series->data[orig_dim].data = NULL;
} else if (series->data [orig_dim].value) {
expr = gnm_expr_new_constant ((GnmValue *)
series->data[orig_dim].value);
data = gnm_go_data_vector_new_expr (sheet, expr);
XL_gog_series_set_dim (parent->series, msdim, data);
}
break;
default:
/* type 5, standard error is not supported */
break;
}
g_object_set (G_OBJECT (parent->series),
prop_name, error_bar,
NULL);
g_object_unref (error_bar);
}
}
if (series->err_type == 0)
xl_chart_import_reg_curve (&state, series);
else
xl_chart_import_error_bar (&state, series);
}
for (j = GOG_MS_DIM_VALUES ; j < GOG_MS_DIM_TYPES; j++ )
if (series->data [j].value != NULL) {
expr = gnm_expr_new_constant ((GnmValue *)series->data [j].value);
if (expr != NULL) {
if (sheet == NULL || series->series == NULL) {
gnm_expr_unref (expr);
continue;
}
data = gnm_go_data_vector_new_expr (sheet, expr);
if (series->extra_dim == 0)
XL_gog_series_set_dim (series->series, j, data);
else if (j == GOG_MS_DIM_VALUES)
XL_gog_series_set_dim (series->series, series->extra_dim, data);
if (NULL != series->data [j].value &&
NULL != (expr = gnm_expr_new_constant ((GnmValue *)series->data [j].value))) {
if (sheet == NULL || series->series == NULL) {
gnm_expr_unref (expr);
continue;
}
data = gnm_go_data_vector_new_expr (sheet, expr);
if (series->extra_dim == 0)
XL_gog_series_set_dim (series->series, j, data);
else if (j == GOG_MS_DIM_VALUES)
XL_gog_series_set_dim (series->series, series->extra_dim, data);
}
}
}
......
......@@ -39,8 +39,6 @@ typedef enum {
MS_BIFF_F_U_DOUBLE_ACC = 5
} MsBiffFontUnderline ;
typedef enum { MS_BIFF_F_S_NONE, MS_BIFF_F_S_SUB, MS_BIFF_F_S_SUPER } MsBiffFontScript ;
typedef enum { /* Horizontal alignment */
MS_BIFF_H_A_GENERAL = 0,
MS_BIFF_H_A_LEFT = 1,
......
......@@ -1279,7 +1279,7 @@ excel_read_FONT (BiffQuery *q, GnmXLImporter *importer)
fd->boldness = 0x2bc;
else
fd->boldness = 0x190;
fd->script = MS_BIFF_F_S_NONE;
fd->script = GO_FONT_SCRIPT_STANDARD;
fd->fontname = excel_get_text (importer, q->data + 5,
GSF_LE_GET_GUINT8 (q->data + 4), NULL);
if (ms_biff_query_peek_next (q, &opcode) &&
......@@ -1298,7 +1298,7 @@ excel_read_FONT (BiffQuery *q, GnmXLImporter *importer)
fd->boldness = 0x2bc;
else
fd->boldness = 0x190;
fd->script = MS_BIFF_F_S_NONE;
fd->script = GO_FONT_SCRIPT_STANDARD;
fd->fontname = excel_get_text (importer, q->data + 7,
GSF_LE_GET_GUINT8 (q->data + 6), NULL);
} else {
......@@ -1306,15 +1306,9 @@ excel_read_FONT (BiffQuery *q, GnmXLImporter *importer)
fd->boldness = GSF_LE_GET_GUINT16 (q->data + 6);
data = GSF_LE_GET_GUINT16 (q->data + 8);
switch (data) {
case 0:
fd->script = MS_BIFF_F_S_NONE;
break;
case 1:
fd->script = MS_BIFF_F_S_SUPER;
break;
case 2:
fd->script = MS_BIFF_F_S_SUB;
break;
case 0: fd->script = GO_FONT_SCRIPT_STANDARD; break;
case 1: fd->script = GO_FONT_SCRIPT_SUPER; break;
case 2: fd->script = GO_FONT_SCRIPT_SUB; break;
default:
fprintf (stderr,"Unknown script %d\n", data);
break;
......@@ -1683,6 +1677,7 @@ excel_get_style_from_xf (ExcelReadSheet *esheet, BiffXFData const *xf)
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 MS_BIFF_F_U_SINGLE:
case MS_BIFF_F_U_SINGLE_ACC:
......@@ -2772,11 +2767,6 @@ ms_wb_get_font_markup (MSContainer const *c, unsigned indx)
default: break;
}
switch (fd->script) {
case MS_BIFF_F_S_SUPER: rise = 500; break;
case MS_BIFF_F_S_SUB: rise = -500; break;
default: break;
}
attrs = pango_attr_list_new ();
add_attr (attrs, pango_attr_family_new (fd->fontname));
......@@ -2785,7 +2775,9 @@ ms_wb_get_font_markup (MSContainer const *c, unsigned indx)
add_attr (attrs, pango_attr_style_new (fd->italic ? PANGO_STYLE_ITALIC : PANGO_STYLE_NORMAL));
add_attr (attrs, pango_attr_strikethrough_new (fd->struck_out));
add_attr (attrs, pango_attr_underline_new (underline));
add_attr (attrs, pango_attr_rise_new (rise));
add_attr (attrs, pango_attr_rise_new (5000 * fd->script));
if (fd->script != GO_FONT_SCRIPT_STANDARD)
add_attr (attrs, pango_attr_scale_new (.5));
color = (fd->color_idx == 127) ? style_color_black ()
: excel_palette_get (importer, fd->color_idx);
......@@ -4560,13 +4552,13 @@ excel_read_CF (BiffQuery *q, ExcelReadSheet *esheet, GnmStyleConditions *sc)
gnm_style_set_font_strike (cond.overlay, 0 != (tmp8 & 0x80));
if (0 == GSF_LE_GET_GUINT8 (data + 28)) {
#if 0
switch (GSF_LE_GET_GUINT8 (data + 10)) {
case 1 : gnm_style_set_font_super (cond.overlay); break;
case 2 : gnm_style_set_font_sub (cond.overlay); break;
default : ignore ... ?
default : fprintf (stderr,"Unknown script %d\n", GSF_LE_GET_GUINT8 (data));
/* fall through */
case 0: gnm_style_set_font_script (cond.overlay, GO_FONT_SCRIPT_STANDARD); break;
case 1: gnm_style_set_font_script (cond.overlay, GO_FONT_SCRIPT_SUPER); break;
case 2: gnm_style_set_font_script (cond.overlay, GO_FONT_SCRIPT_SUB); break;
}
#endif
}
if (0 == GSF_LE_GET_GUINT8 (data + 32)) {
switch (GSF_LE_GET_GUINT8 (data + 12)) {
......
......@@ -16,6 +16,7 @@
#include "ms-excel-biff.h"
#include "ms-container.h"
#include <expr.h>
#include <mstyle.h>
#include <pango/pango-attributes.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
......@@ -80,7 +81,7 @@ typedef struct {
int struck_out; /* boolean : strikethrough */
int color_idx;
int boldness; /* 100->1000 dec, normal = 0x190, bold = 0x2bc */
int script; /* sub = -1, none = 0, super = 1 */
GOFontScript script;
MsBiffFontUnderline underline;
char *fontname;
PangoAttrList *attrs;
......
......@@ -775,6 +775,28 @@ write_border (ExcelWriteSheet const *esheet,
return FALSE;
}
static int
map_underline_to_xl (GnmStyle const *style)
{
switch (gnm_style_get_font_uline (style)) {
default :
case UNDERLINE_NONE : return 0;
case UNDERLINE_SINGLE : return 1;
case UNDERLINE_DOUBLE : return 2;
}
}
static int
map_script_to_xl (GnmStyle const *style)
{
switch (gnm_style_get_font_script (style)) {
case GO_FONT_SCRIPT_SUB : return 2;
default :
case GO_FONT_SCRIPT_STANDARD : return 0;
case GO_FONT_SCRIPT_SUPER : return 1;
}
}
static guint8 const zeros[64];
static void
cb_write_condition (GnmStyleConditions const *sc, CondDetails *cd,
......@@ -855,19 +877,18 @@ cb_write_condition (GnmStyleConditions const *sc, CondDetails *cd,
font_flags |= 0x80;
GSF_LE_SET_GUINT32 (fbuf+68, tmp);
tmp = 0;
if (gnm_style_is_element_set (s, MSTYLE_FONT_UNDERLINE)) {
switch (gnm_style_get_font_uline (s)) {
default :
case UNDERLINE_NONE : tmp = 0; break;
case UNDERLINE_SINGLE : tmp = 1; break;
case UNDERLINE_DOUBLE : tmp = 2; break;
}
tmp = map_underline_to_xl (s);
GSF_LE_SET_GUINT32 (fbuf+76, tmp);
} else
GSF_LE_SET_GUINT32 (fbuf+96, 1);
GSF_LE_SET_GUINT32 (fbuf+76, tmp);
GSF_LE_SET_GUINT32 (fbuf+96, 1); /* flag as unused */
if (gnm_style_is_element_set (s, MSTYLE_FONT_SCRIPT)) {
guint16 script = map_script_to_xl (s);
GSF_LE_SET_GUINT16 (fbuf+72, script);
} else
GSF_LE_SET_GUINT32 (fbuf+92, 1); /* flag as unused */
GSF_LE_SET_GUINT32 (fbuf+92, 1); /* no super/sub yet */
GSF_LE_SET_GUINT16 (fbuf+116, 1); /* dunno ? */
if (gnm_style_is_element_set (s, MSTYLE_FONT_COLOR))
......@@ -1689,6 +1710,7 @@ excel_font_new (GnmStyle const *base_style)
efont->is_italic = gnm_style_get_font_italic (base_style);
efont->underline = gnm_style_get_font_uline (base_style);
efont->strikethrough = gnm_style_get_font_strike (base_style);
efont->script = map_script_to_xl (base_style);
c = gnm_style_get_font_color (base_style);
efont->color = gnm_color_to_bgr (c);
......@@ -1724,6 +1746,15 @@ excel_font_overlay_pango (ExcelWriteFont *efont, GSList *pango)
case PANGO_ATTR_STRIKETHROUGH : efont->strikethrough =
((PangoAttrInt *)attr)->value != 0;
break;
case PANGO_ATTR_RISE :
if (((PangoAttrInt *)attr)->value < 0)
efont->script = 2;
else if (((PangoAttrInt *)attr)->value < 0)
efont->script = 1;
else
efont->script = 0;
break;
case PANGO_ATTR_UNDERLINE :
switch (((PangoAttrInt *)attr)->value) {
case PANGO_UNDERLINE_NONE :
......@@ -1763,7 +1794,8 @@ excel_font_hash (gconstpointer f)
^ font->color