~ubuntu-branches/ubuntu/quantal/gnumeric/quantal

« back to all changes in this revision

Viewing changes to plugins/mps/mps.c

  • Committer: Bazaar Package Importer
  • Author(s): Gauvain Pocentek
  • Date: 2009-06-07 11:10:47 UTC
  • mfrom: (1.1.19 upstream) (2.1.2 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090607111047-l3rtbzfjxvmi1kx0
Tags: 1.9.8-1ubuntu1
* Merge from debian unstable, remaining changes:
  - Promoted gnumeric-doc to Recommends in gnumeric package for help to be
    installed automatically
  - gnumeric-gtk is a transitional package
  - gnumeric conflicts with gnumeric-gtk << 1.8.3-3ubuntu1
  - call initltool-update in po*
  - remove psiconv support (psiconv is in universe):
    o debian/control: remove B-D on libpsiconv-dev
    o debian/rules: don't pass --with-psiconv to ./configure

Show diffs side-by-side

added added

removed removed

Lines of Context:
65
65
 */
66
66
 
67
67
/* Writes a string into a cell. */
68
 
static inline void
 
68
static void
69
69
mps_set_cell (Sheet *sheet, int col, int row, const gchar *str)
70
70
{
71
 
        gnm_cell_set_value (sheet_cell_fetch (sheet, col, row),
72
 
                        value_new_string (str));
 
71
        GnmCell *cell = sheet_cell_fetch (sheet, col, row);
 
72
        gnm_cell_set_value (cell, value_new_string (str));
73
73
}
74
74
 
75
75
/* Writes a float into a cell. */
76
 
static inline void
 
76
static void
77
77
mps_set_cell_float (Sheet *sheet, int col, int row, const gnm_float f)
78
78
{
79
 
        gnm_cell_set_value (sheet_cell_fetch (sheet, col, row), value_new_float (f));
 
79
        GnmCell *cell = sheet_cell_fetch (sheet, col, row);
 
80
        gnm_cell_set_value (cell, value_new_float (f));
80
81
}
81
82
 
82
83
static void
297
298
        else
298
299
                ecol = CONSTRAINT_COL + MAX_COL - 1;
299
300
        for (i = 0; i < ctxt->n_cols; i++) {
300
 
                  mps_set_cell_float (sh, VARIABLE_COL + i % MAX_COL,
301
 
                                      VARIABLE_ROW + (i / MAX_COL), 0.0);
302
 
                  mps_set_cell_float (sh, VARIABLE_COL + i % MAX_COL,
303
 
                                      VARIABLE_ROW + n_rows_per_fn
304
 
                                      + (i / MAX_COL) + 1,
305
 
                           ctxt->matrix[ctxt->objective_row->index][i]);
 
301
                int col = VARIABLE_COL + i % MAX_COL;
 
302
                mps_set_cell_float (sh, col,
 
303
                                    VARIABLE_ROW + (i / MAX_COL), 0.0);
 
304
                mps_set_cell_float (sh, col,
 
305
                                    VARIABLE_ROW + n_rows_per_fn
 
306
                                    + (i / MAX_COL) + 1,
 
307
                                    ctxt->objective_row
 
308
                                    ? ctxt->matrix[ctxt->objective_row->index][i]
 
309
                                    : 0);
306
310
        }
307
311
 
308
312
        /*
455
459
        gint             i;
456
460
        int              n_rows_per_fn;
457
461
        SolverParameters *param = sh->solver_parameters;
 
462
        const char *row_name =
 
463
                ctxt->objective_row
 
464
                ? ctxt->objective_row->name
 
465
                : "-";
458
466
 
459
467
        n_rows_per_fn = (ctxt->n_cols + MAX_COL - 1) / MAX_COL;
460
468
        mps_prepare (wbv, ctxt);
466
474
        if (ctxt->n_cols < MAX_COL)
467
475
                mps_set_cell (sh, VARIABLE_COL - 1,
468
476
                              VARIABLE_ROW + 1 + n_rows_per_fn,
469
 
                              ctxt->objective_row->name);
 
477
                              row_name);
470
478
        else {
471
479
                for (i = 0; i < n_rows_per_fn; i++) {
472
480
                        GString *buf = g_string_new (NULL);
473
481
                        g_string_append_printf (buf, "%s (R[%d])",
474
 
                                           ctxt->objective_row->name, i+1);
 
482
                                                row_name, i + 1);
475
483
                        mps_set_cell (sh, VARIABLE_COL - 1,
476
484
                                      VARIABLE_ROW + 1 + i + n_rows_per_fn,
477
485
                                      buf->str);
489
497
 
490
498
 
491
499
        /* Autofit column A */
492
 
        i = sheet_col_size_fit_pixels (sh, 0, 0, gnm_sheet_get_max_rows (ctxt->sheet) - 1, FALSE);
 
500
        i = sheet_col_size_fit_pixels (sh, 0, 0, gnm_sheet_get_last_row (ctxt->sheet), FALSE);
493
501
        if (i == 0)
494
502
                  return;
495
503
        sheet_col_set_size_pixels (sh, 0, i, TRUE);
515
523
        ctxt->input          = (GsfInputTextline *)gsf_input_textline_new (input);
516
524
        ctxt->line_no        = 1;
517
525
        ctxt->line           = NULL;
518
 
        ctxt->sheet          = workbook_sheet_add (wb, -1);
 
526
        ctxt->sheet          = workbook_sheet_add (wb, -1, GNM_DEFAULT_COLS, GNM_DEFAULT_ROWS);
519
527
 
520
528
        ctxt->name           = NULL;
521
529
        ctxt->rows           = NULL;