[gnumeric] write image name to ODS
- From: Andreas J. Guelzow <guelzow src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] write image name to ODS
- Date: Sat, 11 Apr 2015 06:46:15 +0000 (UTC)
commit 3f78c68e5cc53149fc00a525ed638f04f37d2fa5
Author: Andreas J. Guelzow <aguelzow pyrshep ca>
Date: Sat Apr 11 00:42:49 2015 -0600
write image name to ODS
2015-04-11 Andreas J. Guelzow <aguelzow pyrshep ca>
* openoffice-read.c (od_draw_frame_start): read and store the
image name
(od_draw_frame_end_full): clear the saved image name
(od_draw_image): apply the image name
* openoffice-write.c (odf_write_image): write image name
plugins/openoffice/ChangeLog | 8 ++++++++
plugins/openoffice/openoffice-read.c | 18 +++++++++++++++---
plugins/openoffice/openoffice-write.c | 11 +++++++++++
3 files changed, 34 insertions(+), 3 deletions(-)
---
diff --git a/plugins/openoffice/ChangeLog b/plugins/openoffice/ChangeLog
index 69a9b66..b7b99f7 100644
--- a/plugins/openoffice/ChangeLog
+++ b/plugins/openoffice/ChangeLog
@@ -1,3 +1,11 @@
+2015-04-11 Andreas J. Guelzow <aguelzow pyrshep ca>
+
+ * openoffice-read.c (od_draw_frame_start): read and store the
+ image name
+ (od_draw_frame_end_full): clear the saved image name
+ (od_draw_image): apply the image name
+ * openoffice-write.c (odf_write_image): write image name
+
2015-04-10 Andreas J. Guelzow <aguelzow pyrshep ca>
* openoffice-write.c (odf_write_content): fix leak
diff --git a/plugins/openoffice/openoffice-read.c b/plugins/openoffice/openoffice-read.c
index f98a1c4..9e12d67 100644
--- a/plugins/openoffice/openoffice-read.c
+++ b/plugins/openoffice/openoffice-read.c
@@ -231,6 +231,7 @@ typedef struct {
GogChart *chart;
SheetObject *so;
GSList *list; /* used by Stock plot and textbox*/
+ char *name;
/* set in plot-area */
GogPlot *plot;
@@ -7964,7 +7965,8 @@ od_draw_frame_start (GsfXMLIn *xin, xmlChar const **attrs)
GnmSOAnchorMode mode;
int last_row = gnm_sheet_get_last_row (state->pos.sheet);
int last_col = gnm_sheet_get_last_col (state->pos.sheet);
-
+
+ state->chart.name = NULL;
height = width = x = y = 0.;
for (; attrs != NULL && attrs[0] && attrs[1] ; attrs += 2){
@@ -7991,6 +7993,8 @@ od_draw_frame_start (GsfXMLIn *xin, xmlChar const **attrs)
} else if (oo_attr_int_range (xin,attrs, OO_NS_DRAW, "z-index",
&z, 0, G_MAXINT))
;
+ else if (gsf_xml_in_namecmp (xin, CXML2C (attrs[0]), OO_NS_DRAW, "name"))
+ state->chart.name = g_strdup (CXML2C (attrs[1]));
}
frame_offset[0] = x;
@@ -8064,6 +8068,8 @@ od_draw_frame_end_full (GsfXMLIn *xin, gboolean absolute_distance, char const *c
state->chart.so = NULL;
}
+ g_free (state->chart.name);
+ state->chart.name = NULL;
}
static void
@@ -8387,10 +8393,16 @@ od_draw_image (GsfXMLIn *xin, xmlChar const **attrs)
gsf_off_t len = gsf_input_size (input);
guint8 const *data = gsf_input_read (input, len, NULL);
soi = g_object_new (GNM_SO_IMAGE_TYPE, NULL);
- sheet_object_image_set_image (soi, "", data, len);
-
state->chart.so = GNM_SO (soi);
+ sheet_object_image_set_image (soi, "", data, len);
g_object_unref (input);
+ if (state->chart.name != NULL) {
+ GOImage *image = NULL;
+ g_object_get (G_OBJECT (soi),
+ "image", &image,
+ NULL);
+ go_image_set_name (image, state->chart.name);
+ }
} else
oo_warning (xin, _("Unable to load "
"the file \'%s\'."),
diff --git a/plugins/openoffice/openoffice-write.c b/plugins/openoffice/openoffice-write.c
index 1a08c95..55206b4 100644
--- a/plugins/openoffice/openoffice-write.c
+++ b/plugins/openoffice/openoffice-write.c
@@ -3008,9 +3008,20 @@ odf_write_image (GnmOOExport *state, SheetObject *so, char const *name)
if (name != NULL) {
char *image_type;
char *fullname;
+ GOImage *image = NULL;
+
g_object_get (G_OBJECT (so),
"image-type", &image_type,
+ "image", &image,
NULL);
+
+ if (image) {
+ /* Write attribute for surrounding draw:frame */
+ const char *image_name = go_image_get_name (image);
+ if (image_name)
+ gsf_xml_out_add_cstr (state->xml, DRAW "name", image_name);
+ }
+
fullname = g_strdup_printf ("Pictures/%s.%s", name, image_type);
gsf_xml_out_start_element (state->xml, DRAW "image");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]