[gnumeric] xls: cleanups.



commit 4e0b180283d66b1de25ba3ea9c7062b57d000f8b
Author: Morten Welinder <terra gnome org>
Date:   Thu Oct 8 16:05:28 2009 -0400

    xls: cleanups.

 plugins/excel/ms-escher.c      |   32 +++++++++++++++++---------------
 plugins/excel/ms-escher.h      |    5 ++++-
 plugins/excel/ms-excel-write.c |   15 +++++++--------
 3 files changed, 28 insertions(+), 24 deletions(-)
---
diff --git a/plugins/excel/ms-escher.c b/plugins/excel/ms-escher.c
index fe70b9b..15b5abf 100644
--- a/plugins/excel/ms-escher.c
+++ b/plugins/excel/ms-escher.c
@@ -1267,24 +1267,26 @@ ms_escher_read_OPT_bools (MSEscherHeader *h,
 	g_return_if_fail (n_bools > 0);
 	g_return_if_fail (bools[n_bools-1].pid == pid);
 
-	d (2, printf ("Set of Bools %s(%d) = 0x%08x;\n{\n",
-		      bools[n_bools-1].name, bools[n_bools-1].pid, val););
+	d (2, printf ("Set of Bools %d-%d = 0x%08x;\n{\n",
+		      bools[0].pid, bools[n_bools-1].pid, val););
 
 	for (; i-- > 0 ; mask <<= 1, bit <<= 1) {
+		gboolean set_val = ((val & bit) == bit);
+		gboolean def_val = bools[i].default_val;
+		const MSObjAttrID aid = bools[i].id;
+
 		if (!(val & mask))	/* the value is set */
 			continue;
-		/* If the value is not the default */
-		if ((((val & bit) == bit) ^ bools[i].default_val)) {
-			d (0, printf ("bool %s = %s; /* gnm attr id = %d */\n",
-				      bools[i].name,
-				      /* only exported if they != default_val */
-				      bools[i].default_val ? "false" : "true",
-				      bools[i].id););
-
-			if (bools[i].id != 0)
-			ms_escher_header_add_attr (h,
-				ms_obj_attr_new_flag (bools[i].id));
-		}
+
+		d (0, printf ("bool %s = %s; /* def: %s; gnm: %d */\n",
+			      bools[i].name,
+			      set_val ? "true" : "false",
+			      def_val ? "true" : "false",
+			      aid););
+
+		if (set_val != def_val && aid != 0)
+			ms_escher_header_add_attr
+				(h, ms_obj_attr_new_flag (aid));
 	}
 	d (2, printf ("};\n"););
 }
@@ -1349,7 +1351,7 @@ ms_escher_read_OPT (MSEscherState *state, MSEscherHeader *h)
 		/* 1/20" :  */
 		case 132 : name = "long dyTextBottom"; break;
 		/* Square */
-		case 133 : name = "WrapMode wrap_test_at_margin"; break;
+		case 133 : name = "WrapMode wrap_text_at_margin"; break;
 		/* 0 : Text zoom/scale (used if fFitTextToShape) */
 		case 134 : name = "long scaleText"; break;
 		/* anchor_Top : How to anchor the text */
diff --git a/plugins/excel/ms-escher.h b/plugins/excel/ms-escher.h
index 7ff8345..fbe934e 100644
--- a/plugins/excel/ms-escher.h
+++ b/plugins/excel/ms-escher.h
@@ -18,7 +18,10 @@
 #include <sheet-object.h>
 
 enum {
-	MESP_AUTOTEXTMARGIN      = 0x00bc,
+	MSEP_TXID                = 0x0080,
+	MSEP_WRAPTEXT            = 0x0085,
+	MSEP_SELECTTEXT          = 0x00bb,
+	MSEP_AUTOTEXTMARGIN      = 0x00bc,
 	MSEP_SHAPEPATH           = 0x0144,
 	MSEP_FILLOK              = 0x017f,
 	MSEP_FILLCOLOR           = 0x0181,
diff --git a/plugins/excel/ms-excel-write.c b/plugins/excel/ms-excel-write.c
index b03d8cf..7457a91 100644
--- a/plugins/excel/ms-excel-write.c
+++ b/plugins/excel/ms-excel-write.c
@@ -4339,11 +4339,12 @@ excel_write_textbox_v8 (ExcelWriteSheet *esheet, SheetObject *so)
 	optmark = ms_escher_opt_start (escher);
 	extra = g_string_new (NULL);
 	ms_escher_opt_add_simple (escher, optmark,
-				  0x0080, 0x00c600a0); /* Txid */
+				  MSEP_TXID, 0x00c600a0); /* Txid */
 	ms_escher_opt_add_simple (escher, optmark,
-				  0x0085, 1); /* wrap_text_at_margin */
-	ms_escher_opt_add_simple (escher, optmark,
-				  0x00bf, 0x000a0008); /* wrap_text_at_margin */
+				  MSEP_WRAPTEXT, 1); /* wrap_text_at_margin */
+	ms_escher_opt_add_bool (escher, optmark, MSEP_SELECTTEXT, TRUE);
+	if (is_button)
+		ms_escher_opt_add_bool (escher, optmark, MSEP_AUTOTEXTMARGIN, FALSE);
 	ms_escher_opt_add_color (escher, optmark, MSEP_FILLCOLOR,
 				 style == NULL || style->fill.auto_back
 				 ? GO_COLOR_WHITE
@@ -4361,9 +4362,7 @@ excel_write_textbox_v8 (ExcelWriteSheet *esheet, SheetObject *so)
 	if (name)
 		ms_escher_opt_add_str_wchar (escher, optmark, extra,
 					     MSEP_NAME, name);
-	ms_escher_opt_add_simple (escher, optmark,
-				  0x03bf,
-				  is_button ? 0x00080008 : 0x00080000);
+	ms_escher_opt_add_bool (escher, optmark, MSEP_ISBUTTON, TRUE);
 	go_string_append_gstring (escher, extra);
 	ms_escher_opt_end (escher, optmark);
 	g_string_free (extra, TRUE);
@@ -4450,7 +4449,7 @@ excel_write_line_v8 (ExcelWriteSheet *esheet, SheetObject *so)
 
 	optmark = ms_escher_opt_start (escher);
 	extra = g_string_new (NULL);
-	ms_escher_opt_add_bool (escher, optmark, MESP_AUTOTEXTMARGIN, TRUE);
+	ms_escher_opt_add_bool (escher, optmark, MSEP_AUTOTEXTMARGIN, TRUE);
 	ms_escher_opt_add_simple (escher, optmark, MSEP_SHAPEPATH, 4);
 	ms_escher_opt_add_bool (escher, optmark, MSEP_FILLOK, FALSE);
 	ms_escher_opt_add_bool (escher, optmark, MSEP_NOFILLHITTEST, TRUE);



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