}
-void BufferParams::setBaseClass(textclass_type tc)
+bool BufferParams::setBaseClass(textclass_type tc)
{
+ if (!textclasslist[tc].load()) {
+ docstring s = bformat(_("The document class %1$s."
+ "could not be loaded."),
+ from_utf8(textclasslist[tc].name()));
+ frontend::Alert::error(_("Could not load class"), s);
+ return false;
+ }
+
baseClass_ = tc;
makeTextClass();
+ return true;
}
///Set the LyX TextClass (that is, the layout file) this document is using.
///NOTE This also calls makeTextClass(), to update the local
///TextClass.
- void setBaseClass(textclass_type);
+ bool setBaseClass(textclass_type);
///Returns the TextClass currently in use: the BaseClass as modified
///by modules.
TextClass const & getTextClass() const;
// This must come first so that a language change is correctly noticed
setLanguage();
- // Set the document class.
- textclass_type const old_class =
- kernel().buffer().params().getBaseClass();
- textclass_type const new_class = bp_->getBaseClass();
- if (new_class != old_class) {
- string const name = textclasslist[new_class].name();
- kernel().dispatch(FuncRequest(LFUN_TEXTCLASS_APPLY, name));
- }
-
- int const old_secnumdepth = kernel().buffer().params().secnumdepth;
- int const new_secnumdepth = bp_->secnumdepth;
-
- // Apply the BufferParams.
+ // Apply the BufferParams. Note that this will set the base class
+ // and then update the buffer's layout.
+ //FIXME Could this be done last? Then, I think, we'd get the automatic
+ //update mentioned in the next FIXME...
dispatch_bufferparams(kernel(), params(), LFUN_BUFFER_PARAMS_APPLY);
- // redo the numbering if necessary
- if (new_secnumdepth != old_secnumdepth)
- updateLabels(kernel().buffer());
-
// Generate the colours requested by each new branch.
BranchList & branchlist = params().branchlist();
if (!branchlist.empty()) {
}
-bool ControlDocument::loadTextclass(textclass_type tc) const
-{
- string const name = textclasslist[tc].name();
- kernel().dispatch(FuncRequest(LFUN_TEXTCLASS_LOAD, name));
-
- // Report back whether we were able to change the class.
- bool const success = textclasslist[tc].loaded();
- return success;
-}
-
-
void ControlDocument::saveAsDefault() const
{
dispatch_bufferparams(kernel(), params(), LFUN_BUFFER_SAVE_AS_DEFAULT);
void GuiDocumentDialog::classChanged()
{
- ControlDocument & cntrl = form_->controller();
- BufferParams & params = cntrl.params();
-
+ BufferParams & params = form_->controller().params();
textclass_type const tc = latexModule->classCO->currentIndex();
-
- if (form_->controller().loadTextclass(tc)) {
- params.setJustBaseClass(tc);
- if (lyxrc.auto_reset_options)
- params.useClassDefaults();
- form_->update_contents();
- } else {
- latexModule->classCO->setCurrentIndex(params.getBaseClass());
- }
+ params.setJustBaseClass(tc);
+ if (lyxrc.auto_reset_options)
+ params.useClassDefaults();
+ form_->update_contents();
}