mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 10:00:33 +00:00
tex2lyx: properly set textclass if no class is given
(snippets without \documentclass and no forced class)
This commit is contained in:
parent
e16b9e8d22
commit
720179947e
@ -2141,6 +2141,7 @@ void Preamble::parse(Parser & p, string const & forceclass,
|
|||||||
bool is_full_document = false;
|
bool is_full_document = false;
|
||||||
bool is_lyx_file = false;
|
bool is_lyx_file = false;
|
||||||
bool in_lyx_preamble = false;
|
bool in_lyx_preamble = false;
|
||||||
|
bool class_set = false;
|
||||||
|
|
||||||
// determine whether this is a full document or a fragment for inclusion
|
// determine whether this is a full document or a fragment for inclusion
|
||||||
while (p.good()) {
|
while (p.good()) {
|
||||||
@ -2161,6 +2162,17 @@ void Preamble::parse(Parser & p, string const & forceclass,
|
|||||||
h_inputencoding != "auto-legacy-plain")
|
h_inputencoding != "auto-legacy-plain")
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
// 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);
|
||||||
|
}
|
||||||
|
class_set = true;
|
||||||
|
}
|
||||||
|
|
||||||
Token const & t = p.get_token();
|
Token const & t = p.get_token();
|
||||||
|
|
||||||
#ifdef FILEDEBUG
|
#ifdef FILEDEBUG
|
||||||
@ -2660,15 +2672,20 @@ void Preamble::parse(Parser & p, string const & forceclass,
|
|||||||
vector<string> opts = split_options(p.getArg('[', ']'));
|
vector<string> opts = split_options(p.getArg('[', ']'));
|
||||||
// FIXME This does not work for classes that have a
|
// FIXME This does not work for classes that have a
|
||||||
// different name in LyX than in LaTeX
|
// different name in LyX than in LaTeX
|
||||||
h_textclass = p.getArg('{', '}');
|
string const tclass = p.getArg('{', '}');
|
||||||
p.skip_spaces();
|
p.skip_spaces();
|
||||||
// Force textclass if the user wanted it
|
// Only set text class if a class hasn't been forced
|
||||||
if (!forceclass.empty())
|
// (this was set above)
|
||||||
h_textclass = forceclass;
|
if (!class_set) {
|
||||||
tc.setName(h_textclass);
|
h_textclass = tclass;
|
||||||
if (!LayoutFileList::get().haveClass(h_textclass) || !tc.load()) {
|
// textclass needs to be set at this place as we need to know
|
||||||
cerr << "Error: Could not read layout file for textclass \"" << h_textclass << "\"." << endl;
|
// it for other parameters (such as class-dependent paper size)
|
||||||
exit(EXIT_FAILURE);
|
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);
|
||||||
|
}
|
||||||
|
class_set = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Font sizes.
|
// Font sizes.
|
||||||
@ -3091,6 +3108,15 @@ void Preamble::parse(Parser & p, string const & forceclass,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// remove the whitespace
|
// remove the whitespace
|
||||||
p.skip_spaces();
|
p.skip_spaces();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user