some support for matrix operations with maple ('M-x math-extern maple evalm')

further cosmetics


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2991 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
André Pönitz 2001-11-09 08:35:57 +00:00
parent 83bf7d7ab8
commit c93e9dcbc5
81 changed files with 430 additions and 519 deletions

View File

@ -41,6 +41,8 @@ libmathed_la_SOURCES = \
math_diminset.h \
math_dotsinset.C \
math_dotsinset.h \
math_extern.C \
math_extern.h \
math_exfuncinset.C \
math_exfuncinset.h \
math_exintinset.C \
@ -76,6 +78,8 @@ libmathed_la_SOURCES = \
math_macrotable.h \
math_mathmlstream.C \
math_mathmlstream.h \
math_matrixinset.C \
math_matrixinset.h \
math_metricsinfo.h \
math_metricsinfo.C \
math_nestinset.C \

View File

@ -87,7 +87,7 @@ namespace {
"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}` = `\\\\\\\\`,"
@ -226,7 +226,7 @@ namespace {
ostringstream os;
NormalStream ns(os);
os << "[" << extra << ' ';
ar.writeNormal(ns);
ns << ar;
os << "]";
string data = os.str().c_str();
@ -290,7 +290,7 @@ void InsetFormula::write(Buffer const * buf, ostream & os) const
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;
}
@ -298,7 +298,7 @@ int InsetFormula::latex(Buffer const * buf, ostream & os, bool fragil, bool)
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;
}
@ -539,15 +539,15 @@ bool InsetFormula::display() const
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();
}

View File

@ -78,7 +78,7 @@ Inset * InsetFormulaMacro::clone(Buffer const &, bool) const
void InsetFormulaMacro::write(Buffer const * buf, ostream & os) const
{
os << "FormulaMacro ";
MathWriteInfo wi(buf, os, false);
WriteStream wi(buf, os, false);
par()->write(wi);
}
@ -86,7 +86,7 @@ void InsetFormulaMacro::write(Buffer const * buf, ostream & os) const
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;
}
@ -94,7 +94,7 @@ int InsetFormulaMacro::latex(Buffer const * buf, ostream & os, bool fragile,
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;
}

View File

@ -4,11 +4,11 @@
#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)
@ -52,7 +52,16 @@ MathInset * MathArrayInset::clone() const
}
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";
@ -74,18 +83,17 @@ void MathArrayInset::write(MathWriteInfo & os) const
}
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 << ")";
}

View File

@ -20,13 +20,16 @@ public:
///
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

View File

@ -55,6 +55,14 @@ MathAtom::~MathAtom()
}
void MathAtom::reset(MathInset * p)
{
done();
nucleus_ = p;
}
void MathAtom::done()
{
delete nucleus_;

View File

@ -41,6 +41,8 @@ public:
///
void operator=(MathAtom const &);
///
void reset(MathInset * p);
///
MathInset * nucleus() const;
///
MathInset * operator->() const;

View File

@ -45,13 +45,13 @@ void MathBinaryOpInset::draw(Painter & pain, int x, int y) 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) << ']';
}

View File

@ -21,9 +21,9 @@ public:
///
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:

View File

@ -51,17 +51,13 @@ void MathBinomInset::draw(Painter & pain, int x, int y) const
}
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) << ']';
}

View File

@ -18,9 +18,9 @@ public:
///
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;
///

View File

@ -45,13 +45,13 @@ UpdatableInset * MathBoxInset::asHyperActiveInset() 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);

View File

@ -30,9 +30,9 @@ public:
///
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

View File

@ -21,20 +21,6 @@ MathInset * MathBraceInset::clone() const
}
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);
@ -52,3 +38,17 @@ void MathBraceInset::draw(Painter & pain, int x, int y) const
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) << ']';
}

View File

@ -22,9 +22,9 @@ public:
///
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;

View File

@ -94,7 +94,7 @@ void MathCharInset::writeRaw(std::ostream & os) const
}
void MathCharInset::write(MathWriteInfo & os) const
void MathCharInset::write(WriteStream & os) const
{
writeHeader(os.os);
writeRaw(os.os);
@ -102,7 +102,7 @@ void MathCharInset::write(MathWriteInfo & os) const
}
void MathCharInset::writeNormal(NormalStream & os) const
void MathCharInset::normalize(NormalStream & os) const
{
os << "[char " << char_ << " " << "mathalpha" << "]";
}

View File

@ -27,7 +27,7 @@ public:
///
void draw(Painter &, int x, int y) const;
///
void write(MathWriteInfo & os) const;
void write(WriteStream & os) const;
///
void writeHeader(std::ostream &) const;
///
@ -35,7 +35,7 @@ public:
///
void writeRaw(std::ostream &) const;
///
void writeNormal(NormalStream &) const;
void normalize(NormalStream &) const;
///
int ascent() const;
///

View File

@ -974,7 +974,7 @@ void MathCursor::normalize() 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");
@ -1091,7 +1091,7 @@ void MathCursor::breakLine()
while (popRight())
;
MathHullInset * p = formula()->par()->asMatrixInset();
MathHullInset * p = formula()->par()->asHullInset();
if (!p)
return;
@ -1104,12 +1104,8 @@ void MathCursor::breakLine()
// 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();

View File

@ -3,9 +3,11 @@
#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"
@ -29,19 +31,6 @@ void MathArray::substitute(MathMacro const & m)
}
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());
@ -146,147 +135,6 @@ void MathArray::dump() const
}
// 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)
@ -327,11 +175,3 @@ MathArray::iterator MathArray::end()
{
return bf_.end();
}
bool MathArray::isMatrix() const
{
return size() == 1 && begin()->nucleus() && begin()->nucleus()->isMatrix();
}

View File

@ -23,13 +23,7 @@
class MathScriptInset;
class MathMacro;
class MathWriteInfo;
class MathMetricsInfo;
class LaTeXFeatures;
class NormalStream;
class MapleStream;
class MathMLStream;
class OctaveStream;
#ifdef __GNUG__
@ -104,10 +98,6 @@ public:
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;
///
@ -118,22 +108,6 @@ public:
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

View File

@ -91,7 +91,7 @@ void MathDecorationInset::draw(Painter & pain, int x, int y) const
}
void MathDecorationInset::write(MathWriteInfo & os) const
void MathDecorationInset::write(WriteStream & os) const
{
if (os.fragile && protect())
os << "\\protect";
@ -99,7 +99,7 @@ void MathDecorationInset::write(MathWriteInfo & os) const
}
void MathDecorationInset::writeNormal(NormalStream & os) const
void MathDecorationInset::normalize(NormalStream & os) const
{
os << "[deco " << name_.c_str() << ' ' << cell(0) << ']';
}

View File

@ -22,11 +22,11 @@ public:
///
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;

View File

@ -7,8 +7,8 @@
#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)
@ -42,14 +42,14 @@ string MathDelimInset::latexName(string const & name)
}
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) << ']';
@ -91,17 +91,13 @@ void MathDelimInset::draw(Painter & pain, int x, int y) const
}
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) << ")";

View File

@ -20,28 +20,31 @@ public:
///
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);
};

View File

@ -42,13 +42,13 @@ void MathDotsInset::metrics(MathMetricsInfo const & mi) const
}
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() << "] ";
}

View File

@ -19,9 +19,9 @@ public:
///
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:

View File

@ -17,13 +17,13 @@ MathInset * MathExFuncInset::clone() const
}
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) << ']';
}

View File

@ -14,9 +14,9 @@ public:
///
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;
///

View File

@ -18,14 +18,14 @@ MathInset * MathExIntInset::clone() 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_ << ']'
}

View File

@ -18,9 +18,9 @@ public:
///
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;
///

View File

@ -41,7 +41,7 @@ void MathFracInset::draw(Painter & pain, int x, int y) const
}
void MathFracInset::write(MathWriteInfo & os) const
void MathFracInset::write(WriteStream & os) const
{
if (atop_)
os << '{' << cell(0) << "\\atop " << cell(1) << '}';
@ -50,16 +50,13 @@ void MathFracInset::write(MathWriteInfo & os) const
}
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) << ']';
}

View File

@ -18,13 +18,14 @@ public:
///
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;
///

View File

@ -36,13 +36,13 @@ void MathFuncInset::setName(string const & n)
}
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() << ']';
}

View File

@ -23,9 +23,9 @@ public:
///
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;
///

View File

@ -20,13 +20,13 @@ bool MathFuncLimInset::isScriptable() 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() << ']';
}

View File

@ -14,9 +14,9 @@ public:
///
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;
///

View File

@ -262,7 +262,7 @@ void MathGridInset::draw(Painter & pain, int x, int y) 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)
@ -272,7 +272,7 @@ void MathGridInset::write(MathWriteInfo & os) const
}
void MathGridInset::writeNormal(NormalStream & os) const
void MathGridInset::normalize(NormalStream & os) const
{
os << "[grid ";
for (row_type row = 0; row < nrows(); ++row) {
@ -583,48 +583,3 @@ std::vector<MathInset::idx_type>
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 << ']';
}

View File

@ -64,10 +64,6 @@ public:
///
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;
@ -149,12 +145,18 @@ public:
///
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

View File

@ -645,7 +645,7 @@ void MathHullInset::mutate(MathInsetTypes newtype)
}
void MathHullInset::write(MathWriteInfo & os) const
void MathHullInset::write(WriteStream & os) const
{
header_write(os.os);
@ -667,10 +667,10 @@ void MathHullInset::write(MathWriteInfo & os) const
}
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 << "] ";
}

View File

@ -25,9 +25,9 @@ public:
///
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;
///
@ -51,9 +51,9 @@ public:
///
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);

View File

@ -44,7 +44,7 @@ int MathInset::height() const
std::ostream & operator<<(std::ostream & os, MathInset const & inset)
{
MathWriteInfo wi(0, os, false);
WriteStream wi(0, os, false);
inset.write(wi);
return os;
}
@ -161,10 +161,10 @@ void MathInset::idxDeleteRange(idx_type, idx_type)
{}
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 << "] ";
}
@ -173,7 +173,7 @@ void MathInset::writeNormal(NormalStream & os) const
void MathInset::dump() const
{
lyxerr << "---------------------------------------------\n";
MathWriteInfo wi(0, lyxerr, false);
WriteStream wi(0, lyxerr, false);
write(wi);
lyxerr << "\n---------------------------------------------\n";
}
@ -212,7 +212,7 @@ void MathInset::draw(Painter &, int, int) const
}
void MathInset::write(MathWriteInfo &) const
void MathInset::write(WriteStream &) const
{
lyxerr << "MathInset::write() called directly!\n";
}
@ -221,19 +221,19 @@ void MathInset::write(MathWriteInfo &) const
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);
}

View File

@ -41,13 +41,22 @@
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;
@ -74,7 +83,7 @@ public:
/// 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
@ -168,18 +177,24 @@ public:
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
@ -195,8 +210,6 @@ public:
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; }
@ -216,7 +229,7 @@ public:
virtual void handleFont(MathTextCodes) {}
/// write normalized content
virtual void writeNormal(NormalStream &) const;
virtual void normalize(NormalStream &) const;
///
virtual void maplize(MapleStream &) const;
///

View File

@ -44,13 +44,13 @@ void MathKernInset::metrics(MathMetricsInfo const &) 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() << "]";
}

View File

@ -25,9 +25,9 @@ public:
///
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:

View File

@ -39,16 +39,13 @@ void MathLefteqnInset::draw(Painter & pain, int x, int y) const
}
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) << ']';
}

View File

@ -19,9 +19,9 @@ public:
///
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;
};

View File

@ -155,13 +155,13 @@ void MathMacro::dump() 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)
@ -171,14 +171,12 @@ void MathMacro::write(MathWriteInfo & os) const
}
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 << ']';
}

View File

@ -48,9 +48,9 @@ public:
///
MathInset * clone() const;
///
void write(MathWriteInfo & os) const;
void write(WriteStream & os) const;
///
void writeNormal(NormalStream &) const;
void normalize(NormalStream &) const;
///
void dump() const;

View File

@ -30,7 +30,7 @@ MathInset * MathMacroArgument::clone() const
}
void MathMacroArgument::write(MathWriteInfo & os) const
void MathMacroArgument::write(WriteStream & os) const
{
os << '#' << number_;
}
@ -58,7 +58,7 @@ void MathMacroArgument::draw(Painter & pain, int x, int y) const
}
void MathMacroArgument::writeNormal(NormalStream & os) const
void MathMacroArgument::normalize(NormalStream & os) const
{
os << "[macroarg " << number_ << "] ";
}

View File

@ -22,9 +22,9 @@ public:
///
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);
///

View File

@ -64,7 +64,7 @@ void MathMacroTemplate::draw(Painter & pain, int x, int y) const
}
void MathMacroTemplate::write(MathWriteInfo & os) const
void MathMacroTemplate::write(WriteStream & os) const
{
os << "\n\\newcommand{\\" << name_.c_str() << '}';
if (numargs_ > 0)

View File

@ -25,7 +25,7 @@ public:
///
MathInset * clone() const;
///
void write(MathWriteInfo & os) const;
void write(WriteStream & os) const;
/// Number of arguments
int numargs() const;
///

View File

@ -1,6 +1,7 @@
#include "math_inset.h"
#include "math_mathmlstream.h"
#include "math_extern.h"
MathMLStream::MathMLStream(std::ostream & os)
@ -17,7 +18,7 @@ MathMLStream & MathMLStream::operator<<(MathInset const * p)
MathMLStream & MathMLStream::operator<<(MathArray const & ar)
{
ar.mathmlize(*this);
mathmlize(ar, *this);
return *this;
}
@ -76,7 +77,7 @@ MapleStream & MapleStream::operator<<(MathInset const * p)
MapleStream & MapleStream::operator<<(MathArray const & ar)
{
ar.maplize(*this);
maplize(ar, *this);
return *this;
}
@ -95,6 +96,12 @@ MapleStream & MapleStream::operator<<(char c)
}
MapleStream & MapleStream::operator<<(int i)
{
os_ << i;
return *this;
}
//////////////////////////////////////////////////////////////////////
@ -108,7 +115,7 @@ OctaveStream & OctaveStream::operator<<(MathInset const * p)
OctaveStream & OctaveStream::operator<<(MathArray const & ar)
{
ar.octavize(*this);
octavize(ar, *this);
return *this;
}
@ -132,14 +139,14 @@ OctaveStream & OctaveStream::operator<<(char c)
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;
}
@ -162,39 +169,39 @@ NormalStream & NormalStream::operator<<(char c)
//////////////////////////////////////////////////////////////////////
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;

View File

@ -78,6 +78,8 @@ struct MapleStream {
MapleStream & operator<<(char const *);
///
MapleStream & operator<<(char);
///
MapleStream & operator<<(int);
};
@ -97,20 +99,20 @@ struct OctaveStream {
};
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;

View File

@ -0,0 +1,71 @@
#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 << ']';
}

View File

@ -0,0 +1,38 @@
// -*- 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

View File

@ -136,7 +136,7 @@ bool MathNestInset::idxEnd(idx_type & idx, pos_type & pos) const
void MathNestInset::dump() const
{
MathWriteInfo os(lyxerr);
WriteStream os(lyxerr);
os << "---------------------------------------------\n";
write(os);
os << "\n";

View File

@ -14,13 +14,13 @@ MathInset * MathNotInset::clone() const
}
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] ";
}

View File

@ -13,9 +13,9 @@ public:
///
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;
///

View File

@ -492,7 +492,7 @@ bool Parser::parse_lines(MathAtom & t, bool numbered, bool outmost)
}
if (outmost) {
MathHullInset * m = t->asMatrixInset();
MathHullInset * m = t->asHullInset();
if (!m) {
lyxerr << "error in Parser::parse_lines() 2\n";
return false;
@ -579,7 +579,7 @@ bool Parser::parse_normal(MathAtom & matrix)
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_);
@ -603,7 +603,7 @@ bool Parser::parse_normal(MathAtom & matrix)
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_);
@ -621,7 +621,7 @@ bool Parser::parse_normal(MathAtom & matrix)
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_);

View File

@ -58,19 +58,15 @@ void MathRootInset::draw(Painter & pain, int x, int y) const
}
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) << ']';
}
@ -102,5 +98,5 @@ void MathRootInset::octavize(OctaveStream & os) const
void MathRootInset::mathmlize(MathMLStream & os) const
{
os << "<mroot>" << cell(1) << cell(0) << "</mroot>";
os << MTag("mroot") << cell(1) << cell(0) << ETag("mroot");
}

View File

@ -32,18 +32,19 @@ public:
///
MathInset * clone() const;
///
void draw(Painter &, int x, int y) const;
///
void write(MathWriteInfo & os) const;
///
void writeNormal(NormalStream &) const;
///
void metrics(MathMetricsInfo const & st) const;
///
bool idxUp(int & idx, int & pos) const;
///
bool idxDown(int & idx, int & pos) 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 mathmlize(MathMLStream &) const;
///
void octavize(OctaveStream &) const;

View File

@ -272,14 +272,14 @@ bool MathScriptInset::idxLeft(MathInset::idx_type &,
}
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;
@ -301,14 +301,14 @@ void MathScriptInset::write(MathInset const * nuc, MathWriteInfo & os) const
}
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();

View File

@ -21,9 +21,9 @@ public:
///
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;
///
@ -78,9 +78,9 @@ public:
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;
///

View File

@ -35,13 +35,13 @@ void MathSizeInset::metrics(MathMetricsInfo const & mi) 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) << ']';
}

View File

@ -26,9 +26,9 @@ public:
///
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:
///

View File

@ -21,14 +21,14 @@ MathInset * MathSpaceInset::clone() const
}
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_ << "] ";
}

View File

@ -19,9 +19,9 @@ public:
///
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;
///

View File

@ -48,13 +48,13 @@ void MathSpecialCharInset::draw(Painter & pain, int x, int y) 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_;
}

View File

@ -24,9 +24,9 @@ public:
///
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;
///

View File

@ -19,7 +19,7 @@ MathInset * MathSplitInset::clone() const
}
void MathSplitInset::write(MathWriteInfo & os) const
void MathSplitInset::write(WriteStream & os) const
{
if (os.fragile)
os << "\\protect";

View File

@ -16,7 +16,7 @@ public:
///
MathInset * clone() const;
///
void write(MathWriteInfo & os) const;
void write(WriteStream & os) const;
///
int defaultColSpace(int) { return 0; }
///

View File

@ -43,17 +43,15 @@ void MathSqrtInset::draw(Painter & pain, int x, int y) const
}
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) << ']';
}
@ -65,5 +63,5 @@ void MathSqrtInset::maplize(MapleStream & os) const
void MathSqrtInset::mathmlize(MathMLStream & os) const
{
os << "<msqrt>" << cell(0) << "</msqrt>";
os << MTag("msqrt") << cell(0) << ETag("msqrt");
}

View File

@ -20,11 +20,12 @@ public:
///
void draw(Painter &, int x, int y) const;
///
void write(MathWriteInfo & os) const;
///
void writeNormal(NormalStream &) const;
///
void metrics(MathMetricsInfo const & st) const;
///
void write(WriteStream & os) const;
///
void normalize(NormalStream &) const;
///
void maplize(MapleStream &) const;
///

View File

@ -37,17 +37,13 @@ void MathStackrelInset::draw(Painter & pain, int x, int y) 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) << ']';
}

View File

@ -18,13 +18,14 @@ public:
///
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

View File

@ -55,7 +55,7 @@ void MathStringInset::draw(Painter & pain, int x, int y) const
}
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() << '}';
@ -64,7 +64,7 @@ void MathStringInset::write(MathWriteInfo & os) const
}
void MathStringInset::writeNormal(NormalStream & os) const
void MathStringInset::normalize(NormalStream & os) const
{
os << "[string " << str_.c_str() << ' ' << "mathalpha" << "]";
}

View File

@ -23,9 +23,9 @@ public:
///
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;
///

View File

@ -16,13 +16,13 @@ MathInset * MathSymbolInset::clone() 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() << "]";
}

View File

@ -18,9 +18,9 @@ public:
///
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;
///

View File

@ -4,14 +4,15 @@
#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_()
{}
@ -32,7 +33,8 @@ void MathXArray::metrics(MathMetricsInfo const & st) const
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));
@ -62,7 +64,8 @@ void MathXArray::draw(Painter & pain, int x, int y) const
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;
@ -80,7 +83,8 @@ int MathXArray::pos2x(size_type targetpos) const
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);
@ -103,7 +107,10 @@ MathArray::size_type MathXArray::x2pos(int targetx) const
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