libgsf r1050 - in trunk: . gsf



Author: guelzow
Date: Mon Apr 13 13:19:27 2009
New Revision: 1050
URL: http://svn.gnome.org/viewvc/libgsf?rev=1050&view=rev

Log:
2009-04-13  Andreas J. Guelzow <aguelzow pyrshep ca>

	* gsf/gsf-opendoc-utils.c (GsfOOMetaIn): added field
	(od_meta_user_defined): implement
	(od_meta_user_defined_end): new
	(gsf_opendoc_meta_dtd): handle "user-defined" completely
	(gsf_opendoc_metadata_read): initialize state.name




Modified:
   trunk/ChangeLog
   trunk/NEWS
   trunk/gsf/gsf-opendoc-utils.c

Modified: trunk/NEWS
==============================================================================
--- trunk/NEWS	(original)
+++ trunk/NEWS	Mon Apr 13 13:19:27 2009
@@ -1,5 +1,8 @@
 libgsf 1.14.12
 
+Andreas:
+	* also read user defined OpenDocument metadata
+
 J.H.M. Dassen (Ray):
 	* Fix incorrect use of g_enum_register_static which broke
 	  documentation generation in some environments.

Modified: trunk/gsf/gsf-opendoc-utils.c
==============================================================================
--- trunk/gsf/gsf-opendoc-utils.c	(original)
+++ trunk/gsf/gsf-opendoc-utils.c	Mon Apr 13 13:19:27 2009
@@ -37,6 +37,7 @@
 	GsfDocMetaData	 *md;
 	GsfDocPropVector *keywords;
 	GError		 *err;
+	char             *name;
 } GsfOOMetaIn;
 
 /* Generated based on:
@@ -141,9 +142,34 @@
 	g_free (v);
 }
 
+#define CXML2C(s) ((char const *)(s))
+
+static void
+od_meta_user_defined (GsfXMLIn *xin,  xmlChar const **attrs)
+{
+	GsfOOMetaIn *mi = (GsfOOMetaIn *)xin->user_state;
+
+	for (; attrs != NULL && attrs[0] && attrs[1] ; attrs += 2)
+		if ((0 == strcmp (CXML2C (attrs[0]), "meta:name")) && (attrs[1]!= NULL))
+			mi->name = g_strdup (CXML2C (attrs[1]));
+}
+
 static void
-od_meta_user_defined (G_GNUC_UNUSED GsfXMLIn *xin, G_GNUC_UNUSED GsfXMLBlob *blob)
+od_meta_user_defined_end (GsfXMLIn *xin, G_GNUC_UNUSED GsfXMLBlob *blob)
 {
+	GsfOOMetaIn *mi = (GsfOOMetaIn *)xin->user_state;
+	
+	if (mi->name != NULL) {
+		GValue *res = g_new0 (GValue, 1);
+		if (gsf_xml_gvalue_from_str (res, G_TYPE_STRING, xin->content->str)) {
+			gsf_doc_meta_data_insert (mi->md, mi->name, res);
+			mi->name = NULL;
+		} else {
+			g_free (res);
+			g_free (mi->name);
+			mi->name = NULL;
+		}
+	}
 }
 
 #if 0
@@ -179,8 +205,8 @@
     GSF_XML_IN_NODE (META, META_EDITING_CYCLES,	OO_NS_META, "editing-cycles", TRUE, NULL, &od_meta_editing_cycles),
     GSF_XML_IN_NODE (META, META_EDITING_DURATION, OO_NS_META, "editing-duration", TRUE, NULL, &od_meta_editing_duration),
 
-    GSF_XML_IN_NODE (META, META_USER_DEFINED,	OO_NS_META, "user-defined", TRUE, NULL, &od_meta_user_defined),
-  GSF_XML_IN_NODE_END
+  GSF_XML_IN_NODE (META, META_USER_DEFINED, OO_NS_META, "user-defined", GSF_XML_CONTENT, &od_meta_user_defined,  &od_meta_user_defined_end),
+   GSF_XML_IN_NODE_END
 };
 
 /**
@@ -202,6 +228,7 @@
 	state.md  = md;
 	state.keywords = NULL;
 	state.err = NULL;
+	state.name = NULL;
 
 	doc = gsf_xml_in_doc_new (gsf_opendoc_meta_dtd, gsf_ooo_ns);
 	gsf_xml_in_doc_parse (doc, input, &state);



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