/* This file is part of
- * ======================================================
- *
+ * ======================================================
+ *
* LyX, The Document Processor
- *
+ *
* Copyright 1995 Matthias Ettrich
* Copyright 1995-2001 The LyX Team.
*
#include <utility>
-using lyx::layout_type;
+#ifndef CXX_GLOBAL_CSTD
+using std::exit;
+#endif
+
using lyx::textclass_type;
using std::pair;
using std::make_pair;
using std::endl;
+using std::find_if;
+using std::sort;
// Gets textclass number from name
}
-// Gets layout structure from style number and textclass number
-LyXLayout const &
-LyXTextClassList::Style(textclass_type textclass,
- layout_type layout) const
-{
- classlist[textclass].load();
- if (layout < classlist[textclass].numLayouts())
- return classlist[textclass][layout];
- return classlist[textclass][0];
-}
-
-
-// Gets layout number from name and textclass number
-pair<bool, layout_type> const
-LyXTextClassList::NumberOfLayout(textclass_type textclass,
- string const & name) const
-{
- classlist[textclass].load();
- for (unsigned int i = 0; i < classlist[textclass].numLayouts(); ++i) {
- if (classlist[textclass][i].name() == name)
- return make_pair(true, i);
- }
- return make_pair(false, layout_type(0)); // not found
-}
-
-
-// Gets a layout (style) name from layout number and textclass number
-string const &
-LyXTextClassList::NameOfLayout(textclass_type textclass,
- layout_type layout) const
-{
- static string const dummy("dummy");
- classlist[textclass].load();
- if (layout < classlist[textclass].numLayouts())
- return classlist[textclass][layout].name();
- return dummy;
-}
-
-
-// Gets a textclass name from number
-string const &
-LyXTextClassList::NameOfClass(textclass_type number) const
-{
- static string const dummy("dummy");
- if (classlist.empty()) {
- return dummy;
- }
- lyx::Assert(number < classlist.size());
- return classlist[number].name();
-}
-
-
-// Gets a textclass latexname from number
-string const &
-LyXTextClassList::LatexnameOfClass(textclass_type number) const
-{
- static string const dummy("dummy");
- classlist[number].load();
- if (classlist.empty()) {
- return dummy;
- }
- lyx::Assert(number < classlist.size());
- return classlist[number].latexname();
-}
-
-
-// Gets a textclass description from number
-string const &
-LyXTextClassList::DescOfClass(textclass_type number) const
-{
- static string const dummy("dummy");
- if (classlist.empty()) {
- return dummy;
- }
- lyx::Assert(number < classlist.size());
- return classlist[number].description();
-}
-
-
// Gets a textclass structure from number
LyXTextClass const &
-LyXTextClassList::TextClass(textclass_type textclass) const
+LyXTextClassList::operator[](textclass_type textclass) const
{
classlist[textclass].load();
if (textclass < classlist.size())
"lyxlex was not able to set file: "
<< real_file << endl;
}
-
+
if (!lex.isOK()) {
lyxerr << "LyXTextClassList::Read: unable to open "
"textclass file `" << MakeDisplayPath(real_file, 1000)
<< "'\nCheck your installation. LyX can't continue."
<< endl;
- return false;
+ return false;
}
bool finished = false;
lyxerr[Debug::TCLASS] << "Fname: " << fname << endl;
if (lex.next()) {
string const clname = lex.getString();
- lyxerr[Debug::TCLASS]
- << "Clname: " << clname << endl;
+ lyxerr[Debug::TCLASS] << "Clname: " << clname << endl;
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();
- }
- Add (tmpl);
+ 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();
+ }
+ Add(tmpl);
}
}
}
return true;
}
-
-/* Load textclass
- Returns false if this fails
-*/
-bool LyXTextClassList::Load(textclass_type number) const
-{
- bool result = true;
- if (number < classlist.size()) {
- classlist[number].load();
- if (classlist[number].numLayouts() == 0) {
- result = false;
- }
- } else {
- result = false;
- }
- return result;
-}
-
// Global variable: textclass table.
LyXTextClassList textclasslist;
void LyXSetStyle()
{
lyxerr[Debug::TCLASS] << "LyXSetStyle: parsing configuration...\n";
-
+
if (!textclasslist.Read()) {
lyxerr[Debug::TCLASS] << "LyXSetStyle: an error occured "
"during parsing.\n Exiting." << endl;