2003-08-19 13:00:56 +00:00
|
|
|
|
/**
|
2006-09-17 09:14:18 +00:00
|
|
|
|
* \file InsetMath.C
|
2003-08-19 13:00:56 +00:00
|
|
|
|
* 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>
|
|
|
|
|
|
2006-09-17 09:14:18 +00:00
|
|
|
|
#include "InsetMath.h"
|
|
|
|
|
#include "MathData.h"
|
2006-10-22 10:15:23 +00:00
|
|
|
|
#include "MathStream.h"
|
2007-02-20 18:19:31 +00:00
|
|
|
|
#include "gettext.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"
|
2007-04-02 15:21:36 +00:00
|
|
|
|
#include "support/textutils.h"
|
2005-07-15 08:51:34 +00:00
|
|
|
|
|
2006-08-17 13:23:08 +00:00
|
|
|
|
#include <boost/current_function.hpp>
|
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
namespace lyx {
|
2006-10-19 16:51:30 +00:00
|
|
|
|
|
2003-08-02 11:30:30 +00:00
|
|
|
|
using std::endl;
|
2002-02-16 15:59:55 +00:00
|
|
|
|
|
|
|
|
|
|
2006-09-16 18:11:38 +00:00
|
|
|
|
MathArray & InsetMath::cell(idx_type)
|
2001-06-25 00:06:33 +00:00
|
|
|
|
{
|
2004-04-13 06:27:29 +00:00
|
|
|
|
static MathArray dummyCell;
|
2006-08-17 13:23:08 +00:00
|
|
|
|
lyxerr << BOOST_CURRENT_FUNCTION << ": I don't have any cell" << endl;
|
2001-08-03 17:10:22 +00:00
|
|
|
|
return dummyCell;
|
2001-06-25 00:06:33 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-09-16 18:11:38 +00:00
|
|
|
|
MathArray const & InsetMath::cell(idx_type) const
|
2001-06-25 00:06:33 +00:00
|
|
|
|
{
|
2004-04-13 06:27:29 +00:00
|
|
|
|
static MathArray dummyCell;
|
2006-08-17 13:23:08 +00:00
|
|
|
|
lyxerr << BOOST_CURRENT_FUNCTION << ": I don't have any cell" << 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
|
|
|
|
|
2006-09-16 18:11:38 +00:00
|
|
|
|
void InsetMath::dump() const
|
2001-06-25 00:06:33 +00:00
|
|
|
|
{
|
2003-08-02 11:30:30 +00:00
|
|
|
|
lyxerr << "---------------------------------------------" << endl;
|
2006-10-21 00:16:43 +00:00
|
|
|
|
odocstringstream os;
|
2006-10-19 16:51:30 +00:00
|
|
|
|
WriteStream wi(os, false, true);
|
2001-10-19 11:25:48 +00:00
|
|
|
|
write(wi);
|
2006-10-21 00:16:43 +00:00
|
|
|
|
lyxerr << to_utf8(os.str());
|
2003-08-02 11:30:30 +00:00
|
|
|
|
lyxerr << "\n---------------------------------------------" << endl;
|
2001-06-25 00:06:33 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-09-16 18:11:38 +00:00
|
|
|
|
void InsetMath::metricsT(TextMetricsInfo const &, Dimension &) const
|
2002-03-18 11:45:53 +00:00
|
|
|
|
{
|
2002-04-08 08:12:09 +00:00
|
|
|
|
#ifdef WITH_WARNINGS
|
2006-09-16 18:11:38 +00:00
|
|
|
|
lyxerr << "InsetMath::metricsT(Text) called directly!" << endl;
|
2002-04-08 08:12:09 +00:00
|
|
|
|
#endif
|
2002-03-18 11:45:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-09-16 18:11:38 +00:00
|
|
|
|
void InsetMath::drawT(TextPainter &, int, int) const
|
2002-03-18 11:45:53 +00:00
|
|
|
|
{
|
2002-04-08 08:12:09 +00:00
|
|
|
|
#ifdef WITH_WARNINGS
|
2006-09-16 18:11:38 +00:00
|
|
|
|
lyxerr << "InsetMath::drawT(Text) called directly!" << endl;
|
2002-04-08 08:12:09 +00:00
|
|
|
|
#endif
|
2002-03-18 11:45:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-09-16 18:11:38 +00:00
|
|
|
|
void InsetMath::write(WriteStream & os) const
|
2002-08-05 07:09:11 +00:00
|
|
|
|
{
|
2006-10-22 10:15:23 +00:00
|
|
|
|
docstring const s = name();
|
|
|
|
|
os << "\\" << s;
|
2005-07-15 08:51:34 +00:00
|
|
|
|
// We need an extra ' ' unless this is a single-char-non-ASCII name
|
|
|
|
|
// or anything non-ASCII follows
|
2007-04-02 15:21:36 +00:00
|
|
|
|
if (s.size() != 1 || isAlphaASCII(s[0]))
|
2005-07-15 08:51:34 +00:00
|
|
|
|
os.pendingSpace(true);
|
2002-08-05 07:09:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-03-18 16:52:54 +00:00
|
|
|
|
int InsetMath::plaintext(Buffer const &, odocstream &,
|
2007-02-20 18:19:31 +00:00
|
|
|
|
OutputParams const &) const
|
|
|
|
|
{
|
2007-02-24 15:06:04 +00:00
|
|
|
|
// all math plain text output shall take place in InsetMathHull
|
|
|
|
|
BOOST_ASSERT(false);
|
|
|
|
|
return 0;
|
2007-02-20 18:19:31 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-09-16 18:11:38 +00:00
|
|
|
|
void InsetMath::normalize(NormalStream & os) const
|
2001-08-06 17:20:26 +00:00
|
|
|
|
{
|
2006-10-22 10:15:23 +00:00
|
|
|
|
os << '[' << name() << "] ";
|
2001-08-06 17:20:26 +00:00
|
|
|
|
}
|
2001-11-07 08:51:35 +00:00
|
|
|
|
|
|
|
|
|
|
2006-09-16 18:11:38 +00:00
|
|
|
|
void InsetMath::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
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-09-16 18:11:38 +00:00
|
|
|
|
void InsetMath::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
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-09-16 18:11:38 +00:00
|
|
|
|
void InsetMath::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
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-09-16 18:11:38 +00:00
|
|
|
|
void InsetMath::mathematica(MathematicaStream & os) const
|
2002-07-01 11:17:14 +00:00
|
|
|
|
{
|
|
|
|
|
NormalStream ns(os.os());
|
|
|
|
|
normalize(ns);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-10-22 10:15:23 +00:00
|
|
|
|
void InsetMath::mathmlize(MathStream & os) const
|
2001-11-07 08:51:35 +00:00
|
|
|
|
{
|
2006-10-19 21:00:33 +00:00
|
|
|
|
NormalStream ns(os.os());
|
|
|
|
|
normalize(ns);
|
2001-11-07 08:51:35 +00:00
|
|
|
|
}
|
2002-06-24 15:37:14 +00:00
|
|
|
|
|
|
|
|
|
|
2006-09-16 18:11:38 +00:00
|
|
|
|
HullType InsetMath::getType() const
|
2002-07-08 06:39:40 +00:00
|
|
|
|
{
|
2006-09-03 16:14:51 +00:00
|
|
|
|
return hullNone;
|
2002-07-08 06:39:40 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-10-22 10:15:23 +00:00
|
|
|
|
docstring InsetMath::name() const
|
2002-08-01 15:53:46 +00:00
|
|
|
|
{
|
2006-10-22 10:15:23 +00:00
|
|
|
|
return from_ascii("unknown");
|
2002-08-01 15:53:46 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-10-19 16:51:30 +00:00
|
|
|
|
std::ostream & operator<<(std::ostream & os, MathAtom const & at)
|
|
|
|
|
{
|
2006-10-21 00:16:43 +00:00
|
|
|
|
odocstringstream oss;
|
2006-10-19 16:51:30 +00:00
|
|
|
|
WriteStream wi(oss, false, false);
|
|
|
|
|
at->write(wi);
|
2006-10-21 00:16:43 +00:00
|
|
|
|
return os << to_utf8(oss.str());
|
2006-10-19 16:51:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
odocstream & operator<<(odocstream & os, MathAtom const & at)
|
2002-09-11 09:14:57 +00:00
|
|
|
|
{
|
|
|
|
|
WriteStream wi(os, false, false);
|
|
|
|
|
at->write(wi);
|
|
|
|
|
return os;
|
|
|
|
|
}
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace lyx
|