From: Dekel Tsur Date: Wed, 25 Sep 2002 12:19:13 +0000 (+0000) Subject: Fix reading of old format templates X-Git-Tag: 1.6.10~18234 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=c54cbc95c07bbadac32e8aa00d6e9fb2dfccae4a;p=features.git Fix reading of old format templates git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@5342 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/BufferView.C b/src/BufferView.C index cf61629c17..514026d7f5 100644 --- a/src/BufferView.C +++ b/src/BufferView.C @@ -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; diff --git a/src/ChangeLog b/src/ChangeLog index c00f0420a7..754975a056 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2002-09-25 Dekel Tsur + + * buffer.h (readFile): Add a new argument to the method, to allow + reading of old-format templates. + 2002-09-24 Dekel Tsur * toc.C (getTocList): Get TOC from InsetWrap. diff --git a/src/buffer.C b/src/buffer.C index 610f3dd2cd..0acfd71a74 100644 --- a/src/buffer.C +++ b/src/buffer.C @@ -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); diff --git a/src/buffer.h b/src/buffer.h index 6e5a97c29e..bae622f9e8 100644 --- a/src/buffer.h +++ b/src/buffer.h @@ -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. diff --git a/src/bufferlist.C b/src/bufferlist.C index 51e042724c..fc7609c0f7 100644 --- a/src/bufferlist.C +++ b/src/bufferlist.C @@ -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; } }