]> git.lyx.org Git - features.git/commitdiff
Remove InsetArgument 999 workaround
authorGeorg Baum <baum@lyx.org>
Sat, 3 Jan 2015 16:45:59 +0000 (17:45 +0100)
committerGeorg Baum <baum@lyx.org>
Sat, 3 Jan 2015 16:45:59 +0000 (17:45 +0100)
Since we iterate through all arguments we can as well compute the correct id
directly.

src/tex2lyx/test/test-structure.lyx.lyx
src/tex2lyx/test/test.lyx.lyx
src/tex2lyx/text.cpp

index 08dbf2b1b3f4c7ebfec670a8a088b54b6fe6c892..17ab6e8fe6b3bf358fa8e28d9cff11e820fb9b92 100644 (file)
@@ -188,7 +188,7 @@ A section
 
 \begin_layout Section
 
-\begin_inset Argument 999
+\begin_inset Argument 1
 status collapsed
 
 
index 21ecd0afed7a1fbcff4e1221af0115157dae5527..29f08e3f268a06a186c8e60ec10a96d589e3305c 100644 (file)
@@ -349,7 +349,7 @@ Final text
 \end_deeper
 \begin_layout Section
 
-\begin_inset Argument 999
+\begin_inset Argument 1
 status collapsed
 
 
index fe6a8a30e19acfe977faebc2cb195235540fba4b..0d742bd8913cc876c66fd55bc641c68e783b3b00 100644 (file)
@@ -637,45 +637,31 @@ void output_command_layout(ostream & os, Parser & p, bool outer,
        }
        context.check_deeper(os);
        context.check_layout(os);
-       // FIXME: Adjust to format 446!
-       // Since format 446, layouts do not require anymore all optional
-       // arguments before the required ones. Needs to be implemented!
-       int optargs = 0;
-       while (optargs < context.layout->optArgs()) {
+       int i = 0;
+       Layout::LaTeXArgMap::const_iterator lait = context.layout->latexargs().begin();
+       Layout::LaTeXArgMap::const_iterator const laend = context.layout->latexargs().end();
+       for (; lait != laend; ++lait) {
+               ++i;
                eat_whitespace(p, os, context, false);
-               if (p.next_token().cat() == catEscape ||
-                   p.next_token().character() != '[')
-                       break;
-               p.get_token(); // eat '['
-               // FIXME: Just a workaround. InsetArgument::updateBuffer
-               //        will compute a proper ID for all "999" Arguments
-               //        (which is also what lyx2lyx produces).
-               //        However, tex2lyx should be able to output proper IDs
-               //        itself.
-               begin_inset(os, "Argument 999\n");
-               os << "status collapsed\n\n";
-               parse_text_in_inset(p, os, FLAG_BRACK_LAST, outer, context);
-               end_inset(os);
-               eat_whitespace(p, os, context, false);
-               ++optargs;
-       }
-       int reqargs = 0;
-       while (reqargs < context.layout->requiredArgs()) {
-               eat_whitespace(p, os, context, false);
-               if (p.next_token().cat() != catBegin)
-                       break;
-               p.get_token(); // eat '{'
-               // FIXME: Just a workaround. InsetArgument::updateBuffer
-               //        will compute a proper ID for all "999" Arguments
-               //        (which is also what lyx2lyx produces).
-               //        However, tex2lyx should be able to output proper IDs
-               //        itself.
-               begin_inset(os, "Argument 999\n");
-               os << "status collapsed\n\n";
-               parse_text_in_inset(p, os, FLAG_BRACE_LAST, outer, context);
-               end_inset(os);
+               if (lait->second.mandatory) {
+                       if (p.next_token().cat() != catBegin)
+                               break;
+                       p.get_token(); // eat '{'
+                       begin_inset(os, "Argument ");
+                       os << i << "\nstatus collapsed\n\n";
+                       parse_text_in_inset(p, os, FLAG_BRACE_LAST, outer, context);
+                       end_inset(os);
+               } else {
+                       if (p.next_token().cat() == catEscape ||
+                           p.next_token().character() != '[')
+                               break;
+                       p.get_token(); // eat '['
+                       begin_inset(os, "Argument ");
+                       os << i << "\nstatus collapsed\n\n";
+                       parse_text_in_inset(p, os, FLAG_BRACK_LAST, outer, context);
+                       end_inset(os);
+               }
                eat_whitespace(p, os, context, false);
-               ++reqargs;
        }
        parse_text(p, os, FLAG_ITEM, outer, context);
        context.check_end_layout(os);