+ 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(file,
+ basefont, font);
+ running_font = basefont;
+ open_font = false;
+ }
+ // Blanks are printed before start of fontswitch
+ if (c == ' '){
+ SimpleTeXBlanks(file, texrow, i, column, font, style);
+ }
+ // Do we need to change font?
+ if (font != running_font) {
+ column += font.latexWriteStartChanges(file, 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) {
+ file += "\\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(file, basefont, basefont);
+ open_font = false;
+ }
+ basefont = getFont(-1);
+ running_font = basefont;
+ ++current_cell_number;
+ if (table->CellHasContRow(current_cell_number) >= 0) {
+ TeXContTableRows(file, 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(file,
+ 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(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);
+ }
+ ++current_cell_number;
+ tmp = table->TexEndOfCell(file, current_cell_number);
+ for (; tmp > 0; --tmp)
+ texrow.newline();
+ lyxerr[Debug::LATEX] << "SimpleTeXOneTablePar...done " << this << endl;
+ return return_value;
+}
+#endif
+
+
+#ifdef USE_OSTREAM_ONLY
+// This one spits out the text off ContRows in tables
+bool LyXParagraph::TeXContTableRows(ostream & os,
+ LyXParagraph::size_type i,
+ int current_cell_number,
+ int & column, TexRow & texrow)
+{
+ lyxerr[Debug::LATEX] << "TeXContTableRows... " << this << endl;
+ if (!table)
+ return false;
+
+ char c;
+
+ bool return_value = false;
+ LyXLayout const & style =
+ textclasslist.Style(current_view->buffer()->params.textclass,
+ GetLayout());
+ LyXFont basefont = getFont(-1); // Get layout font
+ LyXFont last_font;
+ // Which font is currently active?
+ LyXFont running_font = basefont;
+ // Do we have an open font change?
+ bool open_font = false;
+
+ size_type lastpos = i;
+ int cell = table->CellHasContRow(current_cell_number);
+ ++current_cell_number;
+ while(cell >= 0) {
+ // first find the right position
+ i = lastpos;
+ for (; (i < size()) && (current_cell_number<cell); ++i) {
+ c = GetChar(i);
+ if (c == LyXParagraph::META_NEWLINE)
+ ++current_cell_number;
+ }
+ lastpos = i;
+ c = GetChar(i);
+ if (table->Linebreaks(table->FirstVirtualCell(cell))) {
+ os << " \\\\\n";
+ texrow.newline();
+ column = 0;
+ } else if ((c != ' ') && (c != LyXParagraph::META_NEWLINE)) {
+ os << ' ';
+ }
+
+ for (; i < size()
+ && (c = GetChar(i)) != LyXParagraph::META_NEWLINE;
+ ++i) {
+ ++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;
+ }
+ }
+ 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);
+ open_font = false;
+ }
+ basefont = getFont(-1);
+ running_font = basefont;
+ cell = table->CellHasContRow(current_cell_number);
+ }
+ lyxerr[Debug::LATEX] << "TeXContTableRows...done " << this << endl;
+ return return_value;
+}
+#else
+// This one spits out the text off ContRows in tables
+bool LyXParagraph::TeXContTableRows(string & file,
+ LyXParagraph::size_type i,
+ int current_cell_number,
+ int & column, TexRow & texrow)
+{
+ lyxerr[Debug::LATEX] << "TeXContTableRows... " << this << endl;
+ if (!table)
+ return false;
+
+ char c;
+
+ bool return_value = false;
+ LyXLayout const & style =
+ textclasslist.Style(current_view->buffer()->params.textclass,
+ GetLayout());
+ LyXFont basefont = getFont(-1); // Get layout font
+ LyXFont last_font;
+ // Which font is currently active?
+ LyXFont running_font = basefont;
+ // Do we have an open font change?
+ bool open_font = false;
+
+ size_type lastpos = i;
+ int cell = table->CellHasContRow(current_cell_number);
+ ++current_cell_number;
+ while(cell >= 0) {
+ // first find the right position