[gnumeric] xls: fix export of check boxes and radio buttons so XL can read them.



commit 5f2a6ba15676c53cd26fc0ec1d055f55e94c5a86
Author: Morten Welinder <terra gnome org>
Date:   Mon Oct 12 11:00:52 2009 -0400

    xls: fix export of check boxes and radio buttons so XL can read them.

 NEWS                           |    1 +
 plugins/excel/ChangeLog        |   10 ++++++++++
 plugins/excel/ms-excel-write.c |    4 ++--
 plugins/excel/ms-obj.c         |   23 +++++++++++++++--------
 plugins/excel/ms-obj.h         |    2 +-
 5 files changed, 29 insertions(+), 11 deletions(-)
---
diff --git a/NEWS b/NEWS
index 7fd5785..aa2b500 100644
--- a/NEWS
+++ b/NEWS
@@ -8,6 +8,7 @@ Jody:
 
 Morten:
 	* Fix sheet-resize vs. merges issue.  [#582030]
+	* Fix xls export if check boxes and radio buttons.  [#597035]
 
 --------------------------------------------------------------------------
 Gnumeric 1.9.14
diff --git a/plugins/excel/ChangeLog b/plugins/excel/ChangeLog
index 25da5ea..901b7a4 100644
--- a/plugins/excel/ChangeLog
+++ b/plugins/excel/ChangeLog
@@ -1,3 +1,13 @@
+2009-10-12  Morten Welinder  <terra gnome org>
+
+	* ms-excel-write.c (excel_write_textbox_v8): Don't write macro
+	records yet.
+
+	* ms-obj.c (ms_objv8_write_checkbox_fmla,
+	ms_objv8_write_macro_fmla): Pad length; use NAME context.
+	(ms_objv8_write_checkbox_link): Take extra "active" argument.  All
+	callers changed.
+
 2009-10-11  Morten Welinder  <terra gnome org>
 
 	* ms-excel-write.c (excel_write_textbox_v8): Call
diff --git a/plugins/excel/ms-excel-write.c b/plugins/excel/ms-excel-write.c
index c026f48..d2fc23b 100644
--- a/plugins/excel/ms-excel-write.c
+++ b/plugins/excel/ms-excel-write.c
@@ -4406,13 +4406,13 @@ excel_write_textbox_v8 (ExcelWriteSheet *esheet, SheetObject *so)
 		ms_objv8_write_note (bp);
 
 	if (type == 11 || type == 12) {
-		ms_objv8_write_checkbox_link (bp);
+		ms_objv8_write_checkbox_link (bp, checkbox_active);
 		if (type == 12)
 			ms_objv8_write_radiobutton (bp);
 		if (checkbox_texpr)
 			ms_objv8_write_checkbox_fmla (bp, esheet,
 						      checkbox_texpr);
-		if (macro_nexpr) {
+		if (0 && macro_nexpr) {
 			GnmExprTop const *texpr =
 				gnm_expr_top_new
 				(gnm_expr_new_name (macro_nexpr,
diff --git a/plugins/excel/ms-obj.c b/plugins/excel/ms-obj.c
index 868b068..e3b8d8e 100644
--- a/plugins/excel/ms-obj.c
+++ b/plugins/excel/ms-obj.c
@@ -1402,15 +1402,18 @@ ms_objv8_write_checkbox_data (BiffPut *bp, gboolean active)
 }
 
 void
-ms_objv8_write_checkbox_link (BiffPut *bp)
+ms_objv8_write_checkbox_link (BiffPut *bp, gboolean active)
 {
 	char data[16];
 
 	GSF_LE_SET_GUINT16 (data, GR_CHECKBOX_LINK);
 	GSF_LE_SET_GUINT16 (data + 2, sizeof (data) - 4);
-	GSF_LE_SET_GUINT32 (data + 4, 1); /* ? */
-	GSF_LE_SET_GUINT32 (data + 8, 0); /* ? */
-	GSF_LE_SET_GUINT32 (data + 12, 0); /* ? */
+	GSF_LE_SET_GUINT16 (data + 4, active); /* ? */
+	GSF_LE_SET_GUINT16 (data + 6, 0x12b0); /* ? */
+	GSF_LE_SET_GUINT16 (data + 8, 0x01ce); /* ? */
+	GSF_LE_SET_GUINT16 (data + 10, 0);
+	GSF_LE_SET_GUINT16 (data + 12, 0);
+	GSF_LE_SET_GUINT16 (data + 14, 2); /* style? */
 	ms_biff_put_var_write (bp, data, sizeof data);
 }
 
@@ -1433,10 +1436,12 @@ ms_objv8_write_checkbox_fmla (BiffPut *bp,
 					texpr,
 					esheet->gnum_sheet, 0, 0,
 					/* eh?  */
-					EXCEL_CALLED_FROM_VALIDATION);
+					EXCEL_CALLED_FROM_NAME);
+	if (fmla_len & 1)
+		ms_biff_put_var_write (bp, "", 1);
 	end_pos = bp->curpos;
 	ms_biff_put_var_seekto (bp, pos);
-	GSF_LE_SET_GUINT16 (hfmla + 2, fmla_len + 6);
+	GSF_LE_SET_GUINT16 (hfmla + 2, (fmla_len + 7) & ~1);
 	GSF_LE_SET_GUINT16 (hfmla + 4, fmla_len);
 	ms_biff_put_var_write (bp, hfmla, sizeof hfmla);
 	ms_biff_put_var_seekto (bp, end_pos);
@@ -1461,10 +1466,12 @@ ms_objv8_write_macro_fmla (BiffPut *bp,
 					texpr,
 					esheet->gnum_sheet, 0, 0,
 					/* eh?  */
-					EXCEL_CALLED_FROM_VALIDATION);
+					EXCEL_CALLED_FROM_NAME);
+	if (fmla_len & 1)
+		ms_biff_put_var_write (bp, "", 1);
 	end_pos = bp->curpos;
 	ms_biff_put_var_seekto (bp, pos);
-	GSF_LE_SET_GUINT16 (hfmla + 2, fmla_len + 6);
+	GSF_LE_SET_GUINT16 (hfmla + 2, (fmla_len + 7) & ~1);
 	GSF_LE_SET_GUINT16 (hfmla + 4, fmla_len);
 	ms_biff_put_var_write (bp, hfmla, sizeof hfmla);
 	ms_biff_put_var_seekto (bp, end_pos);
diff --git a/plugins/excel/ms-obj.h b/plugins/excel/ms-obj.h
index ec25dd3..aef672b 100644
--- a/plugins/excel/ms-obj.h
+++ b/plugins/excel/ms-obj.h
@@ -154,7 +154,7 @@ void ms_objv8_write_listbox	(BiffPut *bp, gboolean filtered);
 void ms_objv8_write_note	(BiffPut *bp);
 
 void ms_objv8_write_checkbox_data (BiffPut *bp, gboolean active);
-void ms_objv8_write_checkbox_link (BiffPut *bp);
+void ms_objv8_write_checkbox_link (BiffPut *bp, gboolean active);
 void ms_objv8_write_checkbox_fmla (BiffPut *bp,
 				   ExcelWriteSheet *esheet,
 				   GnmExprTop const *texpr);



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