int main(int argc, char *argv[]) { char *uri = argv[1]; GsfDocMetaData *meta_data; GsfDocProp *prop; const GValue *value; const char *tmp; gsf_init(); meta_data = props_data_read(uri, NULL); prop = gsf_doc_meta_data_lookup(meta_data, GSF_META_NAME_TITLE); if (prop) { value = gsf_doc_prop_get_val(prop); tmp = g_value_get_string(value); fprintf(stderr, "str: %s\n", tmp); } g_object_unref(meta_data); gsf_shutdown(); exit(0); }
static void msole_thumbnail (GsfInfile *infile, const char *out_filename, int thumb_size) { GsfInput *summary_stream; GsfDocMetaData *meta_data; GsfDocProp *thumb_doc_prop; GValue const *thumb_value; GsfClipData *clip_data; GsfClipFormat clip_format; gconstpointer data; gsize size; GError *error; summary_stream = gsf_infile_child_by_name (infile, "\05SummaryInformation"); if (!summary_stream) show_error_string_and_exit ("Could not find the SummaryInformation stream"); meta_data = gsf_doc_meta_data_new (); error = gsf_msole_metadata_read (summary_stream, meta_data); if (error) show_error_and_exit (error); thumb_doc_prop = gsf_doc_meta_data_lookup (meta_data, GSF_META_NAME_THUMBNAIL); if (!thumb_doc_prop) show_error_string_and_exit ("The metadata does not have a thumbnail property"); thumb_value = gsf_doc_prop_get_val (thumb_doc_prop); if (!thumb_value) show_error_string_and_exit ("We got the thumbnail property, but it didn't have a value!?"); clip_data = GSF_CLIP_DATA (g_value_get_object (thumb_value)); clip_format = gsf_clip_data_get_format (clip_data); if (clip_format == GSF_CLIP_FORMAT_WINDOWS_CLIPBOARD) { GsfClipFormatWindows win_format; error = NULL; win_format = gsf_clip_data_get_windows_clipboard_format (clip_data, &error); if (win_format == GSF_CLIP_FORMAT_WINDOWS_ERROR) show_error_and_exit (error); } error = NULL; data = gsf_clip_data_peek_real_data (clip_data, &size, &error); if (!data) show_error_and_exit (error); write_thumbnail (out_filename, data, size, thumb_size); g_object_unref (clip_data); g_object_unref (meta_data); g_object_unref (summary_stream); }
static void render_title (GString *target, HFRenderInfo *info, G_GNUC_UNUSED char const *args) { if (info->sheet != NULL && info->sheet->workbook != NULL) { GsfDocProp *prop; prop = gsf_doc_meta_data_lookup (go_doc_get_meta_data (GO_DOC (info->sheet->workbook)), GSF_META_NAME_TITLE); if (prop != NULL) { GValue *prop_value = (GValue *) gsf_doc_prop_get_val (prop); if (prop_value != NULL) g_string_append (target, g_value_get_string (prop_value)); } } else g_string_append (target, _("Title")); }
static void cb_metadata_foreach(gpointer key, gpointer value, gpointer user_data) { const gchar *name = key; GsfDocProp *property = value; ChupaMetadata *metadata = user_data; const GValue *property_value; GType value_type; property_value = gsf_doc_prop_get_val(property); value_type = G_VALUE_TYPE(property_value); #define EQUAL_NAME(property_name) \ (chupa_utils_string_equal(name, property_name)) if (EQUAL_NAME("meta:creation-date")) { GTimeVal time_value; if (get_time_value(name, property_value, &time_value)) { chupa_metadata_set_creation_time(metadata, &time_value); } } else if (EQUAL_NAME("dc:creator")) { chupa_metadata_set_author(metadata, g_value_get_string(property_value)); } else if (EQUAL_NAME("dc:date")) { GTimeVal time_value; if (get_time_value(name, property_value, &time_value)) { chupa_metadata_set_modification_time(metadata, &time_value); } } else if (EQUAL_NAME("msole:codepage")) { if (!chupa_metadata_get_original_encoding(metadata)) { gint code_page; gchar *encoding; code_page = g_value_get_int(property_value); encoding = code_page_to_encoding(code_page); chupa_metadata_set_original_encoding(metadata, encoding); g_free(encoding); } } else { chupa_info("[decomposer][excel][metdata][unsupported][%s][%s]", name, g_type_name(value_type)); } #undef EQUAL_NAME }
/** * gsf_doc_prop_dump: * @prop: #GsfDocProp * * A debugging utility to dump @prop as text via g_print * New in 1.14.2 **/ void 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); unsigned i; for (i = 0 ; i < va->n_values; i++) { tmp = g_strdup_value_contents ( g_value_array_get_nth (va, i)); g_print ("\t[%u] = %s\n", i, tmp); g_free (tmp); } } else { tmp = g_strdup_value_contents (val); g_print ("\t= %s\n", tmp); g_free (tmp); } }
void gsf_doc_prop_glue_get_val (GsfDocProp const *prop, GType *type, GValue *value) { GValue const *prop_val; if (prop == NULL) return; prop_val = gsf_doc_prop_get_val (prop); if (prop_val != NULL && G_IS_VALUE (prop_val)) { *type = G_VALUE_TYPE (prop_val); g_value_init (value, *type); g_value_copy (prop_val, value); /* printf ("Type == %d, G_TYPE_STRING=%d, G_VALUE_TYPE (prop_val)=%d\n", *type, G_TYPE_STRING, G_VALUE_TYPE (prop_val)); */ } }
static void cb_print_property (char const *name, GsfDocProp const *prop, GHashTable * human_readable_names) { GValue const *val = gsf_doc_prop_get_val (prop); char *tmp; char const * _name; if((_name = g_hash_table_lookup(human_readable_names, name)) == NULL) _name = name; if (gsf_doc_prop_get_link (prop) != NULL) fprintf (stdout, "\t%s LINKED TO -> '%s'\n", _name, gsf_doc_prop_get_link (prop)); else fprintf (stdout, "\t%s = ", _name); if (VAL_IS_GSF_DOCPROP_VECTOR ((GValue *)val)) { GValueArray *va = gsf_value_get_docprop_varray (val); unsigned i; fprintf(stdout, "["); for (i = 0 ; i < va->n_values; i++) { tmp = g_strdup_value_contents (g_value_array_get_nth (va, i)); if(i != 0) fprintf(stdout, ", "); fprintf (stdout, "(%u, %s)", i, tmp); g_free (tmp); } fprintf(stdout, "]"); } else { tmp = g_strdup_value_contents (val); fprintf (stdout, "%s", tmp); g_free (tmp); } fprintf (stdout, "\n"); }