[gnumeric] Import keywords from xlsx
- From: Andreas J. Guelzow <guelzow src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] Import keywords from xlsx
- Date: Tue, 28 Jun 2011 06:39:25 +0000 (UTC)
commit 20b9e57dd255a374a61ec7f4d5320fdad00f240a
Author: Andreas J Guelzow <aguelzow pyrshep ca>
Date: Tue Jun 28 00:37:56 2011 -0600
Import keywords from xlsx
2011-06-28 Andreas J. Guelzow <aguelzow pyrshep ca>
* xlsx-write-docprops.c (xlsx_read_core_keys): implement
2011-06-28 Andreas J. Guelzow <aguelzow pyrshep ca>
* dialog-doc-metadata.c (dialog_doc_metadata_update_keywords_changed):
fix leak
(dialog_doc_metadata_transform_str_to_docprop_vect): fix leak
plugins/excel/ChangeLog | 4 ++++
plugins/excel/xlsx-read-docprops.c | 34 +++++++++++++++++++++++++++++++---
src/dialogs/ChangeLog | 6 ++++++
src/dialogs/dialog-doc-metadata.c | 2 ++
4 files changed, 43 insertions(+), 3 deletions(-)
---
diff --git a/plugins/excel/ChangeLog b/plugins/excel/ChangeLog
index 1ce3064..31a7511 100644
--- a/plugins/excel/ChangeLog
+++ b/plugins/excel/ChangeLog
@@ -1,3 +1,7 @@
+2011-06-28 Andreas J. Guelzow <aguelzow pyrshep ca>
+
+ * xlsx-write-docprops.c (xlsx_read_core_keys): implement
+
2011-06-27 Andreas J. Guelzow <aguelzow pyrshep ca>
* xlsx-write-docprops.c (xlsx_map_to_keys): new
diff --git a/plugins/excel/xlsx-read-docprops.c b/plugins/excel/xlsx-read-docprops.c
index b61cd7f..03f30dc 100644
--- a/plugins/excel/xlsx-read-docprops.c
+++ b/plugins/excel/xlsx-read-docprops.c
@@ -33,8 +33,36 @@
static void
xlsx_read_core_keys (GsfXMLIn *xin, G_GNUC_UNUSED GsfXMLBlob *blob)
{
-/* xin->content->str */
-/* xin->node->user_data.v_str */
+ XLSXReadState *state = (XLSXReadState *)xin->user_state;
+ gchar **strs, **orig_strs;
+ GsfDocPropVector *keywords;
+ GValue v = {0};
+ int count = 0;
+
+ if (strlen (xin->content->str) == 0)
+ return;
+
+ orig_strs = strs = g_strsplit (xin->content->str, " ", 0);
+ keywords = gsf_docprop_vector_new ();
+
+ while (strs != NULL && *strs != NULL && strlen (*strs) > 0) {
+ g_value_init (&v, G_TYPE_STRING);
+ g_value_set_string (&v, *strs);
+ gsf_docprop_vector_append (keywords, &v);
+ g_value_unset (&v);
+ count ++;
+ strs++;
+ }
+ g_strfreev(orig_strs);
+
+ if (count > 0) {
+ GValue *val = g_new0 (GValue, 1);
+ g_value_init (val, GSF_DOCPROP_VECTOR_TYPE);
+ g_value_set_object (val, keywords);
+ gsf_doc_meta_data_insert (state->metadata,
+ g_strdup (xin->node->user_data.v_str), val);
+ }
+ g_object_unref (keywords);
}
static void
@@ -194,7 +222,7 @@ GSF_XML_IN_NODE_FULL (START, CORE_PROPS, XL_NS_PROP_CP, "coreProperties", GSF_XM
GSF_XML_IN_NODE_FULL (CORE_PROPS, PROP_CATEGORY, XL_NS_PROP_CP, "category", GSF_XML_CONTENT, FALSE, FALSE, NULL, &xlsx_read_prop, .v_str = GSF_META_NAME_CATEGORY),
GSF_XML_IN_NODE_FULL (CORE_PROPS, PROP_CONTENT_STATUS, XL_NS_PROP_CP, "contentStatus", GSF_XML_CONTENT, FALSE, FALSE, NULL, &xlsx_read_prop, .v_str = "cp:contentStatus"),
GSF_XML_IN_NODE_FULL (CORE_PROPS, PROP_CONTENT_TYPE, XL_NS_PROP_CP, "contentType", GSF_XML_CONTENT, FALSE, FALSE, NULL, &xlsx_read_prop, .v_str = "cp:contentType"),
-GSF_XML_IN_NODE_FULL (CORE_PROPS, PROP_KEYWORDS, XL_NS_PROP_CP, "keywords", GSF_XML_CONTENT, FALSE, FALSE, NULL, &xlsx_read_core_keys, 0),
+GSF_XML_IN_NODE_FULL (CORE_PROPS, PROP_KEYWORDS, XL_NS_PROP_CP, "keywords", GSF_XML_CONTENT, FALSE, FALSE, NULL, &xlsx_read_core_keys, .v_str = GSF_META_NAME_KEYWORDS),
GSF_XML_IN_NODE_FULL (CORE_PROPS, PROP_LAST_NODIFIED_BY, XL_NS_PROP_CP, "lastModifiedBy", GSF_XML_CONTENT, FALSE, FALSE, NULL, &xlsx_read_prop, .v_str = GSF_META_NAME_CREATOR),
GSF_XML_IN_NODE_FULL (CORE_PROPS, PROP_LAST_PRINTED, XL_NS_PROP_CP, "lastPrinted", GSF_XML_CONTENT, FALSE, FALSE, NULL, &xlsx_read_prop_dt, .v_str = GSF_META_NAME_PRINT_DATE),
GSF_XML_IN_NODE_FULL (CORE_PROPS, PROP_REVISION, XL_NS_PROP_CP, "revision", GSF_XML_CONTENT, FALSE, FALSE, NULL, &xlsx_read_prop, .v_str = GSF_META_NAME_REVISION_COUNT),
diff --git a/src/dialogs/ChangeLog b/src/dialogs/ChangeLog
index 4ac042d..747a5a9 100644
--- a/src/dialogs/ChangeLog
+++ b/src/dialogs/ChangeLog
@@ -1,3 +1,9 @@
+2011-06-28 Andreas J. Guelzow <aguelzow pyrshep ca>
+
+ * dialog-doc-metadata.c (dialog_doc_metadata_update_keywords_changed):
+ fix leak
+ (dialog_doc_metadata_transform_str_to_docprop_vect): fix leak
+
2011-06-27 Andreas J. Guelzow <aguelzow pyrshep ca>
* dialog-doc-metadata.c (dialog_doc_metadata_get_gsf_prop_val_type):
diff --git a/src/dialogs/dialog-doc-metadata.c b/src/dialogs/dialog-doc-metadata.c
index d4fff66..768bc29 100644
--- a/src/dialogs/dialog-doc-metadata.c
+++ b/src/dialogs/dialog-doc-metadata.c
@@ -207,6 +207,7 @@ dialog_doc_metadata_transform_str_to_docprop_vect (const GValue *string_value,
}
str_done:
g_value_set_object (docprop_value, gdpv);
+ g_object_unref (gdpv);
}
static char *
@@ -983,6 +984,7 @@ dialog_doc_metadata_update_keywords_changed (DialogDocMetaData *state)
(GTK_TREE_MODEL (state->key_store), &iter));
}
g_value_set_object (&val, vector);
+ g_object_unref (vector);
dialog_doc_metadata_set_prop
(state, GSF_META_NAME_KEYWORDS,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]