]> git.lyx.org Git - lyx.git/blobdiff - src/paragraph.C
Scons: update_po target, part one: language_l10n.pot
[lyx.git] / src / paragraph.C
index 26a1dc8037f2b8e100ae14f3e6eb647b8fcbe39d..f95d48d1a22f4cba54b6ab67da3aac1822b2603d 100644 (file)
@@ -33,8 +33,8 @@
 #include "lyxrow.h"
 #include "messages.h"
 #include "outputparams.h"
+#include "output_latex.h"
 #include "paragraph_funcs.h"
-#include "ParagraphList_fwd.h"
 
 #include "rowpainter.h"
 
@@ -793,13 +793,14 @@ string const corrected_env(string const & suffix, string const & env,
 }
 
 
-int adjust_column_count(string const & str, int oldcol)
+void adjust_row_column(string const & str, TexRow & texrow, int & column)
 {
        if (!contains(str, "\n"))
-               return oldcol + str.size();
+               column += str.size();
        else {
                string tmp;
-               return rsplit(str, tmp, '\n').size();
+               texrow.newline();
+               column = rsplit(str, tmp, '\n').size();
        }
 }
 
@@ -808,7 +809,8 @@ int adjust_column_count(string const & str, int oldcol)
 
 // This could go to ParagraphParameters if we want to
 int Paragraph::startTeXParParams(BufferParams const & bparams,
-                                 odocstream & os, bool moving_arg) const
+                                 odocstream & os, TexRow & texrow, 
+                                bool moving_arg) const
 {
        int column = 0;
 
@@ -846,7 +848,7 @@ int Paragraph::startTeXParParams(BufferParams const & bparams,
                else
                        output = corrected_env("\\begin", "flushright", ownerCode());
                os << from_ascii(output);
-               column = adjust_column_count(output, column);
+               adjust_row_column(output, texrow, column);
                break;
        } case LYX_ALIGN_RIGHT: {
                string output;
@@ -855,13 +857,13 @@ int Paragraph::startTeXParParams(BufferParams const & bparams,
                else
                        output = corrected_env("\\begin", "flushleft", ownerCode());
                os << from_ascii(output);
-               column = adjust_column_count(output, column);
+               adjust_row_column(output, texrow, column);
                break;
        } case LYX_ALIGN_CENTER: {
                string output;
                output = corrected_env("\\begin", "center", ownerCode());
                os << from_ascii(output);
-               column = adjust_column_count(output, column);
+               adjust_row_column(output, texrow, column);
                break;
        }
        }
@@ -871,8 +873,9 @@ int Paragraph::startTeXParParams(BufferParams const & bparams,
 
 
 // This could go to ParagraphParameters if we want to
-int Paragraph::endTeXParParams(BufferParams const & bparams,
-                               odocstream & os, bool moving_arg) const
+int Paragraph::endTeXParParams(BufferParams const & bparams,  
+                               odocstream & os, TexRow & texrow,
+                              bool moving_arg) const
 {
        int column = 0;
 
@@ -905,7 +908,7 @@ int Paragraph::endTeXParParams(BufferParams const & bparams,
                else
                        output = corrected_env("\n\\par\\end", "flushright", ownerCode());
                os << from_ascii(output);
-               column = adjust_column_count(output, column);
+               adjust_row_column(output, texrow, column);
                break;
        } case LYX_ALIGN_RIGHT: {
                string output;
@@ -914,13 +917,13 @@ int Paragraph::endTeXParParams(BufferParams const & bparams,
                else
                        output = corrected_env("\n\\par\\end", "flushleft", ownerCode());
                os << from_ascii(output);
-               column = adjust_column_count(output, column);
+               adjust_row_column(output, texrow, column);
                break;
        } case LYX_ALIGN_CENTER: {
                string output;
                output = corrected_env("\n\\par\\end", "center", ownerCode());
                os << from_ascii(output);
-               column = adjust_column_count(output, column);
+               adjust_row_column(output, texrow, column);
                break;
        }
        }
@@ -961,7 +964,6 @@ bool Paragraph::simpleTeXOnePar(Buffer const & buf,
        // As long as we are in the label, this font is the base font of the
        // label. Before the first body character it is set to the base font
        // of the body.
-       // This must be identical to basefont in TeXOnePar().
        LyXFont basefont;
 
        // output change tracking marks only if desired,
@@ -1001,19 +1003,20 @@ bool Paragraph::simpleTeXOnePar(Buffer const & buf,
                        ++column;
                }
                if (!asdefault)
-                       column += startTeXParParams(bparams, os,
+                       column += startTeXParParams(bparams, os, texrow,
                                                    runparams.moving_arg);
        }
 
        // Computed only once per paragraph since bparams.encoding() is expensive
        Encoding const & doc_encoding = bparams.encoding();
+
        for (pos_type i = 0; i < size(); ++i) {
                // First char in paragraph or after label?
                if (i == body_pos) {
                        if (body_pos > 0) {
                                if (open_font) {
                                        column += running_font.latexWriteEndChanges(
-                                               os, basefont, basefont, bparams);
+                                               os, basefont, basefont);
                                        open_font = false;
                                }
                                basefont = getLayoutFont(bparams, outerfont);
@@ -1032,7 +1035,8 @@ bool Paragraph::simpleTeXOnePar(Buffer const & buf,
                        }
 
                        if (!asdefault)
-                               column += startTeXParParams(bparams, os,
+                               column += startTeXParParams(bparams, os, 
+                                                           texrow,
                                                            runparams.moving_arg);
                }
 
@@ -1051,10 +1055,10 @@ bool Paragraph::simpleTeXOnePar(Buffer const & buf,
                        changeType, output);
                runningChangeType = changeType;
 
-               value_type c = getChar(i);
+               value_type const c = getChar(i);
 
                // Fully instantiated font
-               LyXFont font = getFont(bparams, i, outerfont);
+               LyXFont const font = getFont(bparams, i, outerfont);
 
                LyXFont const last_font = running_font;
 
@@ -1065,25 +1069,36 @@ bool Paragraph::simpleTeXOnePar(Buffer const & buf,
                {
                        column += running_font.latexWriteEndChanges(
                                        os, basefont,
-                                       (i == body_pos-1) ? basefont : font,
-                                       bparams);
+                                       (i == body_pos-1) ? basefont : font);
                        running_font = basefont;
                        open_font = false;
                }
 
+               // Switch file encoding if necessary
+               int const count = switchEncoding(os, bparams,
+                               *(runparams.encoding),
+                               *(font.language()->encoding()));
+               if (count > 0) {
+                       column += count;
+                       runparams.encoding = font.language()->encoding();
+               }
+
                // Do we need to change font?
                if ((font != running_font ||
                     font.language() != running_font.language()) &&
                        i != body_pos - 1)
                {
-                       column += font.latexWriteStartChanges(
-                                       os, basefont, last_font, bparams);
+                       column += font.latexWriteStartChanges(os, basefont,
+                                                             last_font);
                        running_font = font;
                        open_font = true;
                }
 
                if (c == ' ') {
                        // Do not print the separation of the optional argument
+                       // if style->pass_thru is false. This works because
+                       // simpleTeXSpecialChars ignores spaces if
+                       // style->pass_thru is false.
                        if (i != body_pos - 1) {
                                if (pimpl_->simpleTeXBlanks(bparams,
                                                doc_encoding, os, texrow,
@@ -1103,7 +1118,7 @@ bool Paragraph::simpleTeXOnePar(Buffer const & buf,
                rp.local_font = &font;
                rp.intitle = style->intitle;
                pimpl_->simpleTeXSpecialChars(buf, bparams, doc_encoding, os,
-                                       texrow, rp, font, running_font,
+                                       texrow, rp, running_font,
                                        basefont, outerfont, open_font,
                                        runningChangeType, *style, i, column, c);
        }
@@ -1114,11 +1129,10 @@ bool Paragraph::simpleTeXOnePar(Buffer const & buf,
                if (next_) {
                        running_font
                                .latexWriteEndChanges(os, basefont,
-                                       next_->getFont(bparams, 0, outerfont),
-                                       bparams);
+                                       next_->getFont(bparams, 0, outerfont));
                } else {
                        running_font.latexWriteEndChanges(os, basefont,
-                                                         basefont, bparams);
+                                                         basefont);
                }
 #else
 #ifdef WITH_WARNINGS
@@ -1126,8 +1140,7 @@ bool Paragraph::simpleTeXOnePar(Buffer const & buf,
 //#warning there as we start another \selectlanguage with the next paragraph if
 //#warning we are in need of this. This should be fixed sometime (Jug)
 #endif
-               running_font.latexWriteEndChanges(os, basefont, basefont,
-                                                 bparams);
+               running_font.latexWriteEndChanges(os, basefont, basefont);
 #endif
        }
 
@@ -1141,7 +1154,8 @@ bool Paragraph::simpleTeXOnePar(Buffer const & buf,
        }
 
        if (!asdefault) {
-               column += endTeXParParams(bparams, os, runparams.moving_arg);
+               column += endTeXParParams(bparams, os, texrow, 
+                                         runparams.moving_arg);
        }
 
        lyxerr[Debug::LATEX] << "SimpleTeXOnePar...done " << this << endl;