[gnumeric] xls: more records for widgets.



commit 733ce7149919c64780ed679fed8e265180745fbb
Author: Morten Welinder <terra gnome org>
Date:   Wed Oct 7 21:59:12 2009 -0400

    xls: more records for widgets.

 plugins/excel/ms-excel-read.c  |    2 ++
 plugins/excel/ms-excel-write.c |    9 +++++++--
 plugins/excel/ms-obj.c         |   33 +++++++++++++++++++++++++++++----
 plugins/excel/ms-obj.h         |    2 ++
 4 files changed, 40 insertions(+), 6 deletions(-)
---
diff --git a/plugins/excel/ms-excel-read.c b/plugins/excel/ms-excel-read.c
index b624d1d..c239099 100644
--- a/plugins/excel/ms-excel-read.c
+++ b/plugins/excel/ms-excel-read.c
@@ -634,6 +634,8 @@ ms_sheet_realize_obj (MSContainer *container, MSObj *obj)
 		break;
 
 	case 0x0C:
+		sheet_widget_radio_button_set_link (obj->gnum_obj,
+			ms_obj_attr_get_expr (obj->attrs, MS_OBJ_ATTR_LINKED_TO_CELL, NULL, FALSE));
 		break;
 
 	case 0x10:
diff --git a/plugins/excel/ms-excel-write.c b/plugins/excel/ms-excel-write.c
index 6fc6139..b092cb2 100644
--- a/plugins/excel/ms-excel-write.c
+++ b/plugins/excel/ms-excel-write.c
@@ -4391,8 +4391,13 @@ excel_write_textbox_v8 (ExcelWriteSheet *esheet, SheetObject *so)
 	if (IS_CELL_COMMENT (so))
 		ms_objv8_write_note (bp);
 
-	if (checkbox_texpr) {
-		ms_objv8_write_checkbox_fmla (bp, esheet, checkbox_texpr);
+	if (type == 11 || type == 12) {
+		ms_objv8_write_checkbox_link (bp);
+		if (type == 12)
+			ms_objv8_write_radiobutton (bp);
+		if (checkbox_texpr)
+			ms_objv8_write_checkbox_fmla (bp, esheet,
+						      checkbox_texpr);
 		ms_objv8_write_checkbox_data (bp, checkbox_active);
 	}
 
diff --git a/plugins/excel/ms-obj.c b/plugins/excel/ms-obj.c
index 0589ad2..a204042 100644
--- a/plugins/excel/ms-obj.c
+++ b/plugins/excel/ms-obj.c
@@ -1393,13 +1393,26 @@ ms_objv8_write_checkbox_data (BiffPut *bp, gboolean active)
 	GSF_LE_SET_GUINT16 (cboxdata, GR_CHECKBOX_DATA);
 	GSF_LE_SET_GUINT16 (cboxdata + 2, sizeof (cboxdata) - 4);
 	GSF_LE_SET_GUINT16 (cboxdata + 4, active);
-	GSF_LE_SET_GUINT16 (cboxdata + 6, 0);
-	GSF_LE_SET_GUINT16 (cboxdata + 8, 0);
-	GSF_LE_SET_GUINT16 (cboxdata + 10, 2);  /* ??? */
+	GSF_LE_SET_GUINT16 (cboxdata + 6, 0); /* accel */
+	GSF_LE_SET_GUINT16 (cboxdata + 8, 0); /* reserved */
+	GSF_LE_SET_GUINT16 (cboxdata + 10, 2);  /* 3d display.  */
 	ms_biff_put_var_write (bp, cboxdata, sizeof cboxdata);
 }
 
 void
+ms_objv8_write_checkbox_link (BiffPut *bp)
+{
+	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, 0); /* ? */
+	GSF_LE_SET_GUINT32 (data + 8, 0); /* ? */
+	GSF_LE_SET_GUINT32 (data + 12, 0); /* ? */
+	ms_biff_put_var_write (bp, data, sizeof data);
+}
+
+void
 ms_objv8_write_checkbox_fmla (BiffPut *bp,
 			      ExcelWriteSheet *esheet,
 			      GnmExprTop const *texpr)
@@ -1409,7 +1422,7 @@ ms_objv8_write_checkbox_fmla (BiffPut *bp,
 	guint16 fmla_len;
 
 	pos = bp->curpos;
-	GSF_LE_SET_GUINT16 (hfmla, 20);
+	GSF_LE_SET_GUINT16 (hfmla, GR_CHECKBOX_FORMULA);
 	GSF_LE_SET_GUINT16 (hfmla + 2, 0);  /* record len */
 	GSF_LE_SET_GUINT16 (hfmla + 4, 0);  /* formula len */
 	GSF_LE_SET_GUINT32 (hfmla + 6, 0);  /* calcid? */
@@ -1426,3 +1439,15 @@ ms_objv8_write_checkbox_fmla (BiffPut *bp,
 	ms_biff_put_var_write (bp, hfmla, sizeof hfmla);
 	ms_biff_put_var_seekto (bp, end_pos);
 }
+
+void
+ms_objv8_write_radiobutton (BiffPut *bp)
+{
+	char rb[10];
+
+	GSF_LE_SET_GUINT16 (rb, GR_RADIO_BUTTON);
+	GSF_LE_SET_GUINT16 (rb + 2, 6);  /* docs: must be 6 */
+	GSF_LE_SET_GUINT32 (rb + 4, 0);  /* ignore */
+	GSF_LE_SET_GUINT16 (rb + 8, 0);  /* ignore */
+	ms_biff_put_var_write (bp, rb, sizeof rb);
+}
diff --git a/plugins/excel/ms-obj.h b/plugins/excel/ms-obj.h
index e8fc93c..5253222 100644
--- a/plugins/excel/ms-obj.h
+++ b/plugins/excel/ms-obj.h
@@ -153,8 +153,10 @@ 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_fmla (BiffPut *bp,
 				   ExcelWriteSheet *esheet,
 				   GnmExprTop const *texpr);
+void ms_objv8_write_radiobutton (BiffPut *bp);
 
 #endif /* GNM_MS_OBJ_H */



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