mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 13:18:28 +00:00
Do not swallow geometry settings if they are given as package options and
replace home made keyval parsing with the more robust process_keyval_opt(). git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@40185 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
8d707723b7
commit
36f7ae1207
@ -544,6 +544,36 @@ void Preamble::handle_hyperref(vector<string> & options)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Preamble::handle_geometry(vector<string> & options)
|
||||||
|
{
|
||||||
|
h_use_geometry = "true";
|
||||||
|
vector<string>::iterator it;
|
||||||
|
// paper orientation
|
||||||
|
if ((it = find(options.begin(), options.end(), "landscape")) != options.end()) {
|
||||||
|
h_paperorientation = "landscape";
|
||||||
|
options.erase(it);
|
||||||
|
}
|
||||||
|
// paper size
|
||||||
|
// keyval version: "paper=letter"
|
||||||
|
string paper = process_keyval_opt(options, "paper");
|
||||||
|
if (!paper.empty())
|
||||||
|
h_papersize = paper + "paper";
|
||||||
|
// alternative version: "letterpaper"
|
||||||
|
handle_opt(options, known_paper_sizes, h_papersize);
|
||||||
|
delete_opt(options, known_paper_sizes);
|
||||||
|
// page margins
|
||||||
|
char const * const * margin = known_paper_margins;
|
||||||
|
for (; *margin; ++margin) {
|
||||||
|
string value = process_keyval_opt(options, *margin);
|
||||||
|
if (!value.empty()) {
|
||||||
|
int k = margin - known_paper_margins;
|
||||||
|
string name = known_coded_paper_margins[k];
|
||||||
|
h_margins += '\\' + name + ' ' + value + '\n';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void Preamble::handle_package(Parser &p, string const & name,
|
void Preamble::handle_package(Parser &p, string const & name,
|
||||||
string const & opts, bool in_lyx_preamble)
|
string const & opts, bool in_lyx_preamble)
|
||||||
{
|
{
|
||||||
@ -714,8 +744,7 @@ void Preamble::handle_package(Parser &p, string const & name,
|
|||||||
; // ignore this
|
; // ignore this
|
||||||
|
|
||||||
else if (name == "geometry")
|
else if (name == "geometry")
|
||||||
; // Ignore this, the geometry settings are made by the \geometry
|
handle_geometry(options);
|
||||||
// command. This command is handled below.
|
|
||||||
|
|
||||||
else if (name == "rotfloat")
|
else if (name == "rotfloat")
|
||||||
; // ignore this
|
; // ignore this
|
||||||
@ -1178,7 +1207,7 @@ void Preamble::parse(Parser & p, string const & forceclass,
|
|||||||
opts.erase(it);
|
opts.erase(it);
|
||||||
}
|
}
|
||||||
// paper sizes
|
// paper sizes
|
||||||
// some size options are know to any document classes, other sizes
|
// some size options are known to any document classes, other sizes
|
||||||
// are handled by the \geometry command of the geometry package
|
// are handled by the \geometry command of the geometry package
|
||||||
handle_opt(opts, known_class_paper_sizes, h_papersize);
|
handle_opt(opts, known_class_paper_sizes, h_papersize);
|
||||||
delete_opt(opts, known_class_paper_sizes);
|
delete_opt(opts, known_class_paper_sizes);
|
||||||
@ -1298,32 +1327,8 @@ void Preamble::parse(Parser & p, string const & forceclass,
|
|||||||
}
|
}
|
||||||
|
|
||||||
else if (t.cs() == "geometry") {
|
else if (t.cs() == "geometry") {
|
||||||
h_use_geometry = "true";
|
|
||||||
vector<string> opts = split_options(p.getArg('{', '}'));
|
vector<string> opts = split_options(p.getArg('{', '}'));
|
||||||
vector<string>::iterator it;
|
handle_geometry(opts);
|
||||||
// paper orientation
|
|
||||||
if ((it = find(opts.begin(), opts.end(), "landscape")) != opts.end()) {
|
|
||||||
h_paperorientation = "landscape";
|
|
||||||
opts.erase(it);
|
|
||||||
}
|
|
||||||
// paper size
|
|
||||||
handle_opt(opts, known_paper_sizes, h_papersize);
|
|
||||||
delete_opt(opts, known_paper_sizes);
|
|
||||||
// page margins
|
|
||||||
char const * const * margin = known_paper_margins;
|
|
||||||
int k = -1;
|
|
||||||
for (; *margin; ++margin) {
|
|
||||||
k += 1;
|
|
||||||
// search for the "=" in e.g. "lmargin=2cm" to get the value
|
|
||||||
for(size_t i = 0; i != opts.size(); i++) {
|
|
||||||
if (opts.at(i).find(*margin) != string::npos) {
|
|
||||||
string::size_type pos = opts.at(i).find("=");
|
|
||||||
string value = opts.at(i).substr(pos + 1);
|
|
||||||
string name = known_coded_paper_margins[k];
|
|
||||||
h_margins += "\\" + name + " " + value + "\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (t.cs() == "definecolor") {
|
else if (t.cs() == "definecolor") {
|
||||||
|
@ -155,6 +155,8 @@ private:
|
|||||||
///
|
///
|
||||||
void handle_hyperref(std::vector<std::string> & options);
|
void handle_hyperref(std::vector<std::string> & options);
|
||||||
///
|
///
|
||||||
|
void handle_geometry(std::vector<std::string> & options);
|
||||||
|
///
|
||||||
void handle_package(Parser &p, std::string const & name,
|
void handle_package(Parser &p, std::string const & name,
|
||||||
std::string const & opts, bool in_lyx_preamble);
|
std::string const & opts, bool in_lyx_preamble);
|
||||||
///
|
///
|
||||||
|
Loading…
Reference in New Issue
Block a user