[gnumeric] more keyword handling fixes



commit a6ae6df4f4a534ae36bf1fd1221b30e2d2e65b03
Author: Andreas J Guelzow <aguelzow pyrshep ca>
Date:   Mon Jun 27 22:26:41 2011 -0600

    more keyword handling fixes
    
    2011-06-27  Andreas J. Guelzow <aguelzow pyrshep ca>
    
    	* xlsx-write-docprops.c (xlsx_map_to_keys): new
    	(xlsx_map_prop_name_to_output_fun): connect xlsx_map_to_keys
    	(xlsx_meta_write_props): depend on xlsx_map_prop_name_to_output_fun
    	even for keywords
    
    2011-06-27  Andreas J. Guelzow <aguelzow pyrshep ca>
    
    	* dialog-doc-metadata.c (dialog_doc_metadata_get_gsf_prop_val_type):
    	GSF_META_NAME_KEYWORDS is of GSF_DOCPROP_VECTOR_TYPE

 plugins/excel/ChangeLog             |    7 ++++
 plugins/excel/xlsx-write-docprops.c |   56 ++++++++++++++++------------------
 src/dialogs/ChangeLog               |    5 +++
 src/dialogs/dialog-doc-metadata.c   |    5 ++-
 4 files changed, 42 insertions(+), 31 deletions(-)
---
diff --git a/plugins/excel/ChangeLog b/plugins/excel/ChangeLog
index 4589d91..c275a3b 100644
--- a/plugins/excel/ChangeLog
+++ b/plugins/excel/ChangeLog
@@ -1,3 +1,10 @@
+2011-06-27  Andreas J. Guelzow <aguelzow pyrshep ca>
+
+	* xlsx-write-docprops.c (xlsx_map_to_keys): new
+	(xlsx_map_prop_name_to_output_fun): connect xlsx_map_to_keys
+	(xlsx_meta_write_props): depend on xlsx_map_prop_name_to_output_fun
+	even for keywords
+	
 2011-06-26  Andreas J. Guelzow <aguelzow pyrshep ca>
 
 	* xlsx-utils.h (XL_NS_PROP_CUSTOM): new
diff --git a/plugins/excel/xlsx-write-docprops.c b/plugins/excel/xlsx-write-docprops.c
index 383b977..5c919c7 100644
--- a/plugins/excel/xlsx-write-docprops.c
+++ b/plugins/excel/xlsx-write-docprops.c
@@ -112,6 +112,31 @@ xlsx_map_to_date_core (GsfXMLOut *output, GValue const *val)
 	}	
 }
 
+static void
+xlsx_map_to_keys (GsfXMLOut *output, GValue const *val)
+{
+		GValueArray *va;
+		unsigned i;
+
+		if (G_TYPE_STRING == G_VALUE_TYPE (val)) {
+			char const *str = g_value_get_string (val);
+			if (str && *str)
+				gsf_xml_out_add_cstr (output, NULL, str);
+		} else if (NULL != (va = gsf_value_get_docprop_varray (val))) {
+			char *str;
+			for (i = 0 ; i < va->n_values; i++) {
+				if (i!=0)
+					gsf_xml_out_add_cstr_unchecked (output, NULL, " ");
+				str = g_value_dup_string (g_value_array_get_nth	(va, i));
+				g_strdelimit (str," \t\n\r",'_');
+				gsf_xml_out_add_cstr (output, NULL, str);
+				/* In Edition 2 we would be allowed to have different */
+				/* sets of keywords depending on laguage */
+				g_free (str);
+			}
+		}	
+}
+
 static output_function
 xlsx_map_prop_name_to_output_fun (char const *name)
 {
@@ -127,6 +152,7 @@ xlsx_map_prop_name_to_output_fun (char const *name)
 			{ GSF_META_NAME_DATE_CREATED,       xlsx_map_to_date_core},
 			{ GSF_META_NAME_DATE_MODIFIED,      xlsx_map_to_date_core},
 			{ GSF_META_NAME_EDITING_DURATION,   xlsx_map_time_to_int},
+			{ GSF_META_NAME_KEYWORDS,           xlsx_map_to_keys},
 			{ GSF_META_NAME_CHARACTER_COUNT,    xlsx_map_to_int},
 			{ GSF_META_NAME_BYTE_COUNT,         xlsx_map_to_int},
 			{ GSF_META_NAME_SECURITY,           xlsx_map_to_int},
@@ -329,36 +355,6 @@ xlsx_meta_write_props (char const *prop_name, GsfDocProp *prop, GsfXMLOut *outpu
 	char const *mapped_name;
 	GValue const *val = gsf_doc_prop_get_val (prop);
 
-	/* Handle specially */
-	if (0 == strcmp (prop_name, GSF_META_NAME_KEYWORDS)) {
-		GValueArray *va;
-		unsigned i;
-		char *str;
-
-		if (G_TYPE_STRING == G_VALUE_TYPE (val)) {
-			str = g_value_dup_string (val);
-			if (str && *str) {
-				gsf_xml_out_start_element (output, "cp:keywords");
-				gsf_xml_out_add_cstr (output, NULL, str);
-				gsf_xml_out_end_element (output);
-			}
-			g_free (str);
-		} else if (NULL != (va = gsf_value_get_docprop_varray (val))) {
-			gsf_xml_out_start_element (output, "cp:keywords");
-			for (i = 0 ; i < va->n_values; i++) {
-				if (i!=0)
-					gsf_xml_out_add_cstr_unchecked (output, NULL, " ");
-				str = g_value_dup_string (g_value_array_get_nth	(va, i));
-				gsf_xml_out_add_cstr (output, NULL, str);
-				/* In Edition 2 we would be allowed to have different */
-				/* sets of keywords depending on laguage */
-				g_free (str);
-			}
-			gsf_xml_out_end_element (output);
-		}
-		return;
-	}
-
 	if (NULL != (mapped_name = xlsx_map_prop_name (prop_name))) {
 		gsf_xml_out_start_element (output, mapped_name);		
 		if (NULL != val) {
diff --git a/src/dialogs/ChangeLog b/src/dialogs/ChangeLog
index c9382e6..0344270 100644
--- a/src/dialogs/ChangeLog
+++ b/src/dialogs/ChangeLog
@@ -1,5 +1,10 @@
 2011-06-27  Andreas J. Guelzow <aguelzow pyrshep ca>
 
+	* dialog-doc-metadata.c (dialog_doc_metadata_get_gsf_prop_val_type):
+	GSF_META_NAME_KEYWORDS is of GSF_DOCPROP_VECTOR_TYPE
+	
+2011-06-27  Andreas J. Guelzow <aguelzow pyrshep ca>
+
 	* doc-meta-data.ui: add a keyword tab, remove keywords from
 	description tab
 	* dialog-doc-metadata.c (dialog_doc_metadata_transform_str_to_docprop_vect):
diff --git a/src/dialogs/dialog-doc-metadata.c b/src/dialogs/dialog-doc-metadata.c
index 3aaf79e..d4fff66 100644
--- a/src/dialogs/dialog-doc-metadata.c
+++ b/src/dialogs/dialog-doc-metadata.c
@@ -600,8 +600,11 @@ dialog_doc_metadata_get_gsf_prop_val_type (DialogDocMetaData *state,
 		}
 	}
 	else {
+		if (0 == strcmp (name, GSF_META_NAME_KEYWORDS))
+			val_type = GSF_DOCPROP_VECTOR_TYPE;
+		else
 		/* FIXME: At this moment, we will assume a G_TYPE_STRING */
-		val_type = G_TYPE_STRING;
+			val_type = G_TYPE_STRING;
 	}
 
 	return val_type;



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