~ubuntu-branches/ubuntu/feisty/gnumeric/feisty

« back to all changes in this revision

Viewing changes to plugins/excel/ms-excel-write.c

  • Committer: Bazaar Package Importer
  • Author(s): Gauvain Pocentek
  • Date: 2006-12-06 13:55:23 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20061206135523-6bh02cebuk0hduva
Tags: 1.7.5-1ubuntu1
* Merge with debian experimental:
  - debian/control, debian/*-gtk-*, debian/rules,
    debian/shlibs.local: Xubuntu changes for
    gtk/gnome multibuild.
  - run intltool-update in po*
  - Build Depend on intltool

Show diffs side-by-side

added added

removed removed

Lines of Context:
159
159
}
160
160
 
161
161
static guint
162
 
map_border_to_xl (StyleBorderType btype, MsBiffVersion ver)
 
162
map_border_to_xl (GnmStyleBorderType btype, MsBiffVersion ver)
163
163
{
164
164
        guint ibtype = btype;
165
165
 
166
 
        if (btype <= STYLE_BORDER_NONE)
167
 
                ibtype = STYLE_BORDER_NONE;
 
166
        if (btype <= GNM_STYLE_BORDER_NONE)
 
167
                ibtype = GNM_STYLE_BORDER_NONE;
168
168
 
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;
171
171
 
172
172
        return ibtype;
173
173
}
1105
1105
/****************************************************************************/
1106
1106
 
1107
1107
typedef struct {
1108
 
        GnmValidation  *v;
 
1108
        GnmValidation const *v;
1109
1109
        GnmInputMsg *msg;
1110
1110
        GSList      *ranges;
1111
1111
} ValInputPair;
2250
2250
        GOFormat        *fmt;
2251
2251
        GnmString       *str;
2252
2252
 
2253
 
        if (cell_has_expr (cell) || cell->value == NULL)
 
2253
        if (gnm_cell_has_expr (cell) || cell->value == NULL)
2254
2254
                return;
2255
2255
 
2256
2256
        if ((fmt = VALUE_FMT (cell->value)) != NULL) {
2257
 
                style = cell_get_style (cell);
 
2257
                style = gnm_cell_get_style (cell);
2258
2258
 
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],
2520
2520
 
2521
2521
        /* Borders */
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);
2526
2526
                if (b) {
2604
2604
                /*********** Byte 10&11 */
2605
2605
                tmp16 = 0;
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);
2619
2619
 
2620
2620
                /*********** Byte 12&13 */
2621
2621
                tmp16 = 0;
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;
2628
2628
 
2629
2629
                diag = 0;
2630
2630
                btype = xfd->border_type[STYLE_DIAGONAL];
2631
 
                if (btype != STYLE_BORDER_NONE)
 
2631
                if (btype != GNM_STYLE_BORDER_NONE)
2632
2632
                        diag |= 1;
2633
2633
                btype = xfd->border_type[STYLE_REV_DIAGONAL];
2634
 
                if (btype != STYLE_BORDER_NONE)
 
2634
                if (btype != GNM_STYLE_BORDER_NONE)
2635
2635
                        diag |= 2;
2636
2636
 
2637
2637
                tmp16 |= diag << 14;
2640
2640
                /*********** Byte 14-17 */
2641
2641
                tmp32 = 0;
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;
2648
2648
 
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;
2655
2655
                        }
2702
2702
 
2703
2703
                /* Borders */
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)
2707
2707
                                & 0x1c0;
2708
2708
                        tmp16 |= (xfd->border_color[STYLE_BOTTOM] << 9)
2712
2712
 
2713
2713
                tmp16  = 0;
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;
2718
2718
                }
2725
2725
                GSF_LE_SET_GUINT16(data+12, tmp16);
2726
2726
 
2727
2727
                tmp16  = 0;
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);
2733
2733
 
2966
2966
        g_return_if_fail (ewb);
2967
2967
        g_return_if_fail (cell);
2968
2968
        g_return_if_fail (esheet);
2969
 
        g_return_if_fail (cell_has_expr (cell));
 
2969
        g_return_if_fail (gnm_cell_has_expr (cell));
2970
2970
        g_return_if_fail (cell->value);
2971
2971
 
2972
2972
        col = cell->pos.col;
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);
3207
3207
        });
3208
3208
 
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) &&
3386
3386
        guint8 *data;
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;
3390
3391
 
3391
3392
        if (NULL != ci) {
3392
3393
                width = ci->size_pts;           /* pts to avoid problems when zooming */
3393
3394
                if (!ci->visible)
3394
3395
                        options = 1;
 
3396
                if (ci->hard_size)
 
3397
                        options |= 2;
 
3398
                /* not user assigned but width != default is 'bestFit' */
 
3399
                else if (fabs (def_width - width) > .1)
 
3400
                        options |= 6;
 
3401
 
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);
4217
4223
        }
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);
4226
4231
        }
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);
4233
4237
        }