I have fixed a small bug in my "missing TeX class" patch, simplified the code, and changed "N/A:" to "No TeX:" (In the dialog, it looks better if we use a _short_ prefix instead of a postfix).
If you like to, you can test the patch. Eagerly awaiting 1.3.1,
Michael
Index: lyx-devel-1.3.Xcvs/lib/chkconfig.ltx =================================================================== RCS file: /cvs/lyx/lyx-devel/lib/chkconfig.ltx,v retrieving revision 1.9 diff -u -r1.9 chkconfig.ltx --- lyx-devel-1.3.Xcvs/lib/chkconfig.ltx 2002/03/01 12:39:19 1.9 +++ lyx-devel-1.3.Xcvs/lib/chkconfig.ltx 2003/01/16 22:50:21 @@ -59,9 +59,9 @@ % the variable chk_<name>. %%% \newcommand{\prefix}{+} % the character used by grep to filter 'good' output -\newcommand{\AddLayout}[3][\default]{ +\newcommand{\AddLayout}[4][\default]{ \def\default{#2} - \immediate\write\layouts{"#2" "#1" "#3"}} + \immediate\write\layouts{"#2" "#1" "#3" "#4"}} \newcommand{\AddVariable}[2]{ \immediate\write\sed{s!@chk_#1@!#2!g} \immediate\write\vars{chk_#1='#2'}} @@ -107,15 +107,17 @@ } \newcommand{\DeclareLaTeXClass}[2][\default]{ \TestItem[#1]{\layoutname}{document class}{cls} - {\AddLayout[\firstelement]{\layoutname}{#2}}{} + {\AddLayout[\firstelement]{\layoutname}{#2}{true}} + {\AddLayout[\firstelement]{\layoutname}{#2}{false}} \expandafter\endinput } \newcommand{\DeclareLinuxDocClass}[2][\default]{ \message{^^J\prefix checking for linuxdoc class \layoutname... } \@ifundefined{haslinuxdoc} - {\message{no^^J}} + {\message{no^^J} + \AddLayout[#1]{\layoutname}{#2}{false}} {\message{yes^^J} - \AddLayout[#1]{\layoutname}{#2}} + \AddLayout[#1]{\layoutname}{#2}{true}} \expandafter\endinput } % Only for compatibility. Will be removed later. @@ -124,9 +126,10 @@ \newcommand{\DeclareDocBookClass}[2][\default]{ \message{^^J\prefix checking for docbook\space\space class \layoutname... } \@ifundefined{hasdocbook} - {\message{no^^J}} + {\message{no^^J} + \AddLayout[#1]{\layoutname}{#2}{false}} {\message{yes^^J} - \AddLayout[#1]{\layoutname}{#2}} + \AddLayout[#1]{\layoutname}{#2}{true}} \expandafter\endinput } Index: lyx-devel-1.3.Xcvs/src/MenuBackend.C =================================================================== RCS file: /cvs/lyx/lyx-devel/src/MenuBackend.C,v retrieving revision 1.63 diff -u -r1.63 MenuBackend.C --- lyx-devel-1.3.Xcvs/src/MenuBackend.C 2003/01/16 10:41:14 1.63 +++ lyx-devel-1.3.Xcvs/src/MenuBackend.C 2003/01/16 22:50:30 @@ -352,7 +352,7 @@ action = LFUN_PREVIEW; break; case MenuItem::UpdateFormats: - formats = Exporter::GetExportableFormats(buf, false); + formats = Exporter::GetExportableFormats(buf, true); action = LFUN_UPDATE; break; default: Index: lyx-devel-1.3.Xcvs/src/buffer.C =================================================================== RCS file: /cvs/lyx/lyx-devel/src/buffer.C,v retrieving revision 1.397 diff -u -r1.397 buffer.C --- lyx-devel-1.3.Xcvs/src/buffer.C 2003/01/16 21:17:08 1.397 +++ lyx-devel-1.3.Xcvs/src/buffer.C 2003/01/16 22:50:38 @@ -621,13 +621,13 @@ #if USE_BOOST_FORMAT Alert::alert(_("Textclass error"), boost::io::str(boost::format(_("The document uses an unknown textclass \"%1$s\".")) % lex.getString()), - _("LyX will not be able to produce output correctly.")); + _("-- substituting default.")); #else Alert::alert( _("Textclass error"), _("The document uses an unknown textclass ") + lex.getString(), - _("LyX will not be able to produce output correctly.")); + _("-- substituting default.")); #endif params.textclass = 0; } @@ -649,6 +649,19 @@ _("-- substituting default")); #endif params.textclass = 0; + } + if (!params.getLyXTextClass().isTeXClassAvailable()) { +#if USE_BOOST_FORMAT + Alert::alert(_("Textclass error"), + boost::io::str(boost::format(_("The document uses a +missing TeX class \"%1$s\".")) % lex.getString()), + _("LyX will not be able to produce output.")); +#else + Alert::alert( + _("Textclass error"), + _("The document uses a missing TeX class ") + + lex.getString(), + _("LyX will not be able to produce output.")); +#endif } } else if (token == "\\options") { lex.eatLine(); Index: lyx-devel-1.3.Xcvs/src/exporter.C =================================================================== RCS file: /cvs/lyx/lyx-devel/src/exporter.C,v retrieving revision 1.25 diff -u -r1.25 exporter.C --- lyx-devel-1.3.Xcvs/src/exporter.C 2003/01/06 14:02:21 1.25 +++ lyx-devel-1.3.Xcvs/src/exporter.C 2003/01/16 22:50:39 @@ -129,10 +129,19 @@ bool Exporter::IsExportable(Buffer const * buffer, string const & format) { vector<string> backends = Backends(buffer); - for (vector<string>::const_iterator it = backends.begin(); - it != backends.end(); ++it) + + vector<string>::const_iterator beg = backends.begin(); + vector<string>::const_iterator end = backends.end(); + vector<string>::const_iterator it = beg; + + for (; it != end; ++it) { + if (it == beg && + !buffer->params.getLyXTextClass().isTeXClassAvailable()) + continue; + if (converters.isReachable(*it, format)) return true; + } return false; } @@ -141,13 +150,21 @@ Exporter::GetExportableFormats(Buffer const * buffer, bool only_viewable) { vector<string> backends = Backends(buffer); - vector<Format const *> result = - converters.getReachable(backends[0], only_viewable, true); - for (vector<string>::const_iterator it = backends.begin() + 1; - it != backends.end(); ++it) { - vector<Format const *> r = - converters.getReachable(*it, only_viewable, false); - result.insert(result.end(), r.begin(), r.end()); + vector<Format const *> result; + bool clear = true; + + vector<string>::const_iterator beg = backends.begin(); + vector<string>::const_iterator end = backends.end(); + vector<string>::const_iterator it = beg; + + for (; it != end; ++it) { + if (it != beg || + buffer->params.getLyXTextClass().isTeXClassAvailable()) { + vector<Format const *> r = + converters.getReachable(*it, only_viewable, clear); + clear = false; + result.insert(result.end(), r.begin(), r.end()); + } } return result; } Index: lyx-devel-1.3.Xcvs/src/lyxfunc.C =================================================================== RCS file: /cvs/lyx/lyx-devel/src/lyxfunc.C,v retrieving revision 1.391 diff -u -r1.391 lyxfunc.C --- lyx-devel-1.3.Xcvs/src/lyxfunc.C 2003/01/09 14:31:24 1.391 +++ lyx-devel-1.3.Xcvs/src/lyxfunc.C 2003/01/16 22:50:44 @@ -327,8 +327,7 @@ || lyxrc.print_command == "none"; break; case LFUN_EXPORT: - disable = ev.argument == "fax" && - !Exporter::IsExportable(buf, ev.argument); + disable = !Exporter::IsExportable(buf, ev.argument); break; case LFUN_UNDO: disable = buf->undostack.empty(); Index: lyx-devel-1.3.Xcvs/src/lyxtextclass.C =================================================================== RCS file: /cvs/lyx/lyx-devel/src/lyxtextclass.C,v retrieving revision 1.22 diff -u -r1.22 lyxtextclass.C --- lyx-devel-1.3.Xcvs/src/lyxtextclass.C 2002/11/27 10:30:13 1.22 +++ lyx-devel-1.3.Xcvs/src/lyxtextclass.C 2003/01/16 22:50:45 @@ -49,9 +49,9 @@ LyXTextClass::LyXTextClass(string const & fn, string const & cln, - string const & desc) + string const & desc, bool texClassAvail ) : name_(fn), latexname_(cln), description_(desc), - floatlist_(new FloatList), ctrs_(new Counters) + floatlist_(new FloatList), ctrs_(new Counters), texClassAvail(texClassAvail) { outputType_ = LATEX; columns_ = 1; @@ -65,6 +65,11 @@ opt_pagestyle_ = "empty|plain|headings|fancy"; provides_ = nothing; loaded = false; +} + + +bool LyXTextClass::isTeXClassAvailable() const { + return texClassAvail; } Index: lyx-devel-1.3.Xcvs/src/lyxtextclass.h =================================================================== RCS file: /cvs/lyx/lyx-devel/src/lyxtextclass.h,v retrieving revision 1.11 diff -u -r1.11 lyxtextclass.h --- lyx-devel-1.3.Xcvs/src/lyxtextclass.h 2002/11/07 19:51:22 1.11 +++ lyx-devel-1.3.Xcvs/src/lyxtextclass.h 2003/01/16 22:50:46 @@ -39,8 +39,12 @@ explicit LyXTextClass(string const & = string(), string const & = string(), - string const & = string()); + string const & = string(), + bool = false ); + /// check whether the TeX class is available + bool isTeXClassAvailable() const; + /// paragraph styles begin iterator. const_iterator begin() const { return layoutlist_.begin(); } /// paragraph styles end iterator @@ -142,6 +146,8 @@ /// int size() const; private: + /// Is the TeX class available? + bool texClassAvail; /// bool delete_layout(string const &); /// Index: lyx-devel-1.3.Xcvs/src/lyxtextclasslist.C =================================================================== RCS file: /cvs/lyx/lyx-devel/src/lyxtextclasslist.C,v retrieving revision 1.9 diff -u -r1.9 lyxtextclasslist.C --- lyx-devel-1.3.Xcvs/src/lyxtextclasslist.C 2002/11/27 10:30:13 1.9 +++ lyx-devel-1.3.Xcvs/src/lyxtextclasslist.C 2003/01/16 22:50:46 @@ -69,7 +69,9 @@ class less_textclass_desc { public: int operator()(LyXTextClass const & tc1, LyXTextClass const & tc2) { - return tc1.description() < tc2.description(); + return (tc1.isTeXClassAvailable() && !tc2.isTeXClassAvailable()) || + (tc1.isTeXClassAvailable() == tc2.isTeXClassAvailable() && + tc1.description() < tc2.description()); } }; @@ -130,13 +132,18 @@ if (lex.next()) { string const desc = lex.getString(); lyxerr[Debug::TCLASS] << "Desc: " << desc << endl; - // This code is run when we have - // fname, clname and desc - LyXTextClass tmpl(fname, clname, desc); - if (lyxerr.debugging(Debug::TCLASS)) { - tmpl.load(); + if (lex.next()) { + string const avail = lex.getString(); + lyxerr[Debug::TCLASS] << "Available: " +<< desc << endl; + // This code is run when we have + // fname, clname, desc, and avail + LyXTextClass tmpl(fname, clname, desc, + avail == "true" ? +true : false ); + if (lyxerr.debugging(Debug::TCLASS)) { + tmpl.load(); + } + classlist_.push_back(tmpl); } - classlist_.push_back(tmpl); } } } Index: lyx-devel-1.3.Xcvs/src/frontends/qt2/QDocument.C =================================================================== RCS file: /cvs/lyx/lyx-devel/src/frontends/qt2/QDocument.C,v retrieving revision 1.32 diff -u -r1.32 QDocument.C --- lyx-devel-1.3.Xcvs/src/frontends/qt2/QDocument.C 2003/01/16 10:56:48 1.32 +++ lyx-devel-1.3.Xcvs/src/frontends/qt2/QDocument.C 2003/01/16 22:50:58 @@ -115,7 +115,12 @@ // layout for (LyXTextClassList::const_iterator cit = textclasslist.begin(); cit != textclasslist.end(); ++cit) { - dialog_->layoutModule->classCO->insertItem(toqstr(cit->description())); + if (cit->isTeXClassAvailable()) { + +dialog_->layoutModule->classCO->insertItem(toqstr(cit->description())); + } else { + dialog_->layoutModule->classCO->insertItem(toqstr("No TeX: " + + +cit->description())); + } } for (int n = 0; tex_fonts[n][0]; ++n) { @@ -463,13 +468,7 @@ // layout - for (int n = 0; n<dialog_->layoutModule->classCO->count(); ++n) { - if (dialog_->layoutModule->classCO->text(n) == - toqstr(controller().textClass().description())) { - dialog_->layoutModule->classCO->setCurrentItem(n); - break; - } - } + dialog_->layoutModule->classCO->setCurrentItem(controller().textClass()); dialog_->updateFontsize(controller().textClass().opt_fontsize(), params.fontsize); Index: lyx-devel-1.3.Xcvs/src/frontends/xforms/FormDocument.C =================================================================== RCS file: /cvs/lyx/lyx-devel/src/frontends/xforms/FormDocument.C,v retrieving revision 1.125 diff -u -r1.125 FormDocument.C --- lyx-devel-1.3.Xcvs/src/frontends/xforms/FormDocument.C 2002/12/01 21:10:37 1.125 +++ lyx-devel-1.3.Xcvs/src/frontends/xforms/FormDocument.C 2003/01/16 22:51:01 @@ -134,7 +134,11 @@ fl_end_form(); for (LyXTextClassList::const_iterator cit = textclasslist.begin(); cit != textclasslist.end(); ++cit) { - combo_doc_class->addto(cit->description()); + if (cit->isTeXClassAvailable()) { + combo_doc_class->addto(cit->description()); + } else { + combo_doc_class->addto("No TeX: " + cit->description()); + } } fl_addto_choice(class_->choice_doc_spacing, @@ -832,7 +836,7 @@ LyXTextClass const & tclass = textclasslist[params.textclass]; - combo_doc_class->select(tclass.description()); + combo_doc_class->select(params.textclass + 1); fl_clear_choice(class_->choice_doc_fontsize); fl_addto_choice(class_->choice_doc_fontsize, "default"); fl_addto_choice(class_->choice_doc_fontsize,