2003-08-19 13:00:56 +00:00
|
|
|
|
/**
|
|
|
|
|
* \file math_factory.C
|
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
|
*
|
|
|
|
|
* \author Andr<EFBFBD> P<EFBFBD>nitz
|
|
|
|
|
*
|
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
|
*/
|
|
|
|
|
|
2001-08-13 14:19:16 +00:00
|
|
|
|
#include <config.h>
|
|
|
|
|
|
2003-09-05 16:18:57 +00:00
|
|
|
|
#include "math_factory.h"
|
2001-08-13 14:19:16 +00:00
|
|
|
|
#include "math_parser.h"
|
2002-02-14 14:52:23 +00:00
|
|
|
|
#include "math_arrayinset.h"
|
2002-02-14 14:19:52 +00:00
|
|
|
|
#include "math_amsarrayinset.h"
|
2001-08-13 15:26:41 +00:00
|
|
|
|
#include "math_binominset.h"
|
2001-10-24 18:29:55 +00:00
|
|
|
|
#include "math_boxinset.h"
|
2004-08-13 15:06:46 +00:00
|
|
|
|
#include "math_boxedinset.h"
|
2003-09-12 10:14:31 +00:00
|
|
|
|
#include "math_boldsymbolinset.h"
|
2002-02-14 14:19:52 +00:00
|
|
|
|
#include "math_casesinset.h"
|
2003-10-02 13:41:00 +00:00
|
|
|
|
#include "math_colorinset.h"
|
2001-08-13 14:19:16 +00:00
|
|
|
|
#include "math_decorationinset.h"
|
2003-10-07 08:51:14 +00:00
|
|
|
|
#include "math_dfracinset.h"
|
2001-08-13 14:19:16 +00:00
|
|
|
|
#include "math_dotsinset.h"
|
2002-06-24 15:37:14 +00:00
|
|
|
|
#include "math_fboxinset.h"
|
2002-08-29 09:57:57 +00:00
|
|
|
|
#include "math_frameboxinset.h"
|
2002-05-30 07:09:54 +00:00
|
|
|
|
#include "math_fontinset.h"
|
2002-07-17 10:25:33 +00:00
|
|
|
|
#include "math_fontoldinset.h"
|
2001-08-13 14:19:16 +00:00
|
|
|
|
#include "math_fracinset.h"
|
2001-08-21 14:20:50 +00:00
|
|
|
|
#include "math_kerninset.h"
|
2001-10-18 13:21:21 +00:00
|
|
|
|
#include "math_lefteqninset.h"
|
2001-08-13 14:19:16 +00:00
|
|
|
|
#include "math_macro.h"
|
2003-09-07 21:25:37 +00:00
|
|
|
|
#include "math_macroarg.h"
|
2001-08-13 14:19:16 +00:00
|
|
|
|
#include "math_macrotable.h"
|
2002-07-12 14:24:47 +00:00
|
|
|
|
#include "math_macrotemplate.h"
|
2003-05-07 07:46:04 +00:00
|
|
|
|
#include "math_makeboxinset.h"
|
2003-08-22 16:01:13 +00:00
|
|
|
|
#include "math_oversetinset.h"
|
2004-04-13 06:27:29 +00:00
|
|
|
|
#include "math_parser.h"
|
2006-04-15 09:54:24 +00:00
|
|
|
|
#include "math_phantominset.h"
|
2001-08-13 14:19:16 +00:00
|
|
|
|
#include "math_rootinset.h"
|
2002-01-03 12:02:54 +00:00
|
|
|
|
#include "math_sizeinset.h"
|
2001-08-13 14:19:16 +00:00
|
|
|
|
#include "math_spaceinset.h"
|
2002-02-14 14:19:52 +00:00
|
|
|
|
#include "math_splitinset.h"
|
2001-08-13 14:19:16 +00:00
|
|
|
|
#include "math_sqrtinset.h"
|
|
|
|
|
#include "math_stackrelinset.h"
|
2002-02-14 14:52:23 +00:00
|
|
|
|
#include "math_substackinset.h"
|
2001-11-09 10:44:24 +00:00
|
|
|
|
#include "math_symbolinset.h"
|
2003-03-03 16:15:38 +00:00
|
|
|
|
#include "math_tabularinset.h"
|
2004-11-11 12:01:34 +00:00
|
|
|
|
#include "math_tfracinset.h"
|
2002-02-01 10:33:06 +00:00
|
|
|
|
#include "math_undersetinset.h"
|
2001-11-09 10:44:24 +00:00
|
|
|
|
#include "math_unknowninset.h"
|
2002-02-05 09:51:40 +00:00
|
|
|
|
#include "math_xarrowinset.h"
|
2006-02-22 12:26:06 +00:00
|
|
|
|
#include "math_xymatrixinset.h"
|
2001-08-13 14:19:16 +00:00
|
|
|
|
|
2002-07-08 06:39:40 +00:00
|
|
|
|
//#include "insets/insetref.h"
|
2002-06-24 15:51:35 +00:00
|
|
|
|
#include "ref_inset.h"
|
|
|
|
|
|
2002-05-30 07:09:54 +00:00
|
|
|
|
#include "debug.h"
|
|
|
|
|
#include "math_support.h"
|
2004-04-06 19:25:39 +00:00
|
|
|
|
|
2002-05-30 07:09:54 +00:00
|
|
|
|
#include "support/filetools.h" // LibFileSearch
|
2003-03-04 16:39:13 +00:00
|
|
|
|
#include "support/lstrings.h"
|
2004-04-06 19:25:39 +00:00
|
|
|
|
|
2002-07-12 03:05:13 +00:00
|
|
|
|
#include "frontends/lyx_gui.h"
|
2002-05-30 07:09:54 +00:00
|
|
|
|
|
|
|
|
|
#include <fstream>
|
2004-07-24 10:55:30 +00:00
|
|
|
|
#include <sstream>
|
2002-05-30 07:09:54 +00:00
|
|
|
|
|
2006-04-08 22:31:11 +00:00
|
|
|
|
using lyx::support::libFileSearch;
|
2003-09-09 22:13:45 +00:00
|
|
|
|
using lyx::support::split;
|
2002-05-30 07:09:54 +00:00
|
|
|
|
|
2003-10-06 15:43:21 +00:00
|
|
|
|
using std::string;
|
2002-11-04 00:15:56 +00:00
|
|
|
|
using std::endl;
|
2003-09-05 18:02:24 +00:00
|
|
|
|
using std::istringstream;
|
2002-11-04 00:15:56 +00:00
|
|
|
|
|
2003-06-30 23:56:22 +00:00
|
|
|
|
bool has_math_fonts;
|
|
|
|
|
|
2002-11-04 02:12:42 +00:00
|
|
|
|
|
2002-05-30 07:09:54 +00:00
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
|
|
// file scope
|
|
|
|
|
typedef std::map<string, latexkeys> WordList;
|
|
|
|
|
WordList theWordList;
|
|
|
|
|
|
|
|
|
|
|
2002-06-18 15:44:30 +00:00
|
|
|
|
bool math_font_available(string & name)
|
|
|
|
|
{
|
|
|
|
|
LyXFont f;
|
|
|
|
|
augmentFont(f, name);
|
|
|
|
|
|
|
|
|
|
// Do we have the font proper?
|
2002-07-12 03:05:13 +00:00
|
|
|
|
if (lyx_gui::font_available(f))
|
2002-06-18 15:44:30 +00:00
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
// can we fake it?
|
|
|
|
|
if (name == "eufrak") {
|
|
|
|
|
name = "lyxfakefrak";
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2002-07-30 16:04:41 +00:00
|
|
|
|
lyxerr[Debug::MATHED]
|
2002-11-04 00:15:56 +00:00
|
|
|
|
<< "font " << name << " not available and I can't fake it"
|
|
|
|
|
<< endl;
|
2002-06-18 15:44:30 +00:00
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2002-05-30 07:09:54 +00:00
|
|
|
|
|
2002-07-11 09:34:58 +00:00
|
|
|
|
void initSymbols()
|
2002-05-30 07:09:54 +00:00
|
|
|
|
{
|
2006-04-08 22:31:11 +00:00
|
|
|
|
string const filename = libFileSearch(string(), "symbols");
|
2002-11-04 00:15:56 +00:00
|
|
|
|
lyxerr[Debug::MATHED] << "read symbols from " << filename << endl;
|
2002-07-11 09:34:58 +00:00
|
|
|
|
if (filename.empty()) {
|
2002-11-04 00:15:56 +00:00
|
|
|
|
lyxerr << "Could not find symbols file" << endl;
|
2002-07-11 09:34:58 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2002-05-30 07:09:54 +00:00
|
|
|
|
std::ifstream fs(filename.c_str());
|
2002-07-12 14:24:47 +00:00
|
|
|
|
string line;
|
2002-10-14 20:19:32 +00:00
|
|
|
|
bool skip = false;
|
2002-11-04 02:12:42 +00:00
|
|
|
|
while (getline(fs, line)) {
|
2002-05-30 07:09:54 +00:00
|
|
|
|
int charid = 0;
|
|
|
|
|
int fallbackid = 0;
|
2002-11-04 02:12:42 +00:00
|
|
|
|
if (!line.empty() && line[0] == '#')
|
2002-07-11 09:34:58 +00:00
|
|
|
|
continue;
|
2002-07-12 14:24:47 +00:00
|
|
|
|
|
2002-10-28 10:39:12 +00:00
|
|
|
|
// special case of iffont/else/endif
|
2002-10-14 20:19:32 +00:00
|
|
|
|
if (line.size() >= 7 && line.substr(0, 6) == "iffont") {
|
2003-09-15 11:00:00 +00:00
|
|
|
|
istringstream is(line);
|
2002-10-14 20:19:32 +00:00
|
|
|
|
string tmp;
|
|
|
|
|
is >> tmp;
|
|
|
|
|
is >> tmp;
|
|
|
|
|
skip = !math_font_available(tmp);
|
|
|
|
|
continue;
|
2002-10-21 13:38:02 +00:00
|
|
|
|
} else if (line.size() >= 4 && line.substr(0, 4) == "else") {
|
|
|
|
|
skip = !skip;
|
|
|
|
|
} else if (line.size() >= 5 && line.substr(0, 5) == "endif") {
|
2002-10-14 20:19:32 +00:00
|
|
|
|
skip = false;
|
|
|
|
|
continue;
|
|
|
|
|
} else if (skip)
|
|
|
|
|
continue;
|
|
|
|
|
|
2002-07-12 14:24:47 +00:00
|
|
|
|
// special case of pre-defined macros
|
|
|
|
|
if (line.size() > 8 && line.substr(0, 5) == "\\def\\") {
|
2004-04-13 06:27:29 +00:00
|
|
|
|
//lyxerr << "macro definition: '" << line << '\'' << endl;
|
|
|
|
|
MacroTable::globalMacros().insert(line);
|
2002-07-12 14:24:47 +00:00
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
2003-09-15 11:00:00 +00:00
|
|
|
|
istringstream is(line);
|
2002-10-14 20:19:32 +00:00
|
|
|
|
latexkeys tmp;
|
2002-07-11 09:34:58 +00:00
|
|
|
|
is >> tmp.name >> tmp.inset;
|
2002-11-04 00:15:56 +00:00
|
|
|
|
if (isFontName(tmp.inset))
|
2002-07-11 09:34:58 +00:00
|
|
|
|
is >> charid >> fallbackid >> tmp.extra >> tmp.xmlname;
|
|
|
|
|
else
|
|
|
|
|
is >> tmp.extra;
|
|
|
|
|
if (!is) {
|
2002-11-27 10:30:28 +00:00
|
|
|
|
lyxerr[Debug::MATHED] << "skipping line '" << line << '\'' << endl;
|
2002-07-11 09:34:58 +00:00
|
|
|
|
lyxerr[Debug::MATHED]
|
2002-11-04 00:15:56 +00:00
|
|
|
|
<< tmp.name << ' ' << tmp.inset << ' ' << tmp.extra << endl;
|
2002-05-30 07:09:54 +00:00
|
|
|
|
continue;
|
2002-07-11 09:34:58 +00:00
|
|
|
|
}
|
2002-05-30 07:09:54 +00:00
|
|
|
|
|
2002-07-11 09:34:58 +00:00
|
|
|
|
if (isFontName(tmp.inset)) {
|
|
|
|
|
// tmp.inset _is_ the fontname here.
|
|
|
|
|
// create fallbacks if necessary
|
2002-12-18 22:15:59 +00:00
|
|
|
|
|
2005-06-07 17:21:51 +00:00
|
|
|
|
// store requirements as long as we can
|
|
|
|
|
if (tmp.inset == "msa" || tmp.inset == "msb")
|
|
|
|
|
tmp.requires = "amssymb";
|
2005-07-26 14:28:45 +00:00
|
|
|
|
// See http://bugzilla.lyx.org/show_bug.cgi?id=1942
|
|
|
|
|
// else if (tmp.inset == "wasy")
|
|
|
|
|
// tmp.requires = "wasysym";
|
2005-06-07 17:21:51 +00:00
|
|
|
|
|
2002-12-18 22:15:59 +00:00
|
|
|
|
// symbol font is not available sometimes
|
|
|
|
|
string symbol_font = "lyxsymbol";
|
|
|
|
|
|
2002-11-04 02:12:42 +00:00
|
|
|
|
if (tmp.extra == "func" || tmp.extra == "funclim" || tmp.extra == "special") {
|
2002-11-04 00:15:56 +00:00
|
|
|
|
lyxerr[Debug::MATHED] << "symbol abuse for " << tmp.name << endl;
|
2002-07-11 09:34:58 +00:00
|
|
|
|
tmp.draw = tmp.name;
|
|
|
|
|
} else if (math_font_available(tmp.inset)) {
|
2002-11-04 00:15:56 +00:00
|
|
|
|
lyxerr[Debug::MATHED] << "symbol available for " << tmp.name << endl;
|
2002-07-11 09:34:58 +00:00
|
|
|
|
tmp.draw += char(charid);
|
2002-12-18 22:15:59 +00:00
|
|
|
|
} else if (fallbackid && math_font_available(symbol_font)) {
|
2002-07-11 09:34:58 +00:00
|
|
|
|
if (tmp.inset == "cmex")
|
|
|
|
|
tmp.inset = "lyxsymbol";
|
|
|
|
|
else
|
|
|
|
|
tmp.inset = "lyxboldsymbol";
|
2002-11-04 00:15:56 +00:00
|
|
|
|
lyxerr[Debug::MATHED] << "symbol fallback for " << tmp.name << endl;
|
|
|
|
|
tmp.draw += char(fallbackid);
|
2002-07-11 09:34:58 +00:00
|
|
|
|
} else {
|
2002-11-04 00:15:56 +00:00
|
|
|
|
lyxerr[Debug::MATHED] << "faking " << tmp.name << endl;
|
2002-07-11 09:34:58 +00:00
|
|
|
|
tmp.draw = tmp.name;
|
|
|
|
|
tmp.inset = "lyxtex";
|
|
|
|
|
}
|
2002-06-18 15:44:30 +00:00
|
|
|
|
} else {
|
2002-07-11 09:34:58 +00:00
|
|
|
|
// it's a proper inset
|
2002-11-04 02:12:42 +00:00
|
|
|
|
lyxerr[Debug::MATHED] << "inset " << tmp.inset
|
|
|
|
|
<< " used for " << tmp.name
|
|
|
|
|
<< endl;
|
2002-05-30 07:09:54 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (theWordList.find(tmp.name) != theWordList.end())
|
2002-11-04 02:12:42 +00:00
|
|
|
|
lyxerr[Debug::MATHED]
|
|
|
|
|
<< "readSymbols: inset " << tmp.name
|
|
|
|
|
<< " already exists." << endl;
|
2002-05-30 07:09:54 +00:00
|
|
|
|
else
|
|
|
|
|
theWordList[tmp.name] = tmp;
|
2002-11-04 02:12:42 +00:00
|
|
|
|
|
|
|
|
|
lyxerr[Debug::MATHED]
|
|
|
|
|
<< "read symbol '" << tmp.name
|
|
|
|
|
<< " inset: " << tmp.inset
|
|
|
|
|
<< " draw: " << int(tmp.draw.empty() ? 0 : tmp.draw[0])
|
|
|
|
|
<< " extra: " << tmp.extra
|
2002-11-27 10:30:28 +00:00
|
|
|
|
<< '\'' << endl;
|
2002-05-30 07:09:54 +00:00
|
|
|
|
}
|
2002-10-28 10:39:12 +00:00
|
|
|
|
string tmp = "cmm";
|
|
|
|
|
string tmp2 = "cmsy";
|
|
|
|
|
has_math_fonts = math_font_available(tmp) && math_font_available(tmp2);
|
2002-05-30 07:09:54 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace anon
|
|
|
|
|
|
|
|
|
|
|
2002-07-12 14:24:47 +00:00
|
|
|
|
void initMath()
|
2002-05-30 07:09:54 +00:00
|
|
|
|
{
|
|
|
|
|
static bool initialized = false;
|
|
|
|
|
if (!initialized) {
|
2006-01-24 11:04:30 +00:00
|
|
|
|
initialized = true;
|
2004-04-13 06:27:29 +00:00
|
|
|
|
initParser();
|
2002-05-30 07:09:54 +00:00
|
|
|
|
initSymbols();
|
|
|
|
|
}
|
2002-07-12 14:24:47 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-05-30 07:09:54 +00:00
|
|
|
|
|
2002-07-12 14:24:47 +00:00
|
|
|
|
latexkeys const * in_word_set(string const & str)
|
|
|
|
|
{
|
2002-05-30 07:09:54 +00:00
|
|
|
|
WordList::iterator it = theWordList.find(str);
|
2005-07-15 08:51:34 +00:00
|
|
|
|
return it != theWordList.end() ? &(it->second) : 0;
|
2001-08-13 14:19:16 +00:00
|
|
|
|
}
|
2001-08-15 05:50:39 +00:00
|
|
|
|
|
|
|
|
|
|
2001-10-12 12:02:49 +00:00
|
|
|
|
MathAtom createMathInset(string const & s)
|
2001-08-15 05:50:39 +00:00
|
|
|
|
{
|
2004-04-13 06:27:29 +00:00
|
|
|
|
//lyxerr << "creating inset with name: '" << s << '\'' << endl;
|
2002-07-31 17:26:14 +00:00
|
|
|
|
latexkeys const * l = in_word_set(s);
|
|
|
|
|
if (l) {
|
|
|
|
|
string const & inset = l->inset;
|
2003-10-02 15:46:33 +00:00
|
|
|
|
//lyxerr << " found inset: '" << inset << '\'' << endl;
|
2002-07-31 17:26:14 +00:00
|
|
|
|
if (inset == "ref")
|
|
|
|
|
return MathAtom(new RefInset(l->name));
|
2003-08-22 16:01:13 +00:00
|
|
|
|
if (inset == "overset")
|
|
|
|
|
return MathAtom(new MathOversetInset);
|
2002-07-31 17:26:14 +00:00
|
|
|
|
if (inset == "underset")
|
|
|
|
|
return MathAtom(new MathUndersetInset);
|
|
|
|
|
if (inset == "decoration")
|
|
|
|
|
return MathAtom(new MathDecorationInset(l));
|
|
|
|
|
if (inset == "space")
|
|
|
|
|
return MathAtom(new MathSpaceInset(l->name));
|
|
|
|
|
if (inset == "dots")
|
|
|
|
|
return MathAtom(new MathDotsInset(l));
|
2005-03-16 17:06:47 +00:00
|
|
|
|
if (inset == "mbox")
|
|
|
|
|
// return MathAtom(new MathMBoxInset);
|
|
|
|
|
// MathMBoxInset is proposed to replace MathBoxInset,
|
|
|
|
|
// but is not ready yet (it needs a BufferView for
|
|
|
|
|
// construction)
|
|
|
|
|
return MathAtom(new MathBoxInset(l->name));
|
2004-08-13 13:19:58 +00:00
|
|
|
|
// if (inset == "fbox")
|
|
|
|
|
// return MathAtom(new MathFboxInset(l));
|
2002-07-31 17:26:14 +00:00
|
|
|
|
if (inset == "style")
|
|
|
|
|
return MathAtom(new MathSizeInset(l));
|
|
|
|
|
if (inset == "font")
|
|
|
|
|
return MathAtom(new MathFontInset(l));
|
|
|
|
|
if (inset == "oldfont")
|
|
|
|
|
return MathAtom(new MathFontOldInset(l));
|
|
|
|
|
if (inset == "matrix")
|
|
|
|
|
return MathAtom(new MathAMSArrayInset(s));
|
2006-04-20 09:55:45 +00:00
|
|
|
|
if (inset == "big")
|
|
|
|
|
// we can't create a MathBigInset, since the argument
|
|
|
|
|
// is missing.
|
|
|
|
|
return MathAtom(new MathUnknownInset(s));
|
2002-07-31 17:26:14 +00:00
|
|
|
|
return MathAtom(new MathSymbolInset(l));
|
|
|
|
|
}
|
|
|
|
|
|
2001-09-12 14:31:18 +00:00
|
|
|
|
if (s.size() == 2 && s[0] == '#' && s[1] >= '1' && s[1] <= '9')
|
2001-10-12 12:02:49 +00:00
|
|
|
|
return MathAtom(new MathMacroArgument(s[1] - '0'));
|
2001-10-23 09:03:07 +00:00
|
|
|
|
if (s.size() == 3 && s[0] == '\\' && s[1] == '#'
|
|
|
|
|
&& s[2] >= '1' && s[2] <= '9')
|
2001-10-12 12:02:49 +00:00
|
|
|
|
return MathAtom(new MathMacroArgument(s[2] - '0'));
|
2004-08-13 15:06:46 +00:00
|
|
|
|
if (s == "boxed")
|
|
|
|
|
return MathAtom(new MathBoxedInset());
|
2004-08-13 13:19:58 +00:00
|
|
|
|
if (s == "fbox")
|
|
|
|
|
return MathAtom(new MathFboxInset());
|
2002-08-29 09:57:57 +00:00
|
|
|
|
if (s == "framebox")
|
|
|
|
|
return MathAtom(new MathFrameboxInset);
|
2003-05-07 07:46:04 +00:00
|
|
|
|
if (s == "makebox")
|
|
|
|
|
return MathAtom(new MathMakeboxInset);
|
2002-03-27 10:51:46 +00:00
|
|
|
|
if (s == "kern")
|
2002-03-25 12:11:25 +00:00
|
|
|
|
return MathAtom(new MathKernInset);
|
2006-02-22 12:26:06 +00:00
|
|
|
|
if (s == "xymatrix")
|
|
|
|
|
return MathAtom(new MathXYMatrixInset);
|
2002-02-15 15:01:01 +00:00
|
|
|
|
if (s == "xrightarrow" || s == "xleftarrow")
|
2002-02-05 09:51:40 +00:00
|
|
|
|
return MathAtom(new MathXArrowInset(s));
|
2004-08-14 14:03:42 +00:00
|
|
|
|
if (s == "split" || s == "gathered" || s == "aligned" || s == "alignedat")
|
2002-02-15 14:50:40 +00:00
|
|
|
|
return MathAtom(new MathSplitInset(s));
|
2002-02-14 14:19:52 +00:00
|
|
|
|
if (s == "cases")
|
|
|
|
|
return MathAtom(new MathCasesInset);
|
2002-02-14 14:52:23 +00:00
|
|
|
|
if (s == "substack")
|
|
|
|
|
return MathAtom(new MathSubstackInset);
|
|
|
|
|
if (s == "subarray" || s == "array")
|
|
|
|
|
return MathAtom(new MathArrayInset(s, 1, 1));
|
2002-05-30 07:09:54 +00:00
|
|
|
|
if (s == "sqrt")
|
|
|
|
|
return MathAtom(new MathSqrtInset);
|
|
|
|
|
if (s == "root")
|
|
|
|
|
return MathAtom(new MathRootInset);
|
2003-03-03 16:15:38 +00:00
|
|
|
|
if (s == "tabular")
|
|
|
|
|
return MathAtom(new MathTabularInset(s, 1, 1));
|
2002-07-10 10:51:43 +00:00
|
|
|
|
if (s == "stackrel")
|
2002-05-30 07:09:54 +00:00
|
|
|
|
return MathAtom(new MathStackrelInset);
|
|
|
|
|
if (s == "binom" || s == "choose")
|
2002-07-04 11:00:51 +00:00
|
|
|
|
return MathAtom(new MathBinomInset(s == "choose"));
|
2002-05-30 07:09:54 +00:00
|
|
|
|
if (s == "over" || s == "frac")
|
|
|
|
|
return MathAtom(new MathFracInset);
|
2006-04-06 09:46:01 +00:00
|
|
|
|
if (s == "nicefrac")
|
|
|
|
|
return MathAtom(new MathFracInset(MathFracInset::NICEFRAC));
|
2002-08-28 08:30:27 +00:00
|
|
|
|
//if (s == "infer")
|
|
|
|
|
// return MathAtom(new MathInferInset);
|
2002-05-30 07:09:54 +00:00
|
|
|
|
if (s == "atop")
|
2006-04-06 09:46:01 +00:00
|
|
|
|
return MathAtom(new MathFracInset(MathFracInset::ATOP));
|
2002-05-30 07:09:54 +00:00
|
|
|
|
if (s == "lefteqn")
|
|
|
|
|
return MathAtom(new MathLefteqnInset);
|
2003-09-12 10:14:31 +00:00
|
|
|
|
if (s == "boldsymbol")
|
|
|
|
|
return MathAtom(new MathBoldsymbolInset);
|
2005-06-17 14:35:19 +00:00
|
|
|
|
if (s == "color" || s == "normalcolor")
|
2003-10-28 08:51:33 +00:00
|
|
|
|
return MathAtom(new MathColorInset(true));
|
|
|
|
|
if (s == "textcolor")
|
|
|
|
|
return MathAtom(new MathColorInset(false));
|
2003-10-07 08:51:14 +00:00
|
|
|
|
if (s == "dfrac")
|
|
|
|
|
return MathAtom(new MathDfracInset);
|
2004-11-11 12:01:34 +00:00
|
|
|
|
if (s == "tfrac")
|
|
|
|
|
return MathAtom(new MathTfracInset);
|
2006-04-15 09:54:24 +00:00
|
|
|
|
if (s == "hphantom")
|
|
|
|
|
return MathAtom(new MathPhantomInset(MathPhantomInset::hphantom));
|
|
|
|
|
if (s == "phantom")
|
|
|
|
|
return MathAtom(new MathPhantomInset(MathPhantomInset::phantom));
|
|
|
|
|
if (s == "vphantom")
|
|
|
|
|
return MathAtom(new MathPhantomInset(MathPhantomInset::vphantom));
|
2001-08-15 05:50:39 +00:00
|
|
|
|
|
2004-04-13 13:54:58 +00:00
|
|
|
|
if (MacroTable::globalMacros().has(s))
|
|
|
|
|
return MathAtom(new MathMacro(s,
|
|
|
|
|
MacroTable::globalMacros().get(s).numargs()));
|
|
|
|
|
//if (MacroTable::localMacros().has(s))
|
|
|
|
|
// return MathAtom(new MathMacro(s,
|
|
|
|
|
// MacroTable::localMacros().get(s).numargs()));
|
|
|
|
|
|
2004-08-13 21:21:10 +00:00
|
|
|
|
//lyxerr << "creating unknown inset '" << s << "'" << endl;
|
2004-04-13 13:54:58 +00:00
|
|
|
|
return MathAtom(new MathUnknownInset(s));
|
2001-08-15 05:50:39 +00:00
|
|
|
|
}
|
2003-03-04 16:39:13 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool createMathInset_fromDialogStr(string const & str, MathArray & ar)
|
|
|
|
|
{
|
|
|
|
|
// An example str:
|
|
|
|
|
// "ref LatexCommand \\ref{sec:Title}\n\\end_inset\n\n";
|
|
|
|
|
string name;
|
|
|
|
|
string body = split(str, name, ' ');
|
|
|
|
|
|
|
|
|
|
if (name != "ref" )
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
// body comes with a head "LatexCommand " and a
|
|
|
|
|
// tail "\nend_inset\n\n". Strip them off.
|
|
|
|
|
string trimmed;
|
|
|
|
|
body = split(body, trimmed, ' ');
|
|
|
|
|
split(body, trimmed, '\n');
|
|
|
|
|
|
|
|
|
|
mathed_parse_cell(ar, trimmed);
|
|
|
|
|
if (ar.size() != 1)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
return ar[0].nucleus();
|
|
|
|
|
}
|