[gnumeric] Include generator name and version in xlsx export



commit 924e00eb8e88915d357ee23aa84a739f9031e263
Author: Andreas J Guelzow <aguelzow pyrshep ca>
Date:   Thu Jun 23 02:50:37 2011 -0600

    Include generator name and version in xlsx export
    
    2011-06-23  Andreas J. Guelzow <aguelzow pyrshep ca>
    
    	* Makefile.am: add xlsx-write-docprops.c
    	* xlsx-write.c (ns_docprops_extended): new
    	(xlsx_write_workbook): call xlsx_write_docprops
    	* xlsx-write-docprops.c: new

 plugins/excel/ChangeLog             |    7 +++
 plugins/excel/Makefile.am           |    1 +
 plugins/excel/xlsx-write-docprops.c |   72 +++++++++++++++++++++++++++++++++++
 plugins/excel/xlsx-write.c          |    4 ++
 4 files changed, 84 insertions(+), 0 deletions(-)
---
diff --git a/plugins/excel/ChangeLog b/plugins/excel/ChangeLog
index fae18b3..e8bb201 100644
--- a/plugins/excel/ChangeLog
+++ b/plugins/excel/ChangeLog
@@ -1,3 +1,10 @@
+2011-06-23  Andreas J. Guelzow <aguelzow pyrshep ca>
+
+	* Makefile.am: add xlsx-write-docprops.c
+	* xlsx-write.c (ns_docprops_extended): new
+	(xlsx_write_workbook): call xlsx_write_docprops
+	* xlsx-write-docprops.c: new
+
 2011-06-16  Andreas J. Guelzow <aguelzow pyrshep ca>
 
 	* xlsx-read-drawing.c (xlsx_drawing_dtd): add srcRect
diff --git a/plugins/excel/Makefile.am b/plugins/excel/Makefile.am
index d46d004..d9f8da8 100644
--- a/plugins/excel/Makefile.am
+++ b/plugins/excel/Makefile.am
@@ -79,6 +79,7 @@ xml_DATA = $(xml_in_files:.xml.in=.xml)
 @INTLTOOL_XML_RULE@
 
 EXTRA_DIST = $(xml_in_files)	\
+	xlsx-write-docprops.c	\
 	xlsx-read-pivot.c	\
 	xlsx-write-pivot.c	\
 	xlsx-read-drawing.c	\
diff --git a/plugins/excel/xlsx-write-docprops.c b/plugins/excel/xlsx-write-docprops.c
new file mode 100644
index 0000000..94e72ee
--- /dev/null
+++ b/plugins/excel/xlsx-write-docprops.c
@@ -0,0 +1,72 @@
+/* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/**
+ * xls-write-docprops.c: MS Excel XLSX export of document properties
+ *
+ * Copyright (C) 2011 Andreas J. Guelzow, All rights reserved 
+ * aguelzow pyrshep ca
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301
+ * USA
+ **/
+
+/*
+ *
+ * DO * NOT * COMPILE * DIRECTLY *
+ * DO * NOT * COMPILE * DIRECTLY *
+ * DO * NOT * COMPILE * DIRECTLY *
+ *
+ * included via xlsx-write.c
+ **/
+
+static void
+xlsx_write_docprops_app (XLSXWriteState *state, GsfOutfile *root_part, GsfOutfile *docprops_dir)
+{
+	GsfOutput *part = gsf_outfile_open_pkg_add_rel 
+		(docprops_dir, "app.xml",
+		 "application/vnd.openxmlformats-officedocument.extended-properties+xml",
+		 root_part,
+		 "http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties";);
+	GsfXMLOut *xml = gsf_xml_out_new (part);
+	
+	gsf_xml_out_start_element (xml, "Properties");
+	gsf_xml_out_add_cstr_unchecked (xml, "xmlns", ns_docprops_extended);
+	gsf_xml_out_add_cstr_unchecked (xml, "xml:space", "preserve");
+	gsf_xml_out_start_element (xml, "Application");
+	gsf_xml_out_add_cstr_unchecked (xml, NULL, PACKAGE_NAME);
+	gsf_xml_out_end_element (xml); /* </Application> */
+	gsf_xml_out_start_element (xml, "AppVersion");
+	gsf_xml_out_add_cstr_unchecked (xml, NULL, VERSION);
+	gsf_xml_out_end_element (xml); /* </AppVersion> */
+	gsf_xml_out_end_element (xml); /* </Properties> */
+	
+	g_object_unref (xml);
+	gsf_output_close (part);
+	g_object_unref (part);
+}
+
+static void
+xlsx_write_docprops_core (XLSXWriteState *state, GsfOutfile *root_part, GsfOutfile *docprops_dir)
+{
+
+}
+
+static void
+xlsx_write_docprops (XLSXWriteState *state, GsfOutfile *root_part)
+{
+	GsfOutfile *docprops_dir    = (GsfOutfile *)gsf_outfile_new_child (root_part, "docProps", TRUE);
+
+	xlsx_write_docprops_app (state, root_part, docprops_dir);
+	xlsx_write_docprops_core (state, root_part, docprops_dir);
+}
diff --git a/plugins/excel/xlsx-write.c b/plugins/excel/xlsx-write.c
index 83443a2..fee4155 100644
--- a/plugins/excel/xlsx-write.c
+++ b/plugins/excel/xlsx-write.c
@@ -74,6 +74,7 @@ enum {
 
 static char const *ns_ss	 = "http://schemas.openxmlformats.org/spreadsheetml/2006/main";;
 static char const *ns_ss_drawing = "http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing";;
+static char const *ns_docprops_extended = "http://schemas.openxmlformats.org/officeDocument/2006/extended-properties";;
 static char const *ns_drawing	 = "http://schemas.openxmlformats.org/drawingml/2006/main";;
 static char const *ns_chart	 = "http://schemas.openxmlformats.org/drawingml/2006/chart";;
 static char const *ns_rel	 = "http://schemas.openxmlformats.org/officeDocument/2006/relationships";;
@@ -1971,6 +1972,8 @@ xlsx_write_calcPR (XLSXWriteState *state, GsfXMLOut *xml)
 
 #include "xlsx-write-pivot.c"
 
+#include "xlsx-write-docprops.c"
+
 static void
 xlsx_write_workbook (XLSXWriteState *state, GsfOutfile *root_part)
 {
@@ -2001,6 +2004,7 @@ xlsx_write_workbook (XLSXWriteState *state, GsfOutfile *root_part)
 
 	xlsx_write_shared_strings (state, wb_part);
 	xlsx_write_styles (state, wb_part);
+	xlsx_write_docprops (state, root_part);
 	cacheRefs = xlsx_write_pivots (state, wb_part);
 
 	xml = gsf_xml_out_new (GSF_OUTPUT (wb_part));



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