+string const InsetGraphics::prepareFile(Buffer const *buf) const
+{
+ // do_convert = Do we need to convert the file?
+ // nice = Do we create a nice version?
+ // This is used when exporting the latex file only.
+ // if (!do_convert)
+ // return original filename
+ // if (!nice)
+ // convert_place = temp directory
+ // return new filename in temp directory
+ // else
+ // convert_place = original file directory
+ // return original filename without the extension
+ //
+ // if it's a zipped one, than let LaTeX do the rest!!!
+ if ((zippedFile(params.filename) && params.noUnzip) || buf->niceFile) {
+ lyxerr[Debug::INFO] << "don't unzip file or export latex"
+ << params.filename << endl;
+ return params.filename;
+ }
+ string filename_ = params.filename;
+ if (zippedFile(filename_))
+ filename_ = unzipFile(filename_);
+ // now we have unzipped files
+ // Get the extension (format) of the original file.
+ // we handle it like a virtual one, so we can have
+ // different extensions with the same type.
+ string const extension = getExtFromContents(filename_);
+ // are we usind latex ((e)ps) or pdflatex (pdf,jpg,png)
+ string const image_target = decideOutputImageFormat(extension);
+ if (extension == image_target) // :-)
+ return filename_;
+// commented out to check if the "not exist"bug is fixed.
+// if (!IsFileReadable(filename_)) { // :-(
+// Alert::alert(_("File") + params.filename,
+// _("isn't readable or doesn't exists!"));
+// return filename_;
+// }
+ string outfile;
+ string const temp = AddName(buf->tmppath, filename_);
+ outfile = RemoveExtension(temp);
+ lyxerr[Debug::INFO] << "tempname = " << temp << "\n";
+ lyxerr[Debug::INFO] << "buf::tmppath = " << buf->tmppath << "\n";
+ lyxerr[Debug::INFO] << "filename_ = " << filename_ << "\n";
+ lyxerr[Debug::INFO] << "outfile = " << outfile << endl;
+ converters.convert(buf, filename_, outfile, extension, image_target);
+ return outfile;
+}