Author: uwestoehr
Date: Mon Nov 7 22:57:49 2011
New Revision: 40157
URL: http://www.lyx.org/trac/changeset/40157
Log:
backporting tex2lyx:
- support for \makebox
- fix import of boxes without an inner box (the on-screen display was broken
because of wrong default width setting)
- fix parsing of \framebox{content}, which LyX does not support yet - we have
to use ERT
Modified:
lyx-devel/branches/BRANCH_2_0_X/src/tex2lyx/TODO.txt
lyx-devel/branches/BRANCH_2_0_X/src/tex2lyx/test/box-color-size-space-align.tex
lyx-devel/branches/BRANCH_2_0_X/src/tex2lyx/text.cpp
lyx-devel/branches/BRANCH_2_0_X/status.20x
Modified: lyx-devel/branches/BRANCH_2_0_X/src/tex2lyx/TODO.txt
==============================================================================
--- lyx-devel/branches/BRANCH_2_0_X/src/tex2lyx/TODO.txt Mon Nov 7
22:50:44 2011 (r40156)
+++ lyx-devel/branches/BRANCH_2_0_X/src/tex2lyx/TODO.txt Mon Nov 7
22:57:49 2011 (r40157)
@@ -61,7 +61,6 @@
390 forward/reverse search \forward_search, \forward_macro
391 decimal alignment in tables InsetTabular
392 new beamer format InsetLayout
-394 \makebox InsetBox use_makebox
396 nameref.sty InsetRef
399 automatic mathdots loading \use_mathdots
401 feyn.sty InsetMathDiagram
Modified:
lyx-devel/branches/BRANCH_2_0_X/src/tex2lyx/test/box-color-size-space-align.tex
==============================================================================
---
lyx-devel/branches/BRANCH_2_0_X/src/tex2lyx/test/box-color-size-space-align.tex
Mon Nov 7 22:50:44 2011 (r40156)
+++
lyx-devel/branches/BRANCH_2_0_X/src/tex2lyx/test/box-color-size-space-align.tex
Mon Nov 7 22:57:49 2011 (r40157)
@@ -102,32 +102,32 @@
blabla \fbox{fbox} blabla
-blabla \framebox{framebox 1} blabla
+blabla \framebox{fr\textcolor{blue}{ame}box 1} blabla
blabla \framebox[3cm]{framebox 2} blabla
blabla \framebox[3cm][l]{framebox 3} blabla
-Dies ist ein Beispieltext. %
+This is an example text. %
\framebox{%
\begin{minipage}[c][1\totalheight][s]{0.2\columnwidth}%
\begin{center}
- Der Boxinhalt
+ The box content
\par\end{center}
\begin{center}
- ist �ber die
+ is evenly distributed
\par\end{center}
\begin{center}
- Boxh�he
+ over the
\par\end{center}
\begin{center}
- gleichm��ig verteilt.
+ box height.
\par\end{center}%
\end{minipage}}
-Dies ist ein Beispieltext.
+This is an example text.
blabla \ovalbox{ovalbox} blabla
Modified: lyx-devel/branches/BRANCH_2_0_X/src/tex2lyx/text.cpp
==============================================================================
--- lyx-devel/branches/BRANCH_2_0_X/src/tex2lyx/text.cpp Mon Nov 7
22:50:44 2011 (r40156)
+++ lyx-devel/branches/BRANCH_2_0_X/src/tex2lyx/text.cpp Mon Nov 7
22:57:49 2011 (r40157)
@@ -735,16 +735,29 @@
string height_unit = "in";
string height_special = "totalheight";
string latex_height;
+ string width_value;
+ string width_unit;
+ string latex_width;
+ string width_special = "none";
if (!inner_type.empty() && p.hasOpt()) {
- position = p.getArg('[', ']');
+ if (inner_type != "makebox")
+ position = p.getArg('[', ']');
+ else {
+ latex_width = p.getArg('[', ']');
+ translate_box_len(latex_width, width_value, width_unit,
width_special);
+ position = "t";
+ }
if (position != "t" && position != "c" && position != "b") {
cerr << "invalid position " << position << " for "
<< inner_type << endl;
position = "c";
}
if (p.hasOpt()) {
- latex_height = p.getArg('[', ']');
- translate_box_len(latex_height, height_value,
height_unit, height_special);
+ if (inner_type != "makebox") {
+ latex_height = p.getArg('[', ']');
+ translate_box_len(latex_height, height_value,
height_unit, height_special);
+ } else
+ hor_pos = p.getArg('[', ']');
if (p.hasOpt()) {
inner_pos = p.getArg('[', ']');
@@ -758,12 +771,9 @@
}
}
}
- string width_value;
- string width_unit;
- string latex_width;
if (inner_type.empty()) {
- if (special.empty())
- latex_width = "\\columnwidth";
+ if (special.empty() && outer_type != "framebox")
+ latex_width = "1\\columnwidth";
else {
Parser p2(special);
latex_width = p2.getArg('[', ']');
@@ -778,9 +788,17 @@
}
}
}
- } else
+ } else if (inner_type != "makebox")
latex_width = p.verbatim_item();
+ // if e.g. only \ovalbox{content} was used, set the width to
1\columnwidth
+ // as this is LyX's standard for such cases (except for makebox)
+ // \framebox is special and handled below
+ if (latex_width.empty() && inner_type != "makebox"
+ && outer_type != "framebox")
+ latex_width = "1\\columnwidth";
+
translate_len(latex_width, width_value, width_unit);
+
bool shadedparbox = false;
if (inner_type == "shaded") {
eat_whitespace(p, os, parent_context, false);
@@ -819,6 +837,16 @@
}
p.popPosition();
}
+ // if only \makebox{content} was used we can set its width to 1\width
+ // because this identic and also identic to \mbox
+ // this doesn't work for \framebox{content}, thus we have to use ERT
for this
+ if (latex_width.empty() && inner_type == "makebox") {
+ width_value = "1";
+ width_unit = "in";
+ width_special = "width";
+ } else if (latex_width.empty() && outer_type == "framebox") {
+ use_ert = true;
+ }
if (use_ert) {
ostringstream ss;
if (!outer_type.empty()) {
@@ -867,6 +895,9 @@
if (outer_flags & FLAG_END)
handle_ert(os, "\\end{" + outer_type + '}',
parent_context);
+ else if (inner_type.empty() && outer_type == "framebox")
+ // in this case it is already closed later
+ ;
else
handle_ert(os, "}", parent_context);
}
@@ -877,8 +908,6 @@
position = "c";
if (inner_pos.empty())
inner_pos = position;
- // FIXME: Support makebox
- bool const use_makebox = false;
parent_context.check_layout(os);
begin_inset(os, "Box ");
if (outer_type == "framed")
@@ -902,10 +931,10 @@
os << "has_inner_box " << !inner_type.empty() << "\n";
os << "inner_pos \"" << inner_pos << "\"\n";
os << "use_parbox " << (inner_type == "parbox" || shadedparbox)
- << '\n';
- os << "use_makebox " << use_makebox << '\n';
+ << '\n';
+ os << "use_makebox " << (inner_type == "makebox") << '\n';
os << "width \"" << width_value << width_unit << "\"\n";
- os << "special \"none\"\n";
+ os << "special \"" << width_special << "\"\n";
os << "height \"" << height_value << height_unit << "\"\n";
os << "height_special \"" << height_special << "\"\n";
os << "status open\n\n";
@@ -914,9 +943,8 @@
// InsetBox::forcePlainLayout() is hard coded and does not
// use the inset layout. Apart from that do we call parse_text
// up to two times, but need only one check_end_layout.
-
bool const forcePlainLayout =
- (!inner_type.empty() || use_makebox) &&
+ (!inner_type.empty() || inner_type == "makebox") &&
outer_type != "shaded" && outer_type != "framed";
Context context(true, parent_context.textclass);
if (forcePlainLayout)
@@ -2668,7 +2696,7 @@
begin_inset(os, "Phantom VPhantom\n");
os << "status open\n";
parse_text_in_inset(p, os, FLAG_ITEM, outer, context,
- "Phantom");
+ "Phantom");
end_inset(os);
}
@@ -3433,13 +3461,15 @@
//\makebox{} will be parsed by parse_box when bug 2956 is fixed
else if (t.cs() == "makebox") {
string arg = t.asInput();
- if (p.next_token().character() == '(')
+ if (p.next_token().character() == '(') {
//the syntax is:
\makebox(x,y)[position]{content}
arg += p.getFullParentheseArg();
- else
- //the syntax is:
\makebox[width][position]{content}
arg += p.getFullOpt();
- handle_ert(os, arg + p.getFullOpt(), context);
+ handle_ert(os, arg + p.get_token().asInput(),
context);
+ } else
+ //the syntax is:
\makebox[width][position]{content}
+ parse_box(p, os, 0, FLAG_ITEM, outer, context,
+ "", "", t.cs());
}
else if (t.cs() == "smallskip" ||
Modified: lyx-devel/branches/BRANCH_2_0_X/status.20x
==============================================================================
--- lyx-devel/branches/BRANCH_2_0_X/status.20x Mon Nov 7 22:50:44 2011
(r40156)
+++ lyx-devel/branches/BRANCH_2_0_X/status.20x Mon Nov 7 22:57:49 2011
(r40157)
@@ -70,6 +70,8 @@
* Subfloats (\subfloat).
+ * Frameless boxes (\makebox). (\mbox is not yet supported by LyX.)
+
* Command \date{} in the preamble to suppress the date output.
@@ -162,6 +164,8 @@
- Fix LaTeX import of tabular environment with optional argument.
+- Fix tex2lyx handling of framed boxes without inner box.
+
- Store the autosave files of unnamed buffers in the correct directory
and make sure they are not left behind after saving (bug 7793).