]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/MathFactory.cpp
Routines for calculating numerical labels for BibTeX citations.
[lyx.git] / src / mathed / MathFactory.cpp
index 1d6d83baf8eb308990eabb19d52e2f6309feb084..eae377706593f0de34e9b8efd21ddaff1c40e7d1 100644 (file)
@@ -62,6 +62,8 @@
 
 #include "frontends/FontLoader.h"
 
+#include "Buffer.h"
+#include "BufferParams.h"
 #include "Encoding.h"
 #include "LyX.h" // use_gui
 #include "OutputParams.h"
@@ -309,6 +311,10 @@ MathAtom createInsetMath(char const * const s, Buffer * buf)
 MathAtom createInsetMath(docstring const & s, Buffer * buf)
 {
        //lyxerr << "creating inset with name: '" << to_utf8(s) << '\'' << endl;
+       if ((s == "ce" || s == "cf") && buf
+           && buf->params().use_mhchem == BufferParams::package_off)
+               return MathAtom(new MathMacro(buf, s));
+
        latexkeys const * l = in_word_set(s);
        if (l) {
                docstring const & inset = l->inset;
@@ -368,11 +374,23 @@ MathAtom createInsetMath(docstring const & s, Buffer * buf)
        if (s.substr(0, 8) == "xymatrix") {
                char spacing_code = '\0';
                Length spacing;
+               bool equal_spacing = false;
                size_t const len = s.length();
                size_t i = 8;
                if (i < len && s[i] == '@') {
                        ++i;
-                       if (i < len) {
+                       if (i < len && s[i] == '!') {
+                               equal_spacing = true;
+                               ++i;
+                               if (i < len) {
+                                       switch (s[i]) {
+                                       case '0':
+                                       case 'R':
+                                       case 'C':
+                                               spacing_code = static_cast<char>(s[i]);
+                                       }
+                               }
+                       } else if (i < len) {
                                switch (s[i]) {
                                case 'R':
                                case 'C':
@@ -384,17 +402,18 @@ MathAtom createInsetMath(docstring const & s, Buffer * buf)
                                        ++i;
                                        break;
                                }
-                       }
-                       if (i < len && s[i] == '=') {
-                               ++i;
-                               spacing = Length(to_ascii(s.substr(i)));
+                               if (i < len && s[i] == '=') {
+                                       ++i;
+                                       spacing = Length(to_ascii(s.substr(i)));
+                               }
                        }
                }
-               return MathAtom(new InsetMathXYMatrix(buf, spacing, spacing_code));
+               return MathAtom(new InsetMathXYMatrix(buf, spacing, spacing_code,
+                       equal_spacing));
        }
        if (s == "xrightarrow" || s == "xleftarrow")
                return MathAtom(new InsetMathXArrow(buf, s));
-       if (s == "split" || s == "gathered" || s == "aligned" || s == "alignedat")
+       if (s == "split" || s == "alignedat")
                return MathAtom(new InsetMathSplit(buf, s));
        if (s == "cases")
                return MathAtom(new InsetMathCases(buf));