errorList.push_back(ErrorItem(_("Document header error"),
s, -1, 0, 0));
}
+
+ params().makeTextClass();
return unknown_tokens;
}
BOOST_ASSERT(paragraphs().empty());
readHeader(lex);
- TextClass const & baseClass = textclasslist[params().getBaseClass()];
- if (!baseClass.load(filePath())) {
- string theclass = baseClass.name();
- Alert::error(_("Can't load document class"), bformat(
- _("Using the default document class, because the "
- "class %1$s could not be loaded."), from_utf8(theclass)));
- params().setBaseClass(defaultTextclass());
- }
if (params().outputChanges) {
bool dvipost = LaTeXFeatures::isAvailable("dvipost");
: pimpl_(new Impl)
{
setBaseClass(defaultTextclass());
+ makeTextClass();
paragraph_separation = PARSEP_INDENT;
quotes_language = InsetQuotes::EnglishQ;
fontsize = "default";
readPreamble(lex);
} else if (token == "\\begin_modules") {
readModules(lex);
- makeTextClass();
} else if (token == "\\options") {
lex.eatLine();
options = lex.getString();
bool BufferParams::setBaseClass(textclass_type tc)
{
- bool retVal = true;
- if (textclasslist[tc].load())
+ if (textclasslist[tc].load()) {
baseClass_ = tc;
- else {
- 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);
- retVal = false;
+ return true;
}
- makeTextClass();
- return retVal;
-}
-
-
-void BufferParams::setJustBaseClass(textclass_type tc)
-{
- baseClass_ = tc;
+
+ 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;
}
void BufferParams::makeTextClass()
{
textClass_.reset(new TextClass(textclasslist[getBaseClass()]));
+
//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.
-bool BufferParams::addLayoutModule(string modName, bool makeClass) {
+bool BufferParams::addLayoutModule(string modName) {
LayoutModuleList::const_iterator it = layoutModules_.begin();
LayoutModuleList::const_iterator end = layoutModules_.end();
for (; it != end; it++) {
if (it != layoutModules_.end())
return false;
layoutModules_.push_back(modName);
- if (makeClass)
- makeTextClass();
return true;
}
-
+/* This is not currently used but may prove useful
bool BufferParams::addLayoutModules(vector<string>modNames)
{
bool retval = true;
vector<string>::const_iterator it = modNames.begin();
vector<string>::const_iterator end = modNames.end();
for (; it != end; ++it)
- retval &= addLayoutModule(*it, false);
- makeTextClass();
+ retval &= addLayoutModule(*it);
return retval;
}
-
+*/
void BufferParams::clearLayoutModules() {
layoutModules_.clear();
- makeTextClass();
}
std::string fontsize;
///Get the LyX TextClass (that is, the layout file) this document is using.
textclass_type getBaseClass() const;
- ///Set the LyX TextClass (that is, the layout file) this document is using.
- ///NOTE This also calls makeTextClass(), to update the local
- ///TextClass.
+ /// Set the LyX TextClass (that is, the layout file) this document is using.
+ /// NOTE: This does not call makeTextClass() to update the local TextClass.
+ /// That needs to be done manually.
bool setBaseClass(textclass_type);
- ///Returns the TextClass currently in use: the BaseClass as modified
- ///by modules.
+ /// Adds the module information to the baseClass information to
+ /// create our local TextClass.
+ void makeTextClass();
+ /// Returns the TextClass currently in use: the BaseClass as modified
+ /// by modules.
TextClass const & getTextClass() const;
- ///Returns a pointer to the TextClass currently in use: the BaseClass
- ///as modified by modules. (See \file TextClassPtr.h for the typedef.)
+ /// Returns a pointer to the TextClass currently in use: the BaseClass
+ /// as modified by modules. (See \file TextClassPtr.h for the typedef.)
TextClassPtr getTextClassPtr() const;
- ///Set the LyX TextClass---layout file---this document is using.
- ///This does NOT call makeTextClass() and so should be used with
- ///care. This is most likely not what you want if you are operating on
- ///BufferParams that are actually associatd with a Buffer. If, on the
- ///other hand, you are using a temporary set of BufferParams---say, in
- ///a controller, it may well be, since in that case the local TextClass
- ///has nothing to do.
- void setJustBaseClass(textclass_type);
/// This bypasses the baseClass and sets the textClass directly.
/// Should be called with care and would be better not being here,
/// but it seems to be needed by CutAndPaste::putClipboard().
std::vector<std::string> const & getModules() const;
/// Add a module to the list of modules in use.
/// Returns true if module was successfully added.
- bool addLayoutModule(std::string modName, bool makeClass = true);
- /// Add a list of modules.
- /// Returns true if all modules were successfully added.
- bool addLayoutModules(std::vector<std::string>modNames);
+ /// The makeClass variable signals whether to call makeTextClass. This
+ /// need not be done if we know this isn't the final time through, or if
+ /// the BufferParams do not represent the parameters for an actual buffer
+ /// (as in GuiDocument).
+ bool addLayoutModule(std::string modName);
+ // Add a list of modules.
+ // Returns true if all modules were successfully added.
+ // Currently unused.
+ // bool addLayoutModules(std::vector<std::string>modNames);
/// Clear the list
void clearLayoutModules();
void readBulletsLaTeX(Lexer &);
///
void readModules(Lexer &);
- /// Adds the module information to the baseClass information to
- /// create our local TextClass.
- void makeTextClass();
-
/// for use with natbib
biblio::CiteEngine cite_engine_;
/// the base TextClass associated with the document
TextClassPtr oldClass = buffer->params().getTextClassPtr();
view()->cursor().recordUndoFullDocument();
buffer->params().clearLayoutModules();
+ buffer->params().makeTextClass();
updateLayout(oldClass, buffer);
updateFlags = Update::Force | Update::FitCursor;
break;
TextClassPtr oldClass = buffer->params().getTextClassPtr();
view()->cursor().recordUndoFullDocument();
buffer->params().addLayoutModule(argument);
+ buffer->params().makeTextClass();
updateLayout(oldClass, buffer);
updateFlags = Update::Force | Update::FitCursor;
break;
TextClassPtr oldClass = buffer->params().getTextClassPtr();
view()->cursor().recordUndoFullDocument();
buffer->params().setBaseClass(new_class);
+ buffer->params().makeTextClass();
updateLayout(oldClass, buffer);
updateFlags = Update::Force | Update::FitCursor;
break;
textclass_type const tc = buffer->params().getBaseClass();
textclasslist.reset(tc);
buffer->params().setBaseClass(tc);
+ buffer->params().makeTextClass();
updateLayout(oldClass, buffer);
updateFlags = Update::Force | Update::FitCursor;
break;
void GuiDocument::classChanged()
{
textclass_type const tc = latexModule->classCO->currentIndex();
- bp_.setJustBaseClass(tc);
+ bp_.setBaseClass(tc);
if (lyxrc.auto_reset_options)
bp_.useClassDefaults();
updateContents();
params.graphicsDriver =
tex_graphics[latexModule->psdriverCO->currentIndex()];
+ // text layout
+ params.setBaseClass(latexModule->classCO->currentIndex());
+
// Modules
params.clearLayoutModules();
QStringList const selMods = selectedModel()->stringList();
for (int i = 0; i != selMods.size(); ++i)
params.addLayoutModule(lyx::fromqstr(selMods[i]));
-
if (mathsModule->amsautoCB->isChecked()) {
params.use_amsmath = BufferParams::package_auto;
} else {
params.use_esint = BufferParams::package_off;
}
- // text layout
- params.setJustBaseClass(latexModule->classCO->currentIndex());
-
if (pageLayoutModule->pagestyleCO->currentIndex() == 0)
params.pagestyle = "default";
else {
void GuiDocument::useClassDefaults()
{
- bp_.setJustBaseClass(latexModule->classCO->currentIndex());
+ bp_.setBaseClass(latexModule->classCO->currentIndex());
bp_.useClassDefaults();
updateContents();
}
// 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(*this, params(), LFUN_BUFFER_PARAMS_APPLY);
// Generate the colours requested by each new branch.