Increase tex2lyx output format to 320.

320: Support protected hfill
Detect other horizontal spaces that are already part of format 319
Add forgotton use_parbox tag to boxes (confuses lyx2lyx, but no lyx)



git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@36949 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Georg Baum 2010-12-19 21:24:24 +00:00
parent 58fde18a9f
commit 300cd0dedd
3 changed files with 49 additions and 20 deletions

View File

@ -284,6 +284,7 @@ raggedleft 2 raggedleft 2 raggedleft 2 raggedleft 2 raggedleft 2
\subsection{Horizontal spaces}
Lines can have an hfill \hfill in the middle.
Lines can have an hfill \hspace{\fill} in the middle.
Lines can have a protected hfill \hspace*{\fill} in the middle.
Lines can have a dotted fill \dotfill in the middle.
Lines can have a rule fill \hrulefill in the middle.
@ -320,7 +321,8 @@ qquad\qquad{}a
\subsection{Vertical spaces}
Lines can have an vfill \vfill in the middle.
Lines can have a vfill \vfill in the middle.
Lines can have a vfill \vspace{\fill} in the middle.
Lines can have a protected vfill \vspace*{\fill} in the middle.
Lines can have vertical space \vspace{2cm} in the middle.
Lines can have protected vertical space \vspace*{2cm} in the middle.

View File

@ -114,7 +114,7 @@ extern CommandMap known_math_environments;
///
extern bool noweb_mode;
/// LyX format that is created by tex2lyx
int const LYX_FORMAT = 319;
int const LYX_FORMAT = 320;
/// path of the master .tex file
extern std::string getMasterFilePath();

View File

@ -831,6 +831,7 @@ void parse_environment(Parser & p, ostream & os, bool outer,
"hor_pos \"c\"\n"
"has_inner_box 0\n"
"inner_pos \"t\"\n"
"use_parbox 0\n"
"width \"100col%\"\n"
"special \"none\"\n"
"height \"1in\"\n"
@ -2729,16 +2730,18 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
}
}
else if (t.cs() == "vspace") {
else if (t.cs() == "hspace" || t.cs() == "vspace") {
bool starred = false;
if (p.next_token().asInput() == "*") {
p.get_token();
starred = true;
}
string name = t.asInput();
string const length = p.verbatim_item();
string unit;
string valstring;
bool valid = splitLatexLength(length, valstring, unit);
bool known_hspace = false;
bool known_vspace = false;
bool known_unit = false;
double value;
@ -2746,21 +2749,31 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
istringstream iss(valstring);
iss >> value;
if (value == 1.0) {
if (unit == "\\smallskipamount") {
unit = "smallskip";
known_vspace = true;
} else if (unit == "\\medskipamount") {
unit = "medskip";
known_vspace = true;
} else if (unit == "\\bigskipamount") {
unit = "bigskip";
known_vspace = true;
} else if (unit == "\\fill") {
unit = "vfill";
known_vspace = true;
if (t.cs()[0] == 'h') {
if (unit == "\\fill") {
if (!starred) {
unit = "";
name = "hfill";
}
known_hspace = true;
}
} else {
if (unit == "\\smallskipamount") {
unit = "smallskip";
known_vspace = true;
} else if (unit == "\\medskipamount") {
unit = "medskip";
known_vspace = true;
} else if (unit == "\\bigskipamount") {
unit = "bigskip";
known_vspace = true;
} else if (unit == "\\fill") {
unit = "vfill";
known_vspace = true;
}
}
}
if (!known_vspace) {
if (!known_hspace && !known_vspace) {
switch (unitFromString(unit)) {
case Length::SP:
case Length::PT:
@ -2782,8 +2795,23 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
}
}
if (known_unit || known_vspace) {
// Literal length or known variable
if (t.cs()[0] == 'h' && (known_unit || known_hspace)) {
// Literal horizontal length or known variable
context.check_layout(os);
begin_inset(os, "Space \\");
os << name;
if (starred)
os << '*';
os << '{';
if (known_hspace)
os << unit;
os << "}\n";
if (known_unit && !known_hspace)
os << "\\length "
<< translate_len(length) << '\n';
end_inset(os);
} else if (known_unit || known_vspace) {
// Literal vertical length or known variable
context.check_layout(os);
begin_inset(os, "VSpace ");
if (known_unit)
@ -2793,8 +2821,7 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
os << '*';
end_inset(os);
} else {
// LyX can't handle other length variables in Inset VSpace
string name = t.asInput();
// LyX can't handle other length variables in Inset V?Space
if (starred)
name += '*';
if (valid) {