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

« back to all changes in this revision

Viewing changes to src/format-template.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:
47
47
        return !strcmp (CXML2C (a), s);
48
48
}
49
49
 
50
 
#define ROW_COL_KEY(row,col) GINT_TO_POINTER (row * SHEET_MAX_COLS + col)
 
50
#define ROW_COL_KEY(row,col) GINT_TO_POINTER ((guint)row * (guint)GNM_MAX_COLS + (guint)col)
51
51
 
52
52
/******************************************************************************
53
53
 * FormatTemplateMember - Getters/setters and creation
65
65
{
66
66
        TemplateMember *member;
67
67
 
68
 
        /* Sanity check for ROW_COL_KEY.  */
69
 
        g_assert (INT_MAX / SHEET_MAX_COLS > SHEET_MAX_ROWS);
70
 
 
71
68
        member = g_new (TemplateMember, 1);
72
69
 
73
70
        member->col.offset         = member->row.offset = 0;
269
266
        ft->edges.top    = TRUE;
270
267
        ft->edges.bottom = TRUE;
271
268
 
272
 
        ft->table     = g_hash_table_new_full (NULL, NULL, NULL, (GDestroyNotify)gnm_style_unref);
 
269
        ft->table = g_hash_table_new_full ((GHashFunc)gnm_cellpos_hash,
 
270
                                           (GEqualFunc)gnm_cellpos_equal,
 
271
                                           (GDestroyNotify)g_free,
 
272
                                           (GDestroyNotify)gnm_style_unref);
273
273
        ft->invalidate_hash = TRUE;
274
274
 
275
275
        range_init (&ft->dimension, 0,0,0,0);
891
891
 *
892
892
 **/
893
893
static void
894
 
format_template_calculate (GnmFormatTemplate *origft, GnmRange const *r, PCalcCallback pc, gpointer cb_data)
 
894
format_template_calculate (GnmFormatTemplate *origft, GnmRange const *r,
 
895
                           PCalcCallback pc, gpointer cb_data)
895
896
{
896
897
        GnmFormatTemplate *ft = origft;
897
898
        GSList *ptr;
963
964
 ******************************************************************************/
964
965
 
965
966
static void
966
 
cb_format_hash_style (GnmFormatTemplate *ft, GnmRange *r, GnmStyle *mstyle, GHashTable *table)
 
967
cb_format_hash_style (GnmFormatTemplate *ft, GnmRange *r, GnmStyle *mstyle, gpointer user)
967
968
{
 
969
        GHashTable *table = user;
968
970
        int row, col;
969
971
 
970
972
        /*
973
975
        mstyle = format_template_filter_style (ft, mstyle, TRUE);
974
976
 
975
977
        for (row = r->start.row; row <= r->end.row; row++)
976
 
                for (col = r->start.col; col <= r->end.col; col++)
977
 
                        g_hash_table_insert (table, ROW_COL_KEY (row, col),
978
 
                                gnm_style_dup (mstyle));
 
978
                for (col = r->start.col; col <= r->end.col; col++) {
 
979
                        GnmCellPos key;
 
980
                        key.col = col;
 
981
                        key.row = row;
 
982
                        g_hash_table_insert (table,
 
983
                                             g_memdup (&key, sizeof (key)),
 
984
                                             gnm_style_dup (mstyle));
 
985
                }
979
986
 
980
987
        /*
981
988
         * Unref here, the hashtable will take care of its own
997
1004
 
998
1005
        g_return_if_fail (ft != NULL);
999
1006
 
1000
 
        g_hash_table_foreach_remove (ft->table, (GHRFunc)g_direct_hash /* :-) */, NULL);
 
1007
        g_hash_table_remove_all (ft->table);
1001
1008
 
1002
1009
        r = ft->dimension;
1003
1010
 
1009
1016
                return;
1010
1017
        }
1011
1018
 
1012
 
        format_template_calculate (ft, &r, (PCalcCallback) cb_format_hash_style, ft->table);
 
1019
        format_template_calculate (ft, &r, cb_format_hash_style, ft->table);
1013
1020
}
1014
1021
 
1015
1022
/**
1029
1036
GnmStyle *
1030
1037
format_template_get_style (GnmFormatTemplate *ft, int row, int col)
1031
1038
{
 
1039
        GnmCellPos key;
 
1040
 
1032
1041
        g_return_val_if_fail (ft != NULL, NULL);
1033
1042
        g_return_val_if_fail (ft->table != NULL, NULL);
1034
1043
 
1041
1050
                format_template_recalc_hash (ft);
1042
1051
        }
1043
1052
 
1044
 
        return g_hash_table_lookup (ft->table, ROW_COL_KEY (row, col));
 
1053
        key.col = col;
 
1054
        key.row = row;
 
1055
        return g_hash_table_lookup (ft->table, &key);
1045
1056
}
1046
1057
 
1047
1058
 
1051
1062
 ******************************************************************************/
1052
1063
 
1053
1064
static void
1054
 
cb_format_sheet_style (GnmFormatTemplate *ft, GnmRange *r, GnmStyle *mstyle, Sheet *sheet)
 
1065
cb_format_sheet_style (GnmFormatTemplate *ft, GnmRange *r, GnmStyle *mstyle, gpointer user)
1055
1066
{
 
1067
        Sheet *sheet = user;
 
1068
 
1056
1069
        g_return_if_fail (ft != NULL);
1057
1070
        g_return_if_fail (r != NULL);
1058
1071
        g_return_if_fail (mstyle != NULL);
1101
1114
{
1102
1115
        for (; regions != NULL ; regions = regions->next)
1103
1116
                format_template_calculate (ft, regions->data,
1104
 
                        (PCalcCallback) cb_format_sheet_style, sheet);
 
1117
                                           cb_format_sheet_style, sheet);
1105
1118
}
1106
1119
 
1107
1120
/******************************************************************************