Fix reading of old format templates

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@5342 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Dekel Tsur 2002-09-25 12:19:13 +00:00
parent 25d9537fbd
commit c54cbc95c0
5 changed files with 21 additions and 8 deletions

View File

@ -315,7 +315,7 @@ bool BufferView::insertLyXFile(string const & filen)
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;

View File

@ -1,3 +1,8 @@
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.

View File

@ -1143,7 +1143,7 @@ void Buffer::readInset(LyXLex & lex, Paragraph *& par,
}
bool Buffer::readFile(LyXLex & lex, Paragraph * par)
bool Buffer::readFile(LyXLex & lex, string const & filename, Paragraph * par)
{
if (lex.isOK()) {
lex.next();
@ -1174,7 +1174,7 @@ bool Buffer::readFile(LyXLex & lex, Paragraph * par)
_("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()) {
@ -1184,7 +1184,9 @@ bool Buffer::readFile(LyXLex & lex, Paragraph * par)
}
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!"),
@ -1195,7 +1197,13 @@ bool Buffer::readFile(LyXLex & lex, Paragraph * par)
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);

View File

@ -108,7 +108,7 @@ public:
\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.

View File

@ -421,7 +421,7 @@ Buffer * BufferList::readFile(string const & s, bool ronly)
// 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);
@ -471,7 +471,7 @@ Buffer * BufferList::newFile(string const & name, string tname, bool isNamed)
LyXLex lex(0, 0);
lex.setFile(tname);
if (lex.isOK()) {
if (b->readFile(lex)) {
if (b->readFile(lex, tname)) {
templateok = true;
}
}