I have issues with Edit Externally in all three of the insets of the "Simple
examples" section of the spreadsheets.lyx example file:

1.
right click on the first external material inset (sheet1.gnumeric) and go to
Edit Externally. I get the error "No information for editing gzip". This should
happen if you have libmagic and gnumeric installed. It happens because of
$ file sheet1.gnumeric
sheet1.gnumeric: gzip compressed data, from Unix, last modified: Fri
Nov 18 07:11:27 2011
even though:
$ mimetype sheet1.gnumeric
sheet1.gnumeric: application/x-gnumeric

in Formats::getFormatFromFile
after
string mime = magic_file(magic_cookie,
        filename.toFilesystemEncoding().c_str());
mime equals "application/x-gzip; charset=binary"

changing the mime-type in file formats to "application/x-gzip"
works but that can't be the best solution.

Is hardcoding a potential solution?
(you just felt a cold shiver go down you, didn't you?)
I understand that hardcoding is rarely a good idea and I would not have
brought it up if I didn't notice a currently hardcoded exception that
is similar:
        // LinkBack files look like PDF, but have the .linkback extension
        string const ext = getExtension(filename.absFileName());
        if (format_name == "pdf" && ext == "linkback") {
#ifdef USE_MACOSX_PACKAGING
                return editLinkBackFile(filename.absFileName().c_str());
#else
                Alert::error(_("Cannot edit file"),
                             _("LinkBack files can only be edited on
Apple Mac OSX."));
                return false;

The solution for gnumeric would be similar: if mime returns
"application/x-gzip" check the extension. I wonder if this applies to other
formats that store compressed data. If so, then at least it would not be
hardcoded only for the specific case of gnumeric.

2.
right click on the second external material inset (sheet2.ods) and go to Edit
Externally. I get the error "Unsupported file format" from Gnumeric. Can
Gnumeric open ods files? For me it fails. Besides, shouldn't the default
viewer/editor be libreoffice? I don't understand configure.py well so I did not
make a patch for this.

3.
right click on the third external material inset (sheet3.xls) and go to Edit
Externally. The file opens in libreoffice, which for me is good. What surprises
me is that in File Formats "gnumeric" was configured to be the Editor. Why is
it (correctly) opening in libreoffice?

Thanks,

Scott

Reply via email to