+ && tocdepth == tclass.tocdepth();
+}
+
+
+DocumentClass const & BufferParams::documentClass() const
+{
+ return *doc_class_;
+}
+
+
+DocumentClass * BufferParams::documentClassPtr() const {
+ return doc_class_;
+}
+
+
+void BufferParams::setDocumentClass(DocumentClass const * const tc) {
+ // evil, but this function is evil
+ doc_class_ = const_cast<DocumentClass *>(tc);
+}
+
+
+bool BufferParams::setBaseClass(string const & classname)
+{
+ LYXERR(Debug::TCLASS, "setBaseClass: " << classname);
+ LayoutFileList const & bcl = LayoutFileList::get();
+ if (!bcl.haveClass(classname)) {
+ docstring s =
+ bformat(_("The document class %1$s could not be found."),
+ from_utf8(classname));
+ frontend::Alert::error(_("Class not found"), s);
+ return false;
+ }
+
+ if (bcl[classname].load()) {
+ pimpl_->baseClass_ = classname;
+ return true;
+ }
+
+ docstring s =
+ bformat(_("The document class %1$s could not be loaded."),
+ from_utf8(classname));
+ frontend::Alert::error(_("Could not load class"), s);
+ return false;
+}
+
+
+LayoutFile const * BufferParams::baseClass() const
+{
+ if (LayoutFileList::get().haveClass(pimpl_->baseClass_))
+ return &(LayoutFileList::get()[pimpl_->baseClass_]);
+ else
+ return 0;
+}
+
+
+LayoutFileIndex const & BufferParams::baseClassID() const
+{
+ return pimpl_->baseClass_;
+}
+
+
+void BufferParams::makeDocumentClass()
+{
+ if (!baseClass())
+ return;
+
+ doc_class_ = &(DocumentClassBundle::get().newClass(*baseClass()));
+
+ //FIXME It might be worth loading the children's modules here,
+ //just as we load their bibliographies and such, instead of just
+ //doing a check in InsetInclude.
+ LayoutModuleList::const_iterator it = layoutModules_.begin();
+ for (; it != layoutModules_.end(); it++) {
+ string const modName = *it;
+ LyXModule * lm = moduleList[modName];
+ if (!lm) {
+ docstring const msg =
+ bformat(_("The module %1$s has been requested by\n"
+ "this document but has not been found in the list of\n"
+ "available modules. If you recently installed it, you\n"
+ "probably need to reconfigure LyX.\n"), from_utf8(modName));
+ frontend::Alert::warning(_("Module not available"),
+ msg + _("Some layouts may not be available."));
+ lyxerr << "BufferParams::makeDocumentClass(): Module " <<
+ modName << " requested but not found in module list." <<
+ endl;
+ continue;
+ }
+ if (!lm->isAvailable()) {
+ docstring const msg =
+ bformat(_("The module %1$s requires a package that is\n"
+ "not available in your LaTeX installation. LaTeX output\n"
+ "may not be possible.\n"), from_utf8(modName));
+ frontend::Alert::warning(_("Package not available"), msg);
+ }
+ FileName layout_file = libFileSearch("layouts", lm->getFilename());
+ if (!doc_class_->read(layout_file, TextClass::MODULE)) {
+ docstring const msg =
+ bformat(_("Error reading module %1$s\n"), from_utf8(modName));
+ frontend::Alert::warning(_("Read Error"), msg);
+ }
+ }