After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 745297 - SheetObjectImage mess
SheetObjectImage mess
Status: RESOLVED FIXED
Product: Gnumeric
Classification: Applications
Component: Sheet Objects
git master
Other Linux
: Normal normal
: ---
Assigned To: Jody Goldberg
Jody Goldberg
Depends on:
Blocks:
 
 
Reported: 2015-02-27 18:03 UTC by Morten Welinder
Modified: 2015-03-09 23:50 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Proposed patch for goffice (10.99 KB, patch)
2015-02-28 17:26 UTC, Jean Bréfort
committed Details | Review
Patch for gnumeric (1.77 KB, patch)
2015-02-28 17:27 UTC, Jean Bréfort
rejected Details | Review
baseparse: respect DISCONT flag on buffers (1.69 KB, patch)
2015-03-09 23:18 UTC, Thiago Sousa Santos
none Details | Review

Description Morten Welinder 2015-02-27 18:03:21 UTC
I added an image to the object tests.  Do try, do something like

../test/t6518-objects.pl --subtests ods

ods drops the image.
xls barfs
xlsx drops the image.
Comment 1 Morten Welinder 2015-02-27 18:44:53 UTC
The problem is somewhere between GOImage (which contains some really
strange code) and sheet-object-image.c
Comment 2 Andreas J. Guelzow 2015-02-27 18:46:18 UTC
If I save object-tests.gnumeric to ods and then open the archive to look at the file, I get a 0 byte image file. Clearly that does not work.

Note that this defintely used to work fine.

To save the file we have:

 static void
odf_write_images (SheetObjectImage *image, char const *name, GnmOOExport *state)
{
	char *image_type;
	char *fullname;
	GsfOutput  *child;
	GByteArray *bytes;

	g_object_get (G_OBJECT (image),
		      "image-type", &image_type,
		      "image-data", &bytes,
		      NULL);
	fullname = g_strdup_printf ("Pictures/%s.%s", name, image_type);

	child = gsf_outfile_new_child_full (state->outfile, fullname, FALSE,
							"compression-level", GSF_ZIP_DEFLATED,
							NULL);
	if (NULL != child) {
		gsf_output_write (child, bytes->len, bytes->data);
		gsf_output_close (child);
		g_object_unref (child);
	}

	g_free (fullname);
	g_free (image_type);

	odf_update_progress (state, state->graph_progress);
}


For the image in question, it turns out that the GByteArray we get has: odf_write_images: Pictures/Image1.jpeg bytes: 0x1128588 len: 0
(adding g_print ("odf_write_images: %s bytes: %p len: %i\n", fullname, bytes, bytes->len); before child = ...)

SO we are not getting any data for the image to write.
Comment 3 Morten Welinder 2015-02-27 22:37:49 UTC
I think it depends on how the image is created.

xls export is suffering from the same thing you see in ods.
Comment 4 Morten Welinder 2015-02-28 00:23:39 UTC
The situation is better now.  "Better", not "good".

The Gnumeric file contains the image in gdk-pixbuf format, around 20k.
It claims to have the jpeg file there.  That would have been around 6k.
This makes the ods export create a file with a jpeg name containing
gdkpixbuf data.

What a mess.

I think GOImage needs to be taught to keep the original image data around.
We could, in principle, recreate jpeg data, but it is lossy.  Thus I don't
want to do that.
Comment 5 Jean Bréfort 2015-02-28 08:47:28 UTC
GOImage does not know the original data for png and jpeg, but it is easy to change that, I suppose. When original data are saved we don't need to save the "rowstride" property, so it will be easy to diffentiate between the two situations.
We also need to get the image data when they are stored only in GOImage. This is something I missed, sorry.
Comment 6 Jean Bréfort 2015-02-28 17:26:57 UTC
Created attachment 298173 [details] [review]
Proposed patch for goffice

This preserves the original data for newly cretaed images and restores valid data for older ones if needed.
Comment 7 Jean Bréfort 2015-02-28 17:27:37 UTC
Created attachment 298174 [details] [review]
Patch for gnumeric
Comment 8 Morten Welinder 2015-02-28 17:58:18 UTC
Feel free to commit.

Note, though, that I already introduced a go_pixbuf_new_from_data but
that it takes arguments in a different order -- sorry about that.
Comment 9 Jean Bréfort 2015-02-28 19:02:25 UTC
I don't see your version of go_pixbuf_new_from_data(). Did you commit it?
Comment 10 Jean Bréfort 2015-02-28 19:20:15 UTC
Comment on attachment 298174 [details] [review]
Patch for gnumeric

Commited the still needed part of it.
Comment 11 Jean Bréfort 2015-02-28 19:21:23 UTC
This problem has been fixed in our software repository. The fix will go into the next software release. Once that release is available, you may want to check for a software upgrade provided by your Linux distribution.

Feel free to reopen if I missed something.
Comment 12 Morten Welinder 2015-02-28 19:31:34 UTC
Looks good to me.
Comment 13 Thiago Sousa Santos 2015-03-09 23:18:18 UTC
Created attachment 298932 [details] [review]
baseparse: respect DISCONT flag on buffers

Drain the parser when a DISCONT buffer is received and then mark
the next buffer to be pushed as a DISCONT one
Comment 14 Morten Welinder 2015-03-09 23:41:45 UTC
Thiago?
Comment 15 Thiago Sousa Santos 2015-03-09 23:50:27 UTC
Sorry, typo when attaching with git-bz