From 660732d74a5c56d20112e18a1d89da1a84e05cc0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20Gullik=20Bj=C3=B8nnes?= Date: Wed, 6 Mar 2002 14:24:34 +0000 Subject: [PATCH] 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 --- src/ChangeLog | 8 ++++++++ src/buffer.C | 8 +++++++- src/insets/insetert.C | 5 ++++- src/paragraph.C | 5 +++++ 4 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 04d4b15f99..04c8983bce 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,11 @@ +2002-03-06 Lars Gullik Bjønnes + + * 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 * CutAndPaste.C (copySelection): set layout for new paragraph. diff --git a/src/buffer.C b/src/buffer.C index 5164fdf482..ad3ac81b45 100644 --- a/src/buffer.C +++ b/src/buffer.C @@ -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" diff --git a/src/insets/insetert.C b/src/insets/insetert.C index 2d6463f0b8..415879dbdd 100644 --- a/src/insets/insetert.C +++ b/src/insets/insetert.C @@ -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(this)); return string(); } + void InsetERT::getDrawFont(LyXFont & font) const { #ifndef INHERIT_LANG diff --git a/src/paragraph.C b/src/paragraph.C index 618504e940..6cd8122d48 100644 --- a/src/paragraph.C +++ b/src/paragraph.C @@ -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.