static void content_end (GsfXMLIn *xin, G_GNUC_UNUSED GsfXMLBlob *unknown) { SheetObject *so = gnm_xml_in_cur_obj (xin); SheetObjectImage *soi = GNM_SO_IMAGE (so); GString *data = xin->content; if (data->len >= 4) { size_t len = gsf_base64_decode_simple (data->str, data->len); if (soi->image) g_object_unref (soi->image); soi->image = go_image_new_from_data (soi->type, data->str, len, NULL, NULL); } }
static void content_end (GsfXMLIn *xin, G_GNUC_UNUSED GsfXMLBlob *unknown) { SheetObject *so = gnm_xml_in_cur_obj (xin); SheetObjectImage *soi = SHEET_OBJECT_IMAGE (so); GString *data = xin->content; if (data->len >= 4) { size_t len = gsf_base64_decode_simple (data->str, data->len); soi->bytes.len = len; soi->bytes.data = g_memdup (data->str, len); soi->image = go_image_new_from_data (soi->type, soi->bytes.data, len, NULL, NULL); } }
/** * sheet_object_image_set_image : * @soi: #SheetObjectImage * @type: * @data: * @data_len * @copy_data: * * Assign raw data and type to @so assuming that it has not been initialized * yet. **/ void sheet_object_image_set_image (SheetObjectImage *soi, char const *type, guint8 *data, unsigned data_len, gboolean copy_data) { g_return_if_fail (IS_SHEET_OBJECT_IMAGE (soi)); g_return_if_fail (soi->bytes.data == NULL && soi->bytes.len == 0); soi->type = (type && *type)? g_strdup (type): NULL; soi->bytes.len = data_len; soi->bytes.data = copy_data ? g_memdup (data, data_len) : data; soi->image = go_image_new_from_data (soi->type, soi->bytes.data, soi->bytes.len, ((soi->type == NULL)? &soi->type: NULL), NULL); if (soi->sheet_object.sheet != NULL) { GOImage *image = go_doc_add_image (GO_DOC (soi->sheet_object.sheet->workbook), NULL, soi->image); if (image != soi->image) { g_object_unref (soi->image); soi->image = g_object_ref (image); } } }
/** * sheet_object_image_set_image : * @soi: #SheetObjectImage * @type: * @data: * @data_len * * Assign raw data and type to @soi. * yet. **/ void sheet_object_image_set_image (SheetObjectImage *soi, char const *type, gconstpointer data, unsigned data_len) { g_return_if_fail (GNM_IS_SO_IMAGE (soi)); g_free (soi->type); soi->type = (type && *type) ? g_strdup (type) : NULL; if (soi->image) g_object_unref (soi->image); soi->image = go_image_new_from_data (soi->type, data, data_len, ((soi->type == NULL)? &soi->type: NULL), NULL); if (soi->sheet_object.sheet != NULL) { /* Share within document. */ GOImage *image = go_doc_add_image (GO_DOC (soi->sheet_object.sheet->workbook), NULL, soi->image); if (image != soi->image) { g_object_unref (soi->image); soi->image = g_object_ref (image); } } }