Il 06/09/2011 03:04, Richard Heck ha scritto:
I guess it would make sense
in support/filetools.{h,cpp}. Though I wonder if there is a better way
than checking extensions....

thanks. Checking the extension is the quickest thing we can do. When working with OpenOffice, I'd say everyone uses the proper file extension, unless you have evidence of the contrary.

Alternatives: extend guessFormatFromContents() in order to identify OpenOffice documents. Or, use the external "file" tool:

  $ file ~/ooooo.odg
  /home/tommaso/ooooo.odg: OpenDocument Drawing

which however fails with Dia compressed diagrams:

  $ file ~/a.dia
  /home/tommaso/a.dia: gzip compressed data, from Unix, max compression

  bool FileName::isZippedFile() const
  {
+       string const&  ex = extension();
+       bool zipped_format = (ex == "odg" || ex == "sxd"
+               || ex == "odt" || ex == "sxw" || ex == "docx"
+               || ex == "ods" || ex == "sxc" || ex == "xlsx"
+               || ex == "gnumeric" || ex == "dia");
+       if (zipped_format)
+               return false;
Shouldn't that be "return true"?

I know it seems counter-intuitive. What I observed was that, if isZippedFile() returns true, then LyX thinks the file is zipped and it needs to unzip it before doing anything with it -- maybe this is ok if I have something like "myfigure.eps.gz", or "myfigure.svg.gz", etc.. Now, when I detect (by extension for now) that the file is in a zipped format that is normally managed in its zipped form by tools (e.g., converters, visualizers), then I simply return false, pretending the file is not zipped. This way LyX doesn't try to unzip it, and it calls the converter properly.

Bye,

    T.

Reply via email to