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

« back to all changes in this revision

Viewing changes to src/sheet-style.c

  • Committer: Bazaar Package Importer
  • Author(s): Gauvain Pocentek
  • Date: 2009-06-22 13:37:20 UTC
  • mfrom: (1.1.20 upstream) (2.1.3 sid)
  • Revision ID: james.westby@ubuntu.com-20090622133720-rtdazsiz2lx5q8l7
Tags: 1.9.9-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
    o debian/gnumeric-plugins-extra.install: don't install the psiconv
      plugin

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
#include "parse-util.h"
33
33
#include "cell.h"
34
34
#include "gutils.h"
35
 
#include <goffice/utils/go-glib-extras.h>
 
35
#include <goffice/goffice.h>
36
36
#include <glib/gi18n-lib.h>
37
37
#include <string.h>
38
38
#include <math.h>
81
81
        }
82
82
 
83
83
        s = gnm_style_link_sheet (s, (Sheet *)sheet);
 
84
 
 
85
        /* Retry the lookup in case "s" changed.  See #585178.  */
 
86
        res = g_hash_table_lookup (sheet->style_data->style_hash, s);
 
87
        if (res != NULL) {
 
88
                gnm_style_link (res);
 
89
                /*
 
90
                 * We are abandoning the linking here.  We cannot use
 
91
                 * gnm_style_unlink as that would call sheet_style_unlink
 
92
                 * and thus remove "res" from the hash.
 
93
                 */
 
94
                s->link_count = 0;
 
95
                s->linked_sheet = NULL;
 
96
                gnm_style_unref (s);
 
97
 
 
98
                return res;
 
99
        }
 
100
 
84
101
        g_hash_table_insert (sheet->style_data->style_hash, s, s);
85
102
        return s;
86
103
}
186
203
 * and GNM_MAX_COLS and GNM_MAX_ROWS in gnumeric.h */
187
204
#define TILE_TOP_LEVEL 6
188
205
 
189
 
#define TILE_SIZE_COL 4
 
206
#define TILE_SIZE_COL 8
190
207
#define TILE_SIZE_ROW 16
191
208
 
192
209
typedef enum {
558
575
        /* Save the style for the surviving area.  */
559
576
        range_init (&save_range, 0, 0,
560
577
                    MIN (cols, old_cols), MIN (rows, old_rows));
561
 
        styles = sheet_style_get_list (sheet, &save_range);
 
578
        styles = sheet_style_get_range (sheet, &save_range);
562
579
 
563
580
        /* Build new empty structures.  */
564
581
        sheet_style_shutdown (sheet);
1862
1879
 
1863
1880
        g_return_if_fail (rinfo != NULL);
1864
1881
 
1865
 
        styles = sheet_style_get_list (rinfo->origin_sheet, &rinfo->origin);
 
1882
        styles = sheet_style_get_range (rinfo->origin_sheet, &rinfo->origin);
1866
1883
 
1867
1884
        sheet_style_set_range (rinfo->origin_sheet, &rinfo->origin,
1868
1885
                               sheet_style_default (rinfo->origin_sheet));
1900
1917
                if (col < 0)
1901
1918
                        col = 0;
1902
1919
                corner.row = 0;
1903
 
                styles = sheet_style_get_list (rinfo->origin_sheet,
 
1920
                styles = sheet_style_get_range (rinfo->origin_sheet,
1904
1921
                               range_init (&r, col, 0, col, gnm_sheet_get_last_row (rinfo->origin_sheet)));
1905
1922
                if (o > 0)
1906
1923
                        for (ptr = styles ; ptr != NULL ; ptr = ptr->next)
1913
1930
                        row = 0;
1914
1931
                corner.col = 0;
1915
1932
                range_init_rows (&r, rinfo->origin_sheet, row, row);
1916
 
                styles = sheet_style_get_list (rinfo->origin_sheet, &r);
 
1933
                styles = sheet_style_get_range (rinfo->origin_sheet, &r);
1917
1934
                if (o > 0)
1918
1935
                        for (ptr = styles ; ptr != NULL ; ptr = ptr->next)
1919
1936
                                ((GnmStyleRegion *)ptr->data)->range.end.row = o;
2171
2188
}
2172
2189
 
2173
2190
/**
2174
 
 * sheet_style_get_list :
 
2191
 * sheet_style_get_range :
2175
2192
 *
2176
2193
 * @sheet :
2177
2194
 * @range :
2180
2197
 * Caller is responsible for freeing.
2181
2198
 */
2182
2199
GnmStyleList *
2183
 
sheet_style_get_list (Sheet const *sheet, GnmRange const *r)
 
2200
sheet_style_get_range (Sheet const *sheet, GnmRange const *r)
2184
2201
{
2185
2202
        GnmStyleList *res = NULL;
2186
2203
        StyleListMerge mi;
2363
2380
 
2364
2381
/**
2365
2382
 * sheet_style_set_list
2366
 
 *
2367
 
 * @sheet     :
2368
 
 * @corner    :
2369
 
 * @transpose :
2370
 
 * @list      :
2371
 
 *
2372
 
 * Applies a list of styles to the sheet with the supplied offset.  Optionally
2373
 
 * transposing the ranges
 
2383
 * @sheet     : #Sheet
 
2384
 * @corner    : The top-left corner (in LTR mode)
 
2385
 * @transpose : should the styles be transposed
 
2386
 * @list      : #GnmStyleList
 
2387
 *
 
2388
 * Overwrites the styles of the ranges given by @corner with the content of
 
2389
 * @list. Optionally transposing the ranges
2374
2390
 **/
2375
2391
GnmSpanCalcFlags
2376
2392
sheet_style_set_list (Sheet *sheet, GnmCellPos const *corner,
2733
2749
                            range_width (&rng), range_height (&rng),
2734
2750
                            tile_type_str[(*tile)->type],
2735
2751
                            tile_type_str[type]);
 
2752
 
2736
2753
        res = cell_tile_style_new (NULL, type);
2737
2754
        switch (type) {
2738
2755
        case TILE_SIMPLE:
2769
2786
 
2770
2787
        while (1) {
2771
2788
                GnmStyle const *mstyle = sheet_style_get (sheet, c, r);
2772
 
                if (res == NULL || mstyle != res->data) {
 
2789
                if (res == NULL ||  !gnm_style_equal (mstyle, res->data)) {
2773
2790
                        gnm_style_ref (mstyle);
2774
2791
                        res = g_slist_prepend (res, GINT_TO_POINTER (c));
2775
2792
                        res = g_slist_prepend (res, GINT_TO_POINTER (r));
2841
2858
 
2842
2859
        g_return_if_fail (IS_SHEET (sheet));
2843
2860
 
 
2861
        if (gnm_debug_flag ("no-style-optimize"))
 
2862
                return;
 
2863
 
2844
2864
        data.ss = gnm_sheet_get_size (sheet);
2845
2865
        data.debug = gnm_debug_flag ("style-optimize");
2846
2866