[libgsf] Use gsf_value_get_docprop_array()
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgsf] Use gsf_value_get_docprop_array()
- Date: Mon, 27 Jan 2020 23:51:51 +0000 (UTC)
commit efff3982a14746048b9f661cb1543838a6071cc9
Author: Marc-André Lureau <marcandre lureau redhat com>
Date: Sun Jan 19 23:30:52 2020 +0400
Use gsf_value_get_docprop_array()
Signed-off-by: Marc-André Lureau <marcandre lureau redhat com>
gsf/gsf-doc-meta-data.c | 7 +++----
gsf/gsf-msole-utils.c | 12 ++++++------
gsf/gsf-opendoc-utils.c | 23 +++++++++++++----------
3 files changed, 22 insertions(+), 20 deletions(-)
---
diff --git a/gsf/gsf-doc-meta-data.c b/gsf/gsf-doc-meta-data.c
index ddcb500..d7dd011 100644
--- a/gsf/gsf-doc-meta-data.c
+++ b/gsf/gsf-doc-meta-data.c
@@ -439,12 +439,11 @@ gsf_doc_prop_dump (GsfDocProp const *prop)
GValue const *val = gsf_doc_prop_get_val (prop);
char *tmp;
if (VAL_IS_GSF_DOCPROP_VECTOR ((GValue *)val)) {
- GValueArray *va = gsf_value_get_docprop_varray (val);
+ GArray *va = gsf_value_get_docprop_array (val);
unsigned i;
- for (i = 0 ; i < va->n_values; i++) {
- tmp = g_strdup_value_contents (
- g_value_array_get_nth (va, i));
+ for (i = 0 ; i < va->len; i++) {
+ tmp = g_strdup_value_contents (&g_array_index (va, GValue, i));
g_print ("\t[%u] = %s\n", i, tmp);
g_free (tmp);
}
diff --git a/gsf/gsf-msole-utils.c b/gsf/gsf-msole-utils.c
index c8e61a9..b13cae4 100644
--- a/gsf/gsf-msole-utils.c
+++ b/gsf/gsf-msole-utils.c
@@ -1385,7 +1385,7 @@ gvalue_to_msole_vt (GValue const *value, GsfMSOleMetaDataPropMap const *map)
return VT_UNKNOWN;
case G_TYPE_OBJECT:
if (VAL_IS_GSF_DOCPROP_VECTOR (value)) {
- GValueArray *vector = gsf_value_get_docprop_varray (value);
+ GArray *vector = gsf_value_get_docprop_array (value);
unsigned i, n;
GsfMSOleVariantType type, tmp;
@@ -1398,10 +1398,10 @@ gvalue_to_msole_vt (GValue const *value, GsfMSOleMetaDataPropMap const *map)
return VT_VECTOR | VT_VARIANT;
} else
type = VT_UNKNOWN;
- n = vector->n_values;
+ n = vector->len;
for (i = 0; i < n; i++) {
tmp = gvalue_to_msole_vt (
- g_value_array_get_nth (vector, i), NULL);
+ &g_array_index (vector, GValue, i), NULL);
if (type == VT_UNKNOWN)
type = tmp;
else if (type != tmp)
@@ -1479,8 +1479,8 @@ msole_metadata_write_prop (WritePropState *state,
}
if (type & VT_VECTOR) {
- GValueArray *vector = gsf_value_get_docprop_varray (value);
- unsigned i, n = vector->n_values;
+ GArray *vector = gsf_value_get_docprop_array (value);
+ unsigned i, n = vector->len;
gboolean res;
GSF_LE_SET_GINT32 (buf, n);
@@ -1488,7 +1488,7 @@ msole_metadata_write_prop (WritePropState *state,
for (i = 0; i < n; i++) {
gboolean suppress = type != (VT_VECTOR | VT_VARIANT);
res &= msole_metadata_write_prop (state, NULL,
- g_value_array_get_nth (vector, i),
+ &g_array_index (vector, GValue, i),
suppress);
}
return res;
diff --git a/gsf/gsf-opendoc-utils.c b/gsf/gsf-opendoc-utils.c
index 197b53a..abf4ce3 100644
--- a/gsf/gsf-opendoc-utils.c
+++ b/gsf/gsf-opendoc-utils.c
@@ -352,11 +352,14 @@ od_meta_user_defined_end (GsfXMLIn *xin, G_GNUC_UNUSED GsfXMLBlob *blob)
GValue const *old = gsf_doc_prop_get_val (prop);
if (G_VALUE_HOLDS (old, GSF_DOCPROP_VECTOR_TYPE)) {
GValue *new = g_new0 (GValue, 1);
- GValueArray *vector;
+ GValue r = G_VALUE_INIT;
+ GArray *vector;
g_value_init (new, GSF_DOCPROP_VECTOR_TYPE);
g_value_copy (old, new);
- vector = gsf_value_get_docprop_varray (new);
- g_value_array_append (vector, res);
+ vector = gsf_value_get_docprop_array (new);
+ g_value_init (&r, G_VALUE_TYPE (res));
+ g_value_copy (res, &r);
+ g_array_append_vals (vector, &r, 1);
gsf_doc_prop_set_val (prop, new);
} else
g_printerr (_("Property \"%s\" used for "
@@ -700,7 +703,7 @@ meta_write_props (char const *prop_name, GsfDocProp *prop, GsfXMLOut *output)
/* Handle specially */
if (0 == strcmp (prop_name, GSF_META_NAME_KEYWORDS)) {
- GValueArray *va;
+ GArray *va;
unsigned i;
char *str;
@@ -714,9 +717,9 @@ meta_write_props (char const *prop_name, GsfDocProp *prop, GsfXMLOut *output)
gsf_xml_out_end_element (output);
}
g_free (str);
- } else if (NULL != (va = gsf_value_get_docprop_varray (val))) {
- for (i = 0 ; i < va->n_values; i++) {
- str = g_value_dup_string (g_value_array_get_nth (va, i));
+ } else if (NULL != (va = gsf_value_get_docprop_array (val))) {
+ for (i = 0 ; i < va->len; i++) {
+ str = g_value_dup_string (&g_array_index (va, GValue, i));
gsf_xml_out_start_element (output, "meta:keyword");
gsf_xml_out_add_cstr (output, NULL, str);
gsf_xml_out_end_element (output);
@@ -728,16 +731,16 @@ meta_write_props (char const *prop_name, GsfDocProp *prop, GsfXMLOut *output)
if (NULL == (mapped_name = od_map_prop_name (prop_name))) {
if (GSF_DOCPROP_VECTOR_TYPE == G_VALUE_TYPE (val)) {
- GValueArray *vector = gsf_value_get_docprop_varray (val);
+ GArray *vector = gsf_value_get_docprop_array (val);
guint i;
- guint num_values = vector->n_values;
+ guint num_values = vector->len;
for (i = 0; i < num_values; i++) {
GValue *v;
char *new_name = g_strdup_printf
("GSF_DOCPROP_VECTOR:%.4i:%s", i, prop_name);
- v = g_value_array_get_nth (vector, i);
+ v = &g_array_index (vector, GValue, i);
meta_write_props_user_defined (new_name, v, output);
g_free (new_name);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]