2001-12-05 08:04:20 +00:00
|
|
|
#include <config.h>
|
|
|
|
|
2001-11-05 17:08:45 +00:00
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma implementation
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "math_stringinset.h"
|
2001-11-08 12:06:56 +00:00
|
|
|
#include "math_mathmlstream.h"
|
2001-12-05 08:04:20 +00:00
|
|
|
#include "math_streamstr.h"
|
2001-11-05 17:08:45 +00:00
|
|
|
#include "LColor.h"
|
2001-11-08 12:15:12 +00:00
|
|
|
#include "math_support.h"
|
2001-11-05 17:08:45 +00:00
|
|
|
#include "math_parser.h"
|
2002-01-18 14:27:54 +00:00
|
|
|
#include "LaTeXFeatures.h"
|
2001-11-05 17:08:45 +00:00
|
|
|
#include "debug.h"
|
|
|
|
|
|
|
|
|
2002-05-30 07:09:54 +00:00
|
|
|
MathStringInset::MathStringInset(string const & s)
|
|
|
|
: str_(s)
|
2001-11-05 17:08:45 +00:00
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
|
MathInset * MathStringInset::clone() const
|
2002-03-21 17:42:56 +00:00
|
|
|
{
|
2001-11-05 17:08:45 +00:00
|
|
|
return new MathStringInset(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-05-30 07:09:54 +00:00
|
|
|
void MathStringInset::metrics(MathMetricsInfo & mi) const
|
2001-11-05 17:08:45 +00:00
|
|
|
{
|
2002-05-30 07:09:54 +00:00
|
|
|
mathed_string_dim(mi.base.font, str_, ascent_, descent_, width_);
|
2001-11-05 17:08:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-05-30 07:09:54 +00:00
|
|
|
void MathStringInset::draw(MathPainterInfo & pi, int x, int y) const
|
2002-03-21 17:42:56 +00:00
|
|
|
{
|
2001-11-05 17:08:45 +00:00
|
|
|
//lyxerr << "drawing '" << str_ << "' code: " << code_ << endl;
|
2002-05-30 07:09:54 +00:00
|
|
|
drawStr(pi, pi.base.font, x, y, str_);
|
2001-11-05 17:08:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-11-09 08:35:57 +00:00
|
|
|
void MathStringInset::normalize(NormalStream & os) const
|
2001-11-05 17:08:45 +00:00
|
|
|
{
|
2001-12-05 08:04:20 +00:00
|
|
|
os << "[string " << str_ << ' ' << "mathalpha" << "]";
|
2001-11-05 17:08:45 +00:00
|
|
|
}
|
2001-11-07 08:51:35 +00:00
|
|
|
|
|
|
|
|
2001-11-07 17:30:26 +00:00
|
|
|
void MathStringInset::maplize(MapleStream & os) const
|
2001-11-07 08:51:35 +00:00
|
|
|
{
|
2002-05-30 07:09:54 +00:00
|
|
|
if (/*code_ != LM_TC_VAR || */ str_.size() <= 1) {
|
2001-12-05 08:04:20 +00:00
|
|
|
os << ' ' << str_ << ' ';
|
2001-11-07 17:30:26 +00:00
|
|
|
return;
|
2002-03-21 17:42:56 +00:00
|
|
|
}
|
2001-11-07 17:30:26 +00:00
|
|
|
|
|
|
|
// insert '*' between adjacent chars if type is LM_TC_VAR
|
|
|
|
os << str_[0];
|
2002-03-21 17:42:56 +00:00
|
|
|
for (string::size_type i = 1; i < str_.size(); ++i)
|
2001-11-07 17:30:26 +00:00
|
|
|
os << '*' << str_[i];
|
2001-11-07 08:51:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-11-07 17:30:26 +00:00
|
|
|
void MathStringInset::octavize(OctaveStream & os) const
|
2001-11-07 08:51:35 +00:00
|
|
|
{
|
2002-05-30 07:09:54 +00:00
|
|
|
if (/*code_ != LM_TC_VAR ||*/ str_.size() <= 1) {
|
2001-12-05 08:04:20 +00:00
|
|
|
os << ' ' << str_ << ' ';
|
2001-11-07 17:30:26 +00:00
|
|
|
return;
|
2002-03-21 17:42:56 +00:00
|
|
|
}
|
2001-11-07 08:51:35 +00:00
|
|
|
|
|
|
|
// insert '*' between adjacent chars if type is LM_TC_VAR
|
2001-11-07 17:30:26 +00:00
|
|
|
os << str_[0];
|
2002-03-21 17:42:56 +00:00
|
|
|
for (string::size_type i = 1; i < str_.size(); ++i)
|
2001-11-07 17:30:26 +00:00
|
|
|
os << '*' << str_[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MathStringInset::mathmlize(MathMLStream & os) const
|
|
|
|
{
|
2002-05-30 07:09:54 +00:00
|
|
|
/*
|
2001-11-07 17:30:26 +00:00
|
|
|
if (code_ == LM_TC_VAR)
|
2001-12-05 08:04:20 +00:00
|
|
|
os << "<mi> " << str_ << " </mi>";
|
2001-11-07 17:30:26 +00:00
|
|
|
else if (code_ == LM_TC_CONST)
|
2001-12-05 08:04:20 +00:00
|
|
|
os << "<mn> " << str_ << " </mn>";
|
2001-11-07 17:30:26 +00:00
|
|
|
else if (code_ == LM_TC_RM || code_ == LM_TC_TEXTRM)
|
2001-12-05 08:04:20 +00:00
|
|
|
os << "<mtext> " << str_ << " </mtext>";
|
2001-11-07 17:30:26 +00:00
|
|
|
else
|
2002-05-30 07:09:54 +00:00
|
|
|
*/
|
2001-12-05 08:04:20 +00:00
|
|
|
os << str_;
|
2001-11-07 08:51:35 +00:00
|
|
|
}
|
2001-11-15 15:14:27 +00:00
|
|
|
|
|
|
|
|
|
|
|
void MathStringInset::write(WriteStream & os) const
|
|
|
|
{
|
2002-05-30 07:09:54 +00:00
|
|
|
os << str_;
|
2001-11-15 15:14:27 +00:00
|
|
|
}
|