[gnumeric] xls: export scroll bars.



commit 69101db2dca21625c95a1758c0467a5c3bdad90f
Author: Morten Welinder <terra gnome org>
Date:   Tue Oct 13 11:32:31 2009 -0400

    xls: export scroll bars.

 NEWS                           |    5 +++--
 plugins/excel/ms-excel-write.c |   31 +++++++++++++++++++++++++------
 plugins/excel/ms-obj.c         |   26 ++++++++++++++++++++++++--
 plugins/excel/ms-obj.h         |    7 ++++++-
 4 files changed, 58 insertions(+), 11 deletions(-)
---
diff --git a/NEWS b/NEWS
index 6c7b8f1..51cc611 100644
--- a/NEWS
+++ b/NEWS
@@ -9,8 +9,9 @@ Jody:
 
 Morten:
 	* Fix sheet-resize vs. merges issue.  [#582030]
-	* Fix xls export of check boxes and radio buttons.  [#597035]
-	* Add xls export of spin buttons.  [#597035]
+	* Fix xls export of check boxes and radio buttons.  [Part of #597035]
+	* Add xls export of spin buttons.  [Part of #597035]
+	* Add xls export of scroll bars.  [Part of #597035]
 
 --------------------------------------------------------------------------
 Gnumeric 1.9.14
diff --git a/plugins/excel/ms-excel-write.c b/plugins/excel/ms-excel-write.c
index 594b1ec..841abb2 100644
--- a/plugins/excel/ms-excel-write.c
+++ b/plugins/excel/ms-excel-write.c
@@ -3969,7 +3969,7 @@ excel_write_autofilter_objs (ExcelWriteSheet *esheet)
 			 * this. not the user*/
 			ms_objv8_write_common (bp,
 				esheet->cur_obj, 0x14, 0x2101);
-			ms_objv8_write_scrollbar (bp);
+			ms_objv8_write_scrollbar_old (bp);
 			ms_objv8_write_listbox (bp, cond != NULL); /* acts as an end */
 		} else {
 			data = ms_biff_put_len_next (bp, BIFF_OBJ, sizeof std_obj_v7);
@@ -4270,7 +4270,7 @@ excel_write_textbox_or_widget_v8 (ExcelWriteSheet *esheet,
 	char *name, *label;
 	GOStyle *style = NULL;
 	gboolean checkbox_active = FALSE;
-	GnmNamedExpr *macro_nexpr = NULL;
+	GnmNamedExpr *macro_nexpr;
 	guint8 zero[4] = { 0, 0, 0, 0 };
 
 	if (has_text_prop) {
@@ -4284,6 +4284,10 @@ excel_write_textbox_or_widget_v8 (ExcelWriteSheet *esheet,
 	}
 	do_textbox = (label != NULL && label[0] != 0);
 
+	macro_nexpr = is_widget
+		? g_hash_table_lookup (esheet->widget_macroname, so)
+		: NULL;
+
 	if (IS_CELL_COMMENT (so)) {
 		static float const offset [4] = { .5, .5, .5, .5 };
 		GnmRange r;
@@ -4323,18 +4327,19 @@ excel_write_textbox_or_widget_v8 (ExcelWriteSheet *esheet,
 		type = 0x0b;
 		flags = 0x0011;
 		g_object_get (so, "active", &checkbox_active, NULL);
-		macro_nexpr = g_hash_table_lookup (esheet->widget_macroname, so);
 	} else if (GNM_IS_SOW_RADIO_BUTTON (so)) {
 		shape = 0xc9;
 		type = 0x0c;
 		flags = 0x0011;
 		g_object_get (so, "active", &checkbox_active, NULL);
-		macro_nexpr = g_hash_table_lookup (esheet->widget_macroname, so);
 	} else if (GNM_IS_SOW_SPINBUTTON (so)) {
 		shape = 0xc9;
 		type = 0x10;
 		flags = 0x0011;
-		macro_nexpr = g_hash_table_lookup (esheet->widget_macroname, so);
+	} else if (GNM_IS_SOW_SCROLLBAR (so)) {
+		shape = 0xc9;
+		type = 0x11;
+		flags = 0x6011;
 	} else {
 		g_assert_not_reached ();
 		return 0;
@@ -4444,6 +4449,19 @@ excel_write_textbox_or_widget_v8 (ExcelWriteSheet *esheet,
 		if (link) gnm_expr_top_unref (link);
 		break;
 	}
+	case 0x11: {
+		GnmExprTop const *link = sheet_widget_adjustment_get_link (so);
+		GtkAdjustment *adj =
+			sheet_widget_adjustment_get_adjustment (so);
+		gboolean horiz = sheet_widget_adjustment_get_horizontal (so);
+		ms_objv8_write_scrollbar (bp,
+					  esheet,
+					  adj, horiz,
+					  link,
+					  macro_nexpr);
+		if (link) gnm_expr_top_unref (link);
+		break;
+	}
 	case 0x19:
 		/* Cell comment. */
 		ms_objv8_write_note (bp);
@@ -5387,7 +5405,8 @@ excel_sheet_new (ExcelWriteState *ewb, Sheet *sheet,
 			handled = TRUE;
 		} else if (GNM_IS_SOW_CHECKBOX (so) ||
 			   GNM_IS_SOW_RADIO_BUTTON (so) ||
-			   GNM_IS_SOW_SPINBUTTON (so)) {
+			   GNM_IS_SOW_SPINBUTTON (so) ||
+			   GNM_IS_SOW_SCROLLBAR (so)) {
 			esheet->widgets =
 				g_slist_prepend (esheet->widgets, so);
 			g_hash_table_insert (esheet->widget_macroname,
diff --git a/plugins/excel/ms-obj.c b/plugins/excel/ms-obj.c
index 9f2efac..57a8bf9 100644
--- a/plugins/excel/ms-obj.c
+++ b/plugins/excel/ms-obj.c
@@ -1332,7 +1332,7 @@ ms_objv8_write_common (BiffPut *bp, int id, int type, guint16 flags)
 }
 
 void
-ms_objv8_write_scrollbar (BiffPut *bp)
+ms_objv8_write_scrollbar_old (BiffPut *bp)
 {
 	/* no docs, but some guesses.  See above */
 	static guint8 const data[] = {
@@ -1564,7 +1564,7 @@ ms_objv8_write_adjustment (BiffPut *bp,
 	GSF_LE_SET_GINT16  (data + 16, SQUEEZE (adj->page_increment));
 #undef SQUEEZE
 	GSF_LE_SET_GINT16  (data + 18, !!horiz);
-	GSF_LE_SET_GINT16  (data + 20, 42);  /* widget in pixels */
+	GSF_LE_SET_GINT16  (data + 20, 15);  /* widget in pixels */
 	GSF_LE_SET_GINT16  (data + 22, 0x0001);  /* draw */
 
 	ms_biff_put_var_write (bp, data, sizeof data);
@@ -1591,3 +1591,25 @@ ms_objv8_write_spinbutton (BiffPut *bp,
 		gnm_expr_top_unref (texpr);
 	}
 }
+
+void
+ms_objv8_write_scrollbar (BiffPut *bp,
+			  ExcelWriteSheet *esheet,
+			  GtkAdjustment *adj, gboolean horiz,
+			  GnmExprTop const *link_texpr,
+			  GnmNamedExpr *macro_nexpr)
+{
+	ms_objv8_write_adjustment (bp, adj, horiz);
+	if (link_texpr)
+		ms_objv8_write_link_fmla (bp, GR_SCROLLBAR_FORMULA,
+					  esheet, link_texpr);
+	if (0 && macro_nexpr) {
+		GnmExprTop const *texpr =
+			gnm_expr_top_new
+			(gnm_expr_new_name (macro_nexpr,
+					    esheet->gnum_sheet,
+					    NULL));
+		ms_objv8_write_macro_fmla (bp, esheet, texpr);
+		gnm_expr_top_unref (texpr);
+	}
+}
diff --git a/plugins/excel/ms-obj.h b/plugins/excel/ms-obj.h
index 42d22c4..a55a15e 100644
--- a/plugins/excel/ms-obj.h
+++ b/plugins/excel/ms-obj.h
@@ -149,7 +149,7 @@ char  *ms_read_TXO   (BiffQuery *q, MSContainer *c, PangoAttrList **markup);
 /********************************************************/
 
 void ms_objv8_write_common	(BiffPut *bp, int id, int type, guint16 flags);
-void ms_objv8_write_scrollbar	(BiffPut *bp);
+void ms_objv8_write_scrollbar_old (BiffPut *bp);
 void ms_objv8_write_listbox	(BiffPut *bp, gboolean filtered);
 
 void ms_objv8_write_note	(BiffPut *bp);
@@ -169,6 +169,11 @@ void ms_objv8_write_spinbutton (BiffPut *bp,
 				GtkAdjustment *adj, gboolean horiz,
 				GnmExprTop const *link_texpr,
 				GnmNamedExpr *macro_nexpr);
+void ms_objv8_write_scrollbar (BiffPut *bp,
+			       ExcelWriteSheet *esheet,
+			       GtkAdjustment *adj, gboolean horiz,
+			       GnmExprTop const *link_texpr,
+			       GnmNamedExpr *macro_nexpr);
 
 
 #endif /* GNM_MS_OBJ_H */



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