*
* Dependencies: Mathed
*
- * Copyright: (c) 1996, 1997 Alejandro Aguilar Sierra
+ * Copyright: 1996, 1997 Alejandro Aguilar Sierra
*
* Version: 0.2, Mathed & Lyx project.
*
#include "support/lstrings.h"
#include "debug.h"
+using std::ostream;
+using std::endl;
ostream & operator<<(ostream & o, MathedTextCodes mtc)
{
}
-void MathMacro::Write(ostream & os)
+void MathMacro::Write(ostream & os, bool fragile)
{
-#ifdef USE_OSTREAM_ONLY
if (tmplate->flags & MMF_Exp) {
lyxerr[Debug::MATHED] << "Expand " << tmplate->flags
<< ' ' << MMF_Exp << endl;
tmplate->update(this);
- tmplate->Write(os);
+ tmplate->Write(os, fragile);
} else {
if (tmplate->flags & MMF_Env) {
os << "\\begin{"
for (int i = 0; i < nargs; ++i) {
array = args[i].array;
- MathParInset::Write(os);
+ MathParInset::Write(os, fragile);
if (i < nargs - 1)
os << "}{";
}
os << ' ';
}
}
-#else
- string output;
- MathMacro::Write(output);
- os << output;
-#endif
}
-#ifndef USE_OSTREAM_ONLY
-void MathMacro::Write(string &file)
-{
- if (tmplate->flags & MMF_Exp) {
- lyxerr[Debug::MATHED] << "Expand " << tmplate->flags
- << ' ' << MMF_Exp << endl;
- tmplate->update(this);
- tmplate->Write(file);
- } else {
- if (tmplate->flags & MMF_Env) {
- file += "\\begin{";
- file += name;
- file += "} ";
- } else {
- file += '\\';
- file += name;
- }
-// if (options) {
-// file += '[';
-// file += options;
-// file += ']';
-// }
-
- if (!(tmplate->flags & MMF_Env) && nargs > 0)
- file += '{';
-
- for (int i = 0; i < nargs; ++i) {
- array = args[i].array;
- MathParInset::Write(file);
- if (i < nargs - 1)
- file += "}{";
- }
- if (tmplate->flags & MMF_Env) {
- file += "\\end{";
- file += name;
- file += '}';
- } else {
- if (nargs > 0)
- file += '}';
- else
- file += ' ';
- }
- }
-}
-#endif
-
-
/*--------------- Macro argument -----------------------------------*/
MathMacroArgument::MathMacroArgument(int n)
MathParInset::draw(pain, x, baseline);
} else {
#ifdef HAVE_SSTREAM
- ostringstream ost;
+ std::ostringstream ost;
ost << '#' << number;
- drawStr(pain, LM_TC_TEX, size, x, baseline, ost.str().c_str(), 2);
+ drawStr(pain, LM_TC_TEX, size, x, baseline,
+ reinterpret_cast<byte const *>(ost.str().c_str()), 2);
#else
char s[3];
ostrstream ost(s, 3);
ost << '#' << number << '\0';
drawStr(pain, LM_TC_TEX, size, x, baseline,
- reinterpret_cast<unsigned char*>(ost.str()), 2);
+ reinterpret_cast<byte *>(ost.str()), 2);
#endif
}
}
MathParInset::Metrics();
} else {
#ifdef HAVE_SSTREAM
- ostringstream ost;
+ std::ostringstream ost;
ost << '#' << number;
- width = mathed_string_width(LM_TC_TEX, size, ost.str().c_str(), 2);
+ width = mathed_string_width(LM_TC_TEX, size,
+ reinterpret_cast<byte const *>(ost.str().c_str()), 2);
mathed_string_height(LM_TC_TEX, size,
- ost.str().c_str(), 2, ascent, descent);
+ reinterpret_cast<byte const *>(ost.str().c_str()),
+ 2, ascent, descent);
#else
char s[3];
ostrstream ost(s, 3);
ost << '#' << number << '\0';
width = mathed_string_width(LM_TC_TEX, size,
- reinterpret_cast<unsigned char*>
+ reinterpret_cast<byte *>
(ost.str()), 2);
mathed_string_height(LM_TC_TEX, size,
- reinterpret_cast<unsigned char*>(ost.str()),
+ reinterpret_cast<byte *>(ost.str()),
2, ascent, descent);
#endif
}
}
-void MathMacroArgument::Write(ostream & os)
+void MathMacroArgument::Write(ostream & os, bool fragile)
{
-#ifdef USE_OSTREAM_ONLY
if (expnd_mode) {
- MathParInset::Write(os);
+ MathParInset::Write(os, fragile);
} else {
os << '#' << number << ' ';
}
-#else
- string output;
- MathMacroArgument::Write(output);
- os << output;
-#endif
}
-#ifndef USE_OSTREAM_ONLY
-void MathMacroArgument::Write(string & file)
-{
- if (expnd_mode) {
- MathParInset::Write(file);
- } else {
- file += '#';
- file += tostr(number);
- file += ' ';
- }
-}
-#endif
-
-
/* --------------------- MathMacroTemplate ---------------------------*/
MathMacroTemplate::MathMacroTemplate(char const * nm, int na, int flg):
}
-void MathMacroTemplate::WriteDef(ostream & os)
+void MathMacroTemplate::WriteDef(ostream & os, bool fragile)
{
os << "\n\\newcommand{\\" << name << "}";
for (int i = 0; i < nargs; ++i) {
args[i].setExpand(false);
}
- Write(os);
+ Write(os, fragile);
os << "}\n";
}
-#ifndef USE_OSTREAM_ONLY
-void MathMacroTemplate::WriteDef(string & file)
-{
- file += "\n\\newcommand{\\";
- file += name;
- file += '}';
-
- if (nargs > 0 ) {
- file += '[';
- file += tostr(nargs);
- file += ']';
- }
-
- file += '{';
-
- for (int i = 0; i < nargs; ++i) {
- args[i].setExpand(false);
- }
- Write(file);
- file += "}\n";
-}
-#endif
-
-
void MathMacroTemplate::setArgument(LyxArrayBase * a, int i)
{
args[i].SetData(a);