[gnumeric] ODF: import/export combo boxes



commit 26540cb7c87ca3cd99c599fbee1fc87bdef0266a
Author: Andreas J Guelzow <aguelzow pyrshep ca>
Date:   Fri Sep 10 19:58:12 2010 -0600

    ODF: import/export combo boxes
    
    2010-09-10  Andreas J. Guelzow <aguelzow pyrshep ca>
    
    	* openoffice-read.c (od_draw_control_start): handle combobox
    	(odf_form_combobox): new
    	(opendoc_content_dtd): connect odf_form_combobox
    	* openoffice-write.c (odf_sheet_control_start_element): new
    	(odf_write_sheet_control_*): use odf_sheet_control_start_element
    	(odf_write_sheet_controls): write combo boxes

 plugins/openoffice/ChangeLog          |    9 +++++++
 plugins/openoffice/openoffice-read.c  |   19 +++++++++++---
 plugins/openoffice/openoffice-write.c |   43 +++++++++++++++++++-------------
 3 files changed, 49 insertions(+), 22 deletions(-)
---
diff --git a/plugins/openoffice/ChangeLog b/plugins/openoffice/ChangeLog
index de88378..c4e8453 100644
--- a/plugins/openoffice/ChangeLog
+++ b/plugins/openoffice/ChangeLog
@@ -1,5 +1,14 @@
 2010-09-10  Andreas J. Guelzow <aguelzow pyrshep ca>
 
+	* openoffice-read.c (od_draw_control_start): handle combobox
+	(odf_form_combobox): new
+	(opendoc_content_dtd): connect odf_form_combobox
+	* openoffice-write.c (odf_sheet_control_start_element): new
+	(odf_write_sheet_control_*): use odf_sheet_control_start_element
+	(odf_write_sheet_controls): write combo boxes
+
+2010-09-10  Andreas J. Guelzow <aguelzow pyrshep ca>
+
 	* openoffice-read.c (od_draw_control_start): handle listboxes
 	(oo_control_free): free new source_cell_range field
 	(odf_form_control): handle new attributes
diff --git a/plugins/openoffice/openoffice-read.c b/plugins/openoffice/openoffice-read.c
index e67a0d1..02d7d9f 100644
--- a/plugins/openoffice/openoffice-read.c
+++ b/plugins/openoffice/openoffice-read.c
@@ -4743,7 +4743,8 @@ od_draw_control_start (GsfXMLIn *xin, xmlChar const **attrs)
 			} else if (oc->t == sheet_widget_checkbox_get_type ()) {
 				so = state->chart.so = g_object_new 
 					(oc->t, "text", oc->label, NULL);
-			} else if (oc->t == sheet_widget_list_get_type ()) {
+			} else if (oc->t == sheet_widget_list_get_type () ||
+				   oc->t == sheet_widget_combo_get_type ()) {
 				so = state->chart.so = g_object_new 
 					(oc->t, NULL);
 			}
@@ -4774,7 +4775,8 @@ od_draw_control_start (GsfXMLIn *xin, xmlChar const **attrs)
 						else if (oc->t == sheet_widget_radio_button_get_type ())
 							sheet_widget_radio_button_set_link
 								(so, texpr);
-						else if (oc->t == sheet_widget_list_get_type ()) {
+						else if (oc->t == sheet_widget_list_get_type () ||
+							 oc->t == sheet_widget_combo_get_type ()) {
 							gnm_expr_top_ref ((result_texpr = texpr));
 							sheet_widget_list_base_set_links (so, texpr, NULL);
 						}
@@ -4782,7 +4784,8 @@ od_draw_control_start (GsfXMLIn *xin, xmlChar const **attrs)
 					}
 				}
 			}
-			if (oc->t == sheet_widget_list_get_type ()) {
+			if (oc->t == sheet_widget_list_get_type () ||
+			    oc->t == sheet_widget_combo_get_type ()) {
 				if (oc->source_cell_range) {
 					GnmParsePos pp;
 					GnmRangeRef ref;
@@ -6262,6 +6265,12 @@ odf_form_listbox (GsfXMLIn *xin, xmlChar const **attrs)
 	odf_form_control (xin, attrs, sheet_widget_list_get_type ());
 }
 
+static void
+odf_form_combobox (GsfXMLIn *xin, xmlChar const **attrs)
+{
+	odf_form_control (xin, attrs, sheet_widget_combo_get_type ());
+}
+
 /****************************************************************************/
 /******************************** settings.xml ******************************/
 
@@ -6857,6 +6866,7 @@ static GsfXMLInNode const opendoc_content_dtd [] =
 	        GSF_XML_IN_NODE (FORMS, FORM, OO_NS_FORM, "form", GSF_XML_NO_CONTENT, NULL, NULL),
 	          GSF_XML_IN_NODE (FORM, FORM_PROPERTIES, OO_NS_FORM, "properties", GSF_XML_NO_CONTENT, NULL, NULL),
 	            GSF_XML_IN_NODE (FORM_PROPERTIES, FORM_PROPERTY, OO_NS_FORM, "property", GSF_XML_NO_CONTENT, NULL, NULL),
+	              GSF_XML_IN_NODE (FORM_PROPERTIES, FORM_LIST_PROPERTY, OO_NS_FORM, "list-property", GSF_XML_NO_CONTENT, NULL, NULL),
 	          GSF_XML_IN_NODE (FORM, FORM_BUTTON, OO_NS_FORM, "button", GSF_XML_NO_CONTENT, NULL, NULL),
 	            GSF_XML_IN_NODE (FORM_BUTTON, FORM_PROPERTIES, OO_NS_FORM, "properties", GSF_XML_NO_CONTENT, NULL, NULL),			/* 2nd Def */
 	            GSF_XML_IN_NODE (FORM_BUTTON, FORM_EVENT_LISTENERS, OO_NS_OFFICE, "event-listeners", GSF_XML_NO_CONTENT, NULL, NULL),
@@ -6869,7 +6879,8 @@ static GsfXMLInNode const opendoc_content_dtd [] =
 	            GSF_XML_IN_NODE (FORM_RADIO, FORM_PROPERTIES, OO_NS_FORM, "properties", GSF_XML_NO_CONTENT, NULL, NULL),			/* 2nd Def */
 	          GSF_XML_IN_NODE (FORM, FORM_LISTBOX, OO_NS_FORM, "listbox", GSF_XML_NO_CONTENT, &odf_form_listbox, NULL),
 	            GSF_XML_IN_NODE (FORM_LISTBOX, FORM_PROPERTIES, OO_NS_FORM, "properties", GSF_XML_NO_CONTENT, NULL, NULL),			/* 2nd Def */
-	              GSF_XML_IN_NODE (FORM_PROPERTIES, FORM_LIST_PROPERTY, OO_NS_FORM, "list-property", GSF_XML_NO_CONTENT, NULL, NULL),
+	          GSF_XML_IN_NODE (FORM, FORM_COMBOBOX, OO_NS_FORM, "combobox", GSF_XML_NO_CONTENT, &odf_form_combobox, NULL),
+	            GSF_XML_IN_NODE (FORM_COMBOBOX, FORM_PROPERTIES, OO_NS_FORM, "properties", GSF_XML_NO_CONTENT, NULL, NULL),			/* 2nd Def */
 	      GSF_XML_IN_NODE (TABLE, TABLE_ROWS, OO_NS_TABLE, "table-rows", GSF_XML_NO_CONTENT, NULL, NULL),
 	      GSF_XML_IN_NODE (TABLE, TABLE_COL, OO_NS_TABLE, "table-column", GSF_XML_NO_CONTENT, &oo_col_start, NULL),
 	      GSF_XML_IN_NODE (TABLE, TABLE_ROW, OO_NS_TABLE, "table-row", GSF_XML_NO_CONTENT, &oo_row_start, &oo_row_end),
diff --git a/plugins/openoffice/openoffice-write.c b/plugins/openoffice/openoffice-write.c
index dd3b663..da5bc6c 100644
--- a/plugins/openoffice/openoffice-write.c
+++ b/plugins/openoffice/openoffice-write.c
@@ -3126,16 +3126,25 @@ odf_write_sheet_control_linked_cell (GnmOOExport *state, GnmExprTop const *texpr
 }
 
 static void
+odf_sheet_control_start_element (GnmOOExport *state, SheetObject *so,
+				 char const *element)
+{
+	char const *id = odf_write_sheet_controls_get_id (state, so);
+	gsf_xml_out_start_element (state->xml, element);
+	gsf_xml_out_add_cstr (state->xml, XML "id", id);
+	gsf_xml_out_add_cstr (state->xml, FORM "id", id);
+	
+}
+
+static void
 odf_write_sheet_control_scrollbar (GnmOOExport *state, SheetObject *so, 
 				   char const *implementation)
 {
-	char const *id = odf_write_sheet_controls_get_id (state, so);
 	GtkAdjustment *adj = sheet_widget_adjustment_get_adjustment (so);
 	GnmExprTop const *texpr = sheet_widget_adjustment_get_link (so);
 
-	gsf_xml_out_start_element (state->xml, FORM "value-range");
-	gsf_xml_out_add_cstr (state->xml, XML "id", id);
-	gsf_xml_out_add_cstr (state->xml, FORM "id", id);
+	odf_sheet_control_start_element (state, so, FORM "value-range");
+
 	if (implementation != NULL)
 		gsf_xml_out_add_cstr (state->xml, 
 				      FORM "control-implementation", 
@@ -3167,15 +3176,13 @@ odf_write_sheet_control_scrollbar (GnmOOExport *state, SheetObject *so,
 static void
 odf_write_sheet_control_checkbox (GnmOOExport *state, SheetObject *so)
 {
-	char const *id = odf_write_sheet_controls_get_id (state, so);
 	GnmExprTop const *texpr = sheet_widget_checkbox_get_link (so);
 	char *label = NULL;
 
 	g_object_get (G_OBJECT (so), "text", &label, NULL);
 
-	gsf_xml_out_start_element (state->xml, FORM "checkbox");
-	gsf_xml_out_add_cstr (state->xml, XML "id", id);
-	gsf_xml_out_add_cstr (state->xml, FORM "id", id);
+	odf_sheet_control_start_element (state, so, FORM "checkbox");
+
 	gsf_xml_out_add_cstr (state->xml, FORM "label", label);
 
 	odf_write_sheet_control_linked_cell (state, texpr);
@@ -3187,14 +3194,12 @@ odf_write_sheet_control_checkbox (GnmOOExport *state, SheetObject *so)
 }
 
 static void
-odf_write_sheet_control_list (GnmOOExport *state, SheetObject *so)
+odf_write_sheet_control_list (GnmOOExport *state, SheetObject *so,
+			      char const *element)
 {
-	char const *id = odf_write_sheet_controls_get_id (state, so);
 	GnmExprTop const *texpr = sheet_widget_list_base_get_result_link (so);
 
-	gsf_xml_out_start_element (state->xml, FORM "listbox");
-	gsf_xml_out_add_cstr (state->xml, XML "id", id);
-	gsf_xml_out_add_cstr (state->xml, FORM "id", id);
+	odf_sheet_control_start_element (state, so, element);
 
 	odf_write_sheet_control_linked_cell (state, texpr);
 	gnm_expr_top_unref (texpr);
@@ -3214,16 +3219,14 @@ odf_write_sheet_control_list (GnmOOExport *state, SheetObject *so)
 static void
 odf_write_sheet_control_radio_button (GnmOOExport *state, SheetObject *so)
 {
-	char const *id = odf_write_sheet_controls_get_id (state, so);
 	GnmExprTop const *texpr = sheet_widget_radio_button_get_link (so);
 	char *label = NULL;
 	GnmValue *val = NULL;
 
 	g_object_get (G_OBJECT (so), "text", &label, "value", &val, NULL);
 
-	gsf_xml_out_start_element (state->xml, FORM "radio");
-	gsf_xml_out_add_cstr (state->xml, XML "id", id);
-	gsf_xml_out_add_cstr (state->xml, FORM "id", id);
+	odf_sheet_control_start_element (state, so, FORM "radio");
+
 	gsf_xml_out_add_cstr (state->xml, FORM "label", label);
 
 	if (val != NULL) {
@@ -3308,7 +3311,11 @@ odf_write_sheet_controls (GnmOOExport *state)
 		else if (GNM_IS_SOW_RADIO_BUTTON (so))
 			odf_write_sheet_control_radio_button (state, so);
 		else if (GNM_IS_SOW_LIST (so))
-			odf_write_sheet_control_list (state, so);
+			odf_write_sheet_control_list (state, so, 
+						      FORM "listbox");
+		else if (GNM_IS_SOW_COMBO (so))
+			odf_write_sheet_control_list (state, so,
+						      FORM "combobox");
 	}
 
 	gsf_xml_out_end_element (state->xml); /* form:form */



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