+#ifdef USE_OSTREAM_ONLY
+ if (!array) return;
+ int brace = 0;
+ latexkeys * l;
+ MathedIter data(array);
+ // hack
+ MathedRowSt const * crow = getRowSt();
+ data.Reset();
+
+ if (!Permit(LMPF_FIXED_SIZE)) {
+ l = lm_get_key_by_id(size, LM_TK_STY);
+ if (l) {
+ os << '\\' << l->name << ' ';
+ }
+ }
+ while (data.OK()) {
+ byte cx = data.GetChar();
+ if (cx >= ' ') {
+ int ls;
+ byte * s = data.GetString(ls);
+
+ if (data.FCode() >= LM_TC_RM && data.FCode() <= LM_TC_TEXTRM) {
+ os << '\\' << math_font_name[data.FCode()-LM_TC_RM] << '{';
+ }
+ while (ls > 0) {
+ if (MathIsSymbol(data.FCode())) {
+ l = lm_get_key_by_id(*s, (data.FCode() == LM_TC_BSYM) ?
+ LM_TK_BIGSYM : LM_TK_SYM);
+ if (l) {
+ os << '\\' << l->name << ' ';
+ } else {
+ lyxerr << "Illegal symbol code[" << *s
+ << " " << ls << " " << data.FCode() << "]";
+ }
+ } else {
+ // Is there a standard logical XOR?
+ if ((data.FCode() == LM_TC_TEX && *s != '{' && *s != '}') ||
+ (data.FCode() == LM_TC_SPECIAL))
+ os << '\\';
+ else {
+ if (*s == '{') ++brace;
+ if (*s == '}') --brace;
+ }
+ if (*s == '}' && data.FCode() == LM_TC_TEX && brace < 0)
+ lyxerr <<"Math warning: Unexpected closing brace."
+ << endl;
+ else
+ os << char(*s);
+ }
+ ++s; --ls;
+ }
+ if (data.FCode()>= LM_TC_RM && data.FCode()<= LM_TC_TEXTRM)
+ os << '}';
+ } else
+ if (MathIsInset(cx)) {
+ MathedInset * p = data.GetInset();
+ if (cx == LM_TC_UP)
+ os << "^{";
+ if (cx == LM_TC_DOWN)
+ os << "_{";
+ p->Write(os);
+ if (cx == LM_TC_UP || cx == LM_TC_DOWN)
+ os << '}';
+ data.Next();
+ } else
+ switch(cx) {
+ case LM_TC_TAB:
+ {
+ os << " & ";
+ data.Next();
+ break;
+ }
+ case LM_TC_CR:
+ {
+ if (crow) {
+ if (!crow->isNumbered()) {
+ os << "\\nonumber ";
+ }
+ if (crow->getLabel()) {
+ os << "\\label{"
+ << crow->getLabel()
+ << "} ";
+ }
+ crow = crow->getNext();
+ }
+ os << "\\\\\n";
+ ++number_of_newlines;
+ data.Next();
+ break;
+ }
+ default:
+ lyxerr << "WMath Error: unrecognized code[" << cx << "]";
+ return;
+ }
+ }
+
+ if (crow) {
+ if (!crow->isNumbered()) {
+ os << "\\nonumber ";
+ }
+ if (crow->getLabel()) {
+ os << "\\label{"
+ << crow->getLabel()
+ << "} ";
+ }
+ }
+#if 1
+ while (brace > 0) {
+ os << '}';
+ --brace;
+ }
+#else
+ // Something like this should work too:
+ os << string(brace, '}'); // not one-off error I hope.
+#endif
+#else