if (c == '#') {
lyxerr[Debug::INFO] << "Will insert file with header" << endl;
- res = buffer()->readFile(lex, text->cursor.par());
+ res = buffer()->readFile(lex, fname, text->cursor.par());
} else {
lyxerr[Debug::INFO] << "Will insert file without header"
<< endl;
+2002-09-25 Dekel Tsur <dekelts@tau.ac.il>
+
+ * buffer.h (readFile): Add a new argument to the method, to allow
+ reading of old-format templates.
+
2002-09-24 Dekel Tsur <dekelts@tau.ac.il>
* toc.C (getTocList): Get TOC from InsetWrap.
}
-bool Buffer::readFile(LyXLex & lex, Paragraph * par)
+bool Buffer::readFile(LyXLex & lex, string const & filename, Paragraph * par)
{
if (lex.isOK()) {
lex.next();
_("Old LyX file format found. "
"Use LyX 0.10.x to read this!"));
return false;
- } else {
+ } else if (!filename.empty()) {
string command =
LibFileSearch("lyx2lyx", "lyx2lyx");
if (command.empty()) {
}
command += " -t"
+tostr(LYX_FORMAT)+" "
- + QuoteName(filename_);
+ + QuoteName(filename);
+ lyxerr[Debug::INFO] << "Running '"
+ << command << "'" << endl;
cmd_ret const ret = RunCommand(command);
if (ret.first) {
Alert::alert(_("ERROR!"),
istringstream is(ret.second);
LyXLex tmplex(0, 0);
tmplex.setStream(is);
- return readFile(tmplex);
+ return readFile(tmplex, string());
+ } else {
+ // This code is reached if lyx2lyx failed (for
+ // some reason) to change the file format of
+ // the file.
+ lyx::Assert(false);
+ return false;
}
}
bool the_end = readLyXformat2(lex, par);
\param par if != 0 insert the file.
\return \c false if method fails.
*/
- bool readFile(LyXLex &, Paragraph * par = 0);
+ bool readFile(LyXLex &, string const &, Paragraph * par = 0);
/** Reads a file without header.
\param par if != 0 insert the file.
// not sure if this is the correct place to begin LyXLex
LyXLex lex(0, 0);
lex.setFile(ts);
- if (b->readFile(lex))
+ if (b->readFile(lex, ts))
return b;
else {
bstore.release(b);
LyXLex lex(0, 0);
lex.setFile(tname);
if (lex.isOK()) {
- if (b->readFile(lex)) {
+ if (b->readFile(lex, tname)) {
templateok = true;
}
}