From 0a10c6461677519f5856310653d83fca9276fcdf Mon Sep 17 00:00:00 2001 From: Dekel Tsur Date: Mon, 16 Jul 2001 14:46:31 +0000 Subject: [PATCH] Generate error insets for unknown layouts. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2250 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/ChangeLog | 5 +++++ src/buffer.C | 29 ++++++++++++++++------------- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index c3bbb2f8e6..eae98645e1 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2001-07-16 Dekel Tsur + + * buffer.C (parseSingleLyXformat2Token): Generate error insets + for unknown layouts. + 2001-07-13 Dekel Tsur * buffer.C (readLyXformat2): Generate an error dialog if there are diff --git a/src/buffer.C b/src/buffer.C index 0260aac4a6..7c1ff1b406 100644 --- a/src/buffer.C +++ b/src/buffer.C @@ -298,7 +298,7 @@ ErtComp ert_comp; } // anon -set unknown_layouts; +int unknown_layouts; // candidate for move to BufferView // (at least some parts in the beginning of the func) @@ -310,7 +310,7 @@ set unknown_layouts; // Returns false if "\the_end" is not read for formats >= 2.13. (Asger) bool Buffer::readLyXformat2(LyXLex & lex, Paragraph * par) { - unknown_layouts.clear(); + unknown_layouts = 0; #ifdef NO_LATEX ert_comp.contents.erase(); ert_comp.active = false; @@ -366,17 +366,15 @@ bool Buffer::readLyXformat2(LyXLex & lex, Paragraph * par) paragraph = first_par; - if (!unknown_layouts.empty()) { - string list; - for (set::const_iterator it = unknown_layouts.begin(); - it != unknown_layouts.end(); ++it) { - if (it != unknown_layouts.begin()) - list += ", "; - list += *it; + if (unknown_layouts > 0) { + string s = _("Couldn't set the layout for "); + if (unknown_layouts == 1) { + s += _("one paragraph"); + } else { + s += tostr(unknown_layouts); + s += _(" paragraphs"); } - WriteAlert(_("Textclass Loading Error!"), - _("The following layouts are undefined:"), - list+"."); + WriteAlert(_("Textclass Loading Error!"),s); } return the_end_read; @@ -520,7 +518,12 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, Paragraph *& par, // layout not found // use default layout "Standard" (0) par->layout = 0; - unknown_layouts.insert(layoutname); + ++unknown_layouts; + string const s = _("Layout had to be changed from\n") + + layoutname + _(" to ") + + textclasslist.NameOfLayout(params.textclass, par->layout); + InsetError * new_inset = new InsetError(s); + par->insertInset(0, new_inset); } // Test whether the layout is obsolete. LyXLayout const & layout =