[gnumeric] Sheet style: code cleanup.
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] Sheet style: code cleanup.
- Date: Mon, 4 Feb 2013 03:58:13 +0000 (UTC)
commit 625da77ca80c04609d947476fc1659a78ec50272
Author: Morten Welinder <terra gnome org>
Date: Sat Feb 2 11:16:25 2013 -0500
Sheet style: code cleanup.
ChangeLog | 5 +++++
src/sheet-style.c | 42 ++++++++++++++++++++++++------------------
2 files changed, 29 insertions(+), 18 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index b915085..e9d9019 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2013-02-02 Morten Welinder <terra gnome org>
+
+ * src/sheet-style.c (rstyle_ctor): Split into rstyle_ctor_style
+ and rstyle_ctor_pstyle. All callers changed.
+
2013-01-18 Morten Welinder <terra gnome org>
* src/mathfunc.c (gnm_matrix_new, gnm_matrix_free)
diff --git a/src/sheet-style.c b/src/sheet-style.c
index 5d86656..990d6ee 100644
--- a/src/sheet-style.c
+++ b/src/sheet-style.c
@@ -237,26 +237,28 @@ pstyle_set_border (GnmStyle *st, GnmBorder *border,
* by caching and rereferencing the merged result for repeated styles.
*/
typedef struct {
- GnmStyle *new_style;
- GnmStyle *pstyle;
+ GnmStyle *new_style;
+ GnmStyle *pstyle;
GHashTable *cache;
Sheet *sheet;
} ReplacementStyle;
-static ReplacementStyle *
-rstyle_ctor (ReplacementStyle *res, GnmStyle *new_style, GnmStyle *pstyle, Sheet *sheet)
+static void
+rstyle_ctor_style (ReplacementStyle *res, GnmStyle *new_style, Sheet *sheet)
{
res->sheet = sheet;
- if (new_style != NULL) {
- res->new_style = sheet_style_find (sheet, new_style);
- res->pstyle = NULL;
- res->cache = NULL;
- } else {
- res->new_style = NULL;
- res->pstyle = pstyle;
- res->cache = g_hash_table_new (g_direct_hash, g_direct_equal);
- }
- return res;
+ res->new_style = sheet_style_find (sheet, new_style);
+ res->pstyle = NULL;
+ res->cache = NULL;
+}
+
+static void
+rstyle_ctor_pstyle (ReplacementStyle *res, GnmStyle *pstyle, Sheet *sheet)
+{
+ res->sheet = sheet;
+ res->new_style = NULL;
+ res->pstyle = pstyle;
+ res->cache = g_hash_table_new (g_direct_hash, g_direct_equal);
}
static void
@@ -1260,9 +1262,10 @@ sheet_style_set_range (Sheet *sheet, GnmRange const *range,
g_return_if_fail (IS_SHEET (sheet));
g_return_if_fail (range != NULL);
+ rstyle_ctor_style (&rs, style, sheet);
cell_tile_apply (&sheet->style_data->styles,
sheet->tile_top_level, 0, 0,
- range, rstyle_ctor (&rs, style, NULL, sheet));
+ range, &rs);
rstyle_dtor (&rs);
}
@@ -1324,9 +1327,10 @@ sheet_style_apply_pos (Sheet *sheet, int col, int row,
g_return_if_fail (IS_SHEET (sheet));
+ rstyle_ctor_pstyle (&rs, pstyle, sheet);
cell_tile_apply_pos (&sheet->style_data->styles,
sheet->tile_top_level, col, row,
- rstyle_ctor (&rs, NULL, pstyle, sheet));
+ &rs);
rstyle_dtor (&rs);
}
/**
@@ -1347,9 +1351,10 @@ sheet_style_set_pos (Sheet *sheet, int col, int row,
g_return_if_fail (IS_SHEET (sheet));
+ rstyle_ctor_style (&rs, style, sheet);
cell_tile_apply_pos (&sheet->style_data->styles,
sheet->tile_top_level, col, row,
- rstyle_ctor (&rs, style, NULL, sheet));
+ &rs);
rstyle_dtor (&rs);
}
@@ -1644,9 +1649,10 @@ sheet_style_apply_range (Sheet *sheet, GnmRange const *range, GnmStyle *pstyle)
g_return_if_fail (IS_SHEET (sheet));
g_return_if_fail (range != NULL);
+ rstyle_ctor_pstyle (&rs, pstyle, sheet);
cell_tile_apply (&sheet->style_data->styles,
sheet->tile_top_level, 0, 0,
- range, rstyle_ctor (&rs, NULL, pstyle, sheet));
+ range, &rs);
rstyle_dtor (&rs);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]