[gnumeric] Styles: don't look at unset style elements' values.



commit 0151bacaf9f377f1dbffa3e0148c13e6b09a8b3b
Author: Morten Welinder <terra gnome org>
Date:   Fri May 11 13:35:02 2012 -0400

    Styles: don't look at unset style elements' values.

 ChangeLog    |    3 +++
 src/mstyle.c |   10 +++++++---
 2 files changed, 10 insertions(+), 3 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 6f148b6..d168d37 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -16,6 +16,9 @@
 	* src/mstyle.c (gnm_style_update): Make hashing half-way decent.
 	Avoid clash between two styles where one is bold and the other is
 	italic.
+	(gnm_style_equal, gnm_style_equal_XL): Only compare style elements
+	that are set.  However, if there are a difference in whether an
+	element is set, the styles are different.
 
 2012-05-10  Morten Welinder  <terra gnome org>
 
diff --git a/src/mstyle.c b/src/mstyle.c
index 92f8342..05c0051 100644
--- a/src/mstyle.c
+++ b/src/mstyle.c
@@ -850,10 +850,10 @@ gnm_style_equal (GnmStyle const *a, GnmStyle const *b)
 
 	if (a == b)
 		return TRUE;
-	if (!gnm_style_equal_XL (a, b))
+	if (a->set != b->set || !gnm_style_equal_XL (a, b))
 		return FALSE;
 	UNROLLED_FOR (i = MSTYLE_VALIDATION, i < MSTYLE_ELEMENT_MAX, i++, {
-		if (!ELEM_IS_EQ (a, b, i))
+		if (elem_is_set (a, i) && !ELEM_IS_EQ (a, b, i))
 			return FALSE;
 	});
 
@@ -870,8 +870,12 @@ gnm_style_equal_XL (GnmStyle const *a, GnmStyle const *b)
 
 	if (a == b)
 		return TRUE;
+
+	if ((a->set ^ b->set) & ((1u << MSTYLE_VALIDATION) - 1))
+		return FALSE;
+
 	UNROLLED_FOR (i = MSTYLE_COLOR_BACK, i < MSTYLE_VALIDATION, i++, {
-		if (!ELEM_IS_EQ (a, b, i))
+		if (elem_is_set (a, i) && !ELEM_IS_EQ (a, b, i))
 			return FALSE;
 	});
 	return TRUE;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]