[gnumeric] add more core properties to xlsx export



commit cd74878f4981cffc329d46a933e5e8b36cbde244
Author: Andreas J Guelzow <aguelzow pyrshep ca>
Date:   Fri Jun 24 17:01:47 2011 -0600

    add more core properties to xlsx export
    
    2011-06-24  Andreas J. Guelzow <aguelzow pyrshep ca>
    
    	* xlsx-write.c: add include
    	* xlsx-write-docprops.c (xlsx_map_prop_type): add more items
    	(xlsx_meta_write_props): also write keywords

 NEWS                                |    1 +
 plugins/excel/ChangeLog             |    6 ++
 plugins/excel/xlsx-write-docprops.c |  103 ++++++++++++++++++++++++++++-------
 plugins/excel/xlsx-write.c          |    1 +
 4 files changed, 92 insertions(+), 19 deletions(-)
---
diff --git a/NEWS b/NEWS
index f80e4ed..5b2d328 100644
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,7 @@ Andreas:
 	* Fix some style import from ODF. [#652492]
 	* Import/Export print formatting from/to ODF. [#653186]
 	* Write some document properties to XLSX.
+	* Fix xlsx schema violations.
 
 Morten:
 	* Fix --with-gnome compilation:  [#652802]
diff --git a/plugins/excel/ChangeLog b/plugins/excel/ChangeLog
index 104d956..d18f959 100644
--- a/plugins/excel/ChangeLog
+++ b/plugins/excel/ChangeLog
@@ -1,5 +1,11 @@
 2011-06-24  Andreas J. Guelzow <aguelzow pyrshep ca>
 
+	* xlsx-write.c: add include
+	* xlsx-write-docprops.c (xlsx_map_prop_type): add more items
+	(xlsx_meta_write_props): also write keywords
+
+2011-06-24  Andreas J. Guelzow <aguelzow pyrshep ca>
+
 	* xlsx-write.c (xlsx_write_shared_strings): xml:space is
 	not allowed
 	(xlsx_write_styles): ditto
diff --git a/plugins/excel/xlsx-write-docprops.c b/plugins/excel/xlsx-write-docprops.c
index e713ebe..daff94c 100644
--- a/plugins/excel/xlsx-write-docprops.c
+++ b/plugins/excel/xlsx-write-docprops.c
@@ -67,18 +67,11 @@ xlsx_map_prop_type (char const *name)
 			char const *gsf_key;
 			char const *xlsx_type;
 		} const map [] = {
-			/* { GSF_META_NAME_TITLE,		"dc:title" }, */
-			/* { GSF_META_NAME_DESCRIPTION,	"dc:description" }, */
-			/* { GSF_META_NAME_SUBJECT,	"dc:subject" }, */
-			/* { GSF_META_NAME_INITIAL_CREATOR,"dc:creator" }, */
-			/* { GSF_META_NAME_CREATOR,	"" }, */
-			/* { GSF_META_NAME_PRINTED_BY,	"" }, */
+			/* Note that in ECMA-376 edition 1 these are the only 2 props   */
+			/* permitted to have types attached to them and they must be as */
+			/* as given here. */
 			{ GSF_META_NAME_DATE_CREATED,   "dcterms:W3CDTF" },
 			{ GSF_META_NAME_DATE_MODIFIED,	"dcterms:W3CDTF" }/* , */
-			/* { GSF_META_NAME_LAST_PRINTED,"cp:lastPrinted" }, */
-			/* { GSF_META_NAME_LANGUAGE,	"dc:language" } , */
-			/* { GSF_META_NAME_REVISION_COUNT,   "" }, */
-			/* { GSF_META_NAME_EDITING_DURATION, "" } */
 		};
 		int i = G_N_ELEMENTS (map);
 
@@ -104,19 +97,61 @@ xlsx_map_prop_name (char const *name)
 			char const *gsf_key;
 			char const *xlsx_key;
 		} const map [] = {
-			{ GSF_META_NAME_TITLE,		"dc:title" },
+			{ GSF_META_NAME_CATEGORY,	"cp:category" },
+			{ "cp:contentStatus",	        "cp:contentStatus" },
+			{ "cp:contentType",	        "cp:contentType" },
+			{ GSF_META_NAME_KEYWORDS,	"cp:keywords" },
+			{ GSF_META_NAME_CREATOR,	"cp:lastModifiedBy" },
+			{ GSF_META_NAME_PRINT_DATE,	"cp:lastPrinted" },
+			{ GSF_META_NAME_REVISION_COUNT,	"cp:revision" },
+			{ "cp:version",	                "cp:version" },
+			{ GSF_META_NAME_INITIAL_CREATOR,"dc:creator" },
 			{ GSF_META_NAME_DESCRIPTION,	"dc:description" },
+			{ "dc:identifier",	        "dc:identifier" },
+			{ GSF_META_NAME_LANGUAGE,	"dc:language" },
 			{ GSF_META_NAME_SUBJECT,	"dc:subject" },
-			{ GSF_META_NAME_INITIAL_CREATOR,"dc:creator" },
-			{ GSF_META_NAME_CREATOR,	"cp:lastModifiedBy" },
-			/* { GSF_META_NAME_PRINTED_BY,	"" }, */
+			{ GSF_META_NAME_TITLE,		"dc:title" },
 			{ GSF_META_NAME_DATE_CREATED,   "dcterms:created" },
-			{ GSF_META_NAME_DATE_MODIFIED,	"dcterms:modified" },
-			{ GSF_META_NAME_LAST_PRINTED,	"cp:lastPrinted" },
-			{ GSF_META_NAME_LANGUAGE,	"dc:language" }/* , */
-			/* { GSF_META_NAME_REVISION_COUNT,   "" }, */
-			/* { GSF_META_NAME_EDITING_DURATION, "" } */
+			{ GSF_META_NAME_DATE_MODIFIED,	"dcterms:modified" }
 		};
+
+		/* Not matching ECMA-376 edition 1 core properties: */
+		/* GSF_META_NAME_CODEPAGE */
+		/* GSF_META_NAME_BYTE_COUNT */
+		/* GSF_META_NAME_CASE_SENSITIVE */
+		/* GSF_META_NAME_CELL_COUNT */
+		/* GSF_META_NAME_CHARACTER_COUNT */
+		/* GSF_META_NAME_DICTIONARY */
+		/* GSF_META_NAME_DOCUMENT_PARTS */
+		/* GSF_META_NAME_HEADING_PAIRS */
+		/* GSF_META_NAME_HIDDEN_SLIDE_COUNT */
+		/* GSF_META_NAME_IMAGE_COUNT */
+		/* GSF_META_NAME_LAST_SAVED_BY */
+		/* GSF_META_NAME_LINKS_DIRTY */
+		/* GSF_META_NAME_LOCALE_SYSTEM_DEFAULT */
+		/* GSF_META_NAME_MANAGER */
+		/* GSF_META_NAME_PRESENTATION_FORMAT */
+		/* GSF_META_NAME_SCALE */
+		/* GSF_META_NAME_SECURITY */
+		/* GSF_META_NAME_THUMBNAIL  */
+		/* GSF_META_NAME_LINE_COUNT */
+		/* GSF_META_NAME_MM_CLIP_COUNT */
+		/* GSF_META_NAME_NOTE_COUNT */
+		/* GSF_META_NAME_OBJECT_COUNT */
+		/* GSF_META_NAME_PAGE_COUNT */
+		/* GSF_META_NAME_PARAGRAPH_COUNT */
+		/* GSF_META_NAME_SLIDE_COUNT */
+		/* GSF_META_NAME_SPREADSHEET_COUNT */
+		/* GSF_META_NAME_TABLE_COUNT */
+		/* GSF_META_NAME_WORD_COUNT */
+		/* GSF_META_NAME_EDITING_DURATION */
+		/* GSF_META_NAME_GENERATOR  the new generator is stored in app.xml  */ 
+		/* GSF_META_NAME_KEYWORD cmp with GSF_META_NAME_KEYWORDS */
+		/* GSF_META_NAME_COMPANY */
+		/* GSF_META_NAME_LAST_PRINTED compare with GSF_META_NAME_PRINT_DATE*/
+		/* GSF_META_NAME_PRINTED_BY */
+		/* GSF_META_NAME_TEMPLATE */
+
 		int i = G_N_ELEMENTS (map);
 
 		xlsx_prop_name_map = g_hash_table_new (g_str_hash, g_str_equal);
@@ -135,6 +170,36 @@ 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))) {
 		char const *mapped_type = xlsx_map_prop_type (prop_name);
 
diff --git a/plugins/excel/xlsx-write.c b/plugins/excel/xlsx-write.c
index 36c98a6..b0e424e 100644
--- a/plugins/excel/xlsx-write.c
+++ b/plugins/excel/xlsx-write.c
@@ -64,6 +64,7 @@
 #include <glib/gi18n-lib.h>
 #include <gsf/gsf-meta-names.h>
 #include <gsf/gsf-doc-meta-data.h>
+#include <gsf/gsf-docprop-vector.h>
 #include <gmodule.h>
 #include <string.h>
 



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