162
map_border_to_xl (StyleBorderType btype, MsBiffVersion ver)
162
map_border_to_xl (GnmStyleBorderType btype, MsBiffVersion ver)
164
164
guint ibtype = btype;
166
if (btype <= STYLE_BORDER_NONE)
167
ibtype = STYLE_BORDER_NONE;
166
if (btype <= GNM_STYLE_BORDER_NONE)
167
ibtype = GNM_STYLE_BORDER_NONE;
169
if (ver <= MS_BIFF_V7 && btype > STYLE_BORDER_HAIR)
170
ibtype = STYLE_BORDER_MEDIUM;
169
if (ver <= MS_BIFF_V7 && btype > GNM_STYLE_BORDER_HAIR)
170
ibtype = GNM_STYLE_BORDER_MEDIUM;
2251
2251
GnmString *str;
2253
if (cell_has_expr (cell) || cell->value == NULL)
2253
if (gnm_cell_has_expr (cell) || cell->value == NULL)
2256
2256
if ((fmt = VALUE_FMT (cell->value)) != NULL) {
2257
style = cell_get_style (cell);
2257
style = gnm_cell_get_style (cell);
2259
2259
/* Collect unique fonts in rich text */
2260
2260
if (VALUE_IS_STRING (cell->value) &&
2477
2477
xfd->pat_foregnd_col, xfd->pat_backgnd_col,
2478
2478
xfd->fill_pattern_idx);
2479
2479
for (i = STYLE_TOP; i < STYLE_ORIENT_MAX; i++) {
2480
if (xfd->border_type[i] != STYLE_BORDER_NONE) {
2480
if (xfd->border_type[i] != GNM_STYLE_BORDER_NONE) {
2481
2481
fprintf (stderr, " border_type[%d] : 0x%x"
2482
2482
" border_color[%d] : 0x%x\n",
2483
2483
i, xfd->border_type[i],
2522
2522
for (i = STYLE_TOP; i < STYLE_ORIENT_MAX; i++) {
2523
xfd->border_type[i] = STYLE_BORDER_NONE;
2523
xfd->border_type[i] = GNM_STYLE_BORDER_NONE;
2524
2524
xfd->border_color[i] = 0;
2525
2525
b = gnm_style_get_border (st, MSTYLE_BORDER_TOP + i);
2604
2604
/*********** Byte 10&11 */
2606
2606
btype = xfd->border_type[STYLE_LEFT];
2607
if (btype != STYLE_BORDER_NONE)
2607
if (btype != GNM_STYLE_BORDER_NONE)
2608
2608
tmp16 |= (map_border_to_xl (btype, bp->version) & 0xf) << 0;
2609
2609
btype = xfd->border_type[STYLE_RIGHT];
2610
if (btype != STYLE_BORDER_NONE)
2610
if (btype != GNM_STYLE_BORDER_NONE)
2611
2611
tmp16 |= (map_border_to_xl (btype, bp->version) & 0xf) << 4;
2612
2612
btype = xfd->border_type[STYLE_TOP];
2613
if (btype != STYLE_BORDER_NONE)
2613
if (btype != GNM_STYLE_BORDER_NONE)
2614
2614
tmp16 |= (map_border_to_xl (btype, bp->version) & 0xf) << 8;
2615
2615
btype = xfd->border_type[STYLE_BOTTOM];
2616
if (btype != STYLE_BORDER_NONE)
2616
if (btype != GNM_STYLE_BORDER_NONE)
2617
2617
tmp16 |= (map_border_to_xl (btype, bp->version) & 0xf) << 12;
2618
2618
GSF_LE_SET_GUINT16 (data+10, tmp16);
2620
2620
/*********** Byte 12&13 */
2622
2622
btype = xfd->border_type[STYLE_LEFT];
2623
if (btype != STYLE_BORDER_NONE)
2623
if (btype != GNM_STYLE_BORDER_NONE)
2624
2624
tmp16 |= (xfd->border_color[STYLE_LEFT] & 0x7f) << 0;
2625
2625
btype = xfd->border_type[STYLE_RIGHT];
2626
if (btype != STYLE_BORDER_NONE)
2626
if (btype != GNM_STYLE_BORDER_NONE)
2627
2627
tmp16 |= (xfd->border_color[STYLE_RIGHT] & 0x7f) << 7;
2630
2630
btype = xfd->border_type[STYLE_DIAGONAL];
2631
if (btype != STYLE_BORDER_NONE)
2631
if (btype != GNM_STYLE_BORDER_NONE)
2633
2633
btype = xfd->border_type[STYLE_REV_DIAGONAL];
2634
if (btype != STYLE_BORDER_NONE)
2634
if (btype != GNM_STYLE_BORDER_NONE)
2637
2637
tmp16 |= diag << 14;
2640
2640
/*********** Byte 14-17 */
2642
2642
btype = xfd->border_type[STYLE_TOP];
2643
if (btype != STYLE_BORDER_NONE)
2643
if (btype != GNM_STYLE_BORDER_NONE)
2644
2644
tmp32 |= (xfd->border_color[STYLE_TOP] & 0x7f) << 0;
2645
2645
btype = xfd->border_type[STYLE_BOTTOM];
2646
if (btype != STYLE_BORDER_NONE)
2646
if (btype != GNM_STYLE_BORDER_NONE)
2647
2647
tmp32 |= (xfd->border_color[STYLE_BOTTOM] & 0x7f) << 7;
2649
2649
diag = (diag & 1) ? STYLE_DIAGONAL : ((diag & 2) ? STYLE_REV_DIAGONAL : 0);
2650
2650
if (diag != 0) {
2651
2651
btype = xfd->border_type [diag];
2652
if (btype != STYLE_BORDER_NONE) {
2652
if (btype != GNM_STYLE_BORDER_NONE) {
2653
2653
tmp32 |= (xfd->border_color[diag] & 0x7f) << 14;
2654
2654
tmp32 |= (map_border_to_xl (btype, bp->version) & 0xf) << 21;
2704
2704
btype = xfd->border_type[STYLE_BOTTOM];
2705
if (btype != STYLE_BORDER_NONE) {
2705
if (btype != GNM_STYLE_BORDER_NONE) {
2706
2706
tmp16 |= (map_border_to_xl (btype, bp->version) << 6)
2708
2708
tmp16 |= (xfd->border_color[STYLE_BOTTOM] << 9)
2714
2714
btype = xfd->border_type[STYLE_TOP];
2715
if (btype != STYLE_BORDER_NONE) {
2715
if (btype != GNM_STYLE_BORDER_NONE) {
2716
2716
tmp16 |= map_border_to_xl (btype, bp->version) & 0x7;
2717
2717
tmp16 |= (xfd->border_color[STYLE_TOP] << 9) & 0xfe00;
2725
2725
GSF_LE_SET_GUINT16(data+12, tmp16);
2728
if (xfd->border_type[STYLE_LEFT] != STYLE_BORDER_NONE)
2728
if (xfd->border_type[STYLE_LEFT] != GNM_STYLE_BORDER_NONE)
2729
2729
tmp16 |= xfd->border_color[STYLE_LEFT] & 0x7f;
2730
if (xfd->border_type[STYLE_RIGHT] != STYLE_BORDER_NONE)
2730
if (xfd->border_type[STYLE_RIGHT] != GNM_STYLE_BORDER_NONE)
2731
2731
tmp16 |= (xfd->border_color[STYLE_RIGHT] << 7) & 0x3f80;
2732
2732
GSF_LE_SET_GUINT16(data+14, tmp16);
3197
3197
GnmParsePos tmp;
3198
3198
fprintf (stderr, "Writing cell at %s '%s' = '%s', xf = 0x%x\n",
3199
3199
cell_name (cell),
3200
(cell_has_expr (cell)
3200
(gnm_cell_has_expr (cell)
3201
3201
? gnm_expr_top_as_string (cell->base.texpr,
3202
3202
parse_pos_init_cell (&tmp, cell),
3203
3203
gnm_expr_conventions_default)
3206
3206
value_get_as_string (cell->value) : "empty"), xf);
3209
if (cell_has_expr (cell))
3209
if (gnm_cell_has_expr (cell))
3210
3210
excel_write_FORMULA (ewb, esheet, cell, xf);
3211
3211
else if ((v = cell->value) != NULL) {
3212
3212
if (VALUE_IS_STRING (v) &&
3387
3387
guint16 charwidths, options = 0;
3388
3388
float width, scale;
3389
float const def_width = esheet->gnum_sheet->cols.default_style.size_pts;
3389
3390
XL_font_width const *spec;
3391
3392
if (NULL != ci) {
3392
3393
width = ci->size_pts; /* pts to avoid problems when zooming */
3393
3394
if (!ci->visible)
3398
/* not user assigned but width != default is 'bestFit' */
3399
else if (fabs (def_width - width) > .1)
3395
3402
options |= (MIN (ci->outline_level, 0x7) << 8);
3396
3403
if (ci->is_collapsed)
3397
3404
options |= 0x1000;
4210
4217
pos = sv->edit_pos;
4211
4218
if (pos.col < sv->unfrozen_top_left.col)
4212
4219
pos.col = sv->unfrozen_top_left.col;
4213
tmp = g_slist_prepend (NULL,
4214
range_init_cellpos (&r, &pos, &pos));
4220
tmp = g_slist_prepend (NULL, range_init_cellpos (&r, &pos));
4215
4221
excel_write_SELECTION (bp, tmp, &pos, 1);
4216
4222
g_slist_free (tmp);
4219
4225
pos = sv->edit_pos;
4220
4226
if (pos.row < sv->unfrozen_top_left.row)
4221
4227
pos.row = sv->unfrozen_top_left.row;
4222
tmp = g_slist_prepend (NULL,
4223
range_init_cellpos (&r, &pos, &pos));
4228
tmp = g_slist_prepend (NULL, range_init_cellpos (&r, &pos));
4224
4229
excel_write_SELECTION (bp, tmp, &pos, 2);
4225
4230
g_slist_free (tmp);
4227
4232
if (sv->unfrozen_top_left.col > 0 && sv->unfrozen_top_left.row > 0) {
4228
4233
pos = sv->edit_pos; /* apparently no bounds check needed */
4229
tmp = g_slist_prepend (NULL,
4230
range_init_cellpos (&r, &pos, &pos));
4234
tmp = g_slist_prepend (NULL, range_init_cellpos (&r, &pos));
4231
4235
excel_write_SELECTION (bp, tmp, &pos, 0);
4232
4236
g_slist_free (tmp);