Commit 3dbb79d1 authored by Jody Goldberg's avatar Jody Goldberg Committed by Jody Goldberg

http://bugzilla.gnome.org/show_bug.cgi?id=136730 be more flexible and

2004-03-11  Jody Goldberg <jody@gnome.org>

	http://bugzilla.gnome.org/show_bug.cgi?id=136730
	* ms-excel-read.c (excel_get_xf) : be more flexible and handle xls
	  generated with no XF records.
	(excel_get_style_from_xf) : ditto.
	(excel_sheet_insert_val) : ditto.

	* ms-obj.c (ms_obj_read_pre_biff8_obj) : despite the name
	  PangoAttributes::end_index is exclusive, not inclusive.

2004-03-08  Jody Goldberg <jody@gnome.org>

	* ms-excel-read.c (excel_read_XF) : throw in a simple heuristic for
	  when to set a valueformat.  At issue is that we want to display
	  dates/times formatted, but do not want to display accounting
	  formats.  This kludge disables the application for any format that
	  has more than one condition.  It's not strictly a solution, but it
	  will solve the common problems.


2004-03-11  Jody Goldberg <jody@gnome.org>

	* src/stf.c (csv_tsv_probe) : Be more forgiving about what might be
	text.  Accept
	    1) *.txt
	    2) Anything that has no null characters in the first 80 bytes
	It won't catch everything, but it should be marginally better.

2004-03-08  Jody Goldberg <jody@gnome.org>

	* src/wbc-gtk.c (wbc_gtk_init) : split the menus into a distinct
	  group.  There's no need to senstize them
parent 1b9235c2
......@@ -127,9 +127,6 @@ Excel i/o
Short Term Goals
----------------
* When we release 1.1.18, we should ask people to nominate certain foreign
encodings as major.
* compartmentalize gconf support
- validate expression names to ensure that they are not simple values (eg TRUE)
......@@ -385,18 +382,12 @@ Short Term Goals
1.31.8) Text alignment (DONE)
1.31.9) Text clipping (DONE)
1.32) Radar plots
1.31.1) Basic (looks trivial) {SamuriaMike}
questions
- how to select a single point for formating ?
- printing
Looking at dia, sodipodi and paps they all seem to
use ft2 (direct or via pango) to stroke the glyphs
Why do we need gnome-print at all ?
Do we need to worry about ps2 vs ps3 for gradients ?
How to handle patterns without more access to ps ?
Is it safe to render to ps and assume that something will translate ?
1.32.1) line (DONE)
1.32.2) area (DONE)
1.32.3) axis labels
1.32.4) fix xls import of marker vs no marker
1.33) Single point formating
1.33.1) Basic {emmanual}
2) stf {Andreas/Morten}
2.1) UTF-8 cleanliness (DONE)
......@@ -476,6 +467,9 @@ Short Term Goals
6.15.6) use appropriate NAME record for function stubs (DONE)
6.15.7) generate CompObj stream
6.15.8) generate property streams to get the flags
6.16) Excel95 object import
6.16.1) TextBox (DONE)
6.17) Excel95 object export
14) Polish up Open and Save
14.1) merge open and import dialogs (DONE)
......@@ -590,12 +584,11 @@ Misc stuff that should be fixed
selected ranges.
: drag based col/row resize should support negative sizes to
correspond to hiding.
: support delete for discontinuous ranges
- Remove duplication of code between analysis-tools.c and collect.c
(Many analysis tools may in fact want to follow the consolidate style)
- Make deletion work for multiple ranges.
- Look into octave/matlab filters
- Talk to shaunm about mathematica (Shouldn't we rather support non-propritary
maxima rather than proprietary Mathematica?)
......
2004-03-11 Jody Goldberg <jody@gnome.org>
* src/stf.c (csv_tsv_probe) : Be more forgiving about what might be
text. Accept
1) *.txt
2) Anything that has no null characters in the first 80 bytes
It won't catch everything, but it should be marginally better.
2004-03-08 Jody Goldberg <jody@gnome.org>
* src/wbc-gtk.c (wbc_gtk_init) : split the menus into a distinct
group. There's no need to senstize them
2004-03-12 Jean Brefort <jean.brefort@ac-dijon.fr>
* src/graph.c (gnm_go_data_vector_load_values): changed initial maximum
......
......@@ -68,6 +68,18 @@ Jody:
* Display the blue range designator even in other panes
http://bugzilla.gnome.org/show_bug.cgi?id=126563
* Fix col/row sizes when copying a sheet with default zoom != 1
http://bugzilla.gnome.org/show_bug.cgi?id=135946
* Add support for mmmmm formats
* persist combos and lists (to gnumeric xml)
* Fix xls import of external 3d references
http://bugzilla.gnome.org/show_bug.cgi?id=136088
* Persist vary-style-by-color for pie plots
* Do not theme colours when using image fills
* Recalc autosized row heights when a font size changes
http://bugzilla.gnome.org/show_bug.cgi?id=135977
* Fix xls import of font and font colours for XL95/XL97 text/labels
* Fix xls import of label outlines for XL95 textboxes
* Make the text probe routine a bit more relaxed
J.H.M. Dassen (Ray):
http://bugzilla.gnome.org/show_bug.cgi?id=135044
......
2004-03-11 Jody Goldberg <jody@gnome.org>
* src/stf.c (csv_tsv_probe) : Be more forgiving about what might be
text. Accept
1) *.txt
2) Anything that has no null characters in the first 80 bytes
It won't catch everything, but it should be marginally better.
2004-03-08 Jody Goldberg <jody@gnome.org>
* src/wbc-gtk.c (wbc_gtk_init) : split the menus into a distinct
group. There's no need to senstize them
2004-03-12 Jean Brefort <jean.brefort@ac-dijon.fr>
* src/graph.c (gnm_go_data_vector_load_values): changed initial maximum
......
2004-03-11 Jody Goldberg <jody@gnome.org>
http://bugzilla.gnome.org/show_bug.cgi?id=136730
* ms-excel-read.c (excel_get_xf) : be more flexible and handle xls
generated with no XF records.
(excel_get_style_from_xf) : ditto.
(excel_sheet_insert_val) : ditto.
* ms-obj.c (ms_obj_read_pre_biff8_obj) : despite the name
PangoAttributes::end_index is exclusive, not inclusive.
2004-03-08 Jody Goldberg <jody@gnome.org>
* ms-excel-read.c (excel_read_XF) : throw in a simple heuristic for
when to set a valueformat. At issue is that we want to display
dates/times formatted, but do not want to display accounting
formats. This kludge disables the application for any format that
has more than one condition. It's not strictly a solution, but it
will solve the common problems.
2004-03-06 Jody Goldberg <jody@gnome.org>
* ms-obj.c (ms_obj_read_pre_biff8_obj) : handle outline width for text
......
......@@ -1126,7 +1126,7 @@ ms_escher_read_OPT (MSEscherState *state, MSEscherHeader *h)
guint const pid = tmp & 0x3fff;
gboolean const is_blip = (tmp & 0x4000) != 0;
gboolean const is_complex = (tmp & 0x8000) != 0;
guint32 const val = GSF_LE_GET_GUINT32(fopte+2);
guint32 val = GSF_LE_GET_GUINT32 (fopte+2);
MSObjAttrID id = MS_OBJ_ATTR_NONE;
/* container is sorted by pid. Use this as sanity test */
......@@ -1439,17 +1439,20 @@ ms_escher_read_OPT (MSEscherState *state, MSEscherHeader *h)
/* NOTE : This test is somewhat questionable.
* The docs say this is a bool but I have seen
* 0x110000 not filled
* 0x100000 not filled
* 0x110010 filled
* 0x010000 filled
*/
if (val & 0x10)
id = MS_OBJ_ATTR_FILLED;
if (val != 0x110010 && val != 0x010000)
id = MS_OBJ_ATTR_UNFILLED;
name = "bool fNoFillHitTest";
break;
/* LineStyle */
/* black : Color of line */
case 448 : name = "Colour lineColor"; break;
case 448 : id = MS_OBJ_ATTR_OUTLINE_COLOR;
name = "Colour lineColor";
break;
/* 1<<16 : Not implemented */
case 449 : name = "long lineOpacity"; break;
/* white : Background color */
......@@ -1509,7 +1512,12 @@ ms_escher_read_OPT (MSEscherState *state, MSEscherHeader *h)
/* TRUE : Register pattern on shape */
case 510 : name = "bool lineFillShape"; break;
/* FALSE : Draw a dashed line if no line */
case 511 : name = "bool fNoLineDrawDash"; break;
case 511 : name = "bool fNoLineDrawDash";
/* 0 == no line
* 0x80008 == line */
if (val == 0)
id = MS_OBJ_ATTR_OUTLINE_STYLE;
break;
/* ShadowStyle */
/* Offset : Type of effect */
......@@ -1824,6 +1832,7 @@ ms_escher_read_ClientTextbox (MSEscherState *state, MSEscherHeader *h)
guint16 opcode;
int has_next_record;
char *text;
PangoAttrList *markup;
g_return_val_if_fail (h->len == COMMON_HEADER_LEN, TRUE);
g_return_val_if_fail (h->offset + h->len == state->end_offset, TRUE);
......@@ -1835,9 +1844,13 @@ ms_escher_read_ClientTextbox (MSEscherState *state, MSEscherHeader *h)
has_next_record = ms_biff_query_next (state->q);
g_return_val_if_fail (has_next_record, TRUE);
text = ms_read_TXO (state->q);
text = ms_read_TXO (state->q, state->container, &markup);
ms_escher_header_add_attr (h,
ms_obj_attr_new_ptr (MS_OBJ_ATTR_TEXT, text));
if (markup != NULL)
ms_escher_header_add_attr (h,
ms_obj_attr_new_markup (MS_OBJ_ATTR_MARKUP, markup));
pango_attr_list_unref (markup);
d (0, printf ("'%s';\n", text););
return FALSE;
}
......
......@@ -154,8 +154,7 @@ ms_sheet_parse_expr_internal (ExcelReadSheet *esheet, guint8 const *data, int le
expr = excel_parse_formula (&esheet->container, esheet, 0, 0,
data, length, FALSE, NULL);
#if 0
{
if (ms_excel_read_debug > 8) {
char *tmp;
GnmParsePos pp;
Sheet *sheet = esheet->sheet;
......@@ -165,7 +164,6 @@ ms_sheet_parse_expr_internal (ExcelReadSheet *esheet, guint8 const *data, int le
puts (tmp);
g_free (tmp);
}
#endif
return expr;
}
......@@ -322,129 +320,102 @@ ms_sheet_obj_anchor_to_pos (Sheet const * sheet, MsBiffVersion const ver,
static gboolean
ms_sheet_realize_obj (MSContainer *container, MSObj *obj)
{
static SheetObjectAnchorType const anchor_types[4] = {
SO_ANCHOR_PERCENTAGE_FROM_COLROW_START,
SO_ANCHOR_PERCENTAGE_FROM_COLROW_START,
SO_ANCHOR_PERCENTAGE_FROM_COLROW_START,
SO_ANCHOR_PERCENTAGE_FROM_COLROW_START
};
float offsets[4];
char const *label;
PangoAttrList *markup;
GnmRange range;
ExcelReadSheet *esheet;
MSObjAttr *anchor;
MSObjAttr *attr, *flip_h, *flip_v;
SheetObjectDirection direction;
SheetObjectAnchor anchor;
SheetObject *so;
if (obj == NULL)
return TRUE;
if (obj->gnum_obj == NULL)
return FALSE;
so = obj->gnum_obj;
g_return_val_if_fail (container != NULL, TRUE);
esheet = (ExcelReadSheet *)container;
anchor = ms_obj_attr_bag_lookup (obj->attrs, MS_OBJ_ATTR_ANCHOR);
if (anchor == NULL) {
attr = ms_obj_attr_bag_lookup (obj->attrs, MS_OBJ_ATTR_ANCHOR);
if (attr == NULL) {
fprintf (stderr,"MISSING anchor for obj %p with id %d of type %s\n", (void *)obj, obj->id, obj->excel_type_name);
return TRUE;
}
if (ms_sheet_obj_anchor_to_pos (esheet->sheet, container->ver,
anchor->v.v_ptr, &range, offsets))
attr->v.v_ptr, &range, offsets))
return TRUE;
if (obj->gnum_obj != NULL) {
static SheetObjectAnchorType const anchor_types[4] = {
SO_ANCHOR_PERCENTAGE_FROM_COLROW_START,
SO_ANCHOR_PERCENTAGE_FROM_COLROW_START,
SO_ANCHOR_PERCENTAGE_FROM_COLROW_START,
SO_ANCHOR_PERCENTAGE_FROM_COLROW_START
flip_h = ms_obj_attr_bag_lookup (obj->attrs, MS_OBJ_ATTR_FLIP_H);
flip_v = ms_obj_attr_bag_lookup (obj->attrs, MS_OBJ_ATTR_FLIP_V);
direction =
((flip_h == NULL) ? SO_DIR_RIGHT : 0) |
((flip_v == NULL) ? SO_DIR_DOWN : 0);
sheet_object_anchor_init (&anchor, &range,
offsets, anchor_types, direction);
sheet_object_anchor_set (so, &anchor);
sheet_object_set_sheet (so, esheet->sheet);
/* handle common attributes */
/* THIS IS DAMN UGLY we should be using gobject properties with common names or something */
label = ms_obj_attr_get_ptr (obj, MS_OBJ_ATTR_TEXT, NULL);
if (label != NULL) {
switch (obj->excel_type) {
case 0x0E: /* label or text box */
case 0x06: gnm_so_text_set_text (so, label);
break;
case 0x07: sheet_widget_button_set_label (so, label);
break;
case 0x0B: sheet_widget_checkbox_set_label (so, label);
break;
case 0x0C: sheet_widget_radio_button_set_label (so, label);
break;
case 0x19: cell_comment_text_set (CELL_COMMENT (so), label);
break;
default:
g_warning ("text for type %x", obj->excel_type);
break;
};
MSObjAttr *flip_h = ms_obj_attr_bag_lookup (obj->attrs, MS_OBJ_ATTR_FLIP_H);
MSObjAttr *flip_v = ms_obj_attr_bag_lookup (obj->attrs, MS_OBJ_ATTR_FLIP_V);
SheetObjectDirection direction =
((flip_h == NULL) ? SO_DIR_RIGHT : 0) |
((flip_v == NULL) ? SO_DIR_DOWN : 0);
SheetObjectAnchor anchor;
sheet_object_anchor_init (&anchor, &range,
offsets, anchor_types, direction);
sheet_object_anchor_set (obj->gnum_obj, &anchor);
sheet_object_set_sheet (obj->gnum_obj, esheet->sheet);
/* cannot be done until we have set the sheet */
if (obj->excel_type == 0x0B) {
sheet_widget_checkbox_set_link (obj->gnum_obj,
ms_obj_attr_get_expr (obj, MS_OBJ_ATTR_CHECKBOX_LINK, NULL));
} else if (obj->excel_type == 0x10 || obj->excel_type == 0x11) {
sheet_widget_adjustment_set_details (obj->gnum_obj,
ms_obj_attr_get_expr (obj, MS_OBJ_ATTR_SCROLLBAR_LINK, NULL),
ms_obj_attr_get_int (obj, MS_OBJ_ATTR_SCROLLBAR_VALUE, 0),
ms_obj_attr_get_int (obj, MS_OBJ_ATTR_SCROLLBAR_MIN, 0),
ms_obj_attr_get_int (obj, MS_OBJ_ATTR_SCROLLBAR_MAX, 100) - 1,
ms_obj_attr_get_int (obj, MS_OBJ_ATTR_SCROLLBAR_INC, 1),
ms_obj_attr_get_int (obj, MS_OBJ_ATTR_SCROLLBAR_PAGE, 10));
} else if (obj->excel_type == 0x19 &&
obj->comment_pos.col >= 0 && obj->comment_pos.row >= 0) {
/* our comment object is too weak. This anchor is for the text box,
* we need to store the indicator */
cell_comment_set_cell (CELL_COMMENT (obj->gnum_obj),
&obj->comment_pos);
}
label = ms_obj_attr_get_ptr (obj, MS_OBJ_ATTR_TEXT, NULL);
if (label != NULL) {
SheetObject *so = obj->gnum_obj;
switch (obj->excel_type) {
case 0x0E: /* label or text box */
case 0x06: gnm_so_text_set_text (so, label);
break;
case 0x07: sheet_widget_button_set_label (so, label);
break;
case 0x0B: sheet_widget_checkbox_set_label (so, label);
break;
case 0x0C: sheet_widget_radio_button_set_label (so, label);
break;
case 0x19: cell_comment_text_set (CELL_COMMENT (so), label);
break;
default:
g_warning ("text for type %x", obj->excel_type);
break;
};
}
}
markup = ms_obj_attr_get_markup (obj, MS_OBJ_ATTR_MARKUP, NULL);
if (markup != NULL) {
switch (obj->excel_type) {
return FALSE;
}
static SheetObject *
ms_sheet_create_obj (MSContainer *container, MSObj *obj)
{
SheetObject *so = NULL;
Workbook *wb;
ExcelReadSheet *esheet;
if (obj == NULL)
return NULL;
g_return_val_if_fail (container != NULL, NULL);
esheet = (ExcelReadSheet *)container;
wb = esheet->container.ewb->gnum_wb;
case 0x0E: /* label or text box */
case 0x06: gnm_so_text_set_markup (so, markup);
break;
default:
g_warning ("markup for type %x", obj->excel_type);
break;
};
}
switch (obj->excel_type) {
case 0x00:
break;
case 0x01: { /* Line */
GnmColor *color;
MSObjAttr *is_arrow = ms_obj_attr_bag_lookup (obj->attrs,
MS_OBJ_ATTR_ARROW_END);
so = sheet_object_line_new (is_arrow != NULL);
color = ms_sheet_map_color (esheet, obj,
GnmColor *color = ms_sheet_map_color (esheet, obj,
MS_OBJ_ATTR_FILL_COLOR);
if (color != NULL)
gnm_so_graphic_set_fill_color (so, color);
break;
}
case 0x00: /* draw the group border */
case 0x02:
case 0x03: { /* Box or Oval */
GnmColor *fill_color = NULL;
GnmColor *outline_color;
so = sheet_object_box_new (obj->excel_type == 3);
if (ms_obj_attr_bag_lookup (obj->attrs, MS_OBJ_ATTR_FILLED))
if (!ms_obj_attr_bag_lookup (obj->attrs, MS_OBJ_ATTR_UNFILLED))
fill_color = ms_sheet_map_color (esheet, obj,
MS_OBJ_ATTR_FILL_COLOR);
outline_color = ms_sheet_map_color (esheet, obj,
......@@ -456,34 +427,28 @@ ms_sheet_create_obj (MSContainer *container, MSObj *obj)
}
case 0x05: /* Chart */
so = sheet_object_graph_new (NULL);
break;
case 0x0E: /* Label */
case 0x06: /* TextBox */
so = g_object_new (sheet_object_text_get_type (), NULL);
if (ms_obj_attr_bag_lookup (obj->attrs, MS_OBJ_ATTR_FILLED))
if (ms_obj_attr_bag_lookup (obj->attrs, MS_OBJ_ATTR_UNFILLED))
gnm_so_graphic_set_fill_color (so, NULL);
else
gnm_so_graphic_set_fill_color (so,
ms_sheet_map_color (esheet, obj, MS_OBJ_ATTR_FILL_COLOR));
else
/* default is None */
gnm_so_graphic_set_fill_color (so, NULL);
gnm_so_filled_set_outline_style (so,
ms_obj_attr_get_int (obj, MS_OBJ_ATTR_OUTLINE_STYLE, 0));
ms_obj_attr_get_int (obj, MS_OBJ_ATTR_OUTLINE_STYLE, 1));
gnm_so_filled_set_outline_color (so,
ms_sheet_map_color (esheet, obj, MS_OBJ_ATTR_OUTLINE_COLOR));
gnm_so_graphic_set_width (so,
ms_obj_attr_get_int (obj, MS_OBJ_ATTR_OUTLINE_WIDTH, 0));
gnm_so_text_set_markup (so,
ms_obj_attr_get_markup (obj, MS_OBJ_ATTR_MARKUP, NULL));
break;
/* Button */
case 0x07: so = g_object_new (sheet_widget_button_get_type (), NULL);
case 0x07:
break;
case 0x08: { /* Picture */
MSObjAttr *blip_id = ms_obj_attr_bag_lookup (obj->attrs,
MS_OBJ_ATTR_BLIP_ID);
......@@ -502,7 +467,7 @@ ms_sheet_create_obj (MSContainer *container, MSObj *obj)
so = sheet_object_box_new (FALSE); /* placeholder */
break;
}
case 0x09: so = g_object_new (sheet_object_polygon_get_type (), NULL);
case 0x09:
gnm_so_polygon_set_points (SHEET_OBJECT (so),
ms_obj_attr_get_array (obj, MS_OBJ_ATTR_POLYGON_COORDS, NULL));
gnm_so_polygon_set_fill_color (so,
......@@ -511,6 +476,108 @@ ms_sheet_create_obj (MSContainer *container, MSObj *obj)
ms_sheet_map_color (esheet, obj, MS_OBJ_ATTR_OUTLINE_COLOR));
break;
case 0x0B:
sheet_widget_checkbox_set_link (obj->gnum_obj,
ms_obj_attr_get_expr (obj, MS_OBJ_ATTR_CHECKBOX_LINK, NULL));
break;
case 0x0C:
break;
case 0x10:
case 0x11:
sheet_widget_adjustment_set_details (obj->gnum_obj,
ms_obj_attr_get_expr (obj, MS_OBJ_ATTR_SCROLLBAR_LINK, NULL),
ms_obj_attr_get_int (obj, MS_OBJ_ATTR_SCROLLBAR_VALUE, 0),
ms_obj_attr_get_int (obj, MS_OBJ_ATTR_SCROLLBAR_MIN, 0),
ms_obj_attr_get_int (obj, MS_OBJ_ATTR_SCROLLBAR_MAX, 100) - 1,
ms_obj_attr_get_int (obj, MS_OBJ_ATTR_SCROLLBAR_INC, 1),
ms_obj_attr_get_int (obj, MS_OBJ_ATTR_SCROLLBAR_PAGE, 10));
break;
case 0x12:
break;
case 0x14:
break;
case 0x19:
/* our comment object is too weak. This anchor is for the text box,
* we need to store the indicator */
if (obj->comment_pos.col >= 0 && obj->comment_pos.row >= 0)
cell_comment_set_cell (CELL_COMMENT (obj->gnum_obj),
&obj->comment_pos);
break;
default:
g_warning ("EXCEL: unhandled excel object of type %s (0x%x) id = %d.",
obj->excel_type_name, obj->excel_type, obj->id);
return TRUE;
}
return FALSE;
}
static SheetObject *
ms_sheet_create_obj (MSContainer *container, MSObj *obj)
{
SheetObject *so = NULL;
Workbook *wb;
ExcelReadSheet *esheet;
if (obj == NULL)
return NULL;
g_return_val_if_fail (container != NULL, NULL);
esheet = (ExcelReadSheet *)container;
wb = esheet->container.ewb->gnum_wb;
switch (obj->excel_type) {
case 0x01: { /* Line */
MSObjAttr *is_arrow = ms_obj_attr_bag_lookup (obj->attrs,
MS_OBJ_ATTR_ARROW_END);
so = sheet_object_line_new (is_arrow != NULL);
break;
}
case 0x00: /* draw the group border */
case 0x02:
case 0x03: /* Box or Oval */
so = sheet_object_box_new (obj->excel_type == 3);
break;
case 0x05: /* Chart */
so = sheet_object_graph_new (NULL);
break;
case 0x0E: /* Label */
case 0x06: /* TextBox */
so = g_object_new (sheet_object_text_get_type (), NULL);
break;
/* Button */
case 0x07: so = g_object_new (sheet_widget_button_get_type (), NULL);
break;
case 0x08: { /* Picture */
MSObjAttr *blip_id = ms_obj_attr_bag_lookup (obj->attrs,
MS_OBJ_ATTR_BLIP_ID);
if (blip_id != NULL) {
MSEscherBlip *blip = ms_container_get_blip (container,
blip_id->v.v_uint - 1);
if (blip != NULL) {
so = ms_sheet_create_image (obj, blip);
blip->needs_free = FALSE; /* image took over managing data */
}
}
/* replace blips we don't know how to handle with rectangles */
if (so == NULL)
so = sheet_object_box_new (FALSE); /* placeholder */
break;
}
case 0x09: so = g_object_new (sheet_object_polygon_get_type (), NULL);
break;
case 0x0B: so = g_object_new (sheet_widget_checkbox_get_type (), NULL);
break;
case 0x0C: so = g_object_new (sheet_widget_radio_button_get_type (), NULL);
......@@ -1407,11 +1474,11 @@ excel_palette_get (ExcelPalette const *pal, gint idx)
d (4, fprintf (stderr,"Color Index %d\n", idx););
/* Black ? */
/* 0 == Black, 64 == system text ? */
if (idx == 0 || idx == 64)
return style_color_black ();
/* White ? */
if (idx == 1)
/* 1 == White, 65 == system back ? */
if (idx == 1 || idx == 65)
return style_color_white ();
idx -= 8;
......@@ -1474,23 +1541,26 @@ excel_get_font (ExcelWorkbook const *ewb, unsigned font_idx)
static BiffXFData const *
excel_get_xf (ExcelReadSheet *esheet, int xfidx)
{
BiffXFData *xf;
GPtrArray const * const p = esheet->container.ewb->XF_cell_records;
g_return_val_if_fail (p != NULL, NULL);
g_return_val_if_fail (p->len, NULL); /* happens in early XL */
if (esheet->container.ver == MS_BIFF_V2)
xfidx &= 0x3f; /* Guess from experimental results */
if (0 > xfidx || xfidx >= (int)p->len) {
/* cheesy guess */
if (xfidx == 0 && esheet->container.ver == MS_BIFF_V2)
return NULL;
g_return_val_if_fail (p->len > 0, NULL);
g_warning ("XL: Xf index 0x%X is not in the range[0..0x%X)", xfidx, p->len);
xfidx = 0;
}
xf = g_ptr_array_index (p, xfidx);
g_return_val_if_fail (xf, NULL);
/* FIXME: when we can handle styles too deal with this correctly */
/* g_return_val_if_fail (xf->xftype == MS_BIFF_X_CELL, NULL); */
return xf;
return g_ptr_array_index (p, xfidx);
}
static GnmStyle *
......@@ -1505,7 +1575,8 @@ excel_get_style_from_xf (ExcelReadSheet *esheet, guint16 xfidx)
d (2, fprintf (stderr,"XF index %d\n", xfidx););
g_return_val_if_fail (xf != NULL, NULL);
if (xf == NULL)
return NULL;
/* If we've already done the conversion use the cached style */
if (xf->mstyle != NULL) {
......@@ -1773,6 +1844,8 @@ excel_read_XF_OLD (BiffQuery *q, ExcelWorkbook *ewb, MsBiffVersion ver)
xf->format_idx = GSF_LE_GET_GUINT8 (q->data + 1);
xf->style_format = (xf->format_idx > 0)
? excel_wb_get_fmt (ewb, xf->format_idx) : NULL;
xf->is_simple_format = xf->style_format == NULL ||
g_slist_length (xf->style_format->entries) <= 1;
xf->wrap_text = FALSE;
xf->shrink_to_fit = FALSE;
......@@ -1879,6 +1952,8 @@ excel_read_XF (BiffQuery *q, ExcelWorkbook *ewb, MsBiffVersion ver)
xf->format_idx = GSF_LE_GET_GUINT16 (q->data + 2);
xf->style_format = (xf->format_idx > 0)
? excel_wb_get_fmt (ewb, xf->format_idx) : NULL;
xf->is_simple_format = xf->style_format == NULL ||
g_slist_length (xf->style_format->entries) <= 1;
data = GSF_LE_GET_GUINT16 (q->data + 4);
xf->locked = (data & 0x0001) != 0;
......@@ -2448,10 +2523,12 @@ excel_sheet_insert_val (ExcelReadSheet *esheet, int xfidx,
g_return_if_fail (v);
g_return_if_fail (esheet);
g_return_if_fail (xf);
excel_set_xf (esheet, col, row, xfidx);
value_set_fmt (v, xf->style_format);
if (xf != NULL) {
excel_set_xf (esheet, col, row, xfidx);
if (xf->is_simple_format)
value_set_fmt (v, xf->style_format);
}
cell_set_value (sheet_cell_fetch (esheet->sheet, col, row), v);
}
......
......@@ -27,6 +27,8 @@ typedef struct _BiffXFData {
guint16 font_idx;
guint16 format_idx;
GnmFormat *style_format;
gboolean is_simple_format;
gboolean hidden;
gboolean locked;
MsBiffXfType xftype; /* -- Very important field... */
......
......@@ -727,7 +727,7 @@ excel_formula_parses_ref_sheets (MSContainer const *container, guint8 const *dat
if (a < 0 || b < 0) /* deleted sheets */
return TRUE;
d (-1, fprintf (stderr, " : 0x%hx : 0x%hx : 0x%hx\n", ixals, a, b););
d (1, fprintf (stderr, " : 0x%hx : 0x%hx : 0x%hx\n", ixals, a, b););
/* ixals < 0 == reference within the current workbook
* ixals == negative one based index into containers externsheet table
......
......@@ -331,9 +331,41 @@ ms_obj_delete (MSObj *obj)
}
}
/* S59EOE.HTM */
typedef struct {
unsigned first, last;
PangoAttrList *accum;
} TXORun;
static gboolean
append_txorun (PangoAttribute *src, TXORun *run)
{
PangoAttribute *dst = pango_attribute_copy (src);
dst->start_index = run->first; /* inclusive */
dst->end_index = run->last; /* exclusize */
pango_attr_list_change (run->accum, dst);
return FALSE;
}
static PangoAttrList *
read_txoruns (MSContainer *container, guint8 const *data, int txo_len)
{
TXORun txo_run;
g_return_val_if_fail (txo_len >= 16, NULL); /* min two records */
txo_run.last = G_MAXINT;
txo_run.accum = pango_attr_list_new ();
for (txo_len -= 16 ; txo_len >= 0 ; txo_len -= 8) {
txo_run.first = GSF_LE_GET_GUINT16 (data + txo_len);
pango_attr_list_filter (ms_container_get_markup (
container, GSF_LE_GET_GUINT16 (data + txo_len + 2)),
(PangoAttrFilterFunc) append_txorun, &txo_run);
txo_run.last = txo_run.first;
}
return txo_run.accum;
}
char *
ms_read_TXO (BiffQuery *q)
ms_read_TXO (BiffQuery *q, MSContainer *c, PangoAttrList **markup)
{
static char const * const orientations [] = {
"Left to right",
......@@ -357,7 +389,7 @@ ms_read_TXO (BiffQuery *q)
int const halign = (options >> 1) & 0x7;
int const valign = (options >> 4) & 0x7;
char *text;
guint16 peek_op;