+ if (pagebreak_top) {
+ file += "\\newpage";
+ further_blank_line = true;
+ }
+ if (added_space_top.kind() != VSpace::NONE) {
+ file += added_space_top.asLatexCommand(current_view->buffer()->params);
+ further_blank_line = true;
+ }
+
+ if (line_top) {
+ file += "\\lyxline{\\" + getFont(0).latexSize() + '}';
+ file += "\\vspace{-1\\parskip}";
+ further_blank_line = true;
+ }
+
+ if (further_blank_line){
+ file += '\n';
+ texrow.newline();
+ }
+
+ LyXDirection direction = getParDirection();
+ LyXDirection global_direction =
+ current_view->buffer()->params.getDocumentDirection();
+ if (direction != global_direction) {
+ if (direction == LYX_DIR_LEFT_TO_RIGHT)
+ file += "\\unsethebrew\n";
+ else
+ file += "\\sethebrew\n";
+ texrow.newline();
+ }
+
+
+ switch (style.latextype) {
+ case LATEX_COMMAND:
+ file += '\\';
+ file += style.latexname();
+ file += style.latexparam();
+ break;
+ case LATEX_ITEM_ENVIRONMENT:
+ if (bibkey) {
+#ifdef USE_OSTREAM_ONLY
+#ifdef HAVE_SSTREAM
+ ostringstream ost;
+ bibkey->Latex(ost, false);
+ file += ost.str().c_str();
+#else
+ ostrstream ost;
+ bibkey->Latex(ost, false);
+ ost << '\0';
+ char * tmp = ost.str();
+ file += tmp;
+ delete [] tmp;
+#endif
+#else
+ bibkey->Latex(file, false);
+#endif
+ } else
+ file += "\\item ";
+ break;
+ case LATEX_LIST_ENVIRONMENT:
+ file += "\\item ";
+ break;
+ default:
+ break;
+ }
+
+ bool need_par = SimpleTeXOnePar(file, texrow);
+
+ // Spit out footnotes
+ while (par && par->footnoteflag != LyXParagraph::NO_FOOTNOTE
+ && par->footnoteflag != footnoteflag) {
+ par = par->TeXFootnote(file, texrow,
+ foot, foot_texrow, foot_count,
+ direction);
+ par->SimpleTeXOnePar(file, texrow);
+ par = par->next;
+ }
+
+ // Make sure that \\par is done with the font of the last
+ // character if this has another size as the default.
+ // This is necessary because LaTeX (and LyX on the screen)
+ // calculates the space between the baselines according
+ // to this font. (Matthias)
+ LyXFont font = getFont(Last()-1);
+ if (need_par) {
+ if (style.resfont.size() != font.size()) {
+ file += '\\';
+ file += font.latexSize();
+ file += ' ';
+ }
+ file += "\\par}";
+ } else if (textclasslist.Style(current_view->buffer()->params.textclass,
+ GetLayout()).isCommand()){
+ if (style.resfont.size() != font.size()) {
+ file += '\\';
+ file += font.latexSize();
+ file += ' ';
+ }
+ file += '}';
+ } else if (style.resfont.size() != font.size()){
+ file += "{\\" + font.latexSize() + " \\par}";
+ }
+
+ if (direction != global_direction)
+ if (direction == LYX_DIR_LEFT_TO_RIGHT)
+ file += "\\sethebrew";
+ else
+ file += "\\unsethebrew";
+
+ switch (style.latextype) {
+ case LATEX_ITEM_ENVIRONMENT:
+ case LATEX_LIST_ENVIRONMENT:
+ if (par && (depth < par->depth)) {
+ file += '\n';
+ texrow.newline();
+ }
+ break;
+ case LATEX_ENVIRONMENT:
+ // if its the last paragraph of the current environment
+ // skip it otherwise fall through
+ if (par
+ && (par->layout != layout
+ || par->depth != depth
+ || par->pextra_type != pextra_type))
+ break;
+ default:
+ if (!(footnoteflag != LyXParagraph::NO_FOOTNOTE
+ && footnotekind != LyXParagraph::FOOTNOTE
+ && footnotekind != LyXParagraph::MARGIN
+ && (table
+ || (par
+ && par->table)))) {
+ // don't insert this if we would be adding it
+ // before or after a table in a float. This
+ // little trick is needed in order to allow
+ // use of tables in \subfigures or \subtables.
+ file += '\n';
+ texrow.newline();
+ }
+ }
+
+ further_blank_line = false;
+ if (line_bottom) {
+ file += "\\lyxline{\\" + getFont(Last()-1).latexSize() + '}';
+ further_blank_line = true;
+ }
+
+ if (added_space_bottom.kind() != VSpace::NONE) {
+ file += added_space_bottom.asLatexCommand(current_view->buffer()->params);
+ further_blank_line = true;
+ }
+
+ if (pagebreak_bottom) {
+ file += "\\newpage";
+ further_blank_line = true;
+ }
+
+ if (further_blank_line){
+ file += '\n';
+ texrow.newline();
+ }
+
+ if (!(footnoteflag != LyXParagraph::NO_FOOTNOTE && par &&
+ par->footnoteflag == LyXParagraph::NO_FOOTNOTE)) {
+ file += '\n';
+ texrow.newline();
+ }
+
+ lyxerr[Debug::LATEX] << "TeXOnePar...done " << par << endl;
+ return par;
+}
+#endif
+
+
+// This one spits out the text of the paragraph
+#ifdef USE_OSTREAM_ONLY
+bool LyXParagraph::SimpleTeXOnePar(ostream & os, TexRow & texrow)
+{
+ lyxerr[Debug::LATEX] << "SimpleTeXOnePar... " << this << endl;
+
+ if (table)
+ return SimpleTeXOneTablePar(os, texrow);
+
+ bool return_value = false;
+
+ LyXLayout const & style =
+ textclasslist.Style(current_view->buffer()->params.textclass,
+ GetLayout());
+ LyXFont basefont, last_font;
+
+ // Maybe we have to create a optional argument.
+ size_type main_body;
+ if (style.labeltype != LABEL_MANUAL)
+ main_body = 0;
+ else
+ main_body = BeginningOfMainBody();
+
+ if (main_body > 0) {
+ os << '[';
+ basefont = getFont(-2); // Get label font
+ } else {
+ basefont = getFont(-1); // Get layout font
+ }
+
+ int column = 0;
+
+ if (main_body >= 0
+ && !text.size()
+ && !IsDummy()) {
+ if (style.isCommand()) {
+ os << '{';
+ ++column;
+ } else if (align != LYX_ALIGN_LAYOUT) {
+ os << '{';
+ ++column;
+ return_value = true;
+ }
+ }
+
+ // Which font is currently active?
+ LyXFont running_font(basefont);
+ // Do we have an open font change?
+ bool open_font = false;
+
+ texrow.start(this, 0);
+
+ 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(os, basefont, basefont);
+ open_font = false;
+ }
+ basefont = getFont(-1); // Now use the layout font
+ running_font = basefont;
+ os << ']';
+ ++column;
+ }
+ if (style.isCommand()) {
+ os << '{';
+ ++column;
+ } else if (align != LYX_ALIGN_LAYOUT) {
+ os << "{\\par";
+ column += 4;
+ 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;
+ }
+ }
+
+ 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(os,
+ 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(os, texrow, i,
+ column, font, style);
+ }
+ }
+
+ // Do we need to change font?
+ if (!font.equalExceptLatex(running_font)
+ && i != main_body-1) {
+ column += font.latexWriteStartChanges(os, 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) {
+ os << '\n';
+ } else {
+ if (open_font) {
+ column += running_font.latexWriteEndChanges(os, basefont, basefont);
+ open_font = false;
+ }
+ basefont = getFont(-1);
+ running_font = basefont;
+ if (font.family() ==
+ LyXFont::TYPEWRITER_FAMILY) {
+ os << "~";
+ }
+ os << "\\\\\n";
+ }
+ texrow.newline();
+ texrow.start(this, i + 1);
+ column = 0;
+ } 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);
+ }
+
+ // Needed if there is an optional argument but no contents.
+ if (main_body > 0 && main_body == size()) {
+ os << "]~";
+ return_value = false;
+ }
+
+ lyxerr[Debug::LATEX] << "SimpleTeXOnePar...done " << this << endl;
+ return return_value;
+}
+#else
+bool LyXParagraph::SimpleTeXOnePar(string & file, TexRow & texrow)
+{
+ lyxerr[Debug::LATEX] << "SimpleTeXOnePar... " << this << endl;
+
+ if (table)
+ return SimpleTeXOneTablePar(file, texrow);
+
+ bool return_value = false;
+
+ LyXLayout const & style =
+ textclasslist.Style(current_view->buffer()->params.textclass,
+ GetLayout());
+ LyXFont basefont, last_font;
+
+ // Maybe we have to create a optional argument.
+ size_type main_body;
+ if (style.labeltype != LABEL_MANUAL)
+ main_body = 0;
+ else
+ main_body = BeginningOfMainBody();