static void gnm_soi_write_xml_sax (SheetObject const *so, GsfXMLOut *output, G_GNUC_UNUSED GnmConventions const *convs) { SheetObjectImage *soi; g_return_if_fail (IS_SHEET_OBJECT_IMAGE (so)); soi = SHEET_OBJECT_IMAGE (so); gsf_xml_out_add_float (output, "crop-top", soi->crop_top, 3); gsf_xml_out_add_float (output, "crop-bottom", soi->crop_bottom, 3); gsf_xml_out_add_float (output, "crop-left", soi->crop_left, 3); gsf_xml_out_add_float (output, "crop-right", soi->crop_right, 3); gsf_xml_out_start_element (output, "Content"); if (soi->type != NULL) gsf_xml_out_add_cstr (output, "image-type", soi->type); if (soi->image && go_image_get_name (soi->image)) { gsf_xml_out_add_cstr (output, "name", go_image_get_name (soi->image)); if (sheet_object_get_sheet (so)) go_doc_save_image (GO_DOC (sheet_object_get_sheet (so)->workbook), go_image_get_name (soi->image)); else { /* looks that this may happen when pasting from another process, see #687414 */ gsize length; guint8 const *data = go_image_get_data (soi->image, &length); gsf_xml_out_add_uint (output, "size-bytes", length); gsf_xml_out_add_base64 (output, NULL, data, length); } } else { gsf_xml_out_add_uint (output, "size-bytes", soi->bytes.len); gsf_xml_out_add_base64 (output, NULL, soi->bytes.data, soi->bytes.len); } gsf_xml_out_end_element (output); }
static gboolean gnm_soi_assign_to_sheet (SheetObject *so, Sheet *sheet) { SheetObjectImage *soi = GNM_SO_IMAGE (so); if (soi->image/* && !go_image_get_name (soi->image)*/) { GODoc *doc = GO_DOC (sheet->workbook); GOImage *image = go_doc_add_image (doc, (soi->name != NULL) ? soi->name : go_image_get_name (soi->image), soi->image); if (soi->image != image) { g_object_unref (soi->image); soi->image = g_object_ref (image); } } else if (soi->name) { GODoc *doc = GO_DOC (sheet->workbook); GType type = go_image_type_for_format (soi->type); if (type != 0) { soi->image = g_object_ref (go_doc_image_fetch (doc, soi->name, type)); if (GO_IS_PIXBUF (soi->image)) /* we need to ensure that the pixbuf type is set because it used to be missed, see #745297 */ g_object_set (soi->image, "image-type", soi->type, NULL); } } else { /* There is nothing we can do */ } return FALSE; }