+ for (size_type i = 0; i < size(); ++i) {
+ ++column;
+ // First char in paragraph or after label?
+ if (i == main_body && !IsDummy()) {
+ if (main_body > 0) {
+ if (open_font) {
+ column += running_font.latexWriteEndChanges(file, basefont, basefont);
+ open_font = false;
+ }
+ basefont = getFont(-1); // Now use the layout font
+ running_font = basefont;
+ file += ']';
+ ++column;
+ }
+ if (style.isCommand()) {
+ file += '{';
+ ++column;
+ } else if (align != LYX_ALIGN_LAYOUT) {
+ file += "{\\par";
+ column += 4;
+ return_value = true;
+ }
+
+ if (noindent) {
+ file += "\\noindent ";
+ column += 10;
+ }
+ switch (align) {
+ case LYX_ALIGN_NONE:
+ case LYX_ALIGN_BLOCK:
+ case LYX_ALIGN_LAYOUT:
+ case LYX_ALIGN_SPECIAL: break;
+ case LYX_ALIGN_LEFT:
+ file += "\\raggedright ";
+ column+= 13;
+ break;
+ case LYX_ALIGN_RIGHT:
+ file += "\\raggedleft ";
+ column+= 12;
+ break;
+ case LYX_ALIGN_CENTER:
+ file += "\\centering ";
+ column+= 11;
+ break;
+ }
+ }
+
+ int c = GetChar(i);
+
+ // Fully instantiated font
+ LyXFont font = getFont(i);
+ last_font = running_font;
+
+ // Spaces at end of font change are simulated to be
+ // outside font change, i.e. we write "\textXX{text} "
+ // rather than "\textXX{text }". (Asger)
+ if (open_font && c == ' ' && i <= size() - 2
+ && !getFont(i+1).equalExceptLatex(running_font)
+ && !getFont(i+1).equalExceptLatex(font)) {
+ font = getFont(i + 1);
+ }
+ // We end font definition before blanks
+ if (!font.equalExceptLatex(running_font) && open_font) {
+ column += running_font.latexWriteEndChanges(file,
+ basefont,
+ (i == main_body-1) ? basefont : font);
+ running_font = basefont;
+ open_font = false;
+ }
+
+ // Blanks are printed before start of fontswitch
+ if (c == ' '){
+ // Do not print the separation of the optional argument
+ if (i != main_body - 1) {
+ SimpleTeXBlanks(file, texrow, i,
+ column, font, style);
+ }
+ }
+
+ // Do we need to change font?
+ if (!font.equalExceptLatex(running_font)
+ && i != main_body-1) {
+ column += font.latexWriteStartChanges(file, basefont, last_font);
+ running_font = font;
+ open_font = true;
+ }
+
+ if (c == LyXParagraph::META_NEWLINE) {
+ // newlines are handled differently here than
+ // the default in SimpleTeXSpecialChars().
+ if (!style.newline_allowed
+ || font.latex() == LyXFont::ON) {
+ file += '\n';
+ } else {
+ if (open_font) {
+ column += running_font.latexWriteEndChanges(file, basefont, basefont);
+ open_font = false;
+ }
+ basefont = getFont(-1);
+ running_font = basefont;
+ if (font.family() ==
+ LyXFont::TYPEWRITER_FAMILY) {
+ file += "~";
+ }
+ file += "\\\\\n";
+ }
+ texrow.newline();
+ texrow.start(this, i + 1);
+ column = 0;
+ } else {
+ SimpleTeXSpecialChars(file, texrow,
+ font, running_font, basefont,
+ open_font, style, i, column, c);
+ }
+ }
+
+ // If we have an open font definition, we have to close it
+ if (open_font) {
+ running_font.latexWriteEndChanges(file, basefont, basefont);
+ }
+
+ // Needed if there is an optional argument but no contents.
+ if (main_body > 0 && main_body == size()) {
+ file += "]~";
+ return_value = false;
+ }
+
+ lyxerr[Debug::LATEX] << "SimpleTeXOnePar...done " << this << endl;
+ return return_value;
+}
+#endif
+
+
+#ifdef USE_OSTREAM_ONLY
+// This one spits out the text of a table paragraph
+bool LyXParagraph::SimpleTeXOneTablePar(ostream & os, TexRow & texrow)
+{
+ lyxerr[Debug::LATEX] << "SimpleTeXOneTablePar... " << this << endl;
+
+ bool return_value = false;
+
+ LyXLayout const & style =
+ textclasslist.Style(current_view->buffer()->params.textclass,
+ GetLayout());
+
+ int column = 0;
+ if (!IsDummy()) { // it is dummy if it is in a float!!!
+ if (style.isCommand()) {
+ os << '{';
+ ++column;
+ } else if (align != LYX_ALIGN_LAYOUT) {
+ os << '{';
+ ++column;
+ return_value = true;
+ }
+ if (noindent) {
+ os << "\\noindent ";
+ column += 10;
+ }
+ switch (align) {
+ case LYX_ALIGN_NONE:
+ case LYX_ALIGN_BLOCK:
+ case LYX_ALIGN_LAYOUT:
+ case LYX_ALIGN_SPECIAL: break;
+ case LYX_ALIGN_LEFT:
+ os << "\\raggedright ";
+ column+= 13;
+ break;
+ case LYX_ALIGN_RIGHT:
+ os << "\\raggedleft ";
+ column+= 12;
+ break;
+ case LYX_ALIGN_CENTER:
+ os << "\\centering ";
+ column+= 11;
+ break;
+ }
+ }
+
+ LyXFont basefont = getFont(-1); // Get layout font
+ // Which font is currently active?
+ LyXFont running_font = basefont;
+ LyXFont last_font;
+ // Do we have an open font change?
+ bool open_font = false;
+ int current_cell_number = -1;
+ int tmp = table->TexEndOfCell(os, current_cell_number);
+ for (; tmp > 0 ; --tmp)
+ texrow.newline();
+
+ texrow.start(this, 0);
+
+ for (size_type i = 0; i < size(); ++i) {
+ char c = GetChar(i);
+ if (table->IsContRow(current_cell_number + 1)) {
+ if (c == LyXParagraph::META_NEWLINE)
+ ++current_cell_number;
+ continue;
+ }
+ ++column;
+
+ // Fully instantiated font
+ LyXFont font = getFont(i);
+ last_font = running_font;
+
+ // Spaces at end of font change are simulated to be
+ // outside font change.
+ // i.e. we write "\textXX{text} " rather than
+ // "\textXX{text }". (Asger)
+ if (open_font && c == ' ' && i <= size() - 2
+ && getFont(i + 1) != running_font
+ && getFont(i + 1) != font) {
+ font = getFont(i + 1);
+ }
+
+ // We end font definition before blanks
+ if (font != running_font && open_font) {
+ column += running_font.latexWriteEndChanges(os,
+ basefont,
+ font);
+ running_font = basefont;
+ open_font = false;
+ }
+ // Blanks are printed before start of fontswitch
+ if (c == ' '){
+ SimpleTeXBlanks(os, texrow, i, column, font, style);
+ }
+ // Do we need to change font?
+ if (font != running_font) {
+ column += font.latexWriteStartChanges(os, basefont,
+ last_font);
+ running_font = font;
+ open_font = true;
+ }
+ // Do we need to turn on LaTeX mode?
+ if (font.latex() != running_font.latex()) {
+ if (font.latex() == LyXFont::ON
+ && style.needprotect) {
+ os << "\\protect ";
+ column += 9;
+ }
+ }
+ if (c == LyXParagraph::META_NEWLINE) {
+ // special case for inside a table
+ // different from default case in
+ // SimpleTeXSpecialChars()
+ if (open_font) {
+ column += running_font
+ .latexWriteEndChanges(os, basefont,
+ basefont);
+ open_font = false;
+ }
+ basefont = getFont(-1);
+ running_font = basefont;
+ ++current_cell_number;
+ if (table->CellHasContRow(current_cell_number) >= 0) {
+ TeXContTableRows(os, i + 1,
+ current_cell_number,
+ column, texrow);
+ }
+ // if this cell follow only ContRows till end don't
+ // put the EndOfCell because it is put after the
+ // for(...)
+ if (table->ShouldBeVeryLastCell(current_cell_number)) {
+ --current_cell_number;
+ break;
+ }
+ int tmp = table->TexEndOfCell(os,
+ current_cell_number);
+ if (tmp > 0) {
+ column = 0;
+ } else if (tmp < 0) {
+ tmp = -tmp;
+ }
+ for (; tmp--;) {
+ texrow.newline();
+ }
+ texrow.start(this, i + 1);
+ } else {
+ SimpleTeXSpecialChars(os, texrow,
+ font, running_font, basefont,
+ open_font, style, i, column, c);
+ }
+ }
+
+ // If we have an open font definition, we have to close it
+ if (open_font) {
+ running_font.latexWriteEndChanges(os, basefont, basefont);
+ }
+ ++current_cell_number;
+ tmp = table->TexEndOfCell(os, current_cell_number);
+ for (; tmp > 0; --tmp)
+ texrow.newline();
+ lyxerr[Debug::LATEX] << "SimpleTeXOneTablePar...done " << this << endl;
+ return return_value;
+}
+#else
+// This one spits out the text of a table paragraph
+bool LyXParagraph::SimpleTeXOneTablePar(string & file, TexRow & texrow)
+{
+ lyxerr[Debug::LATEX] << "SimpleTeXOneTablePar... " << this << endl;
+
+ bool return_value = false;
+
+ LyXLayout const & style =
+ textclasslist.Style(current_view->buffer()->params.textclass,
+ GetLayout());
+
+ int column = 0;
+ if (!IsDummy()) { // it is dummy if it is in a float!!!
+ if (style.isCommand()) {
+ file += '{';
+ ++column;
+ } else if (align != LYX_ALIGN_LAYOUT) {
+ file += '{';
+ ++column;
+ return_value = true;
+ }
+ if (noindent) {
+ file += "\\noindent ";
+ column += 10;
+ }
+ switch (align) {
+ case LYX_ALIGN_NONE:
+ case LYX_ALIGN_BLOCK:
+ case LYX_ALIGN_LAYOUT:
+ case LYX_ALIGN_SPECIAL: break;
+ case LYX_ALIGN_LEFT:
+ file += "\\raggedright ";
+ column+= 13;
+ break;
+ case LYX_ALIGN_RIGHT:
+ file += "\\raggedleft ";
+ column+= 12;
+ break;
+ case LYX_ALIGN_CENTER:
+ file += "\\centering ";
+ column+= 11;
+ break;
+ }
+ }
+
+ LyXFont basefont = getFont(-1); // Get layout font
+ // Which font is currently active?
+ LyXFont running_font = basefont;
+ LyXFont last_font;
+ // Do we have an open font change?
+ bool open_font = false;
+ int current_cell_number = -1;
+ int tmp = table->TexEndOfCell(file, current_cell_number);
+ for (; tmp > 0 ; --tmp)
+ texrow.newline();
+
+ texrow.start(this, 0);
+
+ for (size_type i = 0; i < size(); ++i) {
+ char c = GetChar(i);
+ if (table->IsContRow(current_cell_number + 1)) {
+ if (c == LyXParagraph::META_NEWLINE)
+ ++current_cell_number;
+ continue;
+ }
+ ++column;