adjust xfig conversion to newer xfig as suggested by Jean-Pierre at

http://www.lyx.org/trac/ticket/3016#comment:6


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@36972 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Georg Baum 2010-12-20 21:35:08 +00:00
parent 77a8eb9288
commit 94160f97c0

View File

@ -2588,7 +2588,7 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
if (!tex_name.empty()) if (!tex_name.empty())
filename = tex_name; filename = tex_name;
} }
bool xfig = false; bool external = false;
string outname; string outname;
if (makeAbsPath(filename, path).exists()) { if (makeAbsPath(filename, path).exists()) {
string const abstexname = string const abstexname =
@ -2600,20 +2600,53 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
fix_relative_filename(filename); fix_relative_filename(filename);
string const lyxname = string const lyxname =
changeExtension(filename, ".lyx"); changeExtension(filename, ".lyx");
if (t.cs() == "input" && FileName(absfigname).exists()) { bool xfig = false;
external = FileName(absfigname).exists();
if (t.cs() == "input") {
string const ext = getExtension(abstexname);
// Combined PS/LaTeX:
// x.eps, x.pstex_t (old xfig)
// x.pstex, x.pstex_t (new xfig, e.g. 3.2.5)
FileName const absepsname( FileName const absepsname(
changeExtension(abstexname, ".eps")); changeExtension(abstexname, ".eps"));
FileName const abspstexname(
changeExtension(abstexname, ".pstex"));
bool const xfigeps =
(absepsname.exists() ||
abspstexname.exists()) &&
ext == "pstex_t";
// Combined PDF/LaTeX:
// x.pdf, x.pdftex_t (old xfig)
// x.pdf, x.pdf_t (new xfig, e.g. 3.2.5)
FileName const abspdfname( FileName const abspdfname(
changeExtension(abstexname, ".pdf")); changeExtension(abstexname, ".pdf"));
string const ext = getExtension(abstexname);
bool const xfigpdf = bool const xfigpdf =
abspdfname.exists() && ext == "pdftex_t"; abspdfname.exists() &&
bool const xfigeps = (ext == "pdftex_t" || ext == "pdf_t");
absepsname.exists() && ext == "pstex_t";
xfig = xfigpdf || xfigeps; // Combined PS/PDF/LaTeX:
// x_pspdftex.eps, x_pspdftex.pdf, x.pspdftex
string const absbase2(
removeExtension(abstexname) + "_pspdftex");
FileName const abseps2name(
addExtension(absbase2, ".eps"));
FileName const abspdf2name(
addExtension(absbase2, ".pdf"));
bool const xfigboth =
abspdf2name.exists() &&
abseps2name.exists() && ext == "pspdftex";
xfig = xfigpdf || xfigeps || xfigboth;
external = external && xfig;
} }
if (xfig) { if (external) {
outname = changeExtension(filename, ".fig"); outname = changeExtension(filename, ".fig");
} else if (xfig) {
// Don't try to convert, the result
// would be full of ERT.
outname = filename;
} else if (t.cs() != "verbatiminput" && } else if (t.cs() != "verbatiminput" &&
tex2lyx(abstexname, FileName(abslyxname), tex2lyx(abstexname, FileName(abslyxname),
p.getEncoding())) { p.getEncoding())) {
@ -2626,7 +2659,7 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
<< filename << "'." << endl; << filename << "'." << endl;
outname = filename; outname = filename;
} }
if (xfig) { if (external) {
begin_inset(os, "External\n"); begin_inset(os, "External\n");
os << "\ttemplate XFig\n" os << "\ttemplate XFig\n"
<< "\tfilename " << outname << '\n'; << "\tfilename " << outname << '\n';