]> git.lyx.org Git - lyx.git/blobdiff - src/tex2lyx/tex2lyx.cpp
* src/insets/InsetNote.h:
[lyx.git] / src / tex2lyx / tex2lyx.cpp
index f873845aa768c63a04ec3adc34a6ee99d8477304..6890b370c823fe0c1bf8ce3c00fdf5cf49df2206 100644 (file)
 #include "support/ExceptionMessage.h"
 #include "support/filetools.h"
 #include "support/lstrings.h"
-#include "support/lyxlib.h"
 #include "support/os.h"
 #include "support/Package.h"
-#include "support/unicode.h"
 
 #include <fstream>
 #include <iostream>
@@ -112,7 +110,7 @@ CommandMap known_math_environments;
 
 
 void add_known_command(string const & command, string const & o1,
-                      bool o2)
+       unsigned optionalsNum)
 {
        // We have to handle the following cases:
        // definition                      o1    o2    invocation result
@@ -121,14 +119,14 @@ void add_known_command(string const & command, string const & o1,
        // \newcommand{\foo}[1][]{bar #1}  "[1]" true  \foo       bar
        // \newcommand{\foo}[1][]{bar #1}  "[1]" true  \foo[x]    bar x
        // \newcommand{\foo}[1][x]{bar #1} "[1]" true  \foo[x]    bar x
+       // and the same with \newlyxcommand
        unsigned int nargs = 0;
        vector<ArgumentType> arguments;
        string const opt1 = rtrim(ltrim(o1, "["), "]");
        if (isStrUnsignedInt(opt1)) {
                // The command has arguments
                nargs = convert<unsigned int>(opt1);
-               if (nargs > 0 && o2) {
-                       // The first argument is optional
+               for (unsigned int i = 0; i < optionalsNum; ++i) {
                        arguments.push_back(optional);
                        --nargs;
                }
@@ -399,7 +397,8 @@ void tex2lyx(istream & is, ostream & os)
        //p.dump();
 
        stringstream ss;
-       TextClass textclass = parse_preamble(p, ss, documentclass);
+       TeX2LyXDocClass textclass;
+       parse_preamble(p, ss, documentclass, textclass);
        captionlayout = LayoutPtr(Layout::forCaption());
 
        active_environments.push_back("document");