[gnumeric] ODF: import/export list linkage type



commit 5780f0aabb21ad60428fd95957282ced7aeac476
Author: Andreas J Guelzow <aguelzow pyrshep ca>
Date:   Mon Oct 4 23:27:39 2010 -0600

    ODF: import/export list linkage type
    
    2010-10-04  Andreas J. Guelzow <aguelzow pyrshep ca>
    
    	* openoffice-read.c (od_draw_control_start): use oc->as_index
    	(odf_form_control): read the list-linkage-type
    	* openoffice-write.c (odf_write_sheet_control_list): write
    	  the list-linkage-type

 plugins/openoffice/ChangeLog          |    7 +++++++
 plugins/openoffice/openoffice-read.c  |   24 ++++++++++++++++--------
 plugins/openoffice/openoffice-write.c |    8 +++++++-
 3 files changed, 30 insertions(+), 9 deletions(-)
---
diff --git a/plugins/openoffice/ChangeLog b/plugins/openoffice/ChangeLog
index 2e3c0e7..a7956f4 100644
--- a/plugins/openoffice/ChangeLog
+++ b/plugins/openoffice/ChangeLog
@@ -1,3 +1,10 @@
+2010-10-04  Andreas J. Guelzow <aguelzow pyrshep ca>
+
+	* openoffice-read.c (od_draw_control_start): use oc->as_index
+	(odf_form_control): read the list-linkage-type
+	* openoffice-write.c (odf_write_sheet_control_list): write
+	  the list-linkage-type
+
 2010-10-01  Morten Welinder <terra gnome org>
 
 	* Release 1.10.11
diff --git a/plugins/openoffice/openoffice-read.c b/plugins/openoffice/openoffice-read.c
index 6736e54..78497f8 100644
--- a/plugins/openoffice/openoffice-read.c
+++ b/plugins/openoffice/openoffice-read.c
@@ -191,6 +191,7 @@ typedef struct {
 	char *label;
 	char *implementation;
 	char *source_cell_range;
+	gboolean as_index;
 } OOControl;
 
 typedef struct {
@@ -4896,6 +4897,7 @@ od_draw_control_start (GsfXMLIn *xin, xmlChar const **attrs)
 				} 
 				if (result_texpr != NULL)
 					gnm_expr_top_unref (result_texpr);
+				sheet_widget_list_base_set_result_type (so, oc->as_index);
 			}
 		}
 	} else 
@@ -6509,10 +6511,17 @@ odf_form_control (GsfXMLIn *xin, xmlChar const **attrs, GType t)
 		{ "horizontal",	1},
 		{ NULL,	0 },
 	};
+	static OOEnum const list_linkages [] = {
+		{ "selection",	0},
+		{ "selection-indexes",	1},
+		{ "selection-indices",	1},
+		{ NULL,	0 },
+	};
 	int tmp;
 
 	state->cur_control = NULL;
 	oc->step = oc->page_step = 1;
+	oc->as_index = TRUE;
 
 	for (; attrs != NULL && attrs[0] && attrs[1] ; attrs += 2)
 		/* ODF does not declare an xml: namespace but uses this attribute */
@@ -6558,14 +6567,13 @@ odf_form_control (GsfXMLIn *xin, xmlChar const **attrs, GType t)
 					     OO_NS_FORM, "control-implementation")) {
 			g_free (oc->implementation);
 			oc->implementation =  g_strdup (CXML2C (attrs[1]));
-		} else if (gsf_xml_in_namecmp (xin, CXML2C (attrs[0]), 
-					       OO_NS_FORM, "list-linkage-type")) {
-			if (0 != strcmp (CXML2C (attrs[1]),"selection-indexes") &&
-			    0 != strcmp (CXML2C (attrs[1]),"selection-indices") ) 
-				oo_warning (xin, _("Attribute '%s' has "
-						   "the unsupported value '%s'."), 
-					    "form:list-linkage-type", CXML2C (attrs[1]));
-		} else if (gsf_xml_in_namecmp (xin, CXML2C (attrs[0]), 
+		} else if (oo_attr_enum (xin, attrs, OO_NS_FORM, "list-linkage-type", list_linkages, 
+					 &tmp))
+			oc->as_index = (tmp != 0);
+		else if (oo_attr_enum (xin, attrs, OO_GNUM_NS_EXT, "list-linkage-type", list_linkages, 
+				       &tmp))
+			oc->as_index = (tmp != 0);
+		else if (gsf_xml_in_namecmp (xin, CXML2C (attrs[0]), 
 					     OO_NS_FORM, "source-cell-range")) {
 			g_free (oc->source_cell_range);
 			oc->source_cell_range =  g_strdup (CXML2C (attrs[1]));
diff --git a/plugins/openoffice/openoffice-write.c b/plugins/openoffice/openoffice-write.c
index 9cb6570..76bed9c 100644
--- a/plugins/openoffice/openoffice-write.c
+++ b/plugins/openoffice/openoffice-write.c
@@ -3464,6 +3464,7 @@ odf_write_sheet_control_list (GnmOOExport *state, SheetObject *so,
 			      char const *element)
 {
 	GnmExprTop const *texpr = sheet_widget_list_base_get_result_link (so);
+	gboolean as_index = sheet_widget_list_base_result_type_is_index (so);
 
 	odf_sheet_control_start_element (state, so, element);
 
@@ -3475,7 +3476,12 @@ odf_write_sheet_control_list (GnmOOExport *state, SheetObject *so,
 	if (get_gsf_odf_version () > 101)
 		gsf_xml_out_add_cstr_unchecked 
 			(state->xml, FORM "list-linkage-type", 
-			 "selection-indexes");
+			 as_index ? "selection-indexes" : "selection");
+	else if (state->with_extension)
+		gsf_xml_out_add_cstr_unchecked 
+			(state->xml, GNMSTYLE "list-linkage-type", 
+			 as_index ? "selection-indices" : "selection");
+		
 	gsf_xml_out_add_int (state->xml, FORM "bound-column", 1);
 	gsf_xml_out_end_element (state->xml); /* form:checkbox */
 }



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