handle missing layout gracefully when reading and writing lyx files

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3678 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Lars Gullik Bjønnes 2002-03-06 14:24:34 +00:00
parent 5c84aa9357
commit 660732d74a
4 changed files with 24 additions and 2 deletions

View File

@ -1,3 +1,11 @@
2002-03-06 Lars Gullik Bjønnes <larsbj@birdstep.com>
* paragraph.C (writeFile): if layout is empty write out
defaultLayoutName().
* buffer.C (parseSingleLyXformat2Token): if we have a buggy .lyx
file without named layout we set layout to defaultLayoutName().
2002-03-06 Juergen Vigna <jug@sad.it>
* CutAndPaste.C (copySelection): set layout for new paragraph.

View File

@ -463,8 +463,14 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, Paragraph *& par,
insertErtContents(par, pos);
#endif
lex.eatLine();
string const layoutname = lex.getString();
string layoutname = lex.getString();
LyXTextClass const & tclass = textclasslist[params.textclass];
if (layoutname.empty()) {
layoutname = tclass.defaultLayoutName();
}
bool hasLayout = tclass.hasLayout(layoutname);
if (!hasLayout) {
lyxerr << "Layout '" << layoutname << "' does not"

View File

@ -631,6 +631,7 @@ void InsetERT::status(BufferView * bv, ERTStatus const st) const
need_update = FULL;
switch (st) {
case Inlined:
#warning Another gross hack. (Lgb)
if (bv)
inset.setUpdateStatus(bv, InsetText::INIT);
break;
@ -674,12 +675,14 @@ void InsetERT::close(BufferView * bv) const
}
string const InsetERT::selectNextWordToSpellcheck(BufferView * bv,float &) const
string const InsetERT::selectNextWordToSpellcheck(BufferView * bv,
float &) const
{
bv->unlockInset(const_cast<InsetERT *>(this));
return string();
}
void InsetERT::getDrawFont(LyXFont & font) const
{
#ifndef INHERIT_LANG

View File

@ -187,6 +187,11 @@ void Paragraph::writeFile(Buffer const * buf, ostream & os,
}
// First write the layout
string lay = layout();
if (lay.empty()) {
lay = textclasslist[bparams.textclass].defaultLayoutName();
}
os << "\n\\layout " << layout() << "\n";
// Maybe some vertical spaces.