]> git.lyx.org Git - lyx.git/blobdiff - src/tex2lyx/text.cpp
tex2lyx/text.cpp: code simplification
[lyx.git] / src / tex2lyx / text.cpp
index bd8d02030a970fd1c0a4308b467dfc7f10be2d00..8a9951d3c713acad8f59ff05cb7c5987de10deee 100644 (file)
@@ -210,15 +210,18 @@ char const * const known_pdftex_graphics_formats[] = {"png", "pdf", "jpg",
 char const * const known_tex_extensions[] = {"tex", 0};
 
 /// spaces known by InsetSpace
-char const * const known_spaces[] = { " ", "space", ",", "thinspace", "quad",
-"qquad", "enspace", "enskip", "negthinspace", "hfill", "dotfill", "hrulefill",
-"leftarrowfill", "rightarrowfill", "upbracefill", "downbracefill", 0};
+char const * const known_spaces[] = { " ", "space", ",",
+"thinspace", "quad", "qquad", "enspace", "enskip",
+"negthinspace", "negmedspace", "negthickspace", "textvisiblespace",
+"hfill", "dotfill", "hrulefill", "leftarrowfill", "rightarrowfill",
+"upbracefill", "downbracefill", 0};
 
 /// the same as known_spaces with .lyx names
 char const * const known_coded_spaces[] = { "space{}", "space{}",
 "thinspace{}", "thinspace{}", "quad{}", "qquad{}", "enspace{}", "enskip{}",
-"negthinspace{}", "hfill{}", "dotfill{}", "hrulefill{}", "leftarrowfill{}",
-"rightarrowfill{}", "upbracefill{}", "downbracefill{}", 0};
+"negthinspace{}", "negmedspace{}", "negthickspace{}", "textvisiblespace{}",
+"hfill{}", "dotfill{}", "hrulefill{}", "leftarrowfill{}", "rightarrowfill{}",
+"upbracefill{}", "downbracefill{}", 0};
 
 /// These are translated by LyX to commands like "\\LyX{}", so we have to put
 /// them in ERT. "LaTeXe" must come before "LaTeX"!
@@ -878,6 +881,8 @@ void parse_box(Parser & p, ostream & os, unsigned outer_flags,
                Context context(true, parent_context.textclass);
                context.font = parent_context.font;
 
+               // FIXME, the inset layout should be plain, not standard, see bug #7846
+
                // If we have no inner box the contens will be read with the outer box
                if (!inner_type.empty())
                        parse_text(p, os, inner_flags, outer, context);
@@ -1070,6 +1075,25 @@ void parse_environment(Parser & p, ostream & os, bool outer,
                p.skip_spaces();
        }
 
+       else if (unstarred_name == "sidewaysfigure"
+               || unstarred_name == "sidewaystable") {
+               eat_whitespace(p, os, parent_context, false);
+               parent_context.check_layout(os);
+               if (unstarred_name == "sidewaysfigure")
+                       begin_inset(os, "Float figure\n");
+               else
+                       begin_inset(os, "Float table\n");
+               os << "wide " << convert<string>(is_starred)
+                  << "\nsideways true"
+                  << "\nstatus open\n\n";
+               parse_text_in_inset(p, os, FLAG_END, outer, parent_context);
+               end_inset(os);
+               // We don't need really a new paragraph, but
+               // we must make sure that the next item gets a \begin_layout.
+               parent_context.new_paragraph(os);
+               p.skip_spaces();
+       }
+
        else if (name == "minipage") {
                eat_whitespace(p, os, parent_context, false);
                parse_box(p, os, 0, FLAG_END, outer, parent_context, "", "", name);
@@ -2423,7 +2447,16 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
                        os << "\n\\bar default\n";
                }
 
-               else if (t.cs() == "emph" || t.cs() == "noun") {
+               else if (t.cs() == "sout") {
+                       context.check_layout(os);
+                       os << "\n\\strikeout on\n";
+                       parse_text_snippet(p, os, FLAG_ITEM, outer, context);
+                       context.check_layout(os);
+                       os << "\n\\strikeout default\n";
+               }
+
+               else if (t.cs() == "uuline" || t.cs() == "uwave" ||
+                        t.cs() == "emph" || t.cs() == "noun") {
                        context.check_layout(os);
                        os << "\n\\" << t.cs() << " on\n";
                        parse_text_snippet(p, os, FLAG_ITEM, outer, context);
@@ -2431,6 +2464,21 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
                        os << "\n\\" << t.cs() << " default\n";
                }
 
+               // FIXME, the inset layout should be plain, not standard, see bug #7846
+               else if (t.cs() == "phantom" || t.cs() == "hphantom" ||
+                            t.cs() == "vphantom") {
+                       context.check_layout(os);
+                       if (t.cs() == "phantom")
+                               begin_inset(os, "Phantom Phantom\n");
+                       if (t.cs() == "hphantom")
+                               begin_inset(os, "Phantom Hhantom\n");
+                       if (t.cs() == "vphantom")
+                               begin_inset(os, "Phantom Vhantom\n");
+                       os << "status open\n";
+                       parse_text_in_inset(p, os, FLAG_ITEM, outer, context);
+                       end_inset(os);
+               }
+               
                else if (t.cs() == "lyxline") {
                        // swallow size argument (it is not used anyway)
                        p.getArg('{', '}');
@@ -2458,6 +2506,24 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
                        end_inset(os);
                }
 
+               else if (t.cs() == "rule") {
+                       string offset = "";
+                       string width;
+                       string thickness;
+                       if (p.hasOpt())
+                               offset = p.getArg('[', ']');
+                       width = p.getArg('{', '}');
+                       thickness = p.getArg('{', '}');
+                                       
+                       context.check_layout(os);
+                       begin_command_inset(os, "line", "rule");
+                       if (!offset.empty())
+                               os << "offset \"" << translate_len(offset) << "\"\n";
+                       os << "width \"" << translate_len(width) << "\"\n"
+                                 "height \"" << translate_len(thickness) << "\"\n";
+                       end_inset(os);
+               }
+
                else if (is_known(t.cs(), known_phrases) ||
                         (t.cs() == "protect" &&
                          p.next_token().cat() == catEscape &&
@@ -2655,8 +2721,27 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
                }
 
                else if (t.cs() == "printnomenclature") {
+                       string width = "";
+                       string width_type = "";
                        context.check_layout(os);
                        begin_command_inset(os, "nomencl_print", "printnomenclature");
+                       // case of a custom width
+                       if (p.hasOpt()) {
+                               width = p.getArg('[', ']');
+                               width = translate_len(width);
+                               width_type = "custom";
+                       }
+                       // case of no custom width
+                       // the case of no custom width but the width set
+                       // via \settowidth{\nomlabelwidth}{***} cannot be supported
+                       // because the user could have set anything, not only the width
+                       // of the longest label (which would be width_type = "auto")
+                       string label = convert_command_inset_arg(p.getArg('{', '}'));
+                       if (label.empty() && width_type.empty())
+                               width_type = "none";
+                       os << "set_width \"" << width_type << "\"\n";
+                       if (width_type == "custom")
+                               os << "width \"" << width << '\"';
                        end_inset(os);
                        skip_spaces_braces(p);
                }