#include <algorithm>
+#include "math_amsarrayinset.h"
#include "math_charinset.h"
#include "math_deliminset.h"
#include "math_diffinset.h"
#include "math_exfuncinset.h"
#include "math_exintinset.h"
-#include "math_funcinset.h"
#include "math_fracinset.h"
#include "math_matrixinset.h"
#include "math_mathmlstream.h"
#include "math_scriptinset.h"
#include "math_stringinset.h"
#include "math_symbolinset.h"
+#include "math_unknowninset.h"
#include "Lsstream.h"
#include "debug.h"
MathScriptInset const * asScript(MathArray::const_iterator it)
{
+ if (!it->nucleus())
+ return 0;
if (it->nucleus()->asScriptInset())
return 0;
++it;
// returns sequence of char with same code starting at it up to end
// it might be less, though...
MathArray::const_iterator charSequence(MathArray::const_iterator it,
- MathArray::const_iterator end, string & s, MathTextCodes & c)
+ MathArray::const_iterator end, string & s)
{
- MathCharInset const * p = (*it)->asCharInset();
- c = p->code();
- for (; it != end; ++it) {
- p = (*it)->asCharInset();
- if (!p || p->code() != c)
- break;
- s += p->getChar();
- }
+ for (; it != end && (*it)->asCharInset(); ++it)
+ s += (*it)->getChar();
return it;
}
// create proper string inset
MathStringInset * p = new MathStringInset;
MathArray::const_iterator
- jt = charSequence(it, ar.end(), p->str_, p->code_);
+ jt = charSequence(it, ar.end(), p->str_);
// clean up
(*it).reset(p);
void extractMatrices(MathArray & ar)
{
//lyxerr << "\nMatrices from: " << ar << "\n";
+ // first pass for explicitly delimited stuff
for (MathArray::iterator it = ar.begin(); it != ar.end(); ++it) {
MathDelimInset * del = (*it)->asDelimInset();
if (!del)
continue;
MathInset * arr = singleItem(del->cell(0));
- if (!arr || !arr->asArrayInset())
+ if (!arr || !arr->asGridInset())
+ continue;
+ *it = MathAtom(new MathMatrixInset(*(arr->asGridInset())));
+ }
+
+ // second pass for AMS "pmatrix" etc
+ for (MathArray::iterator it = ar.begin(); it != ar.end(); ++it) {
+ MathAMSArrayInset * ams = (*it)->asAMSArrayInset();
+ if (!ams)
continue;
- *it = MathAtom(new MathMatrixInset(*(arr->asArrayInset())));
+ *it = MathAtom(new MathMatrixInset(*ams));
}
//lyxerr << "\nMatrices to: " << ar << "\n";
}
bool extractNumber(MathArray const & ar, int & i)
{
string s;
- MathTextCodes c;
- charSequence(ar.begin(), ar.end(), s, c);
+ charSequence(ar.begin(), ar.end(), s);
+ istringstream is(s.c_str());
+ is >> i;
+ return is;
+}
+
+
+bool extractNumber(MathArray const & ar, double & i)
+{
+ string s;
+ charSequence(ar.begin(), ar.end(), s);
istringstream is(s.c_str());
is >> i;
return is;
string name;
// is it a function?
- if ((*it)->asFuncInset()) {
+ if ((*it)->asUnknownInset()) {
// it certainly is if it is well known...
- name = (*it)->asFuncInset()->name();
+ name = (*it)->asUnknownInset()->name();
} else {
// is this a user defined function?
// it it probably not, if it doesn't have a name.