[libgsf] Fix writing of boolean values in ODF files. [#676604]



commit cc8c53e9870f7ae23089c8802cedd7c373022c63
Author: Andreas J Guelzow <aguelzow pyrshep ca>
Date:   Tue May 22 19:16:16 2012 -0600

    Fix writing of boolean values in ODF files. [#676604]
    
    2012-05-22  Andreas J. Guelzow <aguelzow pyrshep ca>
    
    	* gsf/gsf-opendoc-utils.c (gsf_xml_out_add_gvalue_for_odf): new
    	(meta_write_props_user_defined): use gsf_xml_out_add_gvalue_for_odf
    	(meta_write_props): use gsf_xml_out_add_gvalue_for_odf

 ChangeLog               |    6 ++++++
 NEWS                    |    1 +
 gsf/gsf-opendoc-utils.c |   17 +++++++++++++++--
 3 files changed, 22 insertions(+), 2 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index a2452ea..4983813 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2012-05-22  Andreas J. Guelzow <aguelzow pyrshep ca>
+
+	* gsf/gsf-opendoc-utils.c (gsf_xml_out_add_gvalue_for_odf): new
+	(meta_write_props_user_defined): use gsf_xml_out_add_gvalue_for_odf
+	(meta_write_props): use gsf_xml_out_add_gvalue_for_odf
+
 2012-05-21  Jean Brefort  <jean brefort normalesup org>
 
 	* configure.in: copied code from introspection.m4
diff --git a/NEWS b/NEWS
index fa14db1..a75b675 100644
--- a/NEWS
+++ b/NEWS
@@ -5,6 +5,7 @@ libgsf 1.14.23
 
 Andreas:
 	* Fix read/write of GSF_DOCPROP_VECTOR_TYPE meta data [Part of #672716]
+	* Fix writing of boolean values in ODF files. [#676604]
 
 Alan Knowles:
 	* Add gobject introspection support. [#610340]
diff --git a/gsf/gsf-opendoc-utils.c b/gsf/gsf-opendoc-utils.c
index f57ab9d..ceaa039 100644
--- a/gsf/gsf-opendoc-utils.c
+++ b/gsf/gsf-opendoc-utils.c
@@ -517,6 +517,19 @@ meta:object-count
 	GSF_META_NAME_OBJECT_COUNT:
 #endif
 
+/* ODF does not like "t" and "f" which we use normally */
+static void
+gsf_xml_out_add_gvalue_for_odf (GsfXMLOut *xout, char const *id, GValue const *val)
+{
+		if (G_VALUE_TYPE (val) == G_TYPE_BOOLEAN) 
+			gsf_xml_out_add_cstr 
+				(xout, id,
+				 g_value_get_boolean (val) ? "true" : "false");
+			else
+				gsf_xml_out_add_gvalue (xout, id, val);	
+}
+
+
 static void
 meta_write_props_user_defined (char const *prop_name, GValue const *val, GsfXMLOut *output)
 {
@@ -559,7 +572,7 @@ meta_write_props_user_defined (char const *prop_name, GValue const *val, GsfXMLO
 	if (NULL != type_name)
 		gsf_xml_out_add_cstr (output, "meta:value-type", type_name);
 	if (NULL != val)
-		gsf_xml_out_add_gvalue (output, NULL, val);
+		gsf_xml_out_add_gvalue_for_odf (output, NULL, val);
 	gsf_xml_out_end_element (output);
 }
 
@@ -621,7 +634,7 @@ meta_write_props (char const *prop_name, GsfDocProp *prop, GsfXMLOut *output)
 	/* Standardized  ODF meta items*/
 	gsf_xml_out_start_element (output, mapped_name);
 	if (NULL != val)
-		gsf_xml_out_add_gvalue (output, NULL, val);
+		gsf_xml_out_add_gvalue_for_odf (output, NULL, val);
 	gsf_xml_out_end_element (output);
 }
 



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