2001-12-02 17:03:46 +00:00
|
|
|
#include <config.h>
|
|
|
|
|
2001-11-07 17:30:26 +00:00
|
|
|
#include "math_mathmlstream.h"
|
2001-12-02 17:03:46 +00:00
|
|
|
#include "math_inset.h"
|
2001-11-09 08:35:57 +00:00
|
|
|
#include "math_extern.h"
|
2001-11-09 16:27:44 +00:00
|
|
|
#include "debug.h"
|
2002-01-14 13:04:06 +00:00
|
|
|
#include "support/lyxalgo.h"
|
2001-12-05 08:04:20 +00:00
|
|
|
|
2001-11-07 17:30:26 +00:00
|
|
|
|
2002-02-16 15:59:55 +00:00
|
|
|
using std::ostream;
|
2002-05-28 11:13:01 +00:00
|
|
|
using std::strlen;
|
2002-02-16 15:59:55 +00:00
|
|
|
|
|
|
|
|
|
|
|
MathMLStream::MathMLStream(ostream & os)
|
2001-11-09 18:02:20 +00:00
|
|
|
: os_(os), tab_(0), line_(0), lastchar_(0)
|
2001-11-08 12:06:56 +00:00
|
|
|
{}
|
|
|
|
|
|
|
|
|
2001-12-03 16:24:50 +00:00
|
|
|
MathMLStream & operator<<(MathMLStream & ms, MathInset const * p)
|
2001-11-07 17:30:26 +00:00
|
|
|
{
|
2001-11-09 16:27:44 +00:00
|
|
|
if (p)
|
2001-12-03 16:24:50 +00:00
|
|
|
p->mathmlize(ms);
|
2001-11-09 16:27:44 +00:00
|
|
|
else
|
2001-12-03 16:24:50 +00:00
|
|
|
lyxerr << "operator<<(MathMLStream, NULL) called\n";
|
|
|
|
return ms;
|
2001-11-07 17:30:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-12-03 16:24:50 +00:00
|
|
|
MathMLStream & operator<<(MathMLStream & ms, MathArray const & ar)
|
2001-11-07 17:30:26 +00:00
|
|
|
{
|
2001-12-03 16:24:50 +00:00
|
|
|
mathmlize(ar, ms);
|
|
|
|
return ms;
|
2001-11-07 17:30:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-12-03 16:24:50 +00:00
|
|
|
MathMLStream & operator<<(MathMLStream & ms, char const * s)
|
2001-11-07 17:30:26 +00:00
|
|
|
{
|
2001-12-03 16:24:50 +00:00
|
|
|
ms.os() << s;
|
|
|
|
return ms;
|
2001-11-07 17:30:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-12-03 16:24:50 +00:00
|
|
|
MathMLStream & operator<<(MathMLStream & ms, char c)
|
2001-11-07 17:30:26 +00:00
|
|
|
{
|
2001-12-03 16:24:50 +00:00
|
|
|
ms.os() << c;
|
|
|
|
return ms;
|
2001-11-07 17:30:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-12-03 16:24:50 +00:00
|
|
|
MathMLStream & operator<<(MathMLStream & ms, MTag const & t)
|
2001-11-08 12:06:56 +00:00
|
|
|
{
|
2001-12-03 16:24:50 +00:00
|
|
|
++ms.tab();
|
|
|
|
ms.cr();
|
|
|
|
ms.os() << '<' << t.tag_ << '>';
|
|
|
|
return ms;
|
2001-11-08 12:06:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-12-03 16:24:50 +00:00
|
|
|
MathMLStream & operator<<(MathMLStream & ms, ETag const & t)
|
2001-11-08 12:06:56 +00:00
|
|
|
{
|
2001-12-03 16:24:50 +00:00
|
|
|
ms.cr();
|
|
|
|
if (ms.tab() > 0)
|
|
|
|
--ms.tab();
|
|
|
|
ms.os() << "</" << t.tag_ << '>';
|
|
|
|
return ms;
|
2001-11-08 12:06:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MathMLStream::cr()
|
|
|
|
{
|
2001-12-03 16:24:50 +00:00
|
|
|
os() << '\n';
|
|
|
|
for (int i = 0; i < tab(); ++i)
|
|
|
|
os() << ' ';
|
2001-11-08 12:06:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
2001-11-07 17:30:26 +00:00
|
|
|
|
|
|
|
|
2001-12-03 16:24:50 +00:00
|
|
|
MapleStream & operator<<(MapleStream & ms, MathInset const * p)
|
2001-11-07 17:30:26 +00:00
|
|
|
{
|
2001-11-09 16:27:44 +00:00
|
|
|
if (p)
|
2001-12-03 16:24:50 +00:00
|
|
|
p->maplize(ms);
|
2001-11-09 16:27:44 +00:00
|
|
|
else
|
2001-12-03 16:24:50 +00:00
|
|
|
lyxerr << "operator<<(MapleStream, NULL) called\n";
|
|
|
|
return ms;
|
2001-11-07 17:30:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-12-03 16:24:50 +00:00
|
|
|
MapleStream & operator<<(MapleStream & ms, MathArray const & ar)
|
2001-11-07 17:30:26 +00:00
|
|
|
{
|
2001-12-03 16:24:50 +00:00
|
|
|
maplize(ar, ms);
|
|
|
|
return ms;
|
2001-11-07 17:30:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-12-03 16:24:50 +00:00
|
|
|
MapleStream & operator<<(MapleStream & ms, char const * s)
|
2001-11-07 17:30:26 +00:00
|
|
|
{
|
2001-12-03 16:24:50 +00:00
|
|
|
ms.os() << s;
|
|
|
|
return ms;
|
2001-11-07 17:30:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-12-03 16:24:50 +00:00
|
|
|
MapleStream & operator<<(MapleStream & ms, char c)
|
2001-11-07 17:30:26 +00:00
|
|
|
{
|
2001-12-03 16:24:50 +00:00
|
|
|
ms.os() << c;
|
|
|
|
return ms;
|
2001-11-07 17:30:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-12-03 16:24:50 +00:00
|
|
|
MapleStream & operator<<(MapleStream & ms, int i)
|
2001-11-09 08:35:57 +00:00
|
|
|
{
|
2001-12-03 16:24:50 +00:00
|
|
|
ms.os() << i;
|
|
|
|
return ms;
|
2001-11-09 08:35:57 +00:00
|
|
|
}
|
|
|
|
|
2001-11-07 17:30:26 +00:00
|
|
|
|
2002-07-01 11:17:14 +00:00
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
|
|
MathematicaStream & operator<<(MathematicaStream & ms, MathInset const * p)
|
|
|
|
{
|
|
|
|
if (p)
|
|
|
|
p->mathematicize(ms);
|
|
|
|
else
|
|
|
|
lyxerr << "operator<<(MathematicaStream, NULL) called\n";
|
|
|
|
return ms;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
MathematicaStream & operator<<(MathematicaStream & ms, MathArray const & ar)
|
|
|
|
{
|
|
|
|
mathematicize(ar, ms);
|
|
|
|
return ms;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
MathematicaStream & operator<<(MathematicaStream & ms, char const * s)
|
|
|
|
{
|
|
|
|
ms.os() << s;
|
|
|
|
return ms;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
MathematicaStream & operator<<(MathematicaStream & ms, char c)
|
|
|
|
{
|
|
|
|
ms.os() << c;
|
|
|
|
return ms;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
MathematicaStream & operator<<(MathematicaStream & ms, int i)
|
|
|
|
{
|
|
|
|
ms.os() << i;
|
|
|
|
return ms;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2001-11-08 12:06:56 +00:00
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
|
2001-11-07 17:30:26 +00:00
|
|
|
|
2001-12-03 16:24:50 +00:00
|
|
|
OctaveStream & operator<<(OctaveStream & ns, MathInset const * p)
|
2001-11-07 17:30:26 +00:00
|
|
|
{
|
2001-11-09 16:27:44 +00:00
|
|
|
if (p)
|
2001-12-03 16:24:50 +00:00
|
|
|
p->octavize(ns);
|
2001-11-09 16:27:44 +00:00
|
|
|
else
|
2001-12-03 16:24:50 +00:00
|
|
|
lyxerr << "operator<<(OctaveStream, NULL) called\n";
|
|
|
|
return ns;
|
2001-11-07 17:30:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-12-03 16:24:50 +00:00
|
|
|
OctaveStream & operator<<(OctaveStream & ns, MathArray const & ar)
|
2001-11-07 17:30:26 +00:00
|
|
|
{
|
2001-12-03 16:24:50 +00:00
|
|
|
octavize(ar, ns);
|
|
|
|
return ns;
|
2001-11-07 17:30:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-12-03 16:24:50 +00:00
|
|
|
OctaveStream & operator<<(OctaveStream & ns, char const * s)
|
2001-11-07 17:30:26 +00:00
|
|
|
{
|
2001-12-03 16:24:50 +00:00
|
|
|
ns.os() << s;
|
|
|
|
return ns;
|
2001-11-07 17:30:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-12-03 16:24:50 +00:00
|
|
|
OctaveStream & operator<<(OctaveStream & ns, char c)
|
2001-11-07 17:30:26 +00:00
|
|
|
{
|
2001-12-03 16:24:50 +00:00
|
|
|
ns.os() << c;
|
|
|
|
return ns;
|
2001-11-07 17:30:26 +00:00
|
|
|
}
|
|
|
|
|
2001-11-08 12:06:56 +00:00
|
|
|
|
2002-04-24 17:07:42 +00:00
|
|
|
OctaveStream & operator<<(OctaveStream & ns, int i)
|
|
|
|
{
|
|
|
|
ns.os() << i;
|
|
|
|
return ns;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-11-08 12:06:56 +00:00
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
2001-12-03 16:24:50 +00:00
|
|
|
NormalStream & operator<<(NormalStream & ns, MathInset const * p)
|
2001-11-08 12:06:56 +00:00
|
|
|
{
|
2001-11-09 16:27:44 +00:00
|
|
|
if (p)
|
2001-12-03 16:24:50 +00:00
|
|
|
p->normalize(ns);
|
2001-11-09 16:27:44 +00:00
|
|
|
else
|
2001-12-03 16:24:50 +00:00
|
|
|
lyxerr << "operator<<(NormalStream, NULL) called\n";
|
|
|
|
return ns;
|
2001-11-08 12:06:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-12-03 16:24:50 +00:00
|
|
|
NormalStream & operator<<(NormalStream & ns, MathArray const & ar)
|
2001-11-08 12:06:56 +00:00
|
|
|
{
|
2001-12-03 16:24:50 +00:00
|
|
|
normalize(ar, ns);
|
|
|
|
return ns;
|
2001-11-08 12:06:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-12-03 16:24:50 +00:00
|
|
|
NormalStream & operator<<(NormalStream & ns, char const * s)
|
2001-11-08 12:06:56 +00:00
|
|
|
{
|
2001-12-03 16:24:50 +00:00
|
|
|
ns.os() << s;
|
|
|
|
return ns;
|
2001-11-08 12:06:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-12-03 16:24:50 +00:00
|
|
|
NormalStream & operator<<(NormalStream & ns, char c)
|
2001-11-08 12:06:56 +00:00
|
|
|
{
|
2001-12-03 16:24:50 +00:00
|
|
|
ns.os() << c;
|
|
|
|
return ns;
|
2001-11-08 12:06:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-07-11 09:34:58 +00:00
|
|
|
NormalStream & operator<<(NormalStream & ns, int i)
|
|
|
|
{
|
|
|
|
ns.os() << i;
|
|
|
|
return ns;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-11-08 12:06:56 +00:00
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
2002-03-25 12:11:25 +00:00
|
|
|
WriteStream::WriteStream(ostream & os, bool fragile, bool latex)
|
|
|
|
: os_(os), fragile_(fragile), latex_(latex), firstitem_(false), line_(0)
|
2001-11-08 12:06:56 +00:00
|
|
|
{}
|
|
|
|
|
|
|
|
|
2002-02-16 15:59:55 +00:00
|
|
|
WriteStream::WriteStream(ostream & os)
|
2002-03-25 12:11:25 +00:00
|
|
|
: os_(os), fragile_(false), latex_(false), firstitem_(false), line_(0)
|
2001-11-08 12:06:56 +00:00
|
|
|
{}
|
|
|
|
|
|
|
|
|
2002-01-11 15:23:10 +00:00
|
|
|
void WriteStream::addlines(unsigned int n)
|
|
|
|
{
|
|
|
|
line_ += n;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-12-03 16:24:50 +00:00
|
|
|
WriteStream & operator<<(WriteStream & ws, MathInset const * p)
|
2001-11-08 12:06:56 +00:00
|
|
|
{
|
2001-11-09 16:27:44 +00:00
|
|
|
if (p)
|
2001-12-03 16:24:50 +00:00
|
|
|
p->write(ws);
|
2001-11-09 16:27:44 +00:00
|
|
|
else
|
2001-12-03 16:24:50 +00:00
|
|
|
lyxerr << "operator<<(WriteStream, NULL) called\n";
|
|
|
|
return ws;
|
2001-11-08 12:06:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-12-03 16:24:50 +00:00
|
|
|
WriteStream & operator<<(WriteStream & ws, MathArray const & ar)
|
2001-11-08 12:06:56 +00:00
|
|
|
{
|
2001-12-03 16:24:50 +00:00
|
|
|
write(ar, ws);
|
|
|
|
return ws;
|
2001-11-08 12:06:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-12-03 16:24:50 +00:00
|
|
|
WriteStream & operator<<(WriteStream & ws, char const * s)
|
2001-12-02 17:03:46 +00:00
|
|
|
{
|
2001-12-03 16:24:50 +00:00
|
|
|
ws.os() << s;
|
2002-01-14 13:04:06 +00:00
|
|
|
ws.addlines(int(lyx::count(s, s+strlen(s), '\n')));
|
2001-12-03 16:24:50 +00:00
|
|
|
return ws;
|
2001-11-08 12:06:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-12-03 16:24:50 +00:00
|
|
|
WriteStream & operator<<(WriteStream & ws, char c)
|
2001-11-08 12:06:56 +00:00
|
|
|
{
|
2001-12-03 16:24:50 +00:00
|
|
|
ws.os() << c;
|
2001-11-19 19:06:05 +00:00
|
|
|
if (c == '\n')
|
2002-01-11 15:23:10 +00:00
|
|
|
ws.addlines(1);
|
2001-12-03 16:24:50 +00:00
|
|
|
return ws;
|
2001-11-08 12:06:56 +00:00
|
|
|
}
|
2001-11-20 07:04:00 +00:00
|
|
|
|
|
|
|
|
2001-12-03 16:24:50 +00:00
|
|
|
WriteStream & operator<<(WriteStream & ws, int i)
|
2001-11-20 07:04:00 +00:00
|
|
|
{
|
2001-12-03 16:24:50 +00:00
|
|
|
ws.os() << i;
|
|
|
|
return ws;
|
2001-11-20 07:04:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-12-03 16:24:50 +00:00
|
|
|
WriteStream & operator<<(WriteStream & ws, unsigned int i)
|
2001-11-20 07:04:00 +00:00
|
|
|
{
|
2001-12-03 16:24:50 +00:00
|
|
|
ws.os() << i;
|
|
|
|
return ws;
|
2001-11-20 07:04:00 +00:00
|
|
|
}
|