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; }
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 void render_path (GString *target, HFRenderInfo *info, G_GNUC_UNUSED char const *args) { if (info->sheet != NULL && info->sheet->workbook != NULL) { char *path = go_dirname_from_uri ( go_doc_get_uri (GO_DOC (info->sheet->workbook)), TRUE); g_string_append (target, path); g_free (path); } else g_string_append (target, _("Path ")); }
static void render_file (GString *target, HFRenderInfo *info, G_GNUC_UNUSED char const *args) { if (info->sheet != NULL && info->sheet->workbook != NULL) { char *name = go_basename_from_uri ( go_doc_get_uri (GO_DOC (info->sheet->workbook))); g_string_append (target, name); g_free (name); } else g_string_append (target, _("File Name")); }
static gboolean cb_workbook_uri (Workbook * wb, gpointer closure) { struct wb_uri_closure *dat = closure; char const *wb_uri = go_doc_get_uri (GO_DOC (wb)); if (wb_uri && strcmp (wb_uri, dat->uri) == 0) { dat->wb = wb; return FALSE; } return TRUE; }
static gboolean gnm_soi_assign_to_sheet (SheetObject *so, Sheet *sheet) { SheetObjectImage *soi = SHEET_OBJECT_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, 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)); } else { /* There is nothing we can do */ } return FALSE; }
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")); }
Workbook * xlsx_conventions_add_extern_ref (GnmConventions *convs, char const *path) { XLSXExprConventions *xconv = (XLSXExprConventions *)convs; Workbook *res = g_object_new (GNM_WORKBOOK_TYPE, NULL); char *id; (void) go_doc_set_uri (GO_DOC (res), path); id = g_strdup_printf ("%d", g_hash_table_size (xconv->extern_wb_by_id) + 1); if (0) g_printerr ("add %s = '%s'\n", id, path); g_hash_table_insert (xconv->extern_wb_by_id, id, res); return res; }
/** * 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); } } }
GODoc * wb_control_get_doc (WorkbookControl const *wbc) { return GO_DOC (wb_control_get_workbook (wbc)); }