]> git.lyx.org Git - lyx.git/blobdiff - src/tex2lyx/text.cpp
tex2lyx/preamble.cpp: support Vietnamese (since format 291)
[lyx.git] / src / tex2lyx / text.cpp
index 637a60919789c49f7974cf8f9fdeb3bc2f1f3836..7eddc0ec80a01b98ca2cb66cb7504222ad0375fc 100644 (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"
@@ -902,7 +903,7 @@ void parse_environment(Parser & p, ostream & os, bool outer,
                        // the two environments as one otherwise (bug 5716)
                        docstring const sep = from_ascii("--Separator--");
                        TeX2LyXDocClass const & textclass(parent_context.textclass);
-                       if (LYX_FORMAT >= 273 && textclass.hasLayout(sep)) {
+                       if (textclass.hasLayout(sep)) {
                                Context newcontext(parent_context);
                                newcontext.layout = &(textclass[sep]);
                                newcontext.check_layout(os);
@@ -2431,13 +2432,13 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
                        skip_spaces_braces(p);
                }
 
-               else if (LYX_FORMAT >= 307 && t.cs() == "slash") {
+               else if (t.cs() == "slash") {
                        context.check_layout(os);
                        os << "\\SpecialChar \\slash{}\n";
                        skip_spaces_braces(p);
                }
 
-               else if (LYX_FORMAT >= 307 && t.cs() == "nobreakdash") {
+               else if (t.cs() == "nobreakdash") {
                        context.check_layout(os);
                        os << "\\SpecialChar \\nobreakdash\n";
                }
@@ -2550,7 +2551,8 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
                        }
                }
 
-               else if (t.cs() == "newline") {
+               else if (t.cs() == "newline"
+                       || t.cs() == "linebreak") {
                        context.check_layout(os);
                        os << "\n\\" << t.cs() << "\n";
                        skip_spaces_braces(p);
@@ -2693,6 +2695,7 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
                }
 
                else if (t.cs() == "newpage" ||
+                       t.cs() == "pagebreak" ||
                        t.cs() == "clearpage" ||
                        t.cs() == "cleardoublepage") {
                        context.check_layout(os);
@@ -2729,16 +2732,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 +2751,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 +2797,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 +2823,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) {