}
}
+void Preamble::setTextClass(string const tclass, TeX2LyXDocClass & tc)
+{
+ h_textclass = tclass;
+ tc.setName(h_textclass);
+ if (!LayoutFileList::get().haveClass(h_textclass) || !tc.load()) {
+ cerr << "Error: Could not read layout file for textclass \"" << h_textclass << "\"." << endl;
+ exit(EXIT_FAILURE);
+ }
+}
+
namespace {
// Force textclass if the user wanted it
if (!forceclass.empty()) {
- h_textclass = forceclass;
- tc.setName(h_textclass);
- if (!LayoutFileList::get().haveClass(h_textclass) || !tc.load()) {
- cerr << "Error: Could not read layout file for textclass \"" << h_textclass << "\"." << endl;
- exit(EXIT_FAILURE);
- }
+ setTextClass(forceclass, tc);
class_set = true;
}
// Only set text class if a class hasn't been forced
// (this was set above)
if (!class_set) {
- h_textclass = tclass;
- // textclass needs to be set at this place as we need to know
- // it for other parameters (such as class-dependent paper size)
- tc.setName(h_textclass);
- if (!LayoutFileList::get().haveClass(h_textclass) || !tc.load()) {
- cerr << "Error: Could not read layout file for textclass \"" << h_textclass << "\"." << endl;
- exit(EXIT_FAILURE);
- }
+ // textclass needs to be set at this place (if not already done)
+ // as we need to know it for other parameters
+ // (such as class-dependent paper size)
+ setTextClass(tclass, tc);
class_set = true;
}
}
// set textclass if not yet done (snippets without \documentclass and forced class)
- if (!class_set) {
- tc.setName(h_textclass);
- if (!LayoutFileList::get().haveClass(h_textclass) || !tc.load()) {
- cerr << "Error: Could not read layout file for textclass \"" << h_textclass << "\"." << endl;
- exit(EXIT_FAILURE);
- }
- }
-
+ if (!class_set)
+ setTextClass(h_textclass, tc);
+
// remove the whitespace
p.skip_spaces();
void registerAuthor(std::string const & name, std::string const & initials);
/// Get author named \p name (must be registered first)
Author const & getAuthor(std::string const & name) const;
+ /// Set text class
+ void setTextClass(std::string const tclass, TeX2LyXDocClass & tc);
/// Get number of arguments of special table column type \c or -1
/// if no column type \p c exists
int getSpecialTableColumnArguments(char c) const;