[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: Wed, 6 Feb 2013 14:10:09 +0000 (UTC)
commit aee0ab1ee7055053783f34806139505d06a77aa8
Author: Morten Welinder <terra gnome org>
Date: Wed Feb 6 09:09:54 2013 -0500
Sheet Style: code cleanup.
ChangeLog | 7 +++++++
src/sheet-style.c | 49 ++++++++++++++++++++++---------------------------
2 files changed, 29 insertions(+), 27 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 11e05dc..22afdeb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2013-02-06 Morten Welinder <terra gnome org>
+
+ * src/sheet-style.c (tile_is_uniform): Extract from
+ cell_tile_optimize.
+ (vector_apply_pstyle): Don't return a value.
+ (cell_tile_apply): Use tile_is_uniform.
+
2013-02-05 Morten Welinder <terra gnome org>
* src/sheet-style.c (sheet_style_get): Simplify with "while"
diff --git a/src/sheet-style.c b/src/sheet-style.c
index 43fc8b1..af9459c 100644
--- a/src/sheet-style.c
+++ b/src/sheet-style.c
@@ -879,19 +879,26 @@ sheet_style_update_grid_color (Sheet const *sheet)
/****************************************************************************/
-static GnmStyle *
-vector_apply_pstyle (GnmStyle **styles, int n, ReplacementStyle *rs)
+static gboolean
+tile_is_uniform (CellTile const *tile)
{
- gboolean is_uniform = TRUE;
+ const int s = tile_size[tile->type];
+ GnmStyle const *st = tile->style_any.style[0];
int i;
- for (i = 0; i < n; i++) {
- rstyle_apply (styles + i, rs);
- if (styles[i] != styles[0])
- is_uniform = FALSE;
- }
+ for (i = 1; i < s; i++)
+ if (tile->style_any.style[i] != st)
+ return FALSE;
- return is_uniform ? styles[0] : NULL;
+ return TRUE;
+}
+
+static void
+vector_apply_pstyle (GnmStyle **styles, int n, ReplacementStyle *rs)
+{
+ int i;
+ for (i = 0; i < n; i++)
+ rstyle_apply (styles + i, rs);
}
static gboolean
@@ -974,10 +981,11 @@ cell_tile_apply (CellTile **tile, int level,
/* Apply new style over top of the entire tile */
if (full_width && full_height) {
if (TILE_SIMPLE <= type && type <= TILE_MATRIX) {
- GnmStyle *uniform = vector_apply_pstyle (
+ vector_apply_pstyle (
(*tile)->style_any.style, tile_size[type], rs);
- if (uniform && type != TILE_SIMPLE) {
- res = cell_tile_style_new (uniform, TILE_SIMPLE);
+ if (type != TILE_SIMPLE && tile_is_uniform (*tile)) {
+ res = cell_tile_style_new ((*tile)->style_any.style[0],
+ TILE_SIMPLE);
cell_tile_dtor (*tile);
*tile = res;
}
@@ -3052,25 +3060,12 @@ cell_tile_optimize (CellTile **tile, int level, CellTileOptimize *data,
switch (type) {
case TILE_COL:
- case TILE_ROW: {
- int s = tile_size[type];
- int i;
- gboolean same = TRUE;
-
- for (i = 1; i < s; i++) {
- if (!gnm_style_eq ((*tile)->style_any.style[0],
- (*tile)->style_any.style[i])) {
- same = FALSE;
- break;
- }
- }
-
- if (!same)
+ case TILE_ROW:
+ if (!tile_is_uniform (*tile))
return;
type = TILE_SIMPLE;
break;
- }
case TILE_MATRIX: {
gboolean csame = TRUE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]