]> git.lyx.org Git - lyx.git/blobdiff - src/tex2lyx/text.cpp
tex2lyx/text.cpp: code simplification
[lyx.git] / src / tex2lyx / text.cpp
index d59081a10be25615b91cf0fc0a0024feaee0d650..8a9951d3c713acad8f59ff05cb7c5987de10deee 100644 (file)
@@ -881,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);
@@ -1073,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);
@@ -2443,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('{', '}');
@@ -2470,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 &&
@@ -2667,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);
                }