]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/MathFactory.C
hopefully fix tex2lyx linking.
[lyx.git] / src / mathed / MathFactory.C
index ac18853eb0eb2d5ab89763eb6154fdfb3bfa405a..3e21d59ae266d2685e12552aeb511da4885d3cba 100644 (file)
@@ -124,7 +124,7 @@ void initSymbols()
        while (getline(fs, line)) {
                int charid     = 0;
                int fallbackid = 0;
-               if (!line.empty() && line[0] == '#')
+               if (line.empty() || line[0] == '#')
                        continue;
 
                // special case of iffont/else/endif
@@ -147,18 +147,25 @@ void initSymbols()
                // special case of pre-defined macros
                if (line.size() > 8 && line.substr(0, 5) == "\\def\\") {
                        //lyxerr << "macro definition: '" << line << '\'' << endl;
-                       MacroTable::globalMacros().insert(from_utf8(line));
+                       istringstream is(line);
+                       string macro;
+                       string requires;
+                       is >> macro >> requires;
+                       MacroTable::globalMacros().insert(from_utf8(macro), requires);
                        continue;
                }
 
                idocstringstream is(from_utf8(line));
                latexkeys tmp;
-               is >> tmp.name >>       tmp.inset;
+               is >> tmp.name >> tmp.inset;
                if (isFontName(tmp.inset))
                        is >> charid >> fallbackid >> tmp.extra >> tmp.xmlname;
                else
                        is >> tmp.extra;
-               if (!is) {
+               // requires is optional
+               if (is)
+                       is >> tmp.requires;
+               else {
                        lyxerr[Debug::MATHED] << "skipping line '" << line << '\'' << endl;
                        lyxerr[Debug::MATHED]
                                << to_utf8(tmp.name) << ' ' << to_utf8(tmp.inset) << ' ' << to_utf8(tmp.extra) << endl;
@@ -170,11 +177,11 @@ void initSymbols()
                        // create fallbacks if necessary
 
                        // store requirements as long as we can
-                       if (tmp.inset == "msa" || tmp.inset == "msb")
+                       if (tmp.requires.empty() &&
+                           (tmp.inset == "msa" || tmp.inset == "msb"))
                                tmp.requires = from_ascii("amssymb");
-                       // See http://bugzilla.lyx.org/show_bug.cgi?id=1942
-                       // else if (tmp.inset == "wasy")
-                       //      tmp.requires = "wasysym";
+                       else if (tmp.inset == "wasy")
+                               tmp.requires = from_ascii("wasysym");
 
                        // symbol font is not available sometimes
                        docstring symbol_font = from_ascii("lyxsymbol");
@@ -216,6 +223,7 @@ void initSymbols()
                        << "  inset: " << to_utf8(tmp.inset)
                        << "  draw: " << int(tmp.draw.empty() ? 0 : tmp.draw[0])
                        << "  extra: " << to_utf8(tmp.extra)
+                       << "  requires: " << to_utf8(tmp.requires)
                        << '\'' << endl;
        }
        docstring tmp = from_ascii("cmm");
@@ -310,8 +318,33 @@ MathAtom createInsetMath(docstring const & s)
                return MathAtom(new InsetMathMakebox);
        if (s == "kern")
                return MathAtom(new InsetMathKern);
-       if (s == "xymatrix")
-               return MathAtom(new InsetMathXYMatrix);
+       if (s.substr(0, 8) == "xymatrix") {
+               char spacing_code = '\0';
+               LyXLength spacing;
+               size_t const len = s.length();
+               size_t i = 8;
+               if (i < len && s[i] == '@') {
+                       ++i;
+                       if (i < len) {
+                               switch (s[i]) {
+                               case 'R':
+                               case 'C':
+                               case 'M':
+                               case 'W':
+                               case 'H':
+                               case 'L':
+                                       spacing_code = static_cast<char>(s[i]);
+                                       ++i;
+                                       break;
+                               }
+                       }
+                       if (i < len && s[i] == '=') {
+                               ++i;
+                               spacing = LyXLength(to_ascii(s.substr(i)));
+                       }
+               }
+               return MathAtom(new InsetMathXYMatrix(spacing, spacing_code));
+       }
        if (s == "xrightarrow" || s == "xleftarrow")
                return MathAtom(new InsetMathXArrow(s));
        if (s == "split" || s == "gathered" || s == "aligned" || s == "alignedat")