]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/MathFactory.cpp
add busy.gif to resources (in line with cmake)
[lyx.git] / src / mathed / MathFactory.cpp
index eae377706593f0de34e9b8efd21ddaff1c40e7d1..ab290cb369bd2733b798ffba230152a308131170 100644 (file)
@@ -44,6 +44,7 @@
 #include "InsetMathHull.h"
 #include "InsetMathXArrow.h"
 #include "InsetMathXYMatrix.h"
+#include "InsetMathDiagram.h"
 #include "MacroTable.h"
 #include "MathMacro.h"
 #include "MathMacroArgument.h"
@@ -78,7 +79,7 @@ bool has_math_fonts;
 
 namespace {
 
-MathWordList theWordList;
+MathWordList theMathWordList;
 
 
 bool isMathFontAvailable(docstring & name)
@@ -134,6 +135,7 @@ void initSymbols()
                        continue;
                } else if (line.size() >= 4 && line.substr(0, 4) == "else") {
                        skip = !skip;
+                       continue;
                } else if (line.size() >= 5 && line.substr(0, 5) == "endif") {
                        skip = false;
                        continue;
@@ -178,6 +180,8 @@ void initSymbols()
                                        tmp.requires = from_ascii("amssymb");
                                else if (tmp.inset == "wasy")
                                        tmp.requires = from_ascii("wasysym");
+                               else if (tmp.inset == "mathscr")
+                                       tmp.requires = from_ascii("mathrsfs");
                        }
 
                        // symbol font is not available sometimes
@@ -207,11 +211,11 @@ void initSymbols()
                                              << " used for " << to_utf8(tmp.name));
                }
 
-               if (theWordList.find(tmp.name) != theWordList.end())
+               if (theMathWordList.find(tmp.name) != theMathWordList.end())
                        LYXERR(Debug::MATHED, "readSymbols: inset " << to_utf8(tmp.name)
                                << " already exists.");
                else
-                       theWordList[tmp.name] = tmp;
+                       theMathWordList[tmp.name] = tmp;
 
                LYXERR(Debug::MATHED, "read symbol '" << to_utf8(tmp.name)
                        << "  inset: " << to_utf8(tmp.inset)
@@ -241,7 +245,7 @@ bool isSpecialChar(docstring const & name)
 
 MathWordList const & mathedWordList()
 {
-       return theWordList;
+       return theMathWordList;
 }
 
 
@@ -278,7 +282,8 @@ bool ensureMath(WriteStream & os, bool needs_math_mode, bool macro)
 }
 
 
-int ensureMode(WriteStream & os, InsetMath::mode_type mode, bool locked)
+int ensureMode(WriteStream & os, InsetMath::mode_type mode,
+               bool locked, bool ascii)
 {
        bool textmode = mode == InsetMath::TEXT_MODE;
        if (os.latex() && textmode && os.pendingBrace()) {
@@ -287,18 +292,20 @@ int ensureMode(WriteStream & os, InsetMath::mode_type mode, bool locked)
                os.pendingSpace(false);
                os.textMode(true);
        }
-       int oldmodes = os.textMode() ? 1 : 0;
+       int oldmodes = os.textMode() ? 0x01 : 0;
        os.textMode(textmode);
-       oldmodes |= os.lockedMode() ? 2 : 0;
+       oldmodes |= os.lockedMode() ? 0x02 : 0;
        os.lockedMode(locked);
+       oldmodes |= os.asciiOnly() ? 0x04 : 0;
+       os.asciiOnly(ascii);
        return oldmodes;
 }
 
 
 latexkeys const * in_word_set(docstring const & str)
 {
-       MathWordList::iterator it = theWordList.find(str);
-       return it != theWordList.end() ? &(it->second) : 0;
+       MathWordList::iterator it = theMathWordList.find(str);
+       return it != theMathWordList.end() ? &(it->second) : 0;
 }
 
 
@@ -411,6 +418,9 @@ MathAtom createInsetMath(docstring const & s, Buffer * buf)
                return MathAtom(new InsetMathXYMatrix(buf, spacing, spacing_code,
                        equal_spacing));
        }
+
+       if (s == "Diagram")
+               return MathAtom(new InsetMathDiagram(buf));
        if (s == "xrightarrow" || s == "xleftarrow")
                return MathAtom(new InsetMathXArrow(buf, s));
        if (s == "split" || s == "alignedat")
@@ -510,17 +520,20 @@ bool createInsetMath_fromDialogStr(docstring const & str, MathData & ar)
        if (name == "ref") {
                InsetCommandParams icp(REF_CODE);
                // FIXME UNICODE
-               InsetCommand::string2params("ref", to_utf8(str), icp);
-               mathed_parse_cell(ar, icp.getCommand());
+               InsetCommand::string2params(to_utf8(str), icp);
+               Encoding const * const utf8 = encodings.fromLyXName("utf8");
+               OutputParams op(utf8);
+               mathed_parse_cell(ar, icp.getCommand(op));
        } else if (name == "mathspace") {
                InsetSpaceParams isp(true);
                InsetSpace::string2params(to_utf8(str), isp);
                InsetSpace is(isp);
-               odocstringstream os;
+               odocstringstream ods;
+               otexstream os(ods);
                Encoding const * const ascii = encodings.fromLyXName("ascii");
                OutputParams op(ascii);
                is.latex(os, op);
-               mathed_parse_cell(ar, os.str());
+               mathed_parse_cell(ar, ods.str());
                if (ar.size() == 2) {
                        // remove "{}"
                        if (ar[1].nucleus()->asBraceInset())