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"
|
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-07-31 17:26:14 +00:00
|
|
|
|
#include "math_ertinset.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"
|
2002-07-08 11:29:51 +00:00
|
|
|
|
#include "math_parboxinset.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"
|
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"
|
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"
|
2003-09-05 17:23:11 +00:00
|
|
|
|
#include "support/std_sstream.h"
|
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"
|
2002-07-12 03:05:13 +00:00
|
|
|
|
#include "frontends/lyx_gui.h"
|
2002-05-30 07:09:54 +00:00
|
|
|
|
|
|
|
|
|
#include <fstream>
|
|
|
|
|
|
2003-09-09 22:13:45 +00:00
|
|
|
|
using lyx::support::LibFileSearch;
|
|
|
|
|
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
|
|
|
|
{
|
2002-07-11 09:34:58 +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\\") {
|
2002-11-27 10:30:28 +00:00
|
|
|
|
//lyxerr << "defining: '" << line << '\'' << endl;
|
2003-09-15 11:00:00 +00:00
|
|
|
|
istringstream is(line);
|
2002-07-12 14:24:47 +00:00
|
|
|
|
MathMacroTable::create(MathAtom(new MathMacroTemplate(is)));
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
// 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) {
|
|
|
|
|
initSymbols();
|
|
|
|
|
initialized = true;
|
|
|
|
|
}
|
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);
|
2002-06-03 07:31:08 +00:00
|
|
|
|
//lyxerr << "looking up '" << str << "' found: "
|
2002-11-04 02:12:42 +00:00
|
|
|
|
// << (it != theWordList.end()) << endl;
|
2002-05-30 07:09:54 +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
|
|
|
|
{
|
2003-10-02 15:46:33 +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));
|
|
|
|
|
if (inset == "mbox")
|
|
|
|
|
return MathAtom(new MathBoxInset(l->name));
|
|
|
|
|
if (inset == "parbox")
|
|
|
|
|
return MathAtom(new MathParboxInset);
|
|
|
|
|
if (inset == "fbox")
|
|
|
|
|
return MathAtom(new MathFboxInset(l));
|
|
|
|
|
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));
|
|
|
|
|
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'));
|
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);
|
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));
|
2002-02-15 14:50:40 +00:00
|
|
|
|
if (s == "split" || s == "gathered" || s == "aligned")
|
|
|
|
|
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);
|
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")
|
|
|
|
|
return MathAtom(new MathFracInset(true));
|
|
|
|
|
if (s == "lefteqn")
|
|
|
|
|
return MathAtom(new MathLefteqnInset);
|
2002-07-31 17:26:14 +00:00
|
|
|
|
if (s == "lyxert")
|
|
|
|
|
return MathAtom(new MathErtInset);
|
2003-09-12 10:14:31 +00:00
|
|
|
|
if (s == "boldsymbol")
|
|
|
|
|
return MathAtom(new MathBoldsymbolInset);
|
2003-10-02 13:41:00 +00:00
|
|
|
|
if (s == "color")
|
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);
|
2001-08-15 05:50:39 +00:00
|
|
|
|
|
2002-03-21 17:42:56 +00:00
|
|
|
|
if (MathMacroTable::has(s))
|
2001-10-12 12:02:49 +00:00
|
|
|
|
return MathAtom(new MathMacro(s));
|
2001-08-15 05:50:39 +00:00
|
|
|
|
|
2003-10-02 15:46:33 +00:00
|
|
|
|
//lyxerr << "creating inset 2 with name: '" << s << '\'' << endl;
|
2001-11-09 10:44:24 +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();
|
|
|
|
|
}
|