math_diminset.h \
math_dotsinset.C \
math_dotsinset.h \
+ math_extern.C \
+ math_extern.h \
math_exfuncinset.C \
math_exfuncinset.h \
math_exintinset.C \
math_macrotable.h \
math_mathmlstream.C \
math_mathmlstream.h \
+ math_matrixinset.C \
+ math_matrixinset.h \
math_metricsinfo.h \
math_metricsinfo.C \
math_nestinset.C \
"subs(`\\,`=`\\cdot `,"
"eval(`latex/latex/*`)):\n";
- // replace spurious \\noalign{\\medskip} in table output
+ // remove spurious \\noalign{\\medskip} in matrix output
header +=
"`latex/latex/matrix`:= "
"subs(`\\\\\\\\\\\\noalign{\\\\medskip}` = `\\\\\\\\`,"
ostringstream os;
NormalStream ns(os);
os << "[" << extra << ' ';
- ar.writeNormal(ns);
+ ns << ar;
os << "]";
string data = os.str().c_str();
int InsetFormula::latex(Buffer const * buf, ostream & os, bool fragil, bool)
const
{
- MathWriteInfo wi(buf, os, fragil);
+ WriteStream wi(buf, os, fragil);
par_->write(wi);
return 1;
}
int InsetFormula::ascii(Buffer const * buf, ostream & os, int) const
{
- MathWriteInfo wi(buf, os, false);
+ WriteStream wi(buf, os, false);
par_->write(wi);
return 1;
}
MathHullInset const * InsetFormula::mat() const
{
- lyx::Assert(par_->asMatrixInset());
- return par_->asMatrixInset();
+ lyx::Assert(par_->asHullInset());
+ return par_->asHullInset();
}
MathHullInset * InsetFormula::mat()
{
- lyx::Assert(par_->asMatrixInset());
- return par_->asMatrixInset();
+ lyx::Assert(par_->asHullInset());
+ return par_->asHullInset();
}
void InsetFormulaMacro::write(Buffer const * buf, ostream & os) const
{
os << "FormulaMacro ";
- MathWriteInfo wi(buf, os, false);
+ WriteStream wi(buf, os, false);
par()->write(wi);
}
int InsetFormulaMacro::latex(Buffer const * buf, ostream & os, bool fragile,
bool /*free_spacing*/) const
{
- MathWriteInfo wi(buf, os, fragile);
+ WriteStream wi(buf, os, fragile);
par()->write(wi);
return 2;
}
int InsetFormulaMacro::ascii(Buffer const * buf, ostream & os, int) const
{
- MathWriteInfo wi(buf, os, false);
+ WriteStream wi(buf, os, false);
par()->write(wi);
return 0;
}
#include "math_arrayinset.h"
#include "math_parser.h"
-#include "support/LOstream.h"
-#include "Lsstream.h"
#include "math_mathmlstream.h"
+#include "Lsstream.h"
using std::vector;
+using std::istringstream;
MathArrayInset::MathArrayInset(int m, int n)
}
-void MathArrayInset::write(MathWriteInfo & os) const
+void MathArrayInset::metrics(MathMetricsInfo const & st) const
+{
+ MathMetricsInfo mi = st;
+ if (mi.style == LM_ST_DISPLAY)
+ mi.style = LM_ST_TEXT;
+ MathGridInset::metrics(mi);
+}
+
+
+void MathArrayInset::write(WriteStream & os) const
{
if (os.fragile)
os << "\\protect";
}
-void MathArrayInset::writeNormal(NormalStream & os) const
+void MathArrayInset::normalize(NormalStream & os) const
{
os << "[array ";
- MathGridInset::writeNormal(os);
+ MathGridInset::normalize(os);
os << "]";
}
-void MathArrayInset::metrics(MathMetricsInfo const & st) const
+void MathArrayInset::maplize(MapleStream & os) const
{
- MathMetricsInfo mi = st;
- if (mi.style == LM_ST_DISPLAY)
- mi.style = LM_ST_TEXT;
- MathGridInset::metrics(mi);
+ os << "array(";
+ MathGridInset::maplize(os);
+ os << ")";
}
///
MathInset * clone() const;
///
- void write(MathWriteInfo & os) const;
- ///
- void writeNormal(NormalStream &) const;
- ///
void metrics(MathMetricsInfo const & st) const;
///
MathArrayInset * asArrayInset() { return this; }
+
+ ///
+ void write(WriteStream & os) const;
+ ///
+ void normalize(NormalStream &) const;
+ ///
+ void maplize(MapleStream &) const;
};
#endif
}
+void MathAtom::reset(MathInset * p)
+{
+ done();
+ nucleus_ = p;
+}
+
+
+
void MathAtom::done()
{
delete nucleus_;
///
void operator=(MathAtom const &);
///
+ void reset(MathInset * p);
+ ///
MathInset * nucleus() const;
///
MathInset * operator->() const;
}
-void MathBinaryOpInset::write(MathWriteInfo & os) const
+void MathBinaryOpInset::write(WriteStream & os) const
{
os << '{' << cell(0) << op_ << cell(1) << '}';
}
-void MathBinaryOpInset::writeNormal(NormalStream & os) const
+void MathBinaryOpInset::normalize(NormalStream & os) const
{
os << "[binop " << op_ << ' ' << cell(0) << ' ' << cell(1) << ']';
}
///
void draw(Painter &, int x, int y) const;
///
- void write(MathWriteInfo & os) const;
+ void write(WriteStream & os) const;
///
- void writeNormal(NormalStream &) const;
+ void normalize(NormalStream &) const;
///
void metrics(MathMetricsInfo const & st) const;
private:
}
-void MathBinomInset::write(MathWriteInfo & os) const
+void MathBinomInset::write(WriteStream & os) const
{
os << '{' << cell(0) << " \\choose " << cell(1) << '}';
}
-void MathBinomInset::writeNormal(NormalStream & os) const
+void MathBinomInset::normalize(NormalStream & os) const
{
- os << "[binom ";
- cell(0).writeNormal(os);
- os << " ";
- cell(1).writeNormal(os);
- os << "] ";
+ os << "[binom " << cell(0) << ' ' << cell(1) << ']';
}
///
MathInset * clone() const;
///
- void write(MathWriteInfo & os) const;
+ void write(WriteStream & os) const;
///
- void writeNormal(NormalStream &) const;
+ void normalize(NormalStream &) const;
///
void metrics(MathMetricsInfo const & st) const;
///
}
-void MathBoxInset::write(MathWriteInfo & os) const
+void MathBoxInset::write(WriteStream & os) const
{
os << "\\" << name_.c_str() << "{" << cell(0) << "}";
}
-void MathBoxInset::writeNormal(NormalStream & os) const
+void MathBoxInset::normalize(NormalStream & os) const
{
os << "[mbox ";
//text_->write(buffer(), os);
///
void draw(Painter &, int x, int y) const;
///
- void write(MathWriteInfo & os) const;
+ void write(WriteStream & os) const;
///
- void writeNormal(NormalStream &) const;
+ void normalize(NormalStream &) const;
///
void metrics(MathMetricsInfo const &) const;
/// identifies BoxInsets
}
-void MathBraceInset::write(MathWriteInfo & os) const
-{
- os << '{' << cell(0) << '}';
-}
-
-
-void MathBraceInset::writeNormal(NormalStream & os) const
-{
- os << "[block ";
- cell(0).writeNormal(os);
- os << "]";
-}
-
-
void MathBraceInset::metrics(MathMetricsInfo const & mi) const
{
xcell(0).metrics(mi);
xcell(0).draw(pain, x + wid_, y);
drawChar(pain, LM_TC_TEX, mi_, x + width_ - wid_, y, '}');
}
+
+
+void MathBraceInset::write(WriteStream & os) const
+{
+ os << '{' << cell(0) << '}';
+}
+
+
+void MathBraceInset::normalize(NormalStream & os) const
+{
+ os << "[block " << cell(0) << ']';
+}
+
+
///
void draw(Painter &, int x, int y) const;
///
- void write(MathWriteInfo & os) const;
+ void write(WriteStream & os) const;
/// write normalized content
- void writeNormal(NormalStream &) const;
+ void normalize(NormalStream &) const;
///
void metrics(MathMetricsInfo const & st) const;
}
-void MathCharInset::write(MathWriteInfo & os) const
+void MathCharInset::write(WriteStream & os) const
{
writeHeader(os.os);
writeRaw(os.os);
}
-void MathCharInset::writeNormal(NormalStream & os) const
+void MathCharInset::normalize(NormalStream & os) const
{
os << "[char " << char_ << " " << "mathalpha" << "]";
}
///
void draw(Painter &, int x, int y) const;
///
- void write(MathWriteInfo & os) const;
+ void write(WriteStream & os) const;
///
void writeHeader(std::ostream &) const;
///
///
void writeRaw(std::ostream &) const;
///
- void writeNormal(NormalStream &) const;
+ void normalize(NormalStream &) const;
///
int ascent() const;
///
lyxerr << "this should not really happen - 2: "
<< pos() << " " << size() << " in idx: " << it->idx()
<< " in atom: '";
- MathWriteInfo wi(0, lyxerr, false);
+ WriteStream wi(0, lyxerr, false);
it->par()->write(wi);
lyxerr << "\n";
dump("error 4");
while (popRight())
;
- MathHullInset * p = formula()->par()->asMatrixInset();
+ MathHullInset * p = formula()->par()->asHullInset();
if (!p)
return;
// split line
const row_type r = row();
- for (col_type c = col() + 1; c < p->ncols(); ++c) {
- const MathHullInset::idx_type i1 = p->index(r, c);
- const MathHullInset::idx_type i2 = p->index(r + 1, c);
- //lyxerr << "swapping cells " << i1 << " and " << i2 << "\n";
- p->cell(i1).swap(p->cell(i2));
- }
+ for (col_type c = col() + 1; c < p->ncols(); ++c)
+ p->cell(p->index(r, c)).swap(p->cell(p->index(r + 1, c)));
// split cell
splitCell();
#endif
#include "math_inset.h"
+#include "math_deliminset.h"
#include "math_charinset.h"
#include "math_scriptinset.h"
#include "math_stringinset.h"
+#include "math_matrixinset.h"
#include "math_mathmlstream.h"
#include "math_support.h"
#include "math_data.h"
}
-MathScriptInset const * MathArray::asScript(const_iterator it) const
-{
- if (it->nucleus()->asScriptInset())
- return 0;
- const_iterator jt = it + 1;
- if (jt == end())
- return 0;
- if (!jt->nucleus())
- return 0;
- return jt->nucleus()->asScriptInset();
-}
-
-
MathAtom & MathArray::at(size_type pos)
{
lyx::Assert(pos < size());
}
-// returns sequence of char with same code starting at it up to end
-// it might be less, though...
-string charSequence(MathArray::const_iterator it, MathArray::const_iterator end)
-{
- string s;
- MathCharInset const * p = it->nucleus()->asCharInset();
- if (!p)
- return s;
-
- for (MathTextCodes c = p->code(); it != end; ++it) {
- if (!it->nucleus())
- break;
- p = it->nucleus()->asCharInset();
- if (!p || p->code() != c)
- break;
- s += p->getChar();
- }
- return s;
-}
-
-
-MathArray MathArray::glueChars() const
-{
- MathArray ar;
- const_iterator it = begin();
- while (it != end()) {
- if (it->nucleus() && it->nucleus()->asCharInset()) {
- string s = charSequence(it, end());
- MathTextCodes c = it->nucleus()->asCharInset()->code();
- ar.push_back(MathAtom(new MathStringInset(s, c)));
- it += s.size();
- } else {
- ar.push_back(*it);
- ++it;
- }
- }
- return ar;
-}
-
-
-bool needAsterisk(MathAtom const &, MathAtom const &)
-{
- return false;
-}
-
-
-MathArray MathArray::guessAsterisks() const
-{
- if (size() <= 1)
- return *this;
- MathArray ar;
- ar.push_back(*begin());
- for (const_iterator it = begin(), jt = begin()+1 ; jt != end(); ++it, ++jt) {
- if (needAsterisk(*it, *jt))
- ar.push_back(MathAtom(new MathCharInset('*')));
- ar.push_back(*it);
- }
- ar.push_back(*end());
- return ar;
-}
-
-
-void MathArray::write(MathWriteInfo & wi) const
-{
- MathArray ar = glueChars();
- for (const_iterator it = ar.begin(); it != ar.end(); ++it) {
- MathInset const * p = it->nucleus();
- if (MathScriptInset const * q = ar.asScript(it)) {
- q->write(p, wi);
- ++it;
- } else {
- p->write(wi);
- }
- }
-}
-
-
-void MathArray::writeNormal(NormalStream & os) const
-{
- MathArray ar = glueChars();
- for (const_iterator it = ar.begin(); it != ar.end(); ++it) {
- MathInset const * p = it->nucleus();
- if (MathScriptInset const * q = ar.asScript(it)) {
- q->writeNormal(p, os);
- ++it;
- } else
- p->writeNormal(os);
- }
-}
-
-
-void MathArray::octavize(OctaveStream & os) const
-{
- MathArray ar = glueChars();
- for (const_iterator it = ar.begin(); it != ar.end(); ++it) {
- MathInset const * p = it->nucleus();
- if (MathScriptInset const * q = ar.asScript(it)) {
- q->octavize(p, os);
- ++it;
- } else
- p->octavize(os);
- }
-}
-
-
-void MathArray::maplize(MapleStream & os) const
-{
- MathArray ar = glueChars();
- for (const_iterator it = ar.begin(); it != ar.end(); ++it) {
- MathInset const * p = it->nucleus();
- if (MathScriptInset const * q = ar.asScript(it)) {
- q->maplize(p, os);
- ++it;
- } else
- p->maplize(os);
- }
-}
-
-
-void MathArray::mathmlize(MathMLStream & os) const
-{
- MathArray ar = glueChars();
- if (ar.size() == 0)
- os << "<mrow/>";
- else if (ar.size() == 1)
- os << ar.begin()->nucleus();
- else {
- os << MTag("mrow");
- for (const_iterator it = ar.begin(); it != ar.end(); ++it) {
- MathInset const * p = it->nucleus();
- if (MathScriptInset const * q = ar.asScript(it)) {
- q->mathmlize(p, os);
- ++it;
- } else
- p->mathmlize(os);
- }
- os << ETag("mrow");
- }
-}
-
-
void MathArray::validate(LaTeXFeatures & features) const
{
for (const_iterator it = begin(); it != end(); ++it)
{
return bf_.end();
}
-
-
-bool MathArray::isMatrix() const
-{
- return size() == 1 && begin()->nucleus() && begin()->nucleus()->isMatrix();
-}
-
-
class MathScriptInset;
class MathMacro;
-class MathWriteInfo;
-class MathMetricsInfo;
class LaTeXFeatures;
-class NormalStream;
-class MapleStream;
-class MathMLStream;
-class OctaveStream;
#ifdef __GNUG__
MathAtom & at(size_type pos);
///
MathAtom const & at(size_type pos) const;
- /// glue chars if necessary
- void write(MathWriteInfo & os) const;
- ///
- void writeNormal(NormalStream &) const;
///
void validate(LaTeXFeatures &) const;
///
iterator begin();
///
iterator end();
- ///
- MathScriptInset const * asScript(const_iterator it) const;
- /// glues chars with the same attributes into MathStringInsets
- MathArray glueChars() const;
- /// insert asterisks in "suitable" places
- MathArray guessAsterisks() const;
-
- /// interface to Octave
- void octavize(OctaveStream &) const;
- /// interface to Maple
- void maplize(MapleStream &) const;
- /// interface to MathML
- void mathmlize(MathMLStream &) const;
-
- ///
- bool isMatrix() const;
private:
/// Buffer
}
-void MathDecorationInset::write(MathWriteInfo & os) const
+void MathDecorationInset::write(WriteStream & os) const
{
if (os.fragile && protect())
os << "\\protect";
}
-void MathDecorationInset::writeNormal(NormalStream & os) const
+void MathDecorationInset::normalize(NormalStream & os) const
{
os << "[deco " << name_.c_str() << ' ' << cell(0) << ']';
}
///
void draw(Painter &, int x, int y) const;
///
- void write(MathWriteInfo & os) const;
+ void write(WriteStream & os) const;
///
void metrics(MathMetricsInfo const & st) const;
///
- void writeNormal(NormalStream & os) const;
+ void normalize(NormalStream & os) const;
///
bool isScriptable() const;
#include "math_deliminset.h"
#include "math_parser.h"
#include "math_support.h"
-#include "support/LOstream.h"
#include "math_mathmlstream.h"
+#include "math_extern.h"
MathDelimInset::MathDelimInset(string const & l, string const & r)
}
-void MathDelimInset::write(MathWriteInfo & os) const
+void MathDelimInset::write(WriteStream & os) const
{
os << "\\left" << latexName(left_).c_str() << cell(0)
<< "\\right" << latexName(right_).c_str();
}
-void MathDelimInset::writeNormal(NormalStream & os) const
+void MathDelimInset::normalize(NormalStream & os) const
{
os << "[delim " << latexName(left_).c_str() << ' '
<< latexName(right_).c_str() << ' ' << cell(0) << ']';
}
-bool MathDelimInset::isMatrix() const
-{
- return left_ == "(" && right_ == ")" && cell(0).size() == 1 &&
- cell(0).begin()->nucleus() && cell(0).begin()->nucleus()->asArrayInset();
-}
-
-
void MathDelimInset::maplize(MapleStream & os) const
{
if (left_ == "|" && right_ == "|") {
- if (cell(0).isMatrix())
+ bool mat =
+ cell(0).size() == 1 && cell(0).begin()->nucleus()
+ && cell(0).begin()->nucleus()->asMatrixInset();
+ if (mat)
os << "linalg[det](" << cell(0) << ")";
else
os << "abs(" << cell(0) << ")";
///
MathInset * clone() const;
///
- void draw(Painter &, int x, int y) const;
+ MathDelimInset * asDelimInset() { return this; }
///
- void write(MathWriteInfo & os) const;
- /// write normalized content
- void writeNormal(NormalStream &) const;
+ MathDelimInset const * asDelimInset() const { return this; }
///
void metrics(MathMetricsInfo const & st) const;
///
- bool isMatrix() const;
+ void draw(Painter &, int x, int y) const;
+
+ ///
+ void write(WriteStream & os) const;
+ /// write normalized content
+ void normalize(NormalStream &) const;
///
void maplize(MapleStream &) const;
///
void mathmlize(MathMLStream &) const;
///
void octavize(OctaveStream &) const;
-private:
- ///
- int dw() const;
///
string left_;
///
string right_;
+private:
+ ///
+ int dw() const;
///
static string latexName(string const & name);
};
}
-void MathDotsInset::write(MathWriteInfo & os) const
+void MathDotsInset::write(WriteStream & os) const
{
os << '\\' << name_.c_str() << ' ';
}
-void MathDotsInset::writeNormal(NormalStream & os) const
+void MathDotsInset::normalize(NormalStream & os) const
{
os << "[" << name_.c_str() << "] ";
}
///
void draw(Painter &, int x, int y) const;
///
- void write(MathWriteInfo & os) const;
+ void write(WriteStream & os) const;
///
- void writeNormal(NormalStream &) const;
+ void normalize(NormalStream &) const;
///
void metrics(MathMetricsInfo const & st) const;
protected:
}
-void MathExFuncInset::write(MathWriteInfo & os) const
+void MathExFuncInset::write(WriteStream & os) const
{
os << '\\' << name_.c_str() << '{' << cell(0) << '}';
}
-void MathExFuncInset::writeNormal(NormalStream & os) const
+void MathExFuncInset::normalize(NormalStream & os) const
{
os << '[' << name_.c_str() << ' ' << cell(0) << ']';
}
///
MathInset * clone() const;
///
- void write(MathWriteInfo & os) const;
+ void write(WriteStream & os) const;
///
- void writeNormal(NormalStream &) const;
+ void normalize(NormalStream &) const;
///
void metrics(MathMetricsInfo const & st) const;
///
}
-void MathExIntInset::write(MathWriteInfo & os) const
+void MathExIntInset::write(WriteStream & os) const
{
scripts_.write(int_.nucleus(), os);
os << core_ << "d" << diff_;
}
-void MathExIntInset::writeNormal(NormalStream & os) const
+void MathExIntInset::normalize(NormalStream & os) const
{
//os << "[int " << scripts_ << ' ' << core_ << ' ' << diff_ << ']'
}
///
void draw(Painter &, int x, int y) const;
///
- void write(MathWriteInfo & os) const;
+ void write(WriteStream & os) const;
///
- void writeNormal(NormalStream &) const;
+ void normalize(NormalStream &) const;
///
void maplize(MapleStream &) const;
///
}
-void MathFracInset::write(MathWriteInfo & os) const
+void MathFracInset::write(WriteStream & os) const
{
if (atop_)
os << '{' << cell(0) << "\\atop " << cell(1) << '}';
}
-void MathFracInset::writeNormal(NormalStream & os) const
+void MathFracInset::normalize(NormalStream & os) const
{
if (atop_)
os << "[atop ";
else
os << "[frac ";
- cell(0).writeNormal(os);
- os << " ";
- cell(1).writeNormal(os);
- os << "] ";
+ os << cell(0) << ' ' << cell(1) << ']';
}
///
MathInset * clone() const;
///
- void write(MathWriteInfo & os) const;
- ///
- void writeNormal(NormalStream &) const;
- ///
void metrics(MathMetricsInfo const & st) const;
///
void draw(Painter &, int x, int y) const;
+
+ ///
+ void write(WriteStream & os) const;
+ ///
+ void normalize(NormalStream &) const;
///
void maplize(MapleStream &) const;
///
}
-void MathFuncInset::write(MathWriteInfo & os) const
+void MathFuncInset::write(WriteStream & os) const
{
os << "\\" << name_.c_str() << ' ';
}
-void MathFuncInset::writeNormal(NormalStream & os) const
+void MathFuncInset::normalize(NormalStream & os) const
{
os << "[func " << name_.c_str() << ']';
}
///
void draw(Painter &, int x, int y) const;
///
- void write(MathWriteInfo &) const;
+ void write(WriteStream &) const;
///
- void writeNormal(NormalStream &) const;
+ void normalize(NormalStream &) const;
///
string const & name() const;
///
}
-void MathFuncLimInset::write(MathWriteInfo & os) const
+void MathFuncLimInset::write(WriteStream & os) const
{
os << '\\' << name_.c_str() << ' ';
}
-void MathFuncLimInset::writeNormal(NormalStream & os) const
+void MathFuncLimInset::normalize(NormalStream & os) const
{
os << "[funclim " << name_.c_str() << ']';
}
///
MathInset * clone() const;
///
- void write(MathWriteInfo & os) const;
+ void write(WriteStream & os) const;
///
- void writeNormal(NormalStream &) const;
+ void normalize(NormalStream &) const;
///
void metrics(MathMetricsInfo const & st) const;
///
}
-void MathGridInset::write(MathWriteInfo & os) const
+void MathGridInset::write(WriteStream & os) const
{
for (row_type row = 0; row < nrows(); ++row) {
for (col_type col = 0; col < ncols(); ++col)
}
-void MathGridInset::writeNormal(NormalStream & os) const
+void MathGridInset::normalize(NormalStream & os) const
{
os << "[grid ";
for (row_type row = 0; row < nrows(); ++row) {
return res;
}
-
-void MathGridInset::maplize(MapleStream & os) const
-{
- os << "array([";
- for (row_type row = 0; row < nrows(); ++row) {
- if (row)
- os << ',';
- os << '[';
- for (col_type col = 0; col < ncols(); ++col) {
- if (col)
- os << ',';
- os << cell(index(row, col));
- }
- os << ']';
- }
- os << "])";
-}
-
-
-void MathGridInset::mathmlize(MathMLStream & os) const
-{
- os << MTag("mtable");
- for (row_type row = 0; row < nrows(); ++row) {
- os << MTag("mtr");
- for (col_type col = 0; col < ncols(); ++col)
- os << cell(index(row, col));
- os << ETag("mtr");
- }
- os << ETag("mtable");
-}
-
-
-void MathGridInset::octavize(OctaveStream & os) const
-{
- os << '[';
- for (row_type row = 0; row < nrows(); ++row) {
- if (row)
- os << ';';
- os << '[';
- for (col_type col = 0; col < ncols(); ++col)
- os << cell(index(row, col)) << ' ';
- os << ']';
- }
- os << ']';
-}
///
MathGridInset(int m, int n, char valign, string const & halign);
///
- void write(MathWriteInfo & os) const;
- ///
- void writeNormal(NormalStream &) const;
- ///
void metrics(MathMetricsInfo const & st) const;
///
void draw(Painter &, int x, int y) const;
///
void setDefaults();
+ ///
+ void write(WriteStream & os) const;
+ ///
+ void normalize(NormalStream &) const;
+/*
///
void maplize(MapleStream &) const;
///
void mathmlize(MathMLStream &) const;
///
void octavize(OctaveStream &) const;
+*/
protected:
/// returns proper 'end of line' code for LaTeX
}
-void MathHullInset::write(MathWriteInfo & os) const
+void MathHullInset::write(WriteStream & os) const
{
header_write(os.os);
}
-void MathHullInset::writeNormal(NormalStream & os) const
+void MathHullInset::normalize(NormalStream & os) const
{
os << "[formula " << normalName(getType()).c_str() << " ";
- MathGridInset::writeNormal(os);
+ MathGridInset::normalize(os);
os << "] ";
}
///
MathInset * clone() const;
///
- void write(MathWriteInfo & os) const;
+ void write(WriteStream & os) const;
///
- void writeNormal(NormalStream &) const;
+ void normalize(NormalStream &) const;
///
void metrics(MathMetricsInfo const & st) const;
///
///
void validate(LaTeXFeatures & features) const;
/// identifies MatrixInsets
- virtual MathHullInset const * asMatrixInset() const { return this; }
- /// identifies MatrixInsets
- virtual MathHullInset * asMatrixInset() { return this; }
+ virtual MathHullInset const * asHullInset() const { return this; }
+ /// identifies HullInset
+ virtual MathHullInset * asHullInset() { return this; }
///
void addRow(row_type);
std::ostream & operator<<(std::ostream & os, MathInset const & inset)
{
- MathWriteInfo wi(0, os, false);
+ WriteStream wi(0, os, false);
inset.write(wi);
return os;
}
{}
-void MathInset::writeNormal(NormalStream & os) const
+void MathInset::normalize(NormalStream & os) const
{
os << "[unknown ";
- MathWriteInfo wi(0, os.os_, false);
+ WriteStream wi(0, os.os_, false);
write(wi);
os << "] ";
}
void MathInset::dump() const
{
lyxerr << "---------------------------------------------\n";
- MathWriteInfo wi(0, lyxerr, false);
+ WriteStream wi(0, lyxerr, false);
write(wi);
lyxerr << "\n---------------------------------------------\n";
}
}
-void MathInset::write(MathWriteInfo &) const
+void MathInset::write(WriteStream &) const
{
lyxerr << "MathInset::write() called directly!\n";
}
void MathInset::octavize(OctaveStream & os) const
{
NormalStream ns(os.os_);
- writeNormal(ns);
+ normalize(ns);
}
void MathInset::maplize(MapleStream & os) const
{
NormalStream ns(os.os_);
- writeNormal(ns);
+ normalize(ns);
}
void MathInset::mathmlize(MathMLStream & os) const
{
NormalStream ns(os.os_);
- writeNormal(ns);
+ normalize(ns);
}
class MathArrayInset;
class MathBoxInset;
class MathCharInset;
+class MathDelimInset;
class MathGridInset;
-class MathNestInset;
class MathHullInset;
+class MathMatrixInset;
+class MathNestInset;
class MathScriptInset;
class MathSpaceInset;
class MathMacroTemplate;
+class NormalStream;
+class OctaveStream;
+class MapleStream;
+class MathMLStream;
+class WriteStream;
+class MathArray;
+
class LaTeXFeatures;
class BufferView;
class UpdatableInset;
/// draw the object
virtual void draw(Painter &, int x, int y) const;
/// write LaTeX and Lyx code
- virtual void write(MathWriteInfo & os) const;
+ virtual void write(WriteStream & os) const;
/// reproduce itself
virtual MathInset * clone() const = 0;
///substitutes macro arguments if necessary
virtual MathScriptInset const * asScriptInset() const { return 0; }
/// identifies ScriptInsets
virtual MathScriptInset * asScriptInset() { return 0; }
- /// identifies MatrixInsets
- virtual MathHullInset const * asMatrixInset() const { return 0; }
- /// identifies MatrixInsets
- virtual MathHullInset * asMatrixInset() { return 0; }
+ /// identifies HullInsets
+ virtual MathHullInset const * asHullInset() const { return 0; }
+ /// identifies HullInsets
+ virtual MathHullInset * asHullInset() { return 0; }
/// identifies SpaceInset
virtual MathSpaceInset * asSpaceInset() { return 0; }
/// identifies GridInset
virtual MathGridInset * asGridInset() { return 0; }
/// identifies ArrayInsets
virtual MathArrayInset * asArrayInset() { return 0; }
+ /// identifies MatrixInsets
+ virtual MathMatrixInset const * asMatrixInset() const { return 0; }
/// identifies BoxInsets
virtual MathBoxInset * asBoxInset() { return 0; }
+ /// identifies DelimInsets
+ virtual MathDelimInset * asDelimInset() { return 0; }
+ /// identifies DelimInsets
+ virtual MathDelimInset const * asDelimInset() const { return 0; }
/// identifies macro templates
virtual MathMacroTemplate * asMacroTemplate() { return 0; }
/// identifies hyperactive insets
virtual bool isRelOp() const { return false; }
///
virtual bool isMacro() const { return false; }
- /// is this a matrix or matrix expression?
- virtual bool isMatrix() const { return false; }
///
virtual char getChar() const { return 0; }
virtual void handleFont(MathTextCodes) {}
/// write normalized content
- virtual void writeNormal(NormalStream &) const;
+ virtual void normalize(NormalStream &) const;
///
virtual void maplize(MapleStream &) const;
///
}
-void MathKernInset::write(MathWriteInfo & os) const
+void MathKernInset::write(WriteStream & os) const
{
os << "\\kern" << wid_.asLatexString().c_str() << " ";
}
-void MathKernInset::writeNormal(NormalStream & os) const
+void MathKernInset::normalize(NormalStream & os) const
{
os << "[kern " << wid_.asLatexString().c_str() << "]";
}
///
void draw(Painter &, int x, int y) const;
///
- void write(MathWriteInfo & os) const;
+ void write(WriteStream & os) const;
///
- void writeNormal(NormalStream &) const;
+ void normalize(NormalStream &) const;
///
void metrics(MathMetricsInfo const & st) const;
private:
}
-void MathLefteqnInset::write(MathWriteInfo & os) const
+void MathLefteqnInset::write(WriteStream & os) const
{
- os << "\\lefteqn{" << cell(0) << "}";
+ os << "\\lefteqn{" << cell(0) << '}';
}
-void MathLefteqnInset::writeNormal(NormalStream & os) const
+void MathLefteqnInset::normalize(NormalStream & os) const
{
- os << "[lefteqn ";
- MathWriteInfo wi(os.os_);
- cell(0).write(wi);
- os << "]";
+ os << "[lefteqn " << cell(0) << ']';
}
///
void draw(Painter &, int x, int y) const;
///
- void write(MathWriteInfo & os) const;
+ void write(WriteStream & os) const;
///
- void writeNormal(NormalStream &) const;
+ void normalize(NormalStream &) const;
///
void metrics(MathMetricsInfo const & st) const;
};
lyxerr << "\n macro: '" << this << "'\n";
lyxerr << " name: '" << name() << "'\n";
lyxerr << " template: '";
- MathWriteInfo wi(lyxerr);
+ WriteStream wi(lyxerr);
tmplate_->write(wi);
lyxerr << "'\n";
}
-void MathMacro::write(MathWriteInfo & os) const
+void MathMacro::write(WriteStream & os) const
{
os << '\\' << name();
for (idx_type i = 0; i < nargs(); ++i)
}
-void MathMacro::writeNormal(NormalStream & os) const
+void MathMacro::normalize(NormalStream & os) const
{
os << "[macro " << name() << " ";
- for (idx_type i = 0; i < nargs(); ++i) {
- cell(i).writeNormal(os);
- os << ' ';
- }
- os << "] ";
+ for (idx_type i = 0; i < nargs(); ++i)
+ os << cell(i) << ' ';
+ os << ']';
}
///
MathInset * clone() const;
///
- void write(MathWriteInfo & os) const;
+ void write(WriteStream & os) const;
///
- void writeNormal(NormalStream &) const;
+ void normalize(NormalStream &) const;
///
void dump() const;
}
-void MathMacroArgument::write(MathWriteInfo & os) const
+void MathMacroArgument::write(WriteStream & os) const
{
os << '#' << number_;
}
}
-void MathMacroArgument::writeNormal(NormalStream & os) const
+void MathMacroArgument::normalize(NormalStream & os) const
{
os << "[macroarg " << number_ << "] ";
}
///
void draw(Painter &, int x, int y) const;
///
- void write(MathWriteInfo & os) const;
+ void write(WriteStream & os) const;
///
- void writeNormal(NormalStream &) const;
+ void normalize(NormalStream &) const;
///
void substitute(MathMacro const & macro);
///
}
-void MathMacroTemplate::write(MathWriteInfo & os) const
+void MathMacroTemplate::write(WriteStream & os) const
{
os << "\n\\newcommand{\\" << name_.c_str() << '}';
if (numargs_ > 0)
///
MathInset * clone() const;
///
- void write(MathWriteInfo & os) const;
+ void write(WriteStream & os) const;
/// Number of arguments
int numargs() const;
///
#include "math_inset.h"
#include "math_mathmlstream.h"
+#include "math_extern.h"
MathMLStream::MathMLStream(std::ostream & os)
MathMLStream & MathMLStream::operator<<(MathArray const & ar)
{
- ar.mathmlize(*this);
+ mathmlize(ar, *this);
return *this;
}
MapleStream & MapleStream::operator<<(MathArray const & ar)
{
- ar.maplize(*this);
+ maplize(ar, *this);
return *this;
}
}
+MapleStream & MapleStream::operator<<(int i)
+{
+ os_ << i;
+ return *this;
+}
+
//////////////////////////////////////////////////////////////////////
OctaveStream & OctaveStream::operator<<(MathArray const & ar)
{
- ar.octavize(*this);
+ octavize(ar, *this);
return *this;
}
NormalStream & NormalStream::operator<<(MathInset const * p)
{
- p->writeNormal(*this);
+ p->normalize(*this);
return *this;
}
NormalStream & NormalStream::operator<<(MathArray const & ar)
{
- ar.writeNormal(*this);
+ normalize(ar, *this);
return *this;
}
//////////////////////////////////////////////////////////////////////
-MathWriteInfo::MathWriteInfo
+WriteStream::WriteStream
(Buffer const * buffer_, std::ostream & os_, bool fragile_)
: buffer(buffer_), os(os_), fragile(fragile_)
{}
-MathWriteInfo::MathWriteInfo(std::ostream & os_)
+WriteStream::WriteStream(std::ostream & os_)
: buffer(0), os(os_), fragile(false)
{}
-MathWriteInfo & MathWriteInfo::operator<<(MathInset const * p)
+WriteStream & WriteStream::operator<<(MathInset const * p)
{
p->write(*this);
return *this;
}
-MathWriteInfo & MathWriteInfo::operator<<(MathArray const & ar)
+WriteStream & WriteStream::operator<<(MathArray const & ar)
{
- ar.write(*this);
+ write(ar, *this);
return *this;
}
-MathWriteInfo & MathWriteInfo::operator<<(char const * s)
+WriteStream & WriteStream::operator<<(char const * s)
{
os << s;
return *this;
}
-MathWriteInfo & MathWriteInfo::operator<<(char c)
+WriteStream & WriteStream::operator<<(char c)
{
os << c;
return *this;
MapleStream & operator<<(char const *);
///
MapleStream & operator<<(char);
+ ///
+ MapleStream & operator<<(int);
};
};
-struct MathWriteInfo {
+struct WriteStream {
///
- MathWriteInfo(Buffer const * buffer_, std::ostream & os_, bool fragile_);
+ WriteStream(Buffer const * buffer_, std::ostream & os_, bool fragile_);
///
- explicit MathWriteInfo(std::ostream & os_);
+ explicit WriteStream(std::ostream & os_);
///
- MathWriteInfo & operator<<(MathInset const *);
+ WriteStream & operator<<(MathInset const *);
///
- MathWriteInfo & operator<<(MathArray const &);
+ WriteStream & operator<<(MathArray const &);
///
- MathWriteInfo & operator<<(char const *);
+ WriteStream & operator<<(char const *);
///
- MathWriteInfo & operator<<(char);
+ WriteStream & operator<<(char);
///
Buffer const * buffer;
--- /dev/null
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
+#include "math_matrixinset.h"
+#include "math_parser.h"
+#include "math_mathmlstream.h"
+#include "Lsstream.h"
+
+
+MathMatrixInset::MathMatrixInset(MathArrayInset const & p)
+ : MathArrayInset(p)
+{}
+
+
+MathInset * MathMatrixInset::clone() const
+{
+ return new MathMatrixInset(*this);
+}
+
+
+void MathMatrixInset::write(WriteStream & os) const
+{
+ MathArrayInset::write(os);
+}
+
+
+void MathMatrixInset::normalize(NormalStream & os) const
+{
+ MathArrayInset::normalize(os);
+}
+
+
+void MathMatrixInset::maplize(MapleStream & os) const
+{
+ os << "matrix(" << int(nrows()) << ',' << int(ncols()) << ",[";
+ for (idx_type idx = 0; idx < nargs(); ++idx) {
+ if (idx)
+ os << ',';
+ os << cell(idx);
+ }
+ os << "])";
+}
+
+
+void MathMatrixInset::mathmlize(MathMLStream & os) const
+{
+ os << MTag("mtable");
+ for (row_type row = 0; row < nrows(); ++row) {
+ os << MTag("mtr");
+ for (col_type col = 0; col < ncols(); ++col)
+ os << cell(index(row, col));
+ os << ETag("mtr");
+ }
+ os << ETag("mtable");
+}
+
+
+void MathMatrixInset::octavize(OctaveStream & os) const
+{
+ os << '[';
+ for (row_type row = 0; row < nrows(); ++row) {
+ if (row)
+ os << ';';
+ os << '[';
+ for (col_type col = 0; col < ncols(); ++col)
+ os << cell(index(row, col)) << ' ';
+ os << ']';
+ }
+ os << ']';
+}
--- /dev/null
+// -*- C++ -*-
+#ifndef MATH_MATRIXINSET_H
+#define MATH_MATRIXINSET_H
+
+#include "math_arrayinset.h"
+
+#ifdef __GNUG__
+#pragma interface
+#endif
+
+// "shortcut" for DelimInset("(",ArrayInset,")")
+
+class MathMatrixInset : public MathArrayInset {
+public:
+ ///
+ MathMatrixInset(MathArrayInset const &);
+ ///
+ MathMatrixInset(string const & str);
+ ///
+ MathInset * clone() const;
+ ///
+ void metrics(MathMetricsInfo const &) const {}
+ /// identifies MatrixInsets
+ MathMatrixInset const * asMatrixInset() const { return this; }
+
+ ///
+ void write(WriteStream & os) const;
+ ///
+ void normalize(NormalStream &) const;
+ ///
+ void maplize(MapleStream &) const;
+ ///
+ void mathmlize(MathMLStream &) const;
+ ///
+ void octavize(OctaveStream &) const;
+};
+
+#endif
void MathNestInset::dump() const
{
- MathWriteInfo os(lyxerr);
+ WriteStream os(lyxerr);
os << "---------------------------------------------\n";
write(os);
os << "\n";
}
-void MathNotInset::write(MathWriteInfo & os) const
+void MathNotInset::write(WriteStream & os) const
{
os << "\\not ";
}
-void MathNotInset::writeNormal(NormalStream & os) const
+void MathNotInset::normalize(NormalStream & os) const
{
os << "[not] ";
}
///
MathInset * clone() const;
///
- void write(MathWriteInfo & os) const;
+ void write(WriteStream & os) const;
///
- void writeNormal(NormalStream &) const;
+ void normalize(NormalStream &) const;
///
void metrics(MathMetricsInfo const & st) const;
///
}
if (outmost) {
- MathHullInset * m = t->asMatrixInset();
+ MathHullInset * m = t->asHullInset();
if (!m) {
lyxerr << "error in Parser::parse_lines() 2\n";
return false;
if (n.cat() == catMath) {
// TeX's $$...$$ syntax for displayed math
matrix = MathAtom(new MathHullInset(LM_OT_EQUATION));
- MathHullInset * p = matrix->asMatrixInset();
+ MathHullInset * p = matrix->asHullInset();
parse_into(p->cell(0), 0);
p->numbered(0, curr_num_);
p->label(0, curr_label_);
curr_num_ = 0;
curr_label_.erase();
matrix = MathAtom(new MathHullInset(LM_OT_EQUATION));
- MathHullInset * p = matrix->asMatrixInset();
+ MathHullInset * p = matrix->asHullInset();
parse_into(p->cell(0), 0);
p->numbered(0, curr_num_);
p->label(0, curr_label_);
curr_num_ = (name == "equation");
curr_label_.erase();
matrix = MathAtom(new MathHullInset(LM_OT_EQUATION));
- MathHullInset * p = matrix->asMatrixInset();
+ MathHullInset * p = matrix->asHullInset();
parse_into(p->cell(0), FLAG_END);
p->numbered(0, curr_num_);
p->label(0, curr_label_);
}
-void MathRootInset::write(MathWriteInfo & os) const
+void MathRootInset::write(WriteStream & os) const
{
os << "\\sqrt[" << cell(0) << "]{" << cell(1) << '}';
}
-void MathRootInset::writeNormal(NormalStream & os) const
+void MathRootInset::normalize(NormalStream & os) const
{
- os << "[root ";
- cell(1).writeNormal(os);
- os << " ";
- cell(0).writeNormal(os);
- os << "]";
+ os << "[root " << cell(1) << ' ' << cell(1) << ']';
}
void MathRootInset::mathmlize(MathMLStream & os) const
{
- os << "<mroot>" << cell(1) << cell(0) << "</mroot>";
+ os << MTag("mroot") << cell(1) << cell(0) << ETag("mroot");
}
///
MathInset * clone() const;
///
- void draw(Painter &, int x, int y) const;
- ///
- void write(MathWriteInfo & os) const;
+ bool idxUp(int & idx, int & pos) const;
///
- void writeNormal(NormalStream &) const;
+ bool idxDown(int & idx, int & pos) const;
///
void metrics(MathMetricsInfo const & st) const;
///
- bool idxUp(int & idx, int & pos) const;
+ void draw(Painter &, int x, int y) const;
+
///
- bool idxDown(int & idx, int & pos) const;
+ void write(WriteStream & os) const;
+ ///
+ void normalize(NormalStream &) const;
///
void mathmlize(MathMLStream &) const;
///
}
-void MathScriptInset::write(MathWriteInfo & os) const
+void MathScriptInset::write(WriteStream & os) const
{
//lyxerr << "unexpected call to MathScriptInset::write()\n";
write(0, os);
}
-void MathScriptInset::write(MathInset const * nuc, MathWriteInfo & os) const
+void MathScriptInset::write(MathInset const * nuc, WriteStream & os) const
{
if (nuc) {
os << nuc;
}
-void MathScriptInset::writeNormal(NormalStream & os) const
+void MathScriptInset::normalize(NormalStream & os) const
{
- //lyxerr << "unexpected call to MathScriptInset::writeNormal()\n";
- writeNormal(0, os);
+ //lyxerr << "unexpected call to MathScriptInset::normalize()\n";
+ normalize(0, os);
}
-void MathScriptInset::writeNormal(MathInset const * nuc, NormalStream & os) const
+void MathScriptInset::normalize(MathInset const * nuc, NormalStream & os) const
{
bool d = hasDown() && down().data_.size();
bool u = hasUp() && up().data_.size();
///
MathInset * clone() const;
///
- void write(MathWriteInfo & os) const;
+ void write(WriteStream & os) const;
///
- void writeNormal(NormalStream & os) const;
+ void normalize(NormalStream & os) const;
///
void metrics(MathMetricsInfo const & st) const;
///
void ensure(bool up);
///
- void write(MathInset const * nuc, MathWriteInfo & os) const;
+ void write(MathInset const * nuc, WriteStream & os) const;
///
- void writeNormal(MathInset const * nuc, NormalStream & os) const;
+ void normalize(MathInset const * nuc, NormalStream & os) const;
///
void octavize(MathInset const * nuc, OctaveStream & os) const;
///
}
-void MathSizeInset::write(MathWriteInfo & os) const
+void MathSizeInset::write(WriteStream & os) const
{
os << "{\\" << key_->name.c_str() << ' ' << cell(0) << '}';
}
-void MathSizeInset::writeNormal(NormalStream & os) const
+void MathSizeInset::normalize(NormalStream & os) const
{
os << "[" << key_->name.c_str() << ' ' << cell(0) << ']';
}
///
void draw(Painter &, int x, int y) const;
///
- void write(MathWriteInfo & os) const;
+ void write(WriteStream & os) const;
///
- void writeNormal(NormalStream &) const;
+ void normalize(NormalStream &) const;
private:
///
}
-void MathSpaceInset::write(MathWriteInfo & os) const
+void MathSpaceInset::write(WriteStream & os) const
{
if (space_ >= 0 && space_ < 6)
os << '\\' << latex_mathspace[space_] << ' ';
}
-void MathSpaceInset::writeNormal(NormalStream & os) const
+void MathSpaceInset::normalize(NormalStream & os) const
{
os << "[space " << space_ << "] ";
}
///
void draw(Painter &, int x, int y) const;
///
- void write(MathWriteInfo & os) const;
+ void write(WriteStream & os) const;
///
- void writeNormal(NormalStream &) const;
+ void normalize(NormalStream &) const;
///
void metrics(MathMetricsInfo const & st) const;
///
}
-void MathSpecialCharInset::write(MathWriteInfo & os) const
+void MathSpecialCharInset::write(WriteStream & os) const
{
os << "\\" << char_;
}
-void MathSpecialCharInset::writeNormal(NormalStream & os) const
+void MathSpecialCharInset::normalize(NormalStream & os) const
{
os << "\\" << char_;
}
///
void draw(Painter &, int x, int y) const;
///
- void write(MathWriteInfo & os) const;
+ void write(WriteStream & os) const;
///
- void writeNormal(NormalStream &) const;
+ void normalize(NormalStream &) const;
///
int ascent() const;
///
}
-void MathSplitInset::write(MathWriteInfo & os) const
+void MathSplitInset::write(WriteStream & os) const
{
if (os.fragile)
os << "\\protect";
///
MathInset * clone() const;
///
- void write(MathWriteInfo & os) const;
+ void write(WriteStream & os) const;
///
int defaultColSpace(int) { return 0; }
///
}
-void MathSqrtInset::write(MathWriteInfo & os) const
+void MathSqrtInset::write(WriteStream & os) const
{
os << "\\sqrt{" << cell(0) << '}';
}
-void MathSqrtInset::writeNormal(NormalStream & os) const
+void MathSqrtInset::normalize(NormalStream & os) const
{
- os << "[sqrt ";
- cell(0).writeNormal(os);
- os << "]";
+ os << "[sqrt " << cell(0) << ']';
}
void MathSqrtInset::mathmlize(MathMLStream & os) const
{
- os << "<msqrt>" << cell(0) << "</msqrt>";
+ os << MTag("msqrt") << cell(0) << ETag("msqrt");
}
///
void draw(Painter &, int x, int y) const;
///
- void write(MathWriteInfo & os) const;
+ void metrics(MathMetricsInfo const & st) const;
+
///
- void writeNormal(NormalStream &) const;
+ void write(WriteStream & os) const;
///
- void metrics(MathMetricsInfo const & st) const;
+ void normalize(NormalStream &) const;
///
void maplize(MapleStream &) const;
///
}
-void MathStackrelInset::write(MathWriteInfo & os) const
+void MathStackrelInset::write(WriteStream & os) const
{
os << "\\stackrel{" << cell(0) << "}{" << cell(1) << '}';
}
-void MathStackrelInset::writeNormal(NormalStream & os) const
+void MathStackrelInset::normalize(NormalStream & os) const
{
- os << "[stackrel ";
- cell(0).writeNormal(os);
- os << " ";
- cell(1).writeNormal(os);
- os << "] ";
+ os << "[stackrel " << cell(0) << ' ' << cell(1) << ']';
}
///
MathInset * clone() const;
///
- void write(MathWriteInfo & os) const;
- ///
- void writeNormal(NormalStream &) const;
- ///
void metrics(MathMetricsInfo const & st) const;
///
void draw(Painter &, int x, int y) const;
+
+ ///
+ void write(WriteStream & os) const;
+ ///
+ void normalize(NormalStream &) const;
};
#endif
}
-void MathStringInset::write(MathWriteInfo & os) const
+void MathStringInset::write(WriteStream & os) const
{
if (math_font_name(code_))
os << '\\' << math_font_name(code_) << '{' << str_.c_str() << '}';
}
-void MathStringInset::writeNormal(NormalStream & os) const
+void MathStringInset::normalize(NormalStream & os) const
{
os << "[string " << str_.c_str() << ' ' << "mathalpha" << "]";
}
///
void draw(Painter &, int x, int y) const;
///
- void write(MathWriteInfo & os) const;
+ void write(WriteStream & os) const;
///
- void writeNormal(NormalStream &) const;
+ void normalize(NormalStream &) const;
///
int ascent() const;
///
}
-void MathSymbolInset::write(MathWriteInfo & os) const
+void MathSymbolInset::write(WriteStream & os) const
{
os << '\\' << sym_->name.c_str() << ' ';
}
-void MathSymbolInset::writeNormal(NormalStream & os) const
+void MathSymbolInset::normalize(NormalStream & os) const
{
os << "[symbol " << sym_->name.c_str() << "]";
}
///
MathInset * clone() const;
///
- void write(MathWriteInfo & os) const;
+ void write(WriteStream & os) const;
///
- void writeNormal(NormalStream &) const;
+ void normalize(NormalStream &) const;
///
void metrics(MathMetricsInfo const & st) const;
///
#pragma implementation
#endif
-#include "math_inset.h"
#include "math_scriptinset.h"
#include "math_support.h"
-#include "math_defs.h"
#include "Painter.h"
#include "debug.h"
+extern MathScriptInset const * asScript(MathArray::const_iterator it);
+
+
MathXArray::MathXArray()
: width_(0), ascent_(0), descent_(0), xo_(0), yo_(0), size_()
{}
for (const_iterator it = begin(); it != end(); ++it) {
MathInset const * p = it->nucleus();
- if (MathScriptInset const * q = data_.asScript(it)) {
+ MathScriptInset const * q = (it + 1 == end()) ? 0 : asScript(it);
+ if (q) {
q->metrics(p, st);
ascent_ = std::max(ascent_, q->ascent(p));
descent_ = std::max(descent_, q->descent(p));
for (const_iterator it = begin(); it != end(); ++it) {
MathInset const * p = it->nucleus();
- if (MathScriptInset const * q = data_.asScript(it)) {
+ MathScriptInset const * q = (it + 1 == end()) ? 0 : asScript(it);
+ if (q) {
q->draw(p, pain, x, y);
x += q->width(p);
++it;
const_iterator target = std::min(begin() + targetpos, end());
for (const_iterator it = begin(); it < target; ++it) {
MathInset const * p = it->nucleus();
- if (MathScriptInset const * q = data_.asScript(it)) {
+ MathScriptInset const * q = (it + 1 == end()) ? 0 : asScript(it);
+ if (q) {
++it;
if (it < target)
x += q->width(p);
int wid = 0;
MathInset const * p = it->nucleus();
- if (MathScriptInset const * q = data_.asScript(it)) {
+ MathScriptInset const * q = 0;
+ if (it + 1 != end())
+ q = asScript(it);
+ if (q) {
wid = q->width(p);
++it;
} else