2003-08-19 13:00:56 +00:00
|
|
|
|
/**
|
|
|
|
|
* \file math_inset.C
|
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
|
* Licence details can be found in the file COPYING.
|
1999-09-27 18:44:28 +00:00
|
|
|
|
*
|
2003-08-19 13:00:56 +00:00
|
|
|
|
* \author Alejandro Aguilar Sierra
|
|
|
|
|
* \author Andr<EFBFBD> P<EFBFBD>nitz
|
1999-09-27 18:44:28 +00:00
|
|
|
|
*
|
2003-08-19 13:00:56 +00:00
|
|
|
|
* Full author contact details are available in file CREDITS.
|
1999-09-27 18:44:28 +00:00
|
|
|
|
*/
|
|
|
|
|
|
2002-09-11 09:14:57 +00:00
|
|
|
|
#include <config.h>
|
|
|
|
|
|
2003-09-05 16:18:57 +00:00
|
|
|
|
#include "math_inset.h"
|
2003-10-12 18:54:12 +00:00
|
|
|
|
#include "math_data.h"
|
2001-11-08 12:06:56 +00:00
|
|
|
|
#include "math_mathmlstream.h"
|
2001-06-25 00:06:33 +00:00
|
|
|
|
#include "debug.h"
|
2001-02-13 13:28:32 +00:00
|
|
|
|
|
2005-07-15 08:51:34 +00:00
|
|
|
|
#include "support/lstrings.h"
|
|
|
|
|
|
2003-10-06 15:43:21 +00:00
|
|
|
|
using std::string;
|
2002-02-16 15:59:55 +00:00
|
|
|
|
using std::ostream;
|
2003-08-02 11:30:30 +00:00
|
|
|
|
using std::endl;
|
2002-02-16 15:59:55 +00:00
|
|
|
|
|
|
|
|
|
|
2002-08-02 14:29:42 +00:00
|
|
|
|
MathArray & MathInset::cell(idx_type)
|
2001-06-25 00:06:33 +00:00
|
|
|
|
{
|
2004-04-13 06:27:29 +00:00
|
|
|
|
static MathArray dummyCell;
|
2003-08-02 11:30:30 +00:00
|
|
|
|
lyxerr << "I don't have a cell 1" << endl;
|
2001-08-03 17:10:22 +00:00
|
|
|
|
return dummyCell;
|
2001-06-25 00:06:33 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2002-08-02 14:29:42 +00:00
|
|
|
|
MathArray const & MathInset::cell(idx_type) const
|
2001-06-25 00:06:33 +00:00
|
|
|
|
{
|
2004-04-13 06:27:29 +00:00
|
|
|
|
static MathArray dummyCell;
|
2003-08-02 11:30:30 +00:00
|
|
|
|
lyxerr << "I don't have a cell 2" << endl;
|
2001-08-03 17:10:22 +00:00
|
|
|
|
return dummyCell;
|
2001-06-25 00:06:33 +00:00
|
|
|
|
}
|
|
|
|
|
|
2001-08-03 09:54:48 +00:00
|
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
|
void MathInset::dump() const
|
|
|
|
|
{
|
2003-08-02 11:30:30 +00:00
|
|
|
|
lyxerr << "---------------------------------------------" << endl;
|
2002-03-25 12:11:25 +00:00
|
|
|
|
WriteStream wi(lyxerr, false, true);
|
2001-10-19 11:25:48 +00:00
|
|
|
|
write(wi);
|
2003-08-02 11:30:30 +00:00
|
|
|
|
lyxerr << "\n---------------------------------------------" << endl;
|
2001-06-25 00:06:33 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-05-28 13:22:36 +00:00
|
|
|
|
void MathInset::metricsT(TextMetricsInfo const &, Dimension &) const
|
2002-03-18 11:45:53 +00:00
|
|
|
|
{
|
2002-04-08 08:12:09 +00:00
|
|
|
|
#ifdef WITH_WARNINGS
|
2003-08-02 11:30:30 +00:00
|
|
|
|
lyxerr << "MathInset::metricsT(Text) called directly!" << endl;
|
2002-04-08 08:12:09 +00:00
|
|
|
|
#endif
|
2002-03-18 11:45:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2002-03-21 06:57:13 +00:00
|
|
|
|
void MathInset::drawT(TextPainter &, int, int) const
|
2002-03-18 11:45:53 +00:00
|
|
|
|
{
|
2002-04-08 08:12:09 +00:00
|
|
|
|
#ifdef WITH_WARNINGS
|
2003-08-02 11:30:30 +00:00
|
|
|
|
lyxerr << "MathInset::drawT(Text) called directly!" << endl;
|
2002-04-08 08:12:09 +00:00
|
|
|
|
#endif
|
2002-03-18 11:45:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2002-08-05 07:09:11 +00:00
|
|
|
|
void MathInset::write(WriteStream & os) const
|
|
|
|
|
{
|
2005-07-15 08:51:34 +00:00
|
|
|
|
string const s = name();
|
|
|
|
|
os << '\\' << s.c_str();S
|
|
|
|
|
// We need an extra ' ' unless this is a single-char-non-ASCII name
|
|
|
|
|
// or anything non-ASCII follows
|
|
|
|
|
if (s.size() != 1 || isalpha(s[0]))
|
|
|
|
|
os.pendingSpace(true);
|
2002-08-05 07:09:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void MathInset::normalize(NormalStream & os) const
|
2001-08-06 17:20:26 +00:00
|
|
|
|
{
|
2002-08-05 07:09:11 +00:00
|
|
|
|
os << '[' << name().c_str() << "] ";
|
2001-08-06 17:20:26 +00:00
|
|
|
|
}
|
2001-11-07 08:51:35 +00:00
|
|
|
|
|
|
|
|
|
|
2003-02-14 14:30:09 +00:00
|
|
|
|
void MathInset::octave(OctaveStream & os) const
|
2001-11-07 08:51:35 +00:00
|
|
|
|
{
|
2001-12-03 16:24:50 +00:00
|
|
|
|
NormalStream ns(os.os());
|
2001-11-09 08:35:57 +00:00
|
|
|
|
normalize(ns);
|
2001-11-07 08:51:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-02-14 14:30:09 +00:00
|
|
|
|
void MathInset::maple(MapleStream & os) const
|
2001-11-07 08:51:35 +00:00
|
|
|
|
{
|
2001-12-03 16:24:50 +00:00
|
|
|
|
NormalStream ns(os.os());
|
2001-11-09 08:35:57 +00:00
|
|
|
|
normalize(ns);
|
2001-11-07 08:51:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-02-14 14:30:09 +00:00
|
|
|
|
void MathInset::maxima(MaximaStream & os) const
|
2002-10-28 17:15:19 +00:00
|
|
|
|
{
|
|
|
|
|
MapleStream ns(os.os());
|
2003-02-14 14:30:09 +00:00
|
|
|
|
maple(ns);
|
2002-10-28 17:15:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-02-14 14:30:09 +00:00
|
|
|
|
void MathInset::mathematica(MathematicaStream & os) const
|
2002-07-01 11:17:14 +00:00
|
|
|
|
{
|
|
|
|
|
NormalStream ns(os.os());
|
|
|
|
|
normalize(ns);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2001-11-07 17:30:26 +00:00
|
|
|
|
void MathInset::mathmlize(MathMLStream & os) const
|
2001-11-07 08:51:35 +00:00
|
|
|
|
{
|
2001-12-03 16:24:50 +00:00
|
|
|
|
NormalStream ns(os.os());
|
2001-11-09 08:35:57 +00:00
|
|
|
|
normalize(ns);
|
2001-11-07 08:51:35 +00:00
|
|
|
|
}
|
2002-06-24 15:37:14 +00:00
|
|
|
|
|
|
|
|
|
|
2002-07-08 06:39:40 +00:00
|
|
|
|
string const & MathInset::getType() const
|
|
|
|
|
{
|
2005-07-15 08:51:34 +00:00
|
|
|
|
static string const t = "none";
|
2002-07-08 06:39:40 +00:00
|
|
|
|
return t;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2002-08-01 15:53:46 +00:00
|
|
|
|
string MathInset::name() const
|
|
|
|
|
{
|
|
|
|
|
return "unknown";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2002-09-11 09:14:57 +00:00
|
|
|
|
ostream & operator<<(ostream & os, MathAtom const & at)
|
|
|
|
|
{
|
|
|
|
|
WriteStream wi(os, false, false);
|
|
|
|
|
at->write(wi);
|
|
|
|
|
return os;
|
|
|
|
|
}
|