2001-06-25 00:06:33 +00:00
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma implementation
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "math_scriptinset.h"
|
2001-11-08 12:15:12 +00:00
|
|
|
#include "math_support.h"
|
2001-11-27 13:57:49 +00:00
|
|
|
#include "math_symbolinset.h"
|
2001-11-08 12:06:56 +00:00
|
|
|
#include "math_mathmlstream.h"
|
|
|
|
#include "support/LAssert.h"
|
2001-11-27 13:57:49 +00:00
|
|
|
#include "debug.h"
|
2001-10-24 16:10:38 +00:00
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
|
2002-02-16 15:59:55 +00:00
|
|
|
using std::max;
|
|
|
|
|
|
|
|
|
2001-10-12 12:02:49 +00:00
|
|
|
MathScriptInset::MathScriptInset()
|
2002-07-30 13:56:02 +00:00
|
|
|
: MathNestInset(3), limits_(0)
|
2001-10-12 12:02:49 +00:00
|
|
|
{
|
|
|
|
script_[0] = false;
|
|
|
|
script_[1] = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-09-11 10:58:17 +00:00
|
|
|
MathScriptInset::MathScriptInset(bool up)
|
2002-07-30 13:56:02 +00:00
|
|
|
: MathNestInset(3), limits_(0)
|
2001-10-12 12:02:49 +00:00
|
|
|
{
|
|
|
|
script_[0] = !up;
|
|
|
|
script_[1] = up;
|
|
|
|
}
|
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
|
2002-07-30 13:56:02 +00:00
|
|
|
MathScriptInset::MathScriptInset(MathAtom const & at, bool up)
|
|
|
|
: MathNestInset(3), limits_(0)
|
|
|
|
{
|
|
|
|
script_[0] = !up;
|
|
|
|
script_[1] = up;
|
|
|
|
cell(2).push_back(at);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
MathInset * MathScriptInset::clone() const
|
2001-06-25 00:06:33 +00:00
|
|
|
{
|
2001-09-11 10:58:17 +00:00
|
|
|
return new MathScriptInset(*this);
|
2001-07-26 06:46:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-09-24 16:25:06 +00:00
|
|
|
MathScriptInset const * MathScriptInset::asScriptInset() const
|
|
|
|
{
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2001-10-12 12:02:49 +00:00
|
|
|
|
|
|
|
MathScriptInset * MathScriptInset::asScriptInset()
|
2001-07-26 06:46:50 +00:00
|
|
|
{
|
2001-10-12 12:02:49 +00:00
|
|
|
return this;
|
2001-07-26 06:46:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-07-30 13:56:02 +00:00
|
|
|
bool MathScriptInset::idxFirst(idx_type & idx, pos_type & pos) const
|
2001-07-26 06:46:50 +00:00
|
|
|
{
|
2002-07-30 13:56:02 +00:00
|
|
|
idx = 2;
|
2002-08-01 11:48:53 +00:00
|
|
|
pos = 0;
|
2002-07-30 13:56:02 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool MathScriptInset::idxLast(idx_type & idx, pos_type & pos) const
|
|
|
|
{
|
|
|
|
idx = 2;
|
|
|
|
pos = nuc().size();
|
|
|
|
return true;
|
2001-07-26 06:46:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-08-02 14:29:42 +00:00
|
|
|
MathArray const & MathScriptInset::down() const
|
2001-10-12 12:02:49 +00:00
|
|
|
{
|
2002-08-02 14:29:42 +00:00
|
|
|
return cell(0);
|
2001-10-12 12:02:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-08-02 14:29:42 +00:00
|
|
|
MathArray & MathScriptInset::down()
|
2002-07-30 13:56:02 +00:00
|
|
|
{
|
2002-08-02 14:29:42 +00:00
|
|
|
return cell(0);
|
2002-07-30 13:56:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-08-02 14:29:42 +00:00
|
|
|
MathArray const & MathScriptInset::up() const
|
2001-10-12 12:02:49 +00:00
|
|
|
{
|
2002-08-02 14:29:42 +00:00
|
|
|
return cell(1);
|
2001-10-12 12:02:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-08-02 14:29:42 +00:00
|
|
|
MathArray & MathScriptInset::up()
|
2001-09-11 10:58:17 +00:00
|
|
|
{
|
2002-08-02 14:29:42 +00:00
|
|
|
return cell(1);
|
2001-10-12 12:02:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MathScriptInset::ensure(bool up)
|
|
|
|
{
|
|
|
|
script_[up] = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-08-02 14:29:42 +00:00
|
|
|
MathArray const & MathScriptInset::nuc() const
|
2002-07-30 13:56:02 +00:00
|
|
|
{
|
2002-08-02 14:29:42 +00:00
|
|
|
return cell(2);
|
2002-07-30 13:56:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-08-02 14:29:42 +00:00
|
|
|
MathArray & MathScriptInset::nuc()
|
2002-07-30 13:56:02 +00:00
|
|
|
{
|
2002-08-02 14:29:42 +00:00
|
|
|
return cell(2);
|
2002-07-30 13:56:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int MathScriptInset::dy0() const
|
2001-10-12 12:02:49 +00:00
|
|
|
{
|
2002-07-30 13:56:02 +00:00
|
|
|
int nd = ndes();
|
2001-10-12 12:02:49 +00:00
|
|
|
if (!hasDown())
|
|
|
|
return nd;
|
|
|
|
int des = down().ascent();
|
2002-07-30 13:56:02 +00:00
|
|
|
if (hasLimits())
|
2001-10-12 12:02:49 +00:00
|
|
|
des += nd + 2;
|
2002-03-21 17:42:56 +00:00
|
|
|
else
|
2002-02-16 15:59:55 +00:00
|
|
|
des = max(des, nd);
|
2001-10-12 12:02:49 +00:00
|
|
|
return des;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-07-30 13:56:02 +00:00
|
|
|
int MathScriptInset::dy1() const
|
2001-10-12 12:02:49 +00:00
|
|
|
{
|
2002-07-30 13:56:02 +00:00
|
|
|
int na = nasc();
|
2001-10-12 12:02:49 +00:00
|
|
|
if (!hasUp())
|
|
|
|
return na;
|
|
|
|
int asc = up().descent();
|
2002-07-30 13:56:02 +00:00
|
|
|
if (hasLimits())
|
2001-10-12 12:02:49 +00:00
|
|
|
asc += na + 2;
|
2002-03-21 17:42:56 +00:00
|
|
|
else
|
2002-02-16 15:59:55 +00:00
|
|
|
asc = max(asc, na);
|
2002-08-02 14:04:16 +00:00
|
|
|
asc = max(asc, 5);
|
2001-10-12 12:02:49 +00:00
|
|
|
return asc;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-07-30 13:56:02 +00:00
|
|
|
int MathScriptInset::dx0() const
|
2001-10-12 12:02:49 +00:00
|
|
|
{
|
|
|
|
lyx::Assert(hasDown());
|
2002-07-30 13:56:02 +00:00
|
|
|
return hasLimits() ? (dim_.w - down().width()) / 2 : nwid();
|
2001-10-12 12:02:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-07-30 13:56:02 +00:00
|
|
|
int MathScriptInset::dx1() const
|
2001-10-12 12:02:49 +00:00
|
|
|
{
|
|
|
|
lyx::Assert(hasUp());
|
2002-07-30 13:56:02 +00:00
|
|
|
return hasLimits() ? (dim_.w - up().width()) / 2 : nwid();
|
2001-10-12 12:02:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-07-30 13:56:02 +00:00
|
|
|
int MathScriptInset::dxx() const
|
2001-10-12 12:02:49 +00:00
|
|
|
{
|
2002-07-30 13:56:02 +00:00
|
|
|
return hasLimits() ? (dim_.w - nwid()) / 2 : 0;
|
2001-10-12 12:02:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-07-30 13:56:02 +00:00
|
|
|
int MathScriptInset::nwid() const
|
2001-10-12 12:02:49 +00:00
|
|
|
{
|
2002-08-02 14:04:16 +00:00
|
|
|
return nuc().size() ? nuc().width() : 2;
|
2001-10-12 12:02:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-07-30 13:56:02 +00:00
|
|
|
int MathScriptInset::nasc() const
|
2001-10-12 12:02:49 +00:00
|
|
|
{
|
2002-08-02 14:04:16 +00:00
|
|
|
return nuc().size() ? nuc().ascent() : 5;
|
2001-10-12 12:02:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-07-30 13:56:02 +00:00
|
|
|
int MathScriptInset::ndes() const
|
2001-10-12 12:02:49 +00:00
|
|
|
{
|
2002-08-02 14:04:16 +00:00
|
|
|
return nuc().size() ? nuc().descent() : 0;
|
2001-10-12 12:02:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-05-30 07:09:54 +00:00
|
|
|
void MathScriptInset::metrics(MathMetricsInfo & mi) const
|
2002-03-21 17:42:56 +00:00
|
|
|
{
|
2002-06-18 15:44:30 +00:00
|
|
|
MathNestInset::metrics(mi);
|
|
|
|
MathScriptChanger dummy(mi.base);
|
2002-07-30 13:56:02 +00:00
|
|
|
dim_.w = 0;
|
|
|
|
if (hasLimits()) {
|
|
|
|
dim_.w = nwid();
|
|
|
|
if (hasUp())
|
|
|
|
dim_.w = max(dim_.w, up().width());
|
|
|
|
if (hasDown())
|
|
|
|
dim_.w = max(dim_.w, down().width());
|
|
|
|
} else {
|
|
|
|
if (hasUp())
|
|
|
|
dim_.w = max(dim_.w, up().width());
|
|
|
|
if (hasDown())
|
|
|
|
dim_.w = max(dim_.w, down().width());
|
|
|
|
dim_.w += nwid();
|
|
|
|
}
|
|
|
|
dim_.a = dy1() + (hasUp() ? up().ascent() : 0);
|
|
|
|
dim_.d = dy0() + (hasDown() ? down().descent() : 0);
|
2002-08-01 11:48:53 +00:00
|
|
|
metricsMarkers2();
|
2001-10-12 12:02:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-05-30 07:09:54 +00:00
|
|
|
void MathScriptInset::draw(MathPainterInfo & pi, int x, int y) const
|
2002-03-21 17:42:56 +00:00
|
|
|
{
|
2002-07-30 13:56:02 +00:00
|
|
|
if (nuc().size())
|
|
|
|
nuc().draw(pi, x + dxx(), y);
|
2002-06-18 15:44:30 +00:00
|
|
|
else if (editing())
|
2002-08-02 14:04:16 +00:00
|
|
|
drawStr(pi, pi.base.font, x + dxx(), y, ".");
|
2002-06-18 15:44:30 +00:00
|
|
|
MathScriptChanger dummy(pi.base);
|
|
|
|
if (hasUp())
|
2002-07-30 13:56:02 +00:00
|
|
|
up().draw(pi, x + dx1(), y - dy1());
|
2002-06-18 15:44:30 +00:00
|
|
|
if (hasDown())
|
2002-07-30 13:56:02 +00:00
|
|
|
down().draw(pi, x + dx0(), y + dy0());
|
2002-08-01 11:48:53 +00:00
|
|
|
drawMarkers2(pi, x, y);
|
2002-06-18 15:44:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-03-21 06:57:13 +00:00
|
|
|
void MathScriptInset::metricsT(TextMetricsInfo const & mi) const
|
2002-03-21 17:42:56 +00:00
|
|
|
{
|
2002-03-19 16:55:58 +00:00
|
|
|
if (hasUp())
|
2002-03-21 06:57:13 +00:00
|
|
|
up().metricsT(mi);
|
2002-03-19 16:55:58 +00:00
|
|
|
if (hasDown())
|
2002-03-21 06:57:13 +00:00
|
|
|
down().metricsT(mi);
|
2002-07-30 13:56:02 +00:00
|
|
|
nuc().metricsT(mi);
|
2002-03-18 11:45:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-03-21 06:57:13 +00:00
|
|
|
void MathScriptInset::drawT(TextPainter & pain, int x, int y) const
|
2002-03-21 17:42:56 +00:00
|
|
|
{
|
2002-07-30 13:56:02 +00:00
|
|
|
if (nuc().size())
|
|
|
|
nuc().drawT(pain, x + dxx(), y);
|
2002-03-18 11:45:53 +00:00
|
|
|
if (hasUp())
|
2002-07-30 13:56:02 +00:00
|
|
|
up().drawT(pain, x + dx1(), y - dy1());
|
2002-03-18 11:45:53 +00:00
|
|
|
if (hasDown())
|
2002-07-30 13:56:02 +00:00
|
|
|
down().drawT(pain, x + dx0(), y + dy0());
|
2002-03-18 11:45:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-10-12 12:02:49 +00:00
|
|
|
|
2002-07-30 13:56:02 +00:00
|
|
|
bool MathScriptInset::hasLimits() const
|
2001-10-12 12:02:49 +00:00
|
|
|
{
|
2002-07-08 13:03:37 +00:00
|
|
|
// obvious cases
|
2001-11-27 13:57:49 +00:00
|
|
|
if (limits_ == 1)
|
|
|
|
return true;
|
|
|
|
if (limits_ == -1)
|
|
|
|
return false;
|
|
|
|
|
2002-03-21 17:42:56 +00:00
|
|
|
// we can only display limits if the nucleus wants some
|
2002-07-30 13:56:02 +00:00
|
|
|
if (!nuc().size())
|
2001-11-27 13:57:49 +00:00
|
|
|
return false;
|
2002-07-30 13:56:02 +00:00
|
|
|
if (!nuc().back()->isScriptable())
|
2001-11-27 13:57:49 +00:00
|
|
|
return false;
|
2002-03-21 17:42:56 +00:00
|
|
|
|
2001-11-27 13:57:49 +00:00
|
|
|
// per default \int has limits beside the \int even in displayed formulas
|
2002-07-30 13:56:02 +00:00
|
|
|
if (nuc().back()->asSymbolInset())
|
|
|
|
if (nuc().back()->asSymbolInset()->name().find("int") != string::npos)
|
2001-11-27 13:57:49 +00:00
|
|
|
return false;
|
|
|
|
|
|
|
|
// assume "real" limits for everything else
|
|
|
|
return true;
|
2001-10-12 12:02:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MathScriptInset::removeEmptyScripts()
|
|
|
|
{
|
|
|
|
for (int i = 0; i <= 1; ++i)
|
2002-03-18 11:45:53 +00:00
|
|
|
if (script_[i] && cell(i).size() == 0) {
|
|
|
|
cell(i).clear();
|
2001-10-12 12:02:49 +00:00
|
|
|
script_[i] = false;
|
2002-03-18 11:45:53 +00:00
|
|
|
}
|
2001-10-12 12:02:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MathScriptInset::removeScript(bool up)
|
|
|
|
{
|
|
|
|
cell(up).clear();
|
|
|
|
script_[up] = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool MathScriptInset::has(bool up) const
|
|
|
|
{
|
|
|
|
return script_[up];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-02-01 11:57:26 +00:00
|
|
|
bool MathScriptInset::empty() const
|
|
|
|
{
|
2002-07-30 13:56:02 +00:00
|
|
|
return !script_[0] && !script_[1] && cell(2).empty();
|
2002-02-01 11:57:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-10-12 12:02:49 +00:00
|
|
|
bool MathScriptInset::hasUp() const
|
|
|
|
{
|
|
|
|
return script_[1];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool MathScriptInset::hasDown() const
|
|
|
|
{
|
|
|
|
return script_[0];
|
2001-07-26 06:46:50 +00:00
|
|
|
}
|
2001-10-12 15:38:58 +00:00
|
|
|
|
|
|
|
|
2002-07-30 13:56:02 +00:00
|
|
|
bool MathScriptInset::idxRight(idx_type &, pos_type &) const
|
2001-10-12 15:38:58 +00:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-07-30 13:56:02 +00:00
|
|
|
bool MathScriptInset::idxLeft(idx_type &, pos_type &) const
|
2001-10-12 15:38:58 +00:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-07-30 13:56:02 +00:00
|
|
|
bool MathScriptInset::idxUpDown(idx_type & idx, pos_type & pos, bool up,
|
|
|
|
int) const
|
2002-03-21 17:42:56 +00:00
|
|
|
{
|
2002-07-30 13:56:02 +00:00
|
|
|
if ((idx == 1 && up) || (idx == 0 && !up))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
// in nuclues?
|
|
|
|
if (idx == 2) {
|
|
|
|
idx = up;
|
|
|
|
pos = 0;
|
|
|
|
} else {
|
|
|
|
idx = 2;
|
|
|
|
pos = cell(2).size();
|
|
|
|
}
|
|
|
|
return true;
|
2001-11-08 12:06:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-07-30 13:56:02 +00:00
|
|
|
void MathScriptInset::write(WriteStream & os) const
|
2001-11-07 08:51:35 +00:00
|
|
|
{
|
2002-07-30 13:56:02 +00:00
|
|
|
if (nuc().size()) {
|
2002-08-02 14:29:42 +00:00
|
|
|
os << nuc();
|
2002-07-30 13:56:02 +00:00
|
|
|
if (nuc().back()->takesLimits()) {
|
2001-11-08 12:06:56 +00:00
|
|
|
if (limits_ == -1)
|
|
|
|
os << "\\nolimits ";
|
|
|
|
if (limits_ == 1)
|
|
|
|
os << "\\limits ";
|
|
|
|
}
|
2002-07-30 13:56:02 +00:00
|
|
|
} else {
|
|
|
|
if (os.firstitem())
|
|
|
|
lyxerr[Debug::MATHED] << "suppressing {} when writing\n";
|
|
|
|
else
|
|
|
|
os << "{}";
|
|
|
|
}
|
2001-11-08 12:06:56 +00:00
|
|
|
|
2002-07-31 17:26:14 +00:00
|
|
|
if (hasDown() && down().size())
|
2002-08-02 14:29:42 +00:00
|
|
|
os << "_{" << down() << '}';
|
2001-11-08 12:06:56 +00:00
|
|
|
|
2002-07-31 17:26:14 +00:00
|
|
|
if (hasUp() && up().size())
|
2002-08-02 14:29:42 +00:00
|
|
|
os << "^{" << up() << '}';
|
2002-08-01 15:53:46 +00:00
|
|
|
|
|
|
|
if (lock_ && !os.latex())
|
|
|
|
os << "\\lyxlock ";
|
2001-11-07 08:51:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-11-09 08:35:57 +00:00
|
|
|
void MathScriptInset::normalize(NormalStream & os) const
|
2002-03-21 17:42:56 +00:00
|
|
|
{
|
2002-07-30 13:56:02 +00:00
|
|
|
bool d = hasDown() && down().size();
|
|
|
|
bool u = hasUp() && up().size();
|
2001-11-08 12:06:56 +00:00
|
|
|
|
2002-07-30 17:51:19 +00:00
|
|
|
if (u && d)
|
|
|
|
os << "[subsup ";
|
|
|
|
else if (u)
|
2001-11-08 12:06:56 +00:00
|
|
|
os << "[sup ";
|
2002-07-30 17:51:19 +00:00
|
|
|
else if (d)
|
2001-11-08 12:06:56 +00:00
|
|
|
os << "[sub ";
|
2002-03-21 17:42:56 +00:00
|
|
|
|
2002-07-30 13:56:02 +00:00
|
|
|
if (nuc().size())
|
2002-08-02 14:29:42 +00:00
|
|
|
os << nuc() << ' ';
|
2001-11-08 12:06:56 +00:00
|
|
|
else
|
|
|
|
os << "[par]";
|
|
|
|
|
2002-07-30 17:51:19 +00:00
|
|
|
if (u && d)
|
2002-08-02 14:29:42 +00:00
|
|
|
os << down() << ' ' << up() << ']';
|
2002-07-30 17:51:19 +00:00
|
|
|
else if (d)
|
2002-08-02 14:29:42 +00:00
|
|
|
os << down() << ']';
|
2002-07-30 17:51:19 +00:00
|
|
|
else if (u)
|
2002-08-02 14:29:42 +00:00
|
|
|
os << up() << ']';
|
2001-11-08 12:06:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-07-30 13:56:02 +00:00
|
|
|
void MathScriptInset::maplize(MapleStream & os) const
|
2001-11-07 08:51:35 +00:00
|
|
|
{
|
2002-07-30 13:56:02 +00:00
|
|
|
if (nuc().size())
|
2002-08-02 14:29:42 +00:00
|
|
|
os << nuc();
|
2002-07-30 13:56:02 +00:00
|
|
|
if (hasDown() && down().size())
|
2002-08-02 14:29:42 +00:00
|
|
|
os << '[' << down() << ']';
|
2002-07-30 13:56:02 +00:00
|
|
|
if (hasUp() && up().size())
|
2002-08-02 14:29:42 +00:00
|
|
|
os << "^(" << up() << ')';
|
2001-11-07 08:51:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-07-30 13:56:02 +00:00
|
|
|
void MathScriptInset::mathematicize(MathematicaStream & os) const
|
2002-07-01 11:17:14 +00:00
|
|
|
{
|
2002-07-30 13:56:02 +00:00
|
|
|
bool d = hasDown() && down().size();
|
|
|
|
bool u = hasUp() && up().size();
|
2002-07-01 11:17:14 +00:00
|
|
|
|
2002-07-30 13:56:02 +00:00
|
|
|
if (nuc().size()) {
|
|
|
|
if (d)
|
2002-08-02 14:29:42 +00:00
|
|
|
os << "Subscript[" << nuc();
|
2002-07-01 11:17:14 +00:00
|
|
|
else
|
2002-08-02 14:29:42 +00:00
|
|
|
os << nuc();
|
2002-07-30 13:56:02 +00:00
|
|
|
}
|
|
|
|
|
2002-07-01 11:17:14 +00:00
|
|
|
if (u)
|
2002-08-02 14:29:42 +00:00
|
|
|
os << "^(" << up() << ")";
|
2002-07-01 11:17:14 +00:00
|
|
|
|
2002-07-30 13:56:02 +00:00
|
|
|
if (nuc().size())
|
2002-07-01 11:17:14 +00:00
|
|
|
if (d)
|
2002-08-02 14:29:42 +00:00
|
|
|
os << "," << down() << "]";
|
2002-07-01 11:17:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-07-30 13:56:02 +00:00
|
|
|
void MathScriptInset::mathmlize( MathMLStream & os) const
|
2001-11-07 08:51:35 +00:00
|
|
|
{
|
2002-07-31 17:26:14 +00:00
|
|
|
bool d = hasDown() && down().size();
|
|
|
|
bool u = hasUp() && up().size();
|
2001-11-07 17:30:26 +00:00
|
|
|
|
2001-11-08 12:06:56 +00:00
|
|
|
if (u && d)
|
|
|
|
os << MTag("msubsup");
|
|
|
|
else if (u)
|
|
|
|
os << MTag("msup");
|
|
|
|
else if (d)
|
|
|
|
os << MTag("msub");
|
2001-11-07 17:30:26 +00:00
|
|
|
|
2002-07-30 13:56:02 +00:00
|
|
|
if (nuc().size())
|
2002-08-02 14:29:42 +00:00
|
|
|
os << nuc();
|
2001-11-07 17:30:26 +00:00
|
|
|
else
|
|
|
|
os << "<mrow/>";
|
|
|
|
|
2001-11-08 12:06:56 +00:00
|
|
|
if (u && d)
|
2002-08-02 14:29:42 +00:00
|
|
|
os << down() << up() << ETag("msubsup");
|
2001-11-08 12:06:56 +00:00
|
|
|
else if (u)
|
2002-08-02 14:29:42 +00:00
|
|
|
os << up() << ETag("msup");
|
2001-11-08 12:06:56 +00:00
|
|
|
else if (d)
|
2002-08-02 14:29:42 +00:00
|
|
|
os << down() << ETag("msub");
|
2001-11-08 12:06:56 +00:00
|
|
|
}
|
|
|
|
|
2001-11-07 17:30:26 +00:00
|
|
|
|
2002-07-30 13:56:02 +00:00
|
|
|
void MathScriptInset::octavize(OctaveStream & os) const
|
2001-11-08 12:06:56 +00:00
|
|
|
{
|
2002-07-30 13:56:02 +00:00
|
|
|
if (nuc().size())
|
2002-08-02 14:29:42 +00:00
|
|
|
os << nuc();
|
2002-07-30 13:56:02 +00:00
|
|
|
if (hasDown() && down().size())
|
2002-08-02 14:29:42 +00:00
|
|
|
os << '[' << down() << ']';
|
2002-07-30 13:56:02 +00:00
|
|
|
if (hasUp() && up().size())
|
2002-08-02 14:29:42 +00:00
|
|
|
os << "^(" << up() << ')';
|
2001-11-07 08:51:35 +00:00
|
|
|
}
|
2002-07-08 13:03:37 +00:00
|
|
|
|
|
|
|
|
|
|
|
void MathScriptInset::infoize(std::ostream & os) const
|
|
|
|
{
|
2002-08-01 11:48:53 +00:00
|
|
|
os << "Scripts";
|
2002-07-08 13:03:37 +00:00
|
|
|
if (limits_)
|
2002-08-01 11:48:53 +00:00
|
|
|
os << (limits_ == 1 ? ", Displayed limits" : ", Inlined limits");
|
2002-07-08 13:03:37 +00:00
|
|
|
}
|