]> git.lyx.org Git - lyx.git/commitdiff
Integrate texrow with otexstream in order to perform automatic line
authorEnrico Forestieri <forenr@lyx.org>
Thu, 10 Feb 2011 20:02:48 +0000 (20:02 +0000)
committerEnrico Forestieri <forenr@lyx.org>
Thu, 10 Feb 2011 20:02:48 +0000 (20:02 +0000)
counting when exporting to latex. This is done for the code comprised
between \begin{document} and \end{document}, while the preamble code
still needs manual calls to TexRow::newline() for registering new lines.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@37584 a592a061-630c-0410-9148-cb99ea01b6c8

79 files changed:
src/Buffer.cpp
src/Paragraph.cpp
src/Paragraph.h
src/insets/Inset.h
src/insets/InsetArgument.cpp
src/insets/InsetArgument.h
src/insets/InsetBibtex.cpp
src/insets/InsetBibtex.h
src/insets/InsetBox.cpp
src/insets/InsetBox.h
src/insets/InsetBranch.cpp
src/insets/InsetBranch.h
src/insets/InsetCaption.cpp
src/insets/InsetCaption.h
src/insets/InsetCitation.cpp
src/insets/InsetCitation.h
src/insets/InsetCommand.cpp
src/insets/InsetCommand.h
src/insets/InsetExternal.cpp
src/insets/InsetExternal.h
src/insets/InsetFloat.cpp
src/insets/InsetFloat.h
src/insets/InsetFloatList.cpp
src/insets/InsetFloatList.h
src/insets/InsetFoot.cpp
src/insets/InsetFoot.h
src/insets/InsetGraphics.cpp
src/insets/InsetGraphics.h
src/insets/InsetHyperlink.cpp
src/insets/InsetHyperlink.h
src/insets/InsetInclude.cpp
src/insets/InsetInclude.h
src/insets/InsetIndex.cpp
src/insets/InsetIndex.h
src/insets/InsetLine.cpp
src/insets/InsetLine.h
src/insets/InsetListings.cpp
src/insets/InsetListings.h
src/insets/InsetNewline.cpp
src/insets/InsetNewline.h
src/insets/InsetNewpage.cpp
src/insets/InsetNewpage.h
src/insets/InsetNomencl.cpp
src/insets/InsetNomencl.h
src/insets/InsetNote.cpp
src/insets/InsetNote.h
src/insets/InsetPhantom.cpp
src/insets/InsetPhantom.h
src/insets/InsetPreview.cpp
src/insets/InsetQuotes.cpp
src/insets/InsetQuotes.h
src/insets/InsetRef.cpp
src/insets/InsetRef.h
src/insets/InsetScript.cpp
src/insets/InsetScript.h
src/insets/InsetSpace.cpp
src/insets/InsetSpace.h
src/insets/InsetSpecialChar.cpp
src/insets/InsetSpecialChar.h
src/insets/InsetTabular.cpp
src/insets/InsetTabular.h
src/insets/InsetText.cpp
src/insets/InsetText.h
src/insets/InsetVSpace.cpp
src/insets/InsetVSpace.h
src/insets/InsetWrap.cpp
src/insets/InsetWrap.h
src/lyxfind.cpp
src/mathed/InsetFormulaMacro.cpp
src/mathed/InsetMathHull.cpp
src/mathed/InsetMathMBox.cpp
src/mathed/InsetMathNest.cpp
src/mathed/InsetMathNest.h
src/mathed/MathFactory.cpp
src/output_latex.cpp
src/output_latex.h
src/support/docstream.cpp
src/support/docstream.h
src/tex2lyx/tex2lyx.cpp

index 1c301b42dc5f79e1ccb38435fc571ac360c48512..5831df1a61b9509583da2b069aacb10ab0c7f507 100644 (file)
@@ -1453,8 +1453,8 @@ void Buffer::writeLaTeXSource(odocstream & os,
        }
 
        // the real stuff
-       otexstream ots(os);
-       latexParagraphs(*this, text(), ots, d->texrow, runparams);
+       otexstream ots(os, d->texrow);
+       latexParagraphs(*this, text(), ots, runparams);
 
        // Restore the parenthood if needed
        if (output_preamble)
@@ -3135,8 +3135,8 @@ void Buffer::getSourceCode(odocstream & os, string const format,
                        xhtmlParagraphs(text(), *this, xs, runparams);
                } else {
                        // latex or literate
-                       otexstream ots(os);
-                       latexParagraphs(*this, text(), ots, texrow, runparams);
+                       otexstream ots(os, texrow);
+                       latexParagraphs(*this, text(), ots, runparams);
                }
        }
 }
index 8d7371ff5fa5ecc0dbd884cd849ec4be85dd85ec..50b0bcfb00dca066acc1493986449a87547d0c96 100644 (file)
@@ -295,7 +295,7 @@ public:
        /// if the next character is a combining character).
        /// \return whether a surrogate pair was output.
        bool simpleTeXBlanks(OutputParams const &,
-                            otexstream &, TexRow & texrow,
+                            otexstream &,
                             pos_type i,
                             unsigned int & column,
                             Font const & font,
@@ -308,17 +308,17 @@ public:
                           Change const &, Encoding const &, pos_type & i);
 
        /// This could go to ParagraphParameters if we want to.
-       int startTeXParParams(BufferParams const &, otexstream &, TexRow &,
+       int startTeXParParams(BufferParams const &, otexstream &,
                              OutputParams const &) const;
 
        /// This could go to ParagraphParameters if we want to.
-       int endTeXParParams(BufferParams const &, otexstream &, TexRow &,
+       int endTeXParParams(BufferParams const &, otexstream &,
                            OutputParams const &) const;
 
        ///
        void latexInset(BufferParams const &,
                                   otexstream &,
-                                  TexRow & texrow, OutputParams &,
+                                  OutputParams &,
                                   Font & running_font,
                                   Font & basefont,
                                   Font const & outerfont,
@@ -866,7 +866,7 @@ int Paragraph::Private::latexSurrogatePair(otexstream & os, char_type c,
 
 
 bool Paragraph::Private::simpleTeXBlanks(OutputParams const & runparams,
-                                      otexstream & os, TexRow & texrow,
+                                      otexstream & os,
                                       pos_type i,
                                       unsigned int & column,
                                       Font const & font,
@@ -899,8 +899,7 @@ bool Paragraph::Private::simpleTeXBlanks(OutputParams const & runparams,
                     || text_[i - 1] == ':'
                     || text_[i - 1] == '!'))) {
                os << '\n';
-               texrow.newline();
-               texrow.start(owner_->id(), i + 1);
+               os.texrow().start(owner_->id(), i + 1);
                column = 0;
        } else if (style.free_spacing) {
                os << '~';
@@ -1006,7 +1005,6 @@ bool Paragraph::Private::isTextAt(string const & str, pos_type pos) const
 
 void Paragraph::Private::latexInset(BufferParams const & bparams,
                                    otexstream & os,
-                                   TexRow & texrow,
                                    OutputParams & runparams,
                                    Font & running_font,
                                    Font & basefont,
@@ -1049,8 +1047,7 @@ void Paragraph::Private::latexInset(BufferParams const & bparams,
                                os << "\\protect ";
 
                }
-               texrow.newline();
-               texrow.start(owner_->id(), i + 1);
+               os.texrow().start(owner_->id(), i + 1);
                column = 0;
        }
 
@@ -1115,10 +1112,10 @@ void Paragraph::Private::latexInset(BufferParams const & bparams,
                }
        }
 
-       int tmp;
+       int prev_rows = os.texrow().rows();
 
        try {
-               tmp = inset->latex(os, runparams);
+               inset->latex(os, runparams);
        } catch (EncodingException & e) {
                // add location information and throw again.
                e.par_id = id_;
@@ -1133,9 +1130,8 @@ void Paragraph::Private::latexInset(BufferParams const & bparams,
                                os << '}';
        }
 
-       if (tmp) {
-               texrow.newlines(tmp);
-               texrow.start(owner_->id(), i + 1);
+       if (os.texrow().rows() > prev_rows) {
+               os.texrow().start(owner_->id(), i + 1);
                column = 0;
        } else {
                column += (unsigned int)(os.os().tellp() - len);
@@ -1357,15 +1353,15 @@ void Paragraph::Private::validate(LaTeXFeatures & features) const
                Buffer const & buf = inset_owner_->buffer();
                BufferParams const & bp = buf.params();
                Font f;
-               TexRow tr;
+               TexRow texrow;
                // Using a string stream here circumvents the encoding
                // switching machinery of odocstream. Therefore the
                // output is wrong if this paragraph contains content
                // that needs to switch encoding.
                odocstringstream ods;
-               otexstream os(ods);
+               otexstream os(ods, texrow);
                if (is_command) {
-                       ods << '\\' << from_ascii(layout_->latexname());
+                       os << '\\' << from_ascii(layout_->latexname());
                        // we have to provide all the optional arguments here, even though
                        // the last one is the only one we care about.
                        // Separate handling of optional argument inset.
@@ -1377,7 +1373,7 @@ void Paragraph::Private::validate(LaTeXFeatures & features) const
                }
                docstring::size_type const length = ods.str().length();
                // this will output "{" at the beginning, but not at the end
-               owner_->latex(bp, f, os, tr, features.runparams(), 0, -1, true);
+               owner_->latex(bp, f, os, features.runparams(), 0, -1, true);
                if (ods.str().length() > length) {
                        if (is_command)
                                ods << '}';
@@ -2119,13 +2115,12 @@ string const corrected_env(string const & suffix, string const & env,
 }
 
 
-void adjust_row_column(string const & str, TexRow & texrow, int & column)
+void adjust_column(string const & str, int & column)
 {
        if (!contains(str, "\n"))
                column += str.size();
        else {
                string tmp;
-               texrow.newline();
                column = rsplit(str, tmp, '\n').size();
        }
 }
@@ -2134,8 +2129,7 @@ void adjust_row_column(string const & str, TexRow & texrow, int & column)
 
 
 int Paragraph::Private::startTeXParParams(BufferParams const & bparams,
-                                otexstream & os, TexRow & texrow,
-                                OutputParams const & runparams) const
+                       otexstream & os, OutputParams const & runparams) const
 {
        int column = 0;
 
@@ -2184,7 +2178,7 @@ int Paragraph::Private::startTeXParParams(BufferParams const & bparams,
                else
                        output = corrected_env(begin_tag, "flushright", code, lastpar);
                os << from_ascii(output);
-               adjust_row_column(output, texrow, column);
+               adjust_column(output, column);
                break;
        } case LYX_ALIGN_RIGHT: {
                string output;
@@ -2193,13 +2187,13 @@ int Paragraph::Private::startTeXParParams(BufferParams const & bparams,
                else
                        output = corrected_env(begin_tag, "flushleft", code, lastpar);
                os << from_ascii(output);
-               adjust_row_column(output, texrow, column);
+               adjust_column(output, column);
                break;
        } case LYX_ALIGN_CENTER: {
                string output;
                output = corrected_env(begin_tag, "center", code, lastpar);
                os << from_ascii(output);
-               adjust_row_column(output, texrow, column);
+               adjust_column(output, column);
                break;
        }
        }
@@ -2209,8 +2203,7 @@ int Paragraph::Private::startTeXParParams(BufferParams const & bparams,
 
 
 int Paragraph::Private::endTeXParParams(BufferParams const & bparams,
-                              otexstream & os, TexRow & texrow,
-                              OutputParams const & runparams) const
+                       otexstream & os, OutputParams const & runparams) const
 {
        int column = 0;
 
@@ -2254,7 +2247,7 @@ int Paragraph::Private::endTeXParParams(BufferParams const & bparams,
                else
                        output = corrected_env(end_tag, "flushright", code, lastpar);
                os << from_ascii(output);
-               adjust_row_column(output, texrow, column);
+               adjust_column(output, column);
                break;
        } case LYX_ALIGN_RIGHT: {
                string output;
@@ -2263,13 +2256,13 @@ int Paragraph::Private::endTeXParParams(BufferParams const & bparams,
                else
                        output = corrected_env(end_tag, "flushleft", code, lastpar);
                os << from_ascii(output);
-               adjust_row_column(output, texrow, column);
+               adjust_column(output, column);
                break;
        } case LYX_ALIGN_CENTER: {
                string output;
                output = corrected_env(end_tag, "center", code, lastpar);
                os << from_ascii(output);
-               adjust_row_column(output, texrow, column);
+               adjust_column(output, column);
                break;
        }
        }
@@ -2281,7 +2274,7 @@ int Paragraph::Private::endTeXParParams(BufferParams const & bparams,
 // This one spits out the text of the paragraph
 void Paragraph::latex(BufferParams const & bparams,
        Font const & outerfont,
-       otexstream & os, TexRow & texrow,
+       otexstream & os,
        OutputParams const & runparams,
        int start_pos, int end_pos, bool force) const
 {
@@ -2328,7 +2321,7 @@ void Paragraph::latex(BufferParams const & bparams,
 
        Encoding const * const prev_encoding = runparams.encoding;
 
-       texrow.start(id(), 0);
+       os.texrow().start(id(), 0);
 
        // if the paragraph is empty, the loop will not be entered at all
        if (empty()) {
@@ -2337,8 +2330,7 @@ void Paragraph::latex(BufferParams const & bparams,
                        ++column;
                }
                if (allowcust)
-                       column += d->startTeXParParams(bparams, os, texrow,
-                                                   runparams);
+                       column += d->startTeXParParams(bparams, os, runparams);
        }
 
        for (pos_type i = 0; i < size(); ++i) {
@@ -2369,7 +2361,6 @@ void Paragraph::latex(BufferParams const & bparams,
 
                        if (allowcust)
                                column += d->startTeXParParams(bparams, os,
-                                                           texrow,
                                                            runparams);
                }
 
@@ -2478,8 +2469,7 @@ void Paragraph::latex(BufferParams const & bparams,
                        // latexSpecialChar ignores spaces if
                        // style.pass_thru is false.
                        if (i != body_pos - 1) {
-                               if (d->simpleTeXBlanks(
-                                               runparams, os, texrow,
+                               if (d->simpleTeXBlanks(runparams, os,
                                                i, column, font, style)) {
                                        // A surrogate pair was output. We
                                        // must not call latexSpecialChar
@@ -2501,8 +2491,7 @@ void Paragraph::latex(BufferParams const & bparams,
                // and then split to handle the two modes separately.
                if (c == META_INSET) {
                        if (i >= start_pos && (end_pos == -1 || i < end_pos)) {
-                               d->latexInset(bparams, os,
-                                               texrow, rp, running_font,
+                               d->latexInset(bparams, os, rp, running_font,
                                                basefont, outerfont, open_font,
                                                runningChange, style, i, column);
                        }
@@ -2560,7 +2549,7 @@ void Paragraph::latex(BufferParams const & bparams,
                os << "}]~";
        }
 
-       if (allowcust && d->endTeXParParams(bparams, os, texrow, runparams)
+       if (allowcust && d->endTeXParParams(bparams, os, runparams)
            && runparams.encoding != prev_encoding) {
                runparams.encoding = prev_encoding;
                if (!runparams.isFullUnicode())
index ca843991f7d028f810d68b69819c464b0e698a53..ed541b922357a9a71f6073fc1a7d95a6fb75a67d 100644 (file)
@@ -192,8 +192,8 @@ public:
 
        /// \param force means: output even if layout.inpreamble is true.
        void latex(BufferParams const &, Font const & outerfont, otexstream &,
-                  TexRow & texrow, OutputParams const &,
-                  int start_pos = 0, int end_pos = -1, bool force = false) const;
+                  OutputParams const &, int start_pos = 0, int end_pos = -1,
+                  bool force = false) const;
 
        /// Can we drop the standard paragraph wrapper?
        bool emptyTag() const;
index 1dfa76fc7b41019f2538e00362a98fe0d08c960a..8ccb6baa69b10cb35035f190653548d0631fc4a4 100644 (file)
@@ -463,9 +463,8 @@ public:
         *  Don't use a temporary stringstream if the final output is
         *  supposed to go to a file.
         *  \sa Buffer::writeLaTeXSource for the reason.
-        *  \return the number of rows (\n's) of generated LaTeX code.
         */
-       virtual int latex(otexstream &, OutputParams const &) const { return 0; }
+       virtual void latex(otexstream &, OutputParams const &) const {}
        /// returns true to override begin and end inset in file
        virtual bool directWrite() const;
        ///
index 33a6c00e2ee91169310a6d697ad1cfd89d1a197b..00ad499d462a56d9e1ce65b6c375c01ed01bdb87 100644 (file)
@@ -33,10 +33,8 @@ void InsetArgument::write(ostream & os) const
 }
 
 
-int InsetArgument::latex(otexstream &, OutputParams const &) const
-{
-       return 0;
-}
+void InsetArgument::latex(otexstream &, OutputParams const &) const
+{}
 
 
 int InsetArgument::plaintext(odocstream &, OutputParams const &) const
@@ -56,18 +54,18 @@ docstring InsetArgument::xhtml(XHTMLStream &, OutputParams const &) const
        return docstring();
 }
 
-int InsetArgument::latexArgument(otexstream & os,
+void InsetArgument::latexArgument(otexstream & os,
                OutputParams const & runparams, bool optional) const
 {
+       TexRow texrow;
        odocstringstream ss;
-       otexstream ots(ss);
-       int ret = InsetText::latex(ots, runparams);
+       otexstream ots(ss, texrow);
+       InsetText::latex(ots, runparams);
        docstring str = ss.str();
        if (optional && str.find(']') != docstring::npos)
                str = '{' + str + '}';
        os << (optional ? '[' : '{') << str
           << (optional ? ']' : '}');
-       return ret;
 }
 
 
index 0a3052f9b4d3a83144e8110b617544e31277d4cb..f45c0ea0ad06200b8450a9be0a955ec744fa6e83 100644 (file)
@@ -30,7 +30,7 @@ public:
        InsetArgument(Buffer *);
 
        /// Outputting the parameter of a LaTeX command
-       int latexArgument(otexstream &, OutputParams const &,
+       void latexArgument(otexstream &, OutputParams const &,
                        bool optional) const;
        ///
        bool hasSettings() const { return false; }
@@ -41,7 +41,7 @@ private:
        ///
        docstring name() const { return from_ascii("Argument"); }
        /// Standard LaTeX output -- short-circuited
-       int latex(otexstream &, OutputParams const &) const;
+       void latex(otexstream &, OutputParams const &) const;
        /// Standard plain text output -- short-circuited
        int plaintext(odocstream &, OutputParams const &) const;
        /// Standard DocBook output -- short-circuited
index bf14e48054a49f51c7f087f9b4b60fec03df25d5..56476d3d1b29382c363c72a691ba61a2e50e8329 100644 (file)
@@ -235,7 +235,7 @@ static string normalizeName(Buffer const & buffer,
 }
 
 
-int InsetBibtex::latex(otexstream & os, OutputParams const & runparams) const
+void InsetBibtex::latex(otexstream & os, OutputParams const & runparams) const
 {
        // the sequence of the commands:
        // 1. \bibliographystyle{style}
@@ -328,9 +328,6 @@ int InsetBibtex::latex(otexstream & os, OutputParams const & runparams) const
                        style = split(style, bibtotoc, ',');
        }
 
-       // line count
-       int nlines = 0;
-
        if (!style.empty()) {
                string base = normalizeName(buffer(), runparams, style, ".bst");
                FileName const try_in_file = 
@@ -358,7 +355,6 @@ int InsetBibtex::latex(otexstream & os, OutputParams const & runparams) const
                os << "\\bibliographystyle{"
                   << from_utf8(latex_path(normalizeName(buffer(), runparams, base, ".bst")))
                   << "}\n";
-               nlines += 1;
        }
 
        // Post this warning only once.
@@ -378,7 +374,6 @@ int InsetBibtex::latex(otexstream & os, OutputParams const & runparams) const
                        btprint = from_ascii("btPrintCited");
                os << "\\" << btprint << "\n"
                   << "\\end{btSect}\n";
-               nlines += 3;
        }
 
        // bibtotoc-Option
@@ -396,13 +391,9 @@ int InsetBibtex::latex(otexstream & os, OutputParams const & runparams) const
                docstring btprint = getParam("btprint");
                if (btprint == "btPrintAll") {
                        os << "\\nocite{*}\n";
-                       nlines += 1;
                }
                os << "\\bibliography{" << db_out << "}\n";
-               nlines += 1;
        }
-
-       return nlines;
 }
 
 
index 954783228cb9b4f82dc80aad4fe1eefeff9ca464..6e38fcc407258d9a3b1a7837fb154e9ee1f88d12 100644 (file)
@@ -50,7 +50,7 @@ public:
        ///
        DisplayType display() const { return AlignCenter; }
        ///
-       int latex(otexstream &, OutputParams const &) const;
+       void latex(otexstream &, OutputParams const &) const;
        ///
        void collectBibKeys(InsetIterator const &) const;
        ///
index c053c5b587f0230e327e6ff63ee16d7f61e502d2..9999426444cbc2224d7ab5f4674c2c0dc10923a0 100644 (file)
@@ -237,7 +237,7 @@ bool InsetBox::getStatus(Cursor & cur, FuncRequest const & cmd,
 }
 
 
-int InsetBox::latex(otexstream & os, OutputParams const & runparams) const
+void InsetBox::latex(otexstream & os, OutputParams const & runparams) const
 {
        BoxType btype = boxtranslator().find(params_.type);
 
@@ -271,7 +271,6 @@ int InsetBox::latex(otexstream & os, OutputParams const & runparams) const
                }
        }
 
-       int i = 0;
        os << "%\n";
        // Adapt to column/text width correctly also if paragraphs indented:
        if (stdwidth)
@@ -282,7 +281,6 @@ int InsetBox::latex(otexstream & os, OutputParams const & runparams) const
                break;
        case Framed:
                os << "\\begin{framed}%\n";
-               i += 1;
                break;
        case Boxed:
                os << "\\framebox";
@@ -368,15 +366,13 @@ int InsetBox::latex(otexstream & os, OutputParams const & runparams) const
                }
 
                os << "%\n";
-               ++i;
        } // end if inner_box
 
        if (btype == Shaded) {
                os << "\\begin{shaded}%\n";
-               ++i;
        }
 
-       i += InsetText::latex(os, runparams);
+       InsetText::latex(os, runparams);
 
        if (btype == Shaded)
                os << "\\end{shaded}";
@@ -407,10 +403,6 @@ int InsetBox::latex(otexstream & os, OutputParams const & runparams) const
                // already done
                break;
        }
-
-       i += 2;
-
-       return i;
 }
 
 
index a001d7121af1f1de642a61f530ed69342f7bff49..57c1f795f4840c2d3ab0b534eba1250b5b77caca 100644 (file)
@@ -111,7 +111,7 @@ private:
        ///
        bool noFontChange() const { return true; }
        ///
-       int latex(otexstream &, OutputParams const &) const;
+       void latex(otexstream &, OutputParams const &) const;
        ///
        int plaintext(odocstream &, OutputParams const &) const;
        ///
index cc81635fa8d660eb90e245d5659386aeb27ed7d9..4888992ba7819da947374c016d5964b218c030ca 100644 (file)
@@ -203,9 +203,10 @@ bool InsetBranch::isBranchSelected() const
 }
 
 
-int InsetBranch::latex(otexstream & os, OutputParams const & runparams) const
+void InsetBranch::latex(otexstream & os, OutputParams const & runparams) const
 {
-       return isBranchSelected() ?  InsetText::latex(os, runparams) : 0;
+       if (isBranchSelected())
+               InsetText::latex(os, runparams);
 }
 
 
index 616abe04b44bb98002a584282ab84d3093dfd85d..18600aeedf2e1c54c92a7b6d313f3c468282606c 100644 (file)
@@ -65,7 +65,7 @@ private:
        ///
        ColorCode backgroundColor(PainterInfo const &) const;
        ///
-       int latex(otexstream &, OutputParams const &) const;
+       void latex(otexstream &, OutputParams const &) const;
        ///
        int plaintext(odocstream &, OutputParams const &) const;
        ///
index 293c3861e1a0458b261ad0b29f0c0e957a8462c7..84efecc2d42e54d2ad1d897ea0b908f7f100cdd5 100644 (file)
@@ -228,12 +228,12 @@ bool InsetCaption::getStatus(Cursor & cur, FuncRequest const & cmd,
 }
 
 
-int InsetCaption::latex(otexstream & os,
-                       OutputParams const & runparams_in) const
+void InsetCaption::latex(otexstream & os,
+                        OutputParams const & runparams_in) const
 {
        if (runparams_in.inFloat == OutputParams::SUBFLOAT)
                // caption is output as an optional argument
-               return 0;
+               return;
        // This is a bit too simplistic to take advantage of
        // caption options we must add more later. (Lgb)
        // This code is currently only able to handle the simple
@@ -244,12 +244,11 @@ int InsetCaption::latex(otexstream & os,
        // optional argument.
        runparams.moving_arg = true;
        os << "\\caption";
-       int l = latexArgInsets(paragraphs()[0], os, runparams, 0, 1);
+       latexArgInsets(paragraphs()[0], os, runparams, 0, 1);
        os << '{';
-       l += InsetText::latex(os, runparams);
+       InsetText::latex(os, runparams);
        os << "}\n";
        runparams_in.encoding = runparams.encoding;
-       return l + 1;
 }
 
 
@@ -290,17 +289,17 @@ docstring InsetCaption::xhtml(XHTMLStream & xs, OutputParams const & rp) const
 }
 
 
-int InsetCaption::getArgument(otexstream & os,
+void InsetCaption::getArgument(otexstream & os,
                        OutputParams const & runparams) const
 {
-       return InsetText::latex(os, runparams);
+       InsetText::latex(os, runparams);
 }
 
 
-int InsetCaption::getOptArg(otexstream & os,
+void InsetCaption::getOptArg(otexstream & os,
                        OutputParams const & runparams) const
 {
-       return latexArgInsets(paragraphs()[0], os, runparams, 0, 1);
+       latexArgInsets(paragraphs()[0], os, runparams, 0, 1);
 }
 
 
index bc0b674de6d7ebb5506e7d4532323b6746fb9dee..03c100f3a4d770ad8d07243cfe270e706e10c67e 100644 (file)
@@ -27,9 +27,9 @@ public:
        ///
        docstring name() const;
        /// return the mandatory argument (LaTeX format) only
-       int getArgument(otexstream & os, OutputParams const &) const;
+       void getArgument(otexstream & os, OutputParams const &) const;
        /// return the optional argument(s) only
-       int getOptArg(otexstream & os, OutputParams const &) const;
+       void getOptArg(otexstream & os, OutputParams const &) const;
        /// return the caption text
        int getCaptionAsPlaintext(odocstream & os, OutputParams const &) const;
        /// return the caption text as HTML
@@ -67,7 +67,7 @@ private:
        // Update the counters of this inset and of its contents
        void updateBuffer(ParIterator const &, UpdateType);
        ///
-       int latex(otexstream & os, OutputParams const &) const;
+       void latex(otexstream & os, OutputParams const &) const;
        ///
        int plaintext(odocstream & os, OutputParams const & runparams) const;
        ///
index 8a427c66efb2852af6401abae965bc7576ac829f..7780f24a8d09c721b3cede8b6ac4fd1787ad68b9 100644 (file)
@@ -556,7 +556,7 @@ void InsetCitation::forToc(docstring & os, size_t) const
 // the \cite command is valid. Eg, the user has natbib enabled, inputs some
 // citations and then changes his mind, turning natbib support off. The output
 // should revert to \cite[]{}
-int InsetCitation::latex(otexstream & os, OutputParams const & runparams) const
+void InsetCitation::latex(otexstream & os, OutputParams const & runparams) const
 {
        CiteEngine cite_engine = buffer().params().citeEngine();
        BiblioInfo const & bi = buffer().masterBibInfo();
@@ -584,8 +584,6 @@ int InsetCitation::latex(otexstream & os, OutputParams const & runparams) const
 
        if (runparams.inulemcmd)
                os << "}";
-
-       return 0;
 }
 
 
index 1c3de97cc88f1142fba5c2abf01299df0558e9b5..49104924cd2d00f0cc31a8e56640ee2b322f0680 100644 (file)
@@ -43,7 +43,7 @@ public:
        ///
        InsetCode lyxCode() const { return CITE_CODE; }
        ///
-       int latex(otexstream &, OutputParams const &) const;
+       void latex(otexstream &, OutputParams const &) const;
        ///
        int plaintext(odocstream &, OutputParams const &) const;
        ///
index 05fe55deb43d6b9fa6d132f794168aa24ad6647b..fd86d03989a9047c038479fb177df6469c2fa295 100644 (file)
@@ -119,11 +119,10 @@ void InsetCommand::setParams(InsetCommandParams const & p)
 }
 
 
-int InsetCommand::latex(otexstream & os, OutputParams const & runparams_in) const
+void InsetCommand::latex(otexstream & os, OutputParams const & runparams_in) const
 {
        OutputParams runparams = runparams_in;
        os << getCommand(runparams);
-       return 0;
 }
 
 
index 6f4c3521b0c592377fb7ba3cba197056df2dcbbb..3ea57c98dc3ade79ca92ebfad310aaa20ce08a5e 100644 (file)
@@ -76,7 +76,7 @@ public:
        ///
        void draw(PainterInfo & pi, int x, int y) const;
        ///
-       int latex(otexstream &, OutputParams const &) const;
+       void latex(otexstream &, OutputParams const &) const;
        ///
        int plaintext(odocstream &, OutputParams const &) const;
        ///
index 67671ac135b0bec06a1a76c6d8d2956b0618facf..f3ea34c011eb735ea1cdfd329cdb190e23c6496e 100644 (file)
@@ -518,8 +518,9 @@ static bool isPreviewWanted(InsetExternalParams const & params)
 
 static docstring latexString(InsetExternal const & inset)
 {
+       TexRow texrow;
        odocstringstream ods;
-       otexstream os(ods);
+       otexstream os(ods, texrow);
        // We don't need to set runparams.encoding since it is not used by
        // latex().
        OutputParams runparams(0);
@@ -636,14 +637,14 @@ void InsetExternal::read(Lexer & lex)
 }
 
 
-int InsetExternal::latex(otexstream & os, OutputParams const & runparams) const
+void InsetExternal::latex(otexstream & os, OutputParams const & runparams) const
 {
        if (params_.draft) {
                // FIXME UNICODE
                os << "\\fbox{\\ttfamily{}"
                   << from_utf8(params_.filename.outputFileName(buffer().filePath()))
                   << "}\n";
-               return 1;
+               return;
        }
 
        // "nice" means that the buffer is exported to LaTeX format but not
@@ -659,25 +660,28 @@ int InsetExternal::latex(otexstream & os, OutputParams const & runparams) const
                external::Template const * const et_ptr =
                        external::getTemplatePtr(params_);
                if (!et_ptr)
-                       return 0;
+                       return;
                external::Template const & et = *et_ptr;
 
                external::Template::Formats::const_iterator cit =
                        et.formats.find("PDFLaTeX");
 
                if (cit != et.formats.end()) {
-                       return external::writeExternal(params_, "PDFLaTeX",
-                                                      buffer(), os.os(),
-                                                      *(runparams.exportdata),
-                                                      external_in_tmpdir,
-                                                      dryrun);
+                       int l = external::writeExternal(params_, "PDFLaTeX",
+                                                       buffer(), os.os(),
+                                                       *(runparams.exportdata),
+                                                       external_in_tmpdir,
+                                                       dryrun);
+                       os.texrow().newlines(l);
+                       return;
                }
        }
 
-       return external::writeExternal(params_, "LaTeX", buffer(), os.os(),
-                                      *(runparams.exportdata),
-                                      external_in_tmpdir,
-                                      dryrun);
+       int l = external::writeExternal(params_, "LaTeX", buffer(), os.os(),
+                                       *(runparams.exportdata),
+                                       external_in_tmpdir,
+                                       dryrun);
+       os.texrow().newlines(l);
 }
 
 
index 2e28c6115a974eb9f8b29eb4a20741005e686e5c..92eb61238fc42117f3b60b4813c7009544938ed8 100644 (file)
@@ -109,7 +109,7 @@ public:
        /// Update not loaded previews
        void updatePreview();
        /// \returns the number of rows (\n's) of generated code.
-       int latex(otexstream &, OutputParams const &) const;
+       void latex(otexstream &, OutputParams const &) const;
        ///
        docstring contextMenuName() const;
        ///
index ea6f0931f6b0b131bde99811a0edb5fe55afeda4..e3876ba1c3305597046967a17fbd53dc0f2cf434 100644 (file)
@@ -325,7 +325,7 @@ docstring InsetFloat::xhtml(XHTMLStream & xs, OutputParams const & rp) const
 }
 
 
-int InsetFloat::latex(otexstream & os, OutputParams const & runparams_in) const
+void InsetFloat::latex(otexstream & os, OutputParams const & runparams_in) const
 {
        if (runparams_in.inFloat != OutputParams::NONFLOAT) {
                if (runparams_in.moving_arg)
@@ -339,10 +339,10 @@ int InsetFloat::latex(otexstream & os, OutputParams const & runparams_in) const
                }
                os << '{';
                rp.inFloat = OutputParams::SUBFLOAT;
-               int const i = InsetText::latex(os, rp);
+               InsetText::latex(os, rp);
                os << "}";
        
-               return i + 1;
+               return;
        }
        OutputParams runparams(runparams_in);
        runparams.inFloat = OutputParams::MAINFLOAT;
@@ -372,27 +372,18 @@ int InsetFloat::latex(otexstream & os, OutputParams const & runparams_in) const
                placement = buf_placement;
        }
 
-       // clear counter
-       os.countLines();
        // Force \begin{<floatname>} to appear in a new line.
        os << breakln << "\\begin{" << from_ascii(tmptype) << '}';
        // We only output placement if different from the def_placement.
        // sidewaysfloats always use their own page
-       if (!placement.empty() && !params_.sideways) {
+       if (!placement.empty() && !params_.sideways)
                os << '[' << from_ascii(placement) << ']';
-       }
        os << '\n';
-       int lines = os.countLines();
 
-       lines += InsetText::latex(os, runparams);
+       InsetText::latex(os, runparams);
 
-       // clear counter
-       os.countLines();
        // Force \end{<floatname>} to appear in a new line.
        os << breakln << "\\end{" << from_ascii(tmptype) << "}\n";
-       lines += os.countLines();
-
-       return lines;
 }
 
 
@@ -486,12 +477,13 @@ docstring InsetFloat::getCaption(OutputParams const & runparams) const
        if (ins == 0)
                return docstring();
 
+       TexRow texrow;
        odocstringstream ods;
-       otexstream os(ods);
+       otexstream os(ods, texrow);
        ins->getOptArg(os, runparams);
        ods << '[';
        odocstringstream odss;
-       otexstream oss(odss);
+       otexstream oss(odss, texrow);
        ins->getArgument(oss, runparams);
        docstring arg = odss.str();
        // Protect ']'
index 1ad57041ec956ae0c75bf1601f5780e4160d2333..9bfc120bb54d8f5bef3f6fcaa3f6f51ac9e007f4 100644 (file)
@@ -81,7 +81,7 @@ private:
        ///
        InsetCode lyxCode() const { return FLOAT_CODE; }
        ///
-       int latex(otexstream &, OutputParams const &) const;
+       void latex(otexstream &, OutputParams const &) const;
        ///
        int plaintext(odocstream &, OutputParams const &) const;
        ///
index b5cdb616c4ae43e6c893de3091785da94e1e8a82..2b2c7fb7d88b41d86e020be4ef25601374b26d41 100644 (file)
@@ -113,7 +113,7 @@ void InsetFloatList::read(Lexer & lex)
 }
 
 
-int InsetFloatList::latex(otexstream & os, OutputParams const &) const
+void InsetFloatList::latex(otexstream & os, OutputParams const &) const
 {
        FloatList const & floats = buffer().params().documentClass().floats();
        FloatList::const_iterator cit = floats[to_ascii(getParam("type"))];
@@ -136,7 +136,6 @@ int InsetFloatList::latex(otexstream & os, OutputParams const &) const
                   << bformat(_("List of %1$s"), getParam("type"))
                   << "}\n";
        }
-       return 1;
 }
 
 
index e03e541d54e419d959346d69fed618ecfc56251d..6f7844eb2658f65fdba1f499f2050877bce6ed2c 100644 (file)
@@ -38,7 +38,7 @@ public:
        ///
        void read(Lexer &);
        ///
-       int latex(otexstream &, OutputParams const &) const;
+       void latex(otexstream &, OutputParams const &) const;
        ///
        int docbook(odocstream &, OutputParams const &) const { return 0; }
        ///
index ef7707a91b3d305971ab5e2b3d019e025a173d51..d7eee84175fc0736d274181013d8d99ade14cd54 100644 (file)
@@ -84,7 +84,7 @@ docstring InsetFoot::toolTip(BufferView const & bv, int x, int y) const
 }
 
 
-int InsetFoot::latex(otexstream & os, OutputParams const & runparams_in) const
+void InsetFoot::latex(otexstream & os, OutputParams const & runparams_in) const
 {
        OutputParams runparams = runparams_in;
        // footnotes in titling commands like \title have moving arguments
@@ -97,11 +97,9 @@ int InsetFoot::latex(otexstream & os, OutputParams const & runparams_in) const
        else
                os << "%\n\\footnote{";
 
-       int const i = InsetText::latex(os, runparams);
+       InsetText::latex(os, runparams);
        os << "%\n}";
        runparams_in.encoding = runparams.encoding;
-
-       return i + 2;
 }
 
 
index 90ec99076f5128b48e6de04a9a67be1587e4f819..e2ba08edb26263b37ce3afe6159bd8479fe4d639 100644 (file)
@@ -32,7 +32,7 @@ private:
        ///
        docstring name() const { return from_ascii("Foot"); }
        ///
-       int latex(otexstream &, OutputParams const &) const;
+       void latex(otexstream &, OutputParams const &) const;
        ///
        int plaintext(odocstream &, OutputParams const &) const;
        ///
index f76666fb05cc4ce555c24de07da9da1831c21b8f..ac76d4e251d1afa5aa4de3d57452cec3fd597c13 100644 (file)
@@ -746,8 +746,8 @@ string InsetGraphics::prepareFile(OutputParams const & runparams) const
 }
 
 
-int InsetGraphics::latex(otexstream & os,
-                        OutputParams const & runparams) const
+void InsetGraphics::latex(otexstream & os,
+                         OutputParams const & runparams) const
 {
        // If there is no file specified or not existing,
        // just output a message about it in the latex output.
@@ -796,8 +796,6 @@ int InsetGraphics::latex(otexstream & os,
        os << from_utf8(latex_str);
 
        LYXERR(Debug::GRAPHICS, "InsetGraphics::latex outputting:\n" << latex_str);
-       // Return how many newlines we issued.
-       return int(count(latex_str.begin(), latex_str.end(),'\n'));
 }
 
 
index 058a9d1cb2f381446ed515563775f706ce23a19a..2a04f0c33cf469d8070c7f0eb50dfc33a8373462 100644 (file)
@@ -72,7 +72,7 @@ private:
         #fragile == true# means, that the inset should take care about
         fragile commands by adding a #\protect# before.
         */
-       int latex(otexstream &, OutputParams const &) const;
+       void latex(otexstream &, OutputParams const &) const;
        ///
        int plaintext(odocstream &, OutputParams const &) const;
        ///
index e3125c3b5291af7e612a005bd14e6d77ddc73371..b6ccdd54fb88dc0a2fc8140e2cd36814d340a12c 100644 (file)
@@ -108,8 +108,8 @@ void InsetHyperlink::viewTarget() const
 }
 
 
-int InsetHyperlink::latex(otexstream & os,
-                         OutputParams const & runparams) const
+void InsetHyperlink::latex(otexstream & os,
+                          OutputParams const & runparams) const
 {
        docstring url = getParam("target");
        docstring name = getParam("name");
@@ -193,8 +193,6 @@ int InsetHyperlink::latex(otexstream & os,
 
        // output the ready \href command
        os << "\\href{" << getParam("type") << url << "}{" << name << '}';
-
-       return 0;
 }
 
 
index 8b6d8fb04fc4166ba11e855bfeca69d4ef613c26..4e428c767decca41ad0fab381bc42580bdf03667 100644 (file)
@@ -46,7 +46,7 @@ public:
        ///
        void validate(LaTeXFeatures &) const;
        ///
-       int latex(otexstream &, OutputParams const &) const;
+       void latex(otexstream &, OutputParams const &) const;
        ///
        int plaintext(odocstream &, OutputParams const &) const;
        ///
index a2b85976db7439d9678b214f337973ea60bff442..4d164cf56b8bd8397b0b864e6df063614714371b 100644 (file)
@@ -479,13 +479,13 @@ Buffer * InsetInclude::loadIfNeeded() const
 }
 
 
-int InsetInclude::latex(otexstream & os, OutputParams const & runparams) const
+void InsetInclude::latex(otexstream & os, OutputParams const & runparams) const
 {
        string incfile = to_utf8(params()["filename"]);
 
        // Do nothing if no file name has been specified
        if (incfile.empty())
-               return 0;
+               return;
 
        FileName const included_file = includedFileName(buffer(), params());
 
@@ -499,7 +499,7 @@ int InsetInclude::latex(otexstream & os, OutputParams const & runparams) const
                Alert::error(_("Recursive input"),
                               bformat(_("Attempted to include file %1$s in itself! "
                               "Ignoring inclusion."), from_utf8(incfile)));
-               return 0;
+               return;
        }
 
        Buffer const * const masterBuffer = buffer().masterBuffer();
@@ -556,7 +556,7 @@ int InsetInclude::latex(otexstream & os, OutputParams const & runparams) const
                
                Buffer * tmp = loadIfNeeded();
                if (!tmp)
-                       return false;
+                       return;
 
                if (tmp->params().baseClass() != masterBuffer->params().baseClass()) {
                        // FIXME UNICODE
@@ -628,7 +628,7 @@ int InsetInclude::latex(otexstream & os, OutputParams const & runparams) const
                                        to_utf8(bformat(_("Could not copy the file\n%1$s\n"
                                                                  "into the temporary directory."),
                                                   from_utf8(included_file.absFileName()))));
-                               return 0;
+                               return;
                        }
                }
        }
@@ -689,8 +689,6 @@ int InsetInclude::latex(otexstream & os, OutputParams const & runparams) const
        case NONE:
                break;
        }
-
-       return 0;
 }
 
 
@@ -960,8 +958,9 @@ bool preview_wanted(InsetCommandParams const & params, Buffer const & buffer)
 
 docstring latexString(InsetInclude const & inset)
 {
+       TexRow texrow;
        odocstringstream ods;
-       otexstream os(ods);
+       otexstream os(ods, texrow);
        // We don't need to set runparams.encoding since this will be done
        // by latex() anyway.
        OutputParams runparams(0);
index 357003a151c916fea070ecc15a2849ca31378b2d..ad216bcca635597eadcb8e184ce146fe5fe681f2 100644 (file)
@@ -87,7 +87,7 @@ public:
        ///
        bool hasSettings() const { return true; }
        ///
-       int latex(otexstream &, OutputParams const &) const;
+       void latex(otexstream &, OutputParams const &) const;
        ///
        int plaintext(odocstream &, OutputParams const &) const;
        ///
index 2badf7c6aa3794ecc4a8445ca3c0cba4cb58c896..fe50bf4fea7ccd5b050cbfe7fb2991a8e045c2e7 100644 (file)
@@ -57,8 +57,7 @@ InsetIndex::InsetIndex(Buffer * buf, InsetIndexParams const & params)
 {}
 
 
-int InsetIndex::latex(otexstream & os,
-                     OutputParams const & runparams_in) const
+void InsetIndex::latex(otexstream & os, OutputParams const & runparams_in) const
 {
        OutputParams runparams(runparams_in);
        runparams.inIndexEntry = true;
@@ -72,11 +71,11 @@ int InsetIndex::latex(otexstream & os,
                os << "\\index";
                os << '{';
        }
-       int i = 0;
 
        // get contents of InsetText as LaTeX and plaintext
+       TexRow texrow;
        odocstringstream ourlatex;
-       otexstream ots(ourlatex);
+       otexstream ots(ourlatex, texrow);
        InsetText::latex(ots, runparams);
        odocstringstream ourplain;
        InsetText::plaintext(ourplain, runparams);
@@ -156,21 +155,17 @@ int InsetIndex::latex(otexstream & os,
                                subst(spart2, from_ascii("\\"), docstring());
                        os << ppart;
                        os << '@';
-                       i += count_char(ppart, '\n');
                }
                docstring const tpart = *it;
                os << tpart;
-               i += count_char(tpart, '\n');
                if (it2 < levels_plain.end())
                        ++it2;
        }
        // write the bit that followed "|"
        if (!cmd.empty()) {
                os << "|" << cmd;
-               i += count_char(cmd, '\n');
        }
        os << '}';
-       return i;
 }
 
 
@@ -558,16 +553,15 @@ bool InsetPrintIndex::getStatus(Cursor & cur, FuncRequest const & cmd,
 }
 
 
-int InsetPrintIndex::latex(otexstream & os, OutputParams const & runparams_in) const
+void InsetPrintIndex::latex(otexstream & os, OutputParams const & runparams_in) const
 {
        if (!buffer().masterBuffer()->params().use_indices) {
                if (getParam("type") == from_ascii("idx"))
                        os << "\\printindex{}";
-               return 0;
+               return;
        }
        OutputParams runparams = runparams_in;
        os << getCommand(runparams);
-       return 0;
 }
 
 
index 4578c174010f0f5574aee6521f99b592e7b3a738..40b450be0b49e4be77d41c05d47037c221cbca25 100644 (file)
@@ -61,7 +61,7 @@ private:
        ///
        docstring xhtml(XHTMLStream &, OutputParams const &) const;
        ///
-       int latex(otexstream &, OutputParams const &) const;
+       void latex(otexstream &, OutputParams const &) const;
        ///
        bool showInsetDialog(BufferView *) const;
        ///
@@ -100,7 +100,7 @@ public:
        ///
        InsetCode lyxCode() const { return INDEX_PRINT_CODE; }
        ///
-       int latex(otexstream &, OutputParams const &) const;
+       void latex(otexstream &, OutputParams const &) const;
        ///
        docstring xhtml(XHTMLStream &, OutputParams const &) const;
        ///
index f81fe2d532aadfb4c4b27a75336b1de19aa415e5..022392d46234acdee8ce9e667538f5efab4c7e9b 100644 (file)
@@ -161,7 +161,7 @@ void InsetLine::draw(PainterInfo & pi, int x, int y) const
 }
 
 
-int InsetLine::latex(otexstream & os, OutputParams const &) const
+void InsetLine::latex(otexstream & os, OutputParams const &) const
 {
        bool have_offset = true;
        Length offset_len = Length(to_ascii(getParam("offset")));
@@ -180,8 +180,6 @@ int InsetLine::latex(otexstream & os, OutputParams const &) const
        if (have_offset)
                os      << "[" << from_ascii(offset) << "]";
        os << "{" << from_ascii(width) << "}{" << from_ascii(height) << '}';
-
-       return 0;
 }
 
 
index 1f3eda65c287065cf35062477abf61d8f69d48d8..d1f6f52df06aa51651da3a61cb332a6f7fa4194c 100644 (file)
@@ -48,7 +48,7 @@ private:
        bool hasSettings() const { return true; }
        void metrics(MetricsInfo &, Dimension &) const;
        void draw(PainterInfo & pi, int x, int y) const;
-       int latex(otexstream &, OutputParams const &) const;
+       void latex(otexstream &, OutputParams const &) const;
        int plaintext(odocstream &, OutputParams const &) const;
        void doDispatch(Cursor & cur, FuncRequest & cmd);
        bool getStatus(Cursor & cur, FuncRequest const & cmd, FuncStatus &) const;
index c10c54bdd1455f0a886faffb6ed0832b5d75bcd5..cb3e9b56cbde4774f05a398620a393c25b812b6e 100644 (file)
@@ -126,12 +126,11 @@ void InsetListings::read(Lexer & lex)
 }
 
 
-int InsetListings::latex(otexstream & os, OutputParams const & runparams) const
+void InsetListings::latex(otexstream & os, OutputParams const & runparams) const
 {
        string param_string = params().params();
        // NOTE: I use {} to quote text, which is an experimental feature
        // of the listings package (see page 25 of the manual)
-       int lines = 0;
        bool const isInline = params().isInline();
        // get the paragraphs. We can not output them directly to given odocstream
        // because we can not yet determine the delimiter character of \lstinline
@@ -200,10 +199,8 @@ int InsetListings::latex(otexstream & os, OutputParams const & runparams) const
                ++par;
                // for the inline case, if there are multiple paragraphs
                // they are simply joined. Otherwise, expect latex errors.
-               if (par != end && !isInline && !captionline) {
+               if (par != end && !isInline && !captionline)
                        code += "\n";
-                       ++lines;
-               }
        }
        if (isInline) {
                char const * delimiter = lstinline_delimiters;
@@ -237,8 +234,6 @@ int InsetListings::latex(otexstream & os, OutputParams const & runparams) const
                OutputParams rp = runparams;
                rp.moving_arg = true;
                docstring const caption = getCaption(rp);
-               // clear counter
-               os.countLines();
                if (param_string.empty() && caption.empty())
                        os << breakln << "\\begin{lstlisting}\n";
                else {
@@ -251,7 +246,6 @@ int InsetListings::latex(otexstream & os, OutputParams const & runparams) const
                        os << from_utf8(param_string) << "]\n";
                }
                os << code << breakln << "\\end{lstlisting}\n";
-               lines += os.countLines();
        }
 
        if (encoding_switched){
@@ -269,8 +263,6 @@ int InsetListings::latex(otexstream & os, OutputParams const & runparams) const
                                  "not representable in the current encoding and have been omitted:\n%1$s."),
                        uncodable));
        }
-
-       return lines;
 }
 
 
@@ -391,8 +383,9 @@ docstring InsetListings::getCaption(OutputParams const & runparams) const
        if (ins == 0)
                return docstring();
 
+       TexRow texrow;
        odocstringstream ods;
-       otexstream os(ods);
+       otexstream os(ods, texrow);
        ins->getOptArg(os, runparams);
        ins->getArgument(os, runparams);
        // the caption may contain \label{} but the listings
index 9dc5a56e2365998a0e0b1f81adc9a96d9955c82e..3741f6d0dbd3a1ead79934a9c3b329f7c60ef500 100644 (file)
@@ -55,7 +55,7 @@ private:
        ///
        void read(Lexer & lex);
        ///
-       int latex(otexstream &, OutputParams const &) const;
+       void latex(otexstream &, OutputParams const &) const;
        ///
        docstring xhtml(XHTMLStream &, OutputParams const &) const;
        ///
index 87a35def3585a2e67aea2786aeab1b3814f0a582..9e7bd384d1e2ea76821df73ced0ad8a16bbed42f 100644 (file)
@@ -142,7 +142,7 @@ ColorCode InsetNewline::ColorName() const
 }
 
 
-int InsetNewline::latex(otexstream & os, OutputParams const & rp) const
+void InsetNewline::latex(otexstream & os, OutputParams const & rp) const
 {
        switch (params_.kind) {
                case InsetNewlineParams::NEWLINE:
@@ -158,7 +158,6 @@ int InsetNewline::latex(otexstream & os, OutputParams const & rp) const
                        os << "\\\\\n";
                        break;
        }
-       return 0;
 }
 
 
index 76c090670ff487963dac54e9c9dcc4a11c0d24b0..de9c7343a9c35a1237971ebfdd81ccb793bb8af4 100644 (file)
@@ -60,7 +60,7 @@ private:
        ///
        void draw(PainterInfo & pi, int x, int y) const;
        ///
-       int latex(otexstream &, OutputParams const &) const;
+       void latex(otexstream &, OutputParams const &) const;
        ///
        int plaintext(odocstream &, OutputParams const &) const;
        ///
index 6a141df2d98be021cb5a6bac063a014c409b9927..b0e290600184852276acd6c51bbeeb15225d9f8c 100644 (file)
@@ -213,7 +213,7 @@ ColorCode InsetNewpage::ColorName() const
 }
 
 
-int InsetNewpage::latex(otexstream & os, OutputParams const &) const
+void InsetNewpage::latex(otexstream & os, OutputParams const &) const
 {
        switch (params_.kind) {
                case InsetNewpageParams::NEWPAGE:
@@ -232,7 +232,6 @@ int InsetNewpage::latex(otexstream & os, OutputParams const &) const
                        os << "\\newpage{}";
                        break;
        }
-       return 0;
 }
 
 
index 2af7f8affc40bbf65306f6ea207381af35547a5d..002ae7f77feaa41456e8543efc61bd4de0bd9782 100644 (file)
@@ -63,7 +63,7 @@ private:
        ///
        void draw(PainterInfo & pi, int x, int y) const;
        ///
-       int latex(otexstream &, OutputParams const &) const;
+       void latex(otexstream &, OutputParams const &) const;
        ///
        int plaintext(odocstream &, OutputParams const &) const;
        ///
index 535d9c095e23a8e8480ac037c048e77c344b378b..cd0a526ea0222f5fe36702627fa9c72febe18f01 100644 (file)
@@ -294,10 +294,9 @@ docstring nomenclWidest(Buffer const & buffer, OutputParams const & runparams)
 } // namespace anon
 
 
-int InsetPrintNomencl::latex(otexstream & os, OutputParams const & runparams_in) const
+void InsetPrintNomencl::latex(otexstream & os, OutputParams const & runparams_in) const
 {
        OutputParams runparams = runparams_in;
-       int lines = 0;
        if (getParam("set_width") == "auto") {
                docstring widest = nomenclWidest(buffer(), runparams);
                // Set the label width via nomencl's command \nomlabelwidth.
@@ -306,7 +305,6 @@ int InsetPrintNomencl::latex(otexstream & os, OutputParams const & runparams_in)
                        os << "\\settowidth{\\nomlabelwidth}{"
                           << widest
                           << "}\n";
-                       ++lines;
                }
        } else if (getParam("set_width") == "custom") {
                // custom length as optional arg of \printnomenclature
@@ -317,11 +315,10 @@ int InsetPrintNomencl::latex(otexstream & os, OutputParams const & runparams_in)
                   << '['
                   << from_ascii(width)
                   << "]{}";
-               return lines;
+               return;
        }
        // output the command \printnomenclature
        os << getCommand(runparams);
-       return lines;
 }
 
 
index d1437f243e3e258e82372ce67c080452192f7c88..f445066550ea8f24bd7b86b48bb479c6d4649741 100644 (file)
@@ -96,7 +96,7 @@ public:
        ///
        DisplayType display() const { return AlignCenter; }
        ///
-       int latex(otexstream &, OutputParams const &) const;
+       void latex(otexstream &, OutputParams const &) const;
        ///
        docstring contextMenuName() const;
        //@}
index acb9cb6b9141b479199ec7dc3a40badc8aed908a..9c9f862839351e8d50268ba661863d12de7c2f09 100644 (file)
@@ -220,10 +220,10 @@ bool InsetNote::isMacroScope() const
 }
 
 
-int InsetNote::latex(otexstream & os, OutputParams const & runparams_in) const
+void InsetNote::latex(otexstream & os, OutputParams const & runparams_in) const
 {
        if (params_.type == InsetNoteParams::Note)
-               return 0;
+               return;
 
        OutputParams runparams(runparams_in);
        if (params_.type == InsetNoteParams::Comment) {
@@ -232,13 +232,6 @@ int InsetNote::latex(otexstream & os, OutputParams const & runparams_in) const
                runparams.exportdata.reset(new ExportData);
        } 
 
-       odocstringstream ss;
-       otexstream ots(ss);
-       ots.canBreakLine(os.canBreakLine());
-       InsetCollapsable::latex(ots, runparams);
-       docstring const str = ss.str();
-       os << str;
-
        // the space after the comment in 'a[comment] b' will be eaten by the
        // comment environment since the space before b is ignored with the
        // following latex output:
@@ -250,13 +243,13 @@ int InsetNote::latex(otexstream & os, OutputParams const & runparams_in) const
        //  b
        //
        // Adding {} before ' b' fixes this.
-       // The {} will be automatically added, but only if needed, by
-       // telling otexstream to protect an immediately following space.
-       os.protectSpace(ots.protectSpace());
+       // The {} will be automatically added, but only if needed, for all
+       // insets whose InsetLayout Display tag is false. This is achieved
+       // by telling otexstream to protect an immediately following space
+       // and is done for both comment and greyedout insets.
+       InsetCollapsable::latex(os, runparams);
 
        runparams_in.encoding = runparams.encoding;
-       // Return how many newlines we issued.
-       return int(count(str.begin(), str.end(), '\n'));
 }
 
 
index c331db7cb2641a8dcce2c10c061cbfd587577fe5..24f9a66542e94149778bbb1e06044c51274b432e 100644 (file)
@@ -79,7 +79,7 @@ private:
        ///
        bool isMacroScope() const;
        ///
-       int latex(otexstream &, OutputParams const &) const;
+       void latex(otexstream &, OutputParams const &) const;
        ///
        int plaintext(odocstream &, OutputParams const &) const;
        ///
index 27a68c0ba9e0c32ff48d45120e6a45021f67f8d5..54aa4abd5c5378dfa9e5598aee5b2abc484bc606 100644 (file)
@@ -307,7 +307,7 @@ docstring InsetPhantom::toolTip(BufferView const &, int, int) const
 }
 
 
-int InsetPhantom::latex(otexstream & os, OutputParams const & runparams) const
+void InsetPhantom::latex(otexstream & os, OutputParams const & runparams) const
 {
        if (params_.type == InsetPhantomParams::Phantom)
                os << "\\phantom{";
@@ -315,10 +315,8 @@ int InsetPhantom::latex(otexstream & os, OutputParams const & runparams) const
                os << "\\hphantom{";
        else if (params_.type == InsetPhantomParams::VPhantom)
                os << "\\vphantom{";
-       int const i = InsetCollapsable::latex(os, runparams);
+       InsetCollapsable::latex(os, runparams);
        os << "}";
-
-       return i;
 }
 
 
index c49895c5f37a4820d11b4c02f6cc3422b54e5634..a6711acdccf576e96397d336291fea8afaa2d0f6 100644 (file)
@@ -76,7 +76,7 @@ private:
        ///
        bool neverIndent() const { return true; }
        ///
-       int latex(otexstream &, OutputParams const &) const;
+       void latex(otexstream &, OutputParams const &) const;
        ///
        int plaintext(odocstream &, OutputParams const &) const;
        ///
index c1b8e3fa5e56e9629d7838106472d51d3d087290..dd23cee5b49ec5c52e4b1c57b6606bd099276264 100644 (file)
@@ -69,8 +69,9 @@ void InsetPreview::addPreview(DocIterator const & inset_pos,
 
 void InsetPreview::preparePreview(DocIterator const & pos) const  
 {
+       TexRow texrow;
        odocstringstream str;  
-       otexstream os(str);
+       otexstream os(str, texrow);
        OutputParams runparams(&pos.buffer()->params().encoding());
        latex(os, runparams);
        docstring const snippet = str.str();
index ff7c6babd10ddcf923d70e738d51ed034f0fa645..74a0e4ae6012b5fb8b9ecd0c6ed82422ac42904f 100644 (file)
@@ -261,7 +261,7 @@ void InsetQuotes::read(Lexer & lex)
 }
 
 
-int InsetQuotes::latex(otexstream & os, OutputParams const & runparams) const
+void InsetQuotes::latex(otexstream & os, OutputParams const & runparams) const
 {
        const int quoteind = quote_index[side_][language_];
        string qstr;
@@ -291,7 +291,6 @@ int InsetQuotes::latex(otexstream & os, OutputParams const & runparams) const
                qstr.insert(0, "{}");
 
        os << from_ascii(qstr);
-       return 0;
 }
 
 
index d13603e9bd647f86a8d9835808b3b5da54e1f315..9b42c273e68275d759f436e2fc3254bc443ee973 100644 (file)
@@ -78,7 +78,7 @@ public:
        ///
        void read(Lexer & lex);
        ///
-       int latex(otexstream &, OutputParams const &) const;
+       void latex(otexstream &, OutputParams const &) const;
        ///
        int plaintext(odocstream &, OutputParams const &) const;
        ///
index 2f8aa2f93c73b53884ca568d329c3dd16d6a7c6e..5322b3bba3efb52fdeba2021976a16e862a56c69 100644 (file)
@@ -136,7 +136,7 @@ docstring InsetRef::getEscapedLabel(OutputParams const & rp) const
 }
 
 
-int InsetRef::latex(otexstream & os, OutputParams const & rp) const
+void InsetRef::latex(otexstream & os, OutputParams const & rp) const
 {
        string const cmd = getCmdName();
        if (cmd != "formatted") {
@@ -146,7 +146,7 @@ int InsetRef::latex(otexstream & os, OutputParams const & rp) const
                docstring const ref = getParam("reference");
                p["reference"] = ref;
                os << p.getCommand(rp);
-               return 0;
+               return;
        } 
        
        // so we're doing a formatted reference.
@@ -155,7 +155,6 @@ int InsetRef::latex(otexstream & os, OutputParams const & rp) const
        docstring prefix;
        docstring const fcmd = getFormattedCmd(data, label, prefix);
        os << fcmd << '{' << label << '}';
-       return 0;
 }
 
 
index 8f8ce848a298ec538f691f5d3904f5904fcf77ae..740bac3dc472b7b63bc7151560381677860f3b87 100644 (file)
@@ -51,7 +51,7 @@ public:
        ///
        DisplayType display() const { return Inline; }
        ///
-       int latex(otexstream &, OutputParams const &) const;
+       void latex(otexstream &, OutputParams const &) const;
        ///
        int plaintext(odocstream &, OutputParams const &) const;
        ///
index 7268be5962726fb761f41a1cc5c3a146c0484a29..b85b36ee13d8e32f476ccdedd431b66ddc494788 100644 (file)
@@ -334,7 +334,7 @@ void InsetScript::validate(LaTeXFeatures & features) const
 }
 
 
-int InsetScript::latex(otexstream & os, OutputParams const & runparams) const
+void InsetScript::latex(otexstream & os, OutputParams const & runparams) const
 {
        switch (params_.type) {
        case InsetScriptParams::Subscript:
@@ -344,10 +344,8 @@ int InsetScript::latex(otexstream & os, OutputParams const & runparams) const
                os << "\\textsuperscript{";
                break;
        }
-       int const i = InsetText::latex(os, runparams);
+       InsetText::latex(os, runparams);
        os << "}";
-
-       return i;
 }
 
 
index c9ac1d30e0abebfa3c50c326587586c068242df4..b2062dabfde1fc6f88097f80fa4414771d95edf4 100644 (file)
@@ -88,7 +88,7 @@ public:
        ///
        virtual void validate(LaTeXFeatures &) const;
        ///
-       int latex(otexstream &, OutputParams const &) const;
+       void latex(otexstream &, OutputParams const &) const;
        ///
        int plaintext(odocstream &, OutputParams const &) const;
        ///
index 023da440289f3b62150a7e214f37e9ad5ba981f6..6e7c94d76576f28c0caffa1697c1d75be72bc2c4 100644 (file)
@@ -521,7 +521,7 @@ void InsetSpace::read(Lexer & lex)
 }
 
 
-int InsetSpace::latex(otexstream & os, OutputParams const & runparams) const
+void InsetSpace::latex(otexstream & os, OutputParams const & runparams) const
 {
        switch (params_.kind) {
        case InsetSpaceParams::NORMAL:
@@ -602,7 +602,6 @@ int InsetSpace::latex(otexstream & os, OutputParams const & runparams) const
                        os << "\\hspace*{" << from_ascii(params_.length.asLatexString()) << "}";
                break;
        }
-       return 0;
 }
 
 
index 7af103f827a5730cc8f3227a3c6d8a61713b21b5..b56ad9cd5b85c689c88562f3db945b4373b2743c 100644 (file)
@@ -120,7 +120,7 @@ public:
        /// Will not be used when lyxf3
        void read(Lexer & lex);
        ///
-       int latex(otexstream &, OutputParams const &) const;
+       void latex(otexstream &, OutputParams const &) const;
        ///
        int plaintext(odocstream &, OutputParams const &) const;
        ///
index d0a5d10a58956754bb232b18d96c5f0491ff6e3c..106755076b5d556eb3b3c66bc0c798d1dff2d7ae 100644 (file)
@@ -205,8 +205,8 @@ void InsetSpecialChar::read(Lexer & lex)
 }
 
 
-int InsetSpecialChar::latex(otexstream & os,
-                           OutputParams const & rp) const
+void InsetSpecialChar::latex(otexstream & os,
+                            OutputParams const & rp) const
 {
        switch (kind_) {
        case HYPHENATION:
@@ -236,7 +236,6 @@ int InsetSpecialChar::latex(otexstream & os,
                os << "\\nobreakdash-";
                break;
        }
-       return 0;
 }
 
 
index e402ef7c7cad22f5baa48544ba585e5dbfe0a465..294c9c265937463371c9e73c5562927a8c18ac8b 100644 (file)
@@ -59,7 +59,7 @@ public:
        /// Will not be used when lyxf3
        void read(Lexer & lex);
        ///
-       int latex(otexstream &, OutputParams const &) const;
+       void latex(otexstream &, OutputParams const &) const;
        ///
        int plaintext(odocstream &, OutputParams const &) const;
        ///
index 4aadb170fe933e4c9ef8c3170251f85b43a7f727..4b2463ded229774b895a34e59d83b8310d3f372e 100644 (file)
@@ -2027,7 +2027,7 @@ bool Tabular::isPartOfMultiRow(row_type row, col_type column) const
 }
 
 
-int Tabular::TeXTopHLine(otexstream & os, row_type row, string const lang) const
+void Tabular::TeXTopHLine(otexstream & os, row_type row, string const lang) const
 {
        // we only output complete row lines and the 1st row here, the rest
        // is done in Tabular::TeXBottomHLine(...)
@@ -2049,7 +2049,7 @@ int Tabular::TeXTopHLine(otexstream & os, row_type row, string const lang) const
 
        // do nothing if empty first row, or incomplete row line after
        if ((row == 0 && nset == 0) || (row > 0 && nset != ncols()))
-               return 0;
+               return;
 
        // only output complete row lines and the 1st row's clines
        if (nset == ncols()) {
@@ -2086,11 +2086,10 @@ int Tabular::TeXTopHLine(otexstream & os, row_type row, string const lang) const
                }
        }
        os << "\n";
-       return 1;
 }
 
 
-int Tabular::TeXBottomHLine(otexstream & os, row_type row, string const lang) const
+void Tabular::TeXBottomHLine(otexstream & os, row_type row, string const lang) const
 {
        // we output bottomlines of row r and the toplines of row r+1
        // if the latter do not span the whole tabular
@@ -2124,7 +2123,7 @@ int Tabular::TeXBottomHLine(otexstream & os, row_type row, string const lang) co
 
        // do nothing if empty, OR incomplete row line with a topline in next row
        if (nset == 0 || (nextrowset && nset != ncols()))
-               return 0;
+               return;
 
        if (nset == ncols()) {
                if (use_booktabs)
@@ -2159,17 +2158,15 @@ int Tabular::TeXBottomHLine(otexstream & os, row_type row, string const lang) co
                }
        }
        os << "\n";
-       return 1;
 }
 
 
-int Tabular::TeXCellPreamble(otexstream & os, idx_type cell,
-                            bool & ismulticol, bool & ismultirow) const
+void Tabular::TeXCellPreamble(otexstream & os, idx_type cell,
+                             bool & ismulticol, bool & ismultirow) const
 {
-       int ret = 0;
        row_type const r = cellRow(cell);
        if (is_long_tabular && row_info[r].caption)
-               return ret;
+               return;
 
        Tabular::VAlignment valign =  getVAlignment(cell, !isMultiColumn(cell));
        LyXAlignment align = getAlignment(cell, !isMultiColumn(cell));
@@ -2275,7 +2272,6 @@ int Tabular::TeXCellPreamble(otexstream & os, idx_type cell,
 
        if (getRotateCell(cell)) {
                os << "\\begin{sideways}\n";
-               ++ret;
        }
        if (getUsebox(cell) == BOX_PARBOX) {
                os << "\\parbox[";
@@ -2307,139 +2303,99 @@ int Tabular::TeXCellPreamble(otexstream & os, idx_type cell,
                }
                os << "]{" << from_ascii(getPWidth(cell).asLatexString())
                   << "}\n";
-               ++ret;
        }
-       return ret;
 }
 
 
-int Tabular::TeXCellPostamble(otexstream & os, idx_type cell,
-                             bool ismulticol, bool ismultirow) const
+void Tabular::TeXCellPostamble(otexstream & os, idx_type cell,
+                              bool ismulticol, bool ismultirow) const
 {
-       int ret = 0;
        row_type const r = cellRow(cell);
        if (is_long_tabular && row_info[r].caption)
-               return ret;
+               return;
 
        // usual cells
        if (getUsebox(cell) == BOX_PARBOX)
                os << '}';
-       else if (getUsebox(cell) == BOX_MINIPAGE) {
-               os << "%\n\\end{minipage}";
-               ret += 2;
-       }
-       if (getRotateCell(cell)) {
-               os << "%\n\\end{sideways}";
-               ++ret;
-       }
+       else if (getUsebox(cell) == BOX_MINIPAGE)
+               os << breakln << "\\end{minipage}";
+       if (getRotateCell(cell))
+               os << breakln << "\\end{sideways}";
        if (ismultirow)
                os << '}';
        if (ismulticol)
                os << '}';
-
-       return ret;
 }
 
 
-int Tabular::TeXLongtableHeaderFooter(otexstream & os,
-                                        OutputParams const & runparams) const
+void Tabular::TeXLongtableHeaderFooter(otexstream & os,
+                                       OutputParams const & runparams) const
 {
        if (!is_long_tabular)
-               return 0;
+               return;
 
-       int ret = 0;
        // caption handling
        // the caption must be output before the headers
        if (haveLTCaption()) {
                for (row_type r = 0; r < nrows(); ++r) {
-                       if (row_info[r].caption) {
-                               ret += TeXRow(os, r, runparams);
-                       }
+                       if (row_info[r].caption)
+                               TeXRow(os, r, runparams);
                }
        }
        // output first header info
        // first header must be output before the header, otherwise the
        // correct caption placement becomes really weird
        if (haveLTFirstHead()) {
-               if (endfirsthead.topDL) {
+               if (endfirsthead.topDL)
                        os << "\\hline\n";
-                       ++ret;
-               }
                for (row_type r = 0; r < nrows(); ++r) {
-                       if (row_info[r].endfirsthead) {
-                               ret += TeXRow(os, r, runparams);
-                       }
+                       if (row_info[r].endfirsthead)
+                               TeXRow(os, r, runparams);
                }
-               if (endfirsthead.bottomDL) {
+               if (endfirsthead.bottomDL)
                        os << "\\hline\n";
-                       ++ret;
-               }
                os << "\\endfirsthead\n";
-               ++ret;
        }
        // output header info
        if (haveLTHead()) {
-               if (endfirsthead.empty && !haveLTFirstHead()) {
+               if (endfirsthead.empty && !haveLTFirstHead())
                        os << "\\endfirsthead\n";
-                       ++ret;
-               }
-               if (endhead.topDL) {
+               if (endhead.topDL)
                        os << "\\hline\n";
-                       ++ret;
-               }
                for (row_type r = 0; r < nrows(); ++r) {
-                       if (row_info[r].endhead) {
-                               ret += TeXRow(os, r, runparams);
-                       }
+                       if (row_info[r].endhead)
+                               TeXRow(os, r, runparams);
                }
-               if (endhead.bottomDL) {
+               if (endhead.bottomDL)
                        os << "\\hline\n";
-                       ++ret;
-               }
                os << "\\endhead\n";
-               ++ret;
        }
        // output footer info
        if (haveLTFoot()) {
-               if (endfoot.topDL) {
+               if (endfoot.topDL)
                        os << "\\hline\n";
-                       ++ret;
-               }
                for (row_type r = 0; r < nrows(); ++r) {
-                       if (row_info[r].endfoot) {
-                               ret += TeXRow(os, r, runparams);
-                       }
+                       if (row_info[r].endfoot)
+                               TeXRow(os, r, runparams);
                }
-               if (endfoot.bottomDL) {
+               if (endfoot.bottomDL)
                        os << "\\hline\n";
-                       ++ret;
-               }
                os << "\\endfoot\n";
-               ++ret;
-               if (endlastfoot.empty && !haveLTLastFoot()) {
+               if (endlastfoot.empty && !haveLTLastFoot())
                        os << "\\endlastfoot\n";
-                       ++ret;
-               }
        }
        // output lastfooter info
        if (haveLTLastFoot()) {
-               if (endlastfoot.topDL) {
+               if (endlastfoot.topDL)
                        os << "\\hline\n";
-                       ++ret;
-               }
                for (row_type r = 0; r < nrows(); ++r) {
-                       if (row_info[r].endlastfoot) {
-                               ret += TeXRow(os, r, runparams);
-                       }
+                       if (row_info[r].endlastfoot)
+                               TeXRow(os, r, runparams);
                }
-               if (endlastfoot.bottomDL) {
+               if (endlastfoot.bottomDL)
                        os << "\\hline\n";
-                       ++ret;
-               }
                os << "\\endlastfoot\n";
-               ++ret;
        }
-       return ret;
 }
 
 
@@ -2453,8 +2409,8 @@ bool Tabular::isValidRow(row_type row) const
 }
 
 
-int Tabular::TeXRow(otexstream & os, row_type row,
-                      OutputParams const & runparams) const
+void Tabular::TeXRow(otexstream & os, row_type row,
+                    OutputParams const & runparams) const
 {
        idx_type cell = cellIndex(row, 0);
        shared_ptr<InsetTableCell> inset = cellInset(cell);
@@ -2462,14 +2418,13 @@ int Tabular::TeXRow(otexstream & os, row_type row,
        string const lang = par.getParLanguage(buffer().params())->lang();
 
        //output the top line
-       int ret = TeXTopHLine(os, row, lang);
+       TeXTopHLine(os, row, lang);
 
        if (row_info[row].top_space_default) {
                if (use_booktabs)
                        os << "\\addlinespace\n";
                else
                        os << "\\noalign{\\vskip\\doublerulesep}\n";
-               ++ret;
        } else if(!row_info[row].top_space.zero()) {
                if (use_booktabs)
                        os << "\\addlinespace["
@@ -2480,7 +2435,6 @@ int Tabular::TeXRow(otexstream & os, row_type row,
                           << from_ascii(row_info[row].top_space.asLatexString())
                           << "}\n";
                }
-               ++ret;
        }
        bool ismulticol = false;
        bool ismultirow = false;
@@ -2495,7 +2449,7 @@ int Tabular::TeXRow(otexstream & os, row_type row,
                }
 
                cell = cellIndex(row, c);
-               ret += TeXCellPreamble(os, cell, ismulticol, ismultirow);
+               TeXCellPreamble(os, cell, ismulticol, ismultirow);
                shared_ptr<InsetTableCell> inset = cellInset(cell);
 
                Paragraph const & par = inset->paragraphs().front();
@@ -2537,15 +2491,15 @@ int Tabular::TeXRow(otexstream & os, row_type row,
                        tail.setBuffer(head.buffer());
                        head.latex(os, newrp);
                        os << '&';
-                       ret += tail.latex(os, newrp);
+                       tail.latex(os, newrp);
                } else if (!isPartOfMultiRow(row, c))
-                       ret += inset->latex(os, newrp);
+                       inset->latex(os, newrp);
 
                runparams.encoding = newrp.encoding;
                if (rtl)
                        os << '}';
 
-               ret += TeXCellPostamble(os, cell, ismulticol, ismultirow);
+               TeXCellPostamble(os, cell, ismulticol, ismultirow);
                if (cell != getLastCellInRow(row)) { // not last cell in row
                        os << " & ";
                }
@@ -2570,17 +2524,15 @@ int Tabular::TeXRow(otexstream & os, row_type row,
                   << ']';
        }
        os << '\n';
-       ++ret;
 
        //output the bottom line
-       ret += TeXBottomHLine(os, row, lang);
+       TeXBottomHLine(os, row, lang);
 
        if (row_info[row].interline_space_default) {
                if (use_booktabs)
                        os << "\\addlinespace\n";
                else
                        os << "\\noalign{\\vskip\\doublerulesep}\n";
-               ++ret;
        } else if (!row_info[row].interline_space.zero()) {
                if (use_booktabs)
                        os << "\\addlinespace["
@@ -2590,25 +2542,21 @@ int Tabular::TeXRow(otexstream & os, row_type row,
                        os << "\\noalign{\\vskip"
                           << from_ascii(row_info[row].interline_space.asLatexString())
                           << "}\n";
-               ++ret;
        }
-       return ret;
 }
 
 
-int Tabular::latex(otexstream & os, OutputParams const & runparams) const
+void Tabular::latex(otexstream & os, OutputParams const & runparams) const
 {
-       int ret = 0;
        bool const is_tabular_star = !tabular_width.zero();
 
        //+---------------------------------------------------------------------
        //+                      first the opening preamble                    +
        //+---------------------------------------------------------------------
 
-       if (rotate) {
+       if (rotate)
                os << "\\begin{sideways}\n";
-               ++ret;
-       }
+
        if (is_long_tabular) {
                os << "\\begin{longtable}";
                switch (longtabular_alignment) {
@@ -2703,9 +2651,8 @@ int Tabular::latex(otexstream & os, OutputParams const & runparams) const
                        os << '|';
        }
        os << "}\n";
-       ++ret;
 
-       ret += TeXLongtableHeaderFooter(os, runparams);
+       TeXLongtableHeaderFooter(os, runparams);
 
        //+---------------------------------------------------------------------
        //+                      the single row and columns (cells)            +
@@ -2713,11 +2660,9 @@ int Tabular::latex(otexstream & os, OutputParams const & runparams) const
 
        for (row_type r = 0; r < nrows(); ++r) {
                if (isValidRow(r)) {
-                       ret += TeXRow(os, r, runparams);
-                       if (is_long_tabular && row_info[r].newpage) {
+                       TeXRow(os, r, runparams);
+                       if (is_long_tabular && row_info[r].newpage)
                                os << "\\newpage\n";
-                               ++ret;
-                       }
                }
        }
 
@@ -2727,19 +2672,15 @@ int Tabular::latex(otexstream & os, OutputParams const & runparams) const
 
        if (is_long_tabular)
                os << "\\end{longtable}";
-       else
+       else {
                if (is_tabular_star)
                        os << "\\end{tabular*}";
                else
                        os << "\\end{tabular}";
-       if (rotate) {
-               // clear counter
-               os.countLines();
-               os << breakln << "\\end{sideways}";
-               ret += os.countLines();
        }
 
-       return ret;
+       if (rotate)
+               os << breakln << "\\end{sideways}";
 }
 
 
@@ -4744,9 +4685,9 @@ Inset::DisplayType InsetTabular::display() const
 }
 
 
-int InsetTabular::latex(otexstream & os, OutputParams const & runparams) const
+void InsetTabular::latex(otexstream & os, OutputParams const & runparams) const
 {
-       return tabular.latex(os, runparams);
+       tabular.latex(os, runparams);
 }
 
 
index dbcfcfe2bc5a1407eddaafef610e718889aeffca..6903ae42a10f403d3bc3c17357cebe80e90fa72a 100644 (file)
@@ -453,7 +453,7 @@ public:
        ///
        void read(Lexer &);
        ///
-       int latex(otexstream &, OutputParams const &) const;
+       void latex(otexstream &, OutputParams const &) const;
        ///
        int docbook(odocstream & os, OutputParams const &) const;
        ///
@@ -719,22 +719,22 @@ public:
        ///
        BoxType useParbox(idx_type cell) const;
        ///
-       // helper function for Latex returns number of newlines
+       // helper function for Latex
        ///
-       int TeXTopHLine(otexstream &, row_type row, std::string const lang) const;
+       void TeXTopHLine(otexstream &, row_type row, std::string const lang) const;
        ///
-       int TeXBottomHLine(otexstream &, row_type row, std::string const lang) const;
+       void TeXBottomHLine(otexstream &, row_type row, std::string const lang) const;
        ///
-       int TeXCellPreamble(otexstream &, idx_type cell, bool & ismulticol, bool & ismultirow) const;
+       void TeXCellPreamble(otexstream &, idx_type cell, bool & ismulticol, bool & ismultirow) const;
        ///
-       int TeXCellPostamble(otexstream &, idx_type cell, bool ismulticol, bool ismultirow) const;
+       void TeXCellPostamble(otexstream &, idx_type cell, bool ismulticol, bool ismultirow) const;
        ///
-       int TeXLongtableHeaderFooter(otexstream &, OutputParams const &) const;
+       void TeXLongtableHeaderFooter(otexstream &, OutputParams const &) const;
        ///
        bool isValidRow(row_type const row) const;
        ///
-       int TeXRow(otexstream &, row_type const row,
-                  OutputParams const &) const;
+       void TeXRow(otexstream &, row_type const row,
+                   OutputParams const &) const;
        ///
        // helper functions for plain text
        ///
@@ -810,7 +810,7 @@ public:
        ///
        DisplayType display() const;
        ///
-       int latex(otexstream &, OutputParams const &) const;
+       void latex(otexstream &, OutputParams const &) const;
        ///
        int plaintext(odocstream &, OutputParams const &) const;
        ///
index 56d88e620bbb169a8109bd8572c95039f48d6632..327440d37c2119cb40e207440e4d076f5fa1eeb2 100644 (file)
@@ -370,14 +370,13 @@ void InsetText::validate(LaTeXFeatures & features) const
 }
 
 
-int InsetText::latex(otexstream & os, OutputParams const & runparams) const
+void InsetText::latex(otexstream & os, OutputParams const & runparams) const
 {
        // This implements the standard way of handling the LaTeX
        // output of a text inset, either a command or an
        // environment. Standard collapsable insets should not
        // redefine this, non-standard ones may call this.
        InsetLayout const & il = getLayout();
-       int rows = 0;
        if (!il.latexname().empty()) {
                if (il.latextype() == InsetLayout::COMMAND) {
                        // FIXME UNICODE
@@ -388,8 +387,6 @@ int InsetText::latex(otexstream & os, OutputParams const & runparams) const
                                os << from_utf8(il.latexparam());
                        os << '{';
                } else if (il.latextype() == InsetLayout::ENVIRONMENT) {
-                       // clear counter
-                       os.countLines();
                        if (il.isDisplay())
                            os << breakln;
                        else
@@ -397,7 +394,6 @@ int InsetText::latex(otexstream & os, OutputParams const & runparams) const
                        os << "\\begin{" << from_utf8(il.latexname()) << "}\n";
                        if (!il.latexparam().empty())
                                os << from_utf8(il.latexparam());
-                       rows += os.countLines();
                }
        }
        OutputParams rp = runparams;
@@ -409,17 +405,13 @@ int InsetText::latex(otexstream & os, OutputParams const & runparams) const
        rp.par_end = paragraphs().size();
 
        // Output the contents of the inset
-       TexRow texrow;
-       latexParagraphs(buffer(), text_, os, texrow, rp);
-       rows += texrow.rows();
+       latexParagraphs(buffer(), text_, os, rp);
        runparams.encoding = rp.encoding;
 
        if (!il.latexname().empty()) {
                if (il.latextype() == InsetLayout::COMMAND) {
                        os << "}";
                } else if (il.latextype() == InsetLayout::ENVIRONMENT) {
-                       // clear counter
-                       os.countLines();
                        // A comment environment doesn't need a % before \n\end
                        if (il.isDisplay() || runparams.inComment)
                            os << breakln;
@@ -428,10 +420,8 @@ int InsetText::latex(otexstream & os, OutputParams const & runparams) const
                        os << "\\end{" << from_utf8(il.latexname()) << "}\n";
                        if (!il.isDisplay())
                                os.protectSpace(true);
-                       rows += os.countLines();
                }
        }
-       return rows;
 }
 
 
index e8d8ba6a941b9fcd2d1a09c54ea3072e35248de7..1f643c029fcc9a606ad35e576508e46bf05ceaea 100644 (file)
@@ -73,7 +73,7 @@ public:
        Text & text() { return text_; }
        Text const & text() const { return text_; }
        ///
-       int latex(otexstream &, OutputParams const &) const;
+       void latex(otexstream &, OutputParams const &) const;
        ///
        int plaintext(odocstream &, OutputParams const &) const;
        ///
index 18ae4dcf13539a36abb30c28efaef48cf8418916..057435eedaf437e77395bedf8c182443553b4fbb 100644 (file)
@@ -201,10 +201,9 @@ void InsetVSpace::draw(PainterInfo & pi, int x, int y) const
 }
 
 
-int InsetVSpace::latex(otexstream & os, OutputParams const &) const
+void InsetVSpace::latex(otexstream & os, OutputParams const &) const
 {
        os << from_ascii(space_.asLatexCommand(buffer().params())) << '\n';
-       return 1;
 }
 
 
index ef4b7c11f43d14a94bf1728ef2bbe02b17552562..4a8a1049316ab64da5ba2fb852a0a6b69425eb0b 100644 (file)
@@ -45,7 +45,7 @@ private:
        ///
        void draw(PainterInfo & pi, int x, int y) const;
        ///
-       int latex(otexstream &, OutputParams const &) const;
+       void latex(otexstream &, OutputParams const &) const;
        ///
        int plaintext(odocstream &, OutputParams const &) const;
        ///
index f245d00e46c758401ff54fcd12661e557f117374..c40f7005b7727275781a5b77ce6a3fe37c5a887e 100644 (file)
@@ -182,7 +182,7 @@ void InsetWrap::validate(LaTeXFeatures & features) const
 }
 
 
-int InsetWrap::latex(otexstream & os, OutputParams const & runparams_in) const
+void InsetWrap::latex(otexstream & os, OutputParams const & runparams_in) const
 {
        OutputParams runparams(runparams_in);
        runparams.inFloat = OutputParams::MAINFLOAT;
@@ -196,9 +196,8 @@ int InsetWrap::latex(otexstream & os, OutputParams const & runparams_in) const
        if (over.value() != 0)
                os << '[' << from_ascii(params_.overhang.asLatexString()) << ']';
        os << '{' << from_ascii(params_.width.asLatexString()) << "}%\n";
-       int const i = InsetText::latex(os, runparams);
+       InsetText::latex(os, runparams);
        os << "\\end{wrap" << from_ascii(params_.type) << "}%\n";
-       return i + 2;
 }
 
 
index 674d2869c22318a032e831871aed369b20d33626..f533e6d0a3b8553da4c2d54dfbc54e9b78fea318 100644 (file)
@@ -65,7 +65,7 @@ private:
        ///
        docstring toolTip(BufferView const & bv, int x, int y) const;
        ///
-       int latex(otexstream &, OutputParams const &) const;
+       void latex(otexstream &, OutputParams const &) const;
        ///
        int plaintext(odocstream &, OutputParams const &) const;
        ///
index 88e325d6f5db37f5e714f5fed369575133bf2145..409a2e2cf7f2a1bf8d24fbf5725d111dd2311a0a 100644 (file)
@@ -718,18 +718,17 @@ private:
 static docstring buffer_to_latex(Buffer & buffer) 
 {
        OutputParams runparams(&buffer.params().encoding());
+       TexRow texrow;
        odocstringstream ods;
-       otexstream os(ods);
+       otexstream os(ods, texrow);
        runparams.nice = true;
        runparams.flavor = OutputParams::LATEX;
        runparams.linelen = 80; //lyxrc.plaintext_linelen;
        // No side effect of file copying and image conversion
        runparams.dryrun = true;
-       buffer.texrow().reset();
        pit_type const endpit = buffer.paragraphs().size();
        for (pit_type pit = 0; pit != endpit; ++pit) {
-               TeXOnePar(buffer, buffer.text(),
-                         pit, os, buffer.texrow(), runparams);
+               TeXOnePar(buffer, buffer.text(), pit, os, runparams);
                LYXERR(Debug::FIND, "searchString up to here: " << ods.str());
        }
        return ods.str();
@@ -995,7 +994,7 @@ docstring latexifyFromCursor(DocIterator const & cur, int len)
 
        TexRow texrow;
        odocstringstream ods;
-       otexstream os(ods);
+       otexstream os(ods, texrow);
        OutputParams runparams(&buf.params().encoding());
        runparams.nice = false;
        runparams.flavor = OutputParams::LATEX;
@@ -1008,7 +1007,7 @@ docstring latexifyFromCursor(DocIterator const & cur, int len)
                pos_type endpos = cur.paragraph().size();
                if (len != -1 && endpos > cur.pos() + len)
                        endpos = cur.pos() + len;
-               TeXOnePar(buf, *cur.innerText(), cur.pit(), os, texrow, runparams,
+               TeXOnePar(buf, *cur.innerText(), cur.pit(), os, runparams,
                        string(), cur.pos(), endpos);
                LYXERR(Debug::FIND, "Latexified text: '" << lyx::to_utf8(ods.str()) << "'");
        } else if (cur.inMathed()) {
@@ -1318,15 +1317,15 @@ static void findAdvReplace(BufferView * bv, FindAndReplaceOptions const & opt, M
                LYXERR(Debug::FIND, "After pasteParagraphList() cur=" << cur << endl);
                sel_len = repl_buffer.paragraphs().begin()->size();
        } else {
+               TexRow texrow;
                odocstringstream ods;
-               otexstream os(ods);
+               otexstream os(ods, texrow);
                OutputParams runparams(&repl_buffer.params().encoding());
                runparams.nice = false;
                runparams.flavor = OutputParams::LATEX;
                runparams.linelen = 8000; //lyxrc.plaintext_linelen;
                runparams.dryrun = true;
-               TexRow texrow;
-               TeXOnePar(repl_buffer, repl_buffer.text(), 0, os, texrow, runparams);
+               TeXOnePar(repl_buffer, repl_buffer.text(), 0, os, runparams);
                //repl_buffer.getSourceCode(ods, 0, repl_buffer.paragraphs().size(), false);
                docstring repl_latex = ods.str();
                LYXERR(Debug::FIND, "Latexified replace_buffer: '" << repl_latex << "'");
index d43fa0c7370394e6a0ef6a8c016caefb0bd49f21..07ed683c55b485ae8668a764b5b24f383710ffee 100644 (file)
@@ -70,8 +70,8 @@ void InsetFormulaMacro::write(ostream & os) const
 }
 
 
-int InsetFormulaMacro::latex(otexstream & os,
-                            OutputParams const & runparams) const
+void InsetFormulaMacro::latex(otexstream & os,
+                             OutputParams const & runparams) const
 {
        //lyxerr << "InsetFormulaMacro::latex" << endl;
        WriteStream wi(os.os(), runparams.moving_arg, true,
@@ -80,7 +80,7 @@ int InsetFormulaMacro::latex(otexstream & os,
        wi.canBreakLine(os.canBreakLine());
        tmpl()->write(wi);
        os.canBreakLine(wi.canBreakLine());
-       return 2;
+       os.texrow().newlines(wi.line());
 }
 
 
index f06f7eba22204005958d69e93843dc6d1925238e..9c1ec053abf721338e0667ea6356ce07347a22cd 100644 (file)
@@ -1920,7 +1920,6 @@ int InsetMathHull::docbook(odocstream & os, OutputParams const & runparams) cons
        ++ms.tab(); ms.cr(); ms.os() << '<' << bname << '>';
 
        odocstringstream ls;
-       otexstream ols(ls);
        if (runparams.flavor == OutputParams::XML) {
                ms << MTag("alt role='tex' ");
                // Workaround for db2latex: db2latex always includes equations with
@@ -1936,8 +1935,12 @@ int InsetMathHull::docbook(odocstream & os, OutputParams const & runparams) cons
                InsetMathGrid::mathmlize(ms);
                ms << ETag("math");
        } else {
+               TexRow texrow;
+               texrow.reset();
+               otexstream ols(ls, texrow);
                ms << MTag("alt role='tex'");
-               res = latex(ols, runparams);
+               latex(ols, runparams);
+               res = texrow.rows();
                ms << from_utf8(subst(subst(to_utf8(ls.str()), "&", "&amp;"), "<", "&lt;"));
                ms << ETag("alt");
        }
index 4d1f3503c24ed3a8499034a4df0b82e62fe7e89f..527a080793bfd2c5d4a2cad01d92d267eba479ab 100644 (file)
@@ -75,8 +75,8 @@ void InsetMathMBox::write(WriteStream & ws) const
                ws << "\\mbox{\n";
                TexRow texrow;
                OutputParams runparams(&buffer().params().encoding());
-               otexstream os(ws.os());
-               latexParagraphs(buffer(), text_.text(), os, texrow, runparams);
+               otexstream os(ws.os(), texrow);
+               latexParagraphs(buffer(), text_.text(), os, runparams);
                ws.addlines(texrow.rows());
                ws << "}";
        } else {
@@ -89,13 +89,11 @@ void InsetMathMBox::write(WriteStream & ws) const
 }
 
 
-int InsetMathMBox::latex(otexstream & os, OutputParams const & runparams) const
+void InsetMathMBox::latex(otexstream & os, OutputParams const & runparams) const
 {
        os << "\\mbox{\n";
-       TexRow texrow;
-       latexParagraphs(buffer(), text_.text(), os, texrow, runparams);
+       latexParagraphs(buffer(), text_.text(), os, runparams);
        os << "}";
-       return texrow.rows();
 }
 
 
index 1c6437d9737f907386b87ed5390775e3ad7aa36a..25204bc91bcacc7bbdae76a78bfd8f5e951bf459 100644 (file)
@@ -394,7 +394,7 @@ void InsetMathNest::normalize(NormalStream & os) const
 }
 
 
-int InsetMathNest::latex(otexstream & os, OutputParams const & runparams) const
+void InsetMathNest::latex(otexstream & os, OutputParams const & runparams) const
 {
        WriteStream wi(os.os(), runparams.moving_arg, true,
                       runparams.dryrun ? WriteStream::wsDryrun : WriteStream::wsDefault,
@@ -402,7 +402,7 @@ int InsetMathNest::latex(otexstream & os, OutputParams const & runparams) const
        wi.canBreakLine(os.canBreakLine());
        write(wi);
        os.canBreakLine(wi.canBreakLine());
-       return wi.line();
+       os.texrow().newlines(wi.line());
 }
 
 
index ee1e38cb585688617b672ef4950cb38ff1362cfb..5a737c3b61bc1e421f582bf01b6e5c94b76e9d4a 100644 (file)
@@ -111,7 +111,7 @@ public:
        /// writes [, name(), and args in []
        void normalize(NormalStream & os) const;
        ///
-       int latex(otexstream & os, OutputParams const & runparams) const;
+       void latex(otexstream & os, OutputParams const & runparams) const;
        ///
        bool setMouseHover(BufferView const * bv, bool mouse_hover);
        ///
index ab290cb369bd2733b798ffba230152a308131170..f8b9185028a3b644d493da25fd927c2ee482604c 100644 (file)
@@ -528,8 +528,9 @@ bool createInsetMath_fromDialogStr(docstring const & str, MathData & ar)
                InsetSpaceParams isp(true);
                InsetSpace::string2params(to_utf8(str), isp);
                InsetSpace is(isp);
+               TexRow texrow;
                odocstringstream ods;
-               otexstream os(ods);
+               otexstream os(ods, texrow);
                Encoding const * const ascii = encodings.fromLyXName("ascii");
                OutputParams op(ascii);
                is.latex(os, op);
index a5473bf4813d5684a00479d1570d3670de9810d2..336133098302a6643a181997a1c06efae3389bff 100644 (file)
@@ -76,9 +76,11 @@ struct TeXEnvironementData
 };
 
 
-static TeXEnvironementData prepareEnvironement(Buffer const & buf, Text const & text,
-               ParagraphList::const_iterator pit, otexstream & os, TexRow & texrow,
-               OutputParams const & runparams)
+static TeXEnvironementData prepareEnvironement(Buffer const & buf,
+                                       Text const & text,
+                                       ParagraphList::const_iterator pit,
+                                       otexstream & os,
+                                       OutputParams const & runparams)
 {
        TeXEnvironementData data;
 
@@ -131,7 +133,6 @@ static TeXEnvironementData prepareEnvironement(Buffer const & buf, Text const &
                                prev_par_lang))
                          // the '%' is necessary to prevent unwanted whitespace
                          << "%\n";
-                       texrow.newline();
                }
 
                if ((lang_end_command.empty() ||
@@ -148,7 +149,6 @@ static TeXEnvironementData prepareEnvironement(Buffer const & buf, Text const &
                                           << "]";
                          // the '%' is necessary to prevent unwanted whitespace
                        os << "%\n";
-                       texrow.newline();
                }
        }
 
@@ -157,19 +157,13 @@ static TeXEnvironementData prepareEnvironement(Buffer const & buf, Text const &
                os << "\\begin{LyXParagraphLeftIndent}{"
                   << from_ascii(pit->params().leftIndent().asLatexString())
                   << "}\n";
-               texrow.newline();
                data.leftindent_open = true;
        }
 
        if (style.isEnvironment()) {
                os << "\\begin{" << from_ascii(style.latexname()) << '}';
-               if (style.optargs != 0 || style.reqargs != 0) {
-                       int ret = latexArgInsets(*pit, os, runparams, style.reqargs, style.optargs);
-                       while (ret > 0) {
-                               texrow.newline();
-                               --ret;
-                       }
-               }
+               if (style.optargs != 0 || style.reqargs != 0)
+                       latexArgInsets(*pit, os, runparams, style.reqargs, style.optargs);
                if (style.latextype == LATEX_LIST_ENVIRONMENT) {
                        os << '{'
                           << pit->params().labelWidthString()
@@ -183,7 +177,6 @@ static TeXEnvironementData prepareEnvironement(Buffer const & buf, Text const &
                                  << "}\n";
                } else
                        os << from_ascii(style.latexparam()) << '\n';
-               texrow.newline();
        }
        data.style = &style;
 
@@ -196,26 +189,23 @@ static TeXEnvironementData prepareEnvironement(Buffer const & buf, Text const &
                           << "}{" << from_ascii(bparams.fonts_cjk) << "}%\n";
                open_encoding_ = CJK;
                data.cjk_nested = true;
-               texrow.newline();
        }
        return data;
 }
 
 
-static void finishEnvironement(otexstream & os, TexRow & texrow,
-               OutputParams const & runparams, TeXEnvironementData const & data)
+static void finishEnvironement(otexstream & os, OutputParams const & runparams,
+                              TeXEnvironementData const & data)
 {
        if (open_encoding_ == CJK && data.cjk_nested) {
                // We need to close the encoding even if it does not change
                // to do correct environment nesting
                os << "\\end{CJK}\n";
-               texrow.newline();
                open_encoding_ = none;
        }
 
        if (data.style->isEnvironment()) {
                os << "\\end{" << from_ascii(data.style->latexname()) << "}\n";
-               texrow.newline();
                prev_env_language_ = data.par_language;
                if (runparams.encoding != data.prev_encoding) {
                        runparams.encoding = data.prev_encoding;
@@ -226,7 +216,6 @@ static void finishEnvironement(otexstream & os, TexRow & texrow,
 
        if (data.leftindent_open) {
                os << "\\end{LyXParagraphLeftIndent}\n";
-               texrow.newline();
                prev_env_language_ = data.par_language;
                if (runparams.encoding != data.prev_encoding) {
                        runparams.encoding = data.prev_encoding;
@@ -237,9 +226,9 @@ static void finishEnvironement(otexstream & os, TexRow & texrow,
 }
 
 
-void TeXEnvironment(Buffer const & buf,
-              Text const & text, OutputParams const & runparams,
-                  pit_type & pit, otexstream & os, TexRow & texrow)
+void TeXEnvironment(Buffer const & buf, Text const & text,
+                   OutputParams const & runparams,
+                   pit_type & pit, otexstream & os)
 {
        ParagraphList const & paragraphs = text.paragraphs();
        ParagraphList::const_iterator par = paragraphs.constIterator(pit);
@@ -272,7 +261,7 @@ void TeXEnvironment(Buffer const & buf,
                        && par->params().depth() == current_depth
                        && par->params().leftIndent() == current_left_indent) {
                        // We are still in the same environment so TeXOnePar and continue;
-                       TeXOnePar(buf, text, pit, os, texrow, runparams);
+                       TeXOnePar(buf, text, pit, os, runparams);
                        continue;
                }
 
@@ -295,7 +284,6 @@ void TeXEnvironment(Buffer const & buf,
                        // many? i.e. that we sometimes will have
                        // three in a row.
                        os << '\n';
-                       texrow.newline();
                }
 
                // FIXME This test should not be necessary.
@@ -307,16 +295,16 @@ void TeXEnvironment(Buffer const & buf,
 
                if (!style.isEnvironment()) {
                        // This is a standard paragraph, no need to call TeXEnvironment.
-                       TeXOnePar(buf, text, pit, os, texrow, runparams);
+                       TeXOnePar(buf, text, pit, os, runparams);
                        continue;
                }
 
                // This is a new environment.
-               TeXEnvironementData const data = prepareEnvironement(buf, text, par,
-                       os, texrow, runparams);
+               TeXEnvironementData const data =
+                       prepareEnvironement(buf, text, par, os, runparams);
                // Recursive call to TeXEnvironment!
-               TeXEnvironment(buf, text, runparams, pit, os, texrow);
-               finishEnvironement(os, texrow, runparams, data);
+               TeXEnvironment(buf, text, runparams, pit, os);
+               finishEnvironement(os, runparams, data);
        }
 
        if (pit != runparams.par_end)
@@ -326,7 +314,7 @@ void TeXEnvironment(Buffer const & buf,
 } // namespace anon
 
 
-int latexArgInsets(Paragraph const & par, otexstream & os,
+void latexArgInsets(Paragraph const & par, otexstream & os,
        OutputParams const & runparams, unsigned int reqargs,
        unsigned int optargs)
 {
@@ -348,16 +336,15 @@ int latexArgInsets(Paragraph const & par, otexstream & os,
        }
 
        if (!reqargs && ilist.size() == 0)
-               return 0;
+               return;
 
-       int lines = 0;
        bool const have_optional_args = ilist.size() > reqargs;
        if (have_optional_args) {
                unsigned int todo = ilist.size() - reqargs;
                for (unsigned int i = 0; i < todo; ++i) {
                        InsetArgument const * ins = ilist.front();
                        ilist.pop_front();
-                       lines += ins->latexArgument(os, runparams, true);
+                       ins->latexArgument(os, runparams, true);
                }
        }
 
@@ -365,7 +352,7 @@ int latexArgInsets(Paragraph const & par, otexstream & os,
        // arguments.
        LASSERT(ilist.size() <= reqargs, /* */);
        if (!reqargs)
-               return lines;
+               return;
 
        for (unsigned int i = 0; i < reqargs; ++i) {
                if (ilist.empty())
@@ -374,30 +361,24 @@ int latexArgInsets(Paragraph const & par, otexstream & os,
                else {
                        InsetArgument const * ins = ilist.front();
                        ilist.pop_front();
-                       lines += ins->latexArgument(os, runparams, false);
+                       ins->latexArgument(os, runparams, false);
                }
        }
-       return lines;
 }
 
 namespace {
 
 // output the proper paragraph start according to latextype.
-void parStartCommand(Paragraph const & par, otexstream & os, TexRow & texrow,
-                    OutputParams const & runparams,Layout const & style) 
+void parStartCommand(Paragraph const & par, otexstream & os,
+                    OutputParams const & runparams, Layout const & style) 
 {
        switch (style.latextype) {
        case LATEX_COMMAND:
                os << '\\' << from_ascii(style.latexname());
 
                // Separate handling of optional argument inset.
-               if (style.optargs != 0 || style.reqargs != 0) {
-                       int ret = latexArgInsets(par, os, runparams, style.reqargs, style.optargs);
-                       while (ret > 0) {
-                               texrow.newline();
-                               --ret;
-                       }
-               }
+               if (style.optargs != 0 || style.reqargs != 0)
+                       latexArgInsets(par, os, runparams, style.reqargs, style.optargs);
                else
                        os << from_ascii(style.latexparam());
                break;
@@ -417,12 +398,12 @@ void parStartCommand(Paragraph const & par, otexstream & os, TexRow & texrow,
 
 // FIXME: this should be anonymous
 void TeXOnePar(Buffer const & buf,
-         Text const & text,
-         pit_type pit,
-         otexstream & os, TexRow & texrow,
-         OutputParams const & runparams_in,
-         string const & everypar,
-         int start_pos, int end_pos)
+              Text const & text,
+              pit_type pit,
+              otexstream & os,
+              OutputParams const & runparams_in,
+              string const & everypar,
+              int start_pos, int end_pos)
 {
        BufferParams const & bparams = buf.params();
        ParagraphList const & paragraphs = text.paragraphs();
@@ -461,15 +442,11 @@ void TeXOnePar(Buffer const & buf,
                // No newline before first paragraph in this lyxtext
                if (pit > 0) {
                        os << '\n';
-                       texrow.newline();
-                       if (!text.inset().getLayout().parbreakIsNewline()) {
+                       if (!text.inset().getLayout().parbreakIsNewline())
                                os << '\n';
-                               texrow.newline();
-                       }
                }
 
-               par.latex(bparams, outerfont, os, texrow, runparams, start_pos,
-                       end_pos);
+               par.latex(bparams, outerfont, os, runparams, start_pos, end_pos);
                return;
        }
 
@@ -478,10 +455,9 @@ void TeXOnePar(Buffer const & buf,
 
        if (style.pass_thru) {
                Font const outerfont = text.outerFont(pit);
-               parStartCommand(par, os, texrow,runparams, style);
+               parStartCommand(par, os, runparams, style);
 
-               par.latex(bparams, outerfont, os, texrow, runparams, start_pos,
-                       end_pos);
+               par.latex(bparams, outerfont, os, runparams, start_pos, end_pos);
 
                // I did not create a parEndCommand for this minuscule
                // task because in the other user of parStartCommand
@@ -490,17 +466,14 @@ void TeXOnePar(Buffer const & buf,
                        os << "}\n";
                else
                        os << '\n';
-               texrow.newline();
                if (!style.parbreak_is_newline) {
                        os << '\n';
-                       texrow.newline();
                } else if (nextpar) {
-                       Layout const nextstyle = text.inset().forcePlainLayout() ?
-                               bparams.documentClass().plainLayout() : nextpar->layout();
-                       if (nextstyle.name() != style.name()) {
+                       Layout const nextstyle = text.inset().forcePlainLayout()
+                               ? bparams.documentClass().plainLayout()
+                               : nextpar->layout();
+                       if (nextstyle.name() != style.name())
                                os << '\n';
-                               texrow.newline();
-                       }
                }
 
                return;
@@ -566,7 +539,6 @@ void TeXOnePar(Buffer const & buf,
                                prev_lang))
                           // the '%' is necessary to prevent unwanted whitespace
                           << "%\n";
-                       texrow.newline();
                }
 
                // We need to open a new language if we couldn't close the previous
@@ -625,7 +597,6 @@ void TeXOnePar(Buffer const & buf,
                                                  << "]";
                                   // the '%' is necessary to prevent unwanted whitespace
                                os << "%\n";
-                               texrow.newline();
                        }
                }
        }
@@ -668,13 +639,11 @@ void TeXOnePar(Buffer const & buf,
                                os << "\\begin{CJK}{" << from_ascii(par_language->encoding()->latexName())
                                   << "}{" << from_ascii(bparams.fonts_cjk) << "}%\n";
                                open_encoding_ = CJK;
-                               texrow.newline();
                        }
                        if (encoding->package() != Encoding::none && enc_switch.first) {
                                if (enc_switch.second > 0) {
                                        // the '%' is necessary to prevent unwanted whitespace
                                        os << "%\n";
-                                       texrow.newline();
                                }
                                // With CJK, the CJK tag had to be closed first (see above)
                                if (runparams.encoding->package() == Encoding::CJK) {
@@ -684,7 +653,6 @@ void TeXOnePar(Buffer const & buf,
                                                par_lang))
                                        // the '%' is necessary to prevent unwanted whitespace
                                        << "%\n";
-                                       texrow.newline();
                                }
                                runparams.encoding = encoding;
                        }
@@ -699,7 +667,6 @@ void TeXOnePar(Buffer const & buf,
        if (par.allowParagraphCustomization()) {
                if (par.params().startOfAppendix()) {
                        os << "\\appendix\n";
-                       texrow.newline();
                }
 
                if (!par.params().spacing().isDefault()
@@ -707,22 +674,20 @@ void TeXOnePar(Buffer const & buf,
                {
                        os << from_ascii(par.params().spacing().writeEnvirBegin(useSetSpace))
                            << '\n';
-                       texrow.newline();
                }
 
                if (style.isCommand()) {
                        os << '\n';
-                       texrow.newline();
                }
        }
 
-       parStartCommand(par, os, texrow,runparams, style);
+       parStartCommand(par, os, runparams, style);
 
        Font const outerfont = text.outerFont(pit);
 
        // FIXME UNICODE
        os << from_utf8(everypar);
-       par.latex(bparams, outerfont, os, texrow, runparams, start_pos, end_pos);
+       par.latex(bparams, outerfont, os, runparams, start_pos, end_pos);
 
        // Make sure that \\par is done with the font of the last
        // character if this has another size as the default.
@@ -780,10 +745,8 @@ void TeXOnePar(Buffer const & buf,
        if (par.allowParagraphCustomization()) {
                if (!par.params().spacing().isDefault()
                        && (runparams.isLastPar || !nextpar->hasSameLayout(par))) {
-                       if (pending_newline) {
+                       if (pending_newline)
                                os << '\n';
-                               texrow.newline();
-                       }
                        os << from_ascii(par.params().spacing().writeEnvirEnd(useSetSpace));
                        pending_newline = true;
                }
@@ -809,10 +772,9 @@ void TeXOnePar(Buffer const & buf,
                // we need to reset the language at the end of footnote or
                // float.
 
-               if (pending_newline) {
+               if (pending_newline)
                        os << '\n';
-                       texrow.newline();
-               }
+
                // when the paragraph uses CJK, the language has to be closed earlier
                if (font.language()->encoding()->package() != Encoding::CJK) {
                        if (lang_end_command.empty()) {
@@ -844,10 +806,8 @@ void TeXOnePar(Buffer const & buf,
        if (closing_rtl_ltr_environment)
                os << "}";
 
-       if (pending_newline) {
+       if (pending_newline)
                os << '\n';
-               texrow.newline();
-       }
 
        // if this is a CJK-paragraph and the next isn't, close CJK
        // also if the next paragraph is a multilingual environment (because of nesting)
@@ -871,10 +831,7 @@ void TeXOnePar(Buffer const & buf,
                                        break;
                                // end of main text
                                if (maintext) {
-                                       os << '\n';
-                                       texrow.newline();
-                                       os << "\\end{CJK}\n";
-                                       texrow.newline();
+                                       os << "\n\\end{CJK}\n";
                                // end of an inset
                                } else
                                        os << "\\end{CJK}";
@@ -927,7 +884,6 @@ void TeXOnePar(Buffer const & buf,
                    // http://www.mail-archive.com/lyx-devel@lists.lyx.org/msg145787.html
                    || nextpar->params().depth() != par.params().depth()) {
                        os << '\n';
-                       texrow.newline();
                }
        }
 
@@ -942,7 +898,6 @@ void TeXOnePar(Buffer const & buf,
 void latexParagraphs(Buffer const & buf,
                     Text const & text,
                     otexstream & os,
-                    TexRow & texrow,
                     OutputParams const & runparams,
                     string const & everypar)
 {
@@ -958,7 +913,6 @@ void latexParagraphs(Buffer const & buf,
            && bparams.encoding().package() == Encoding::CJK) {
                os << "\\begin{CJK}{" << from_ascii(bparams.encoding().latexName())
                << "}{" << from_ascii(bparams.fonts_cjk) << "}%\n";
-               texrow.newline();
                open_encoding_ = CJK;
        }
        // if "auto begin" is switched off, explicitly switch the
@@ -981,7 +935,6 @@ void latexParagraphs(Buffer const & buf,
                            << from_ascii(bparams.language->polyglossiaOpts())
                            << "]";
                os << '\n';
-               texrow.newline();
        }
 
        ParagraphList const & paragraphs = text.paragraphs();
@@ -1022,7 +975,6 @@ void latexParagraphs(Buffer const & buf,
                                        os << "\\begin{"
                                                        << from_ascii(tclass.titlename())
                                                        << "}\n";
-                                       texrow.newline();
                                }
                        }
                } else if (was_title && !already_title) {
@@ -1034,7 +986,6 @@ void latexParagraphs(Buffer const & buf,
                                os << "\\" << from_ascii(tclass.titlename())
                                                << "\n";
                        }
-                       texrow.newline();
                        already_title = true;
                        was_title = false;
                }
@@ -1042,15 +993,15 @@ void latexParagraphs(Buffer const & buf,
 
                if (!layout.isEnvironment() && par->params().leftIndent().zero()) {
                        // This is a standard top level paragraph, TeX it and continue.
-                       TeXOnePar(buf, text, pit, os, texrow, runparams, everypar);
+                       TeXOnePar(buf, text, pit, os, runparams, everypar);
                        continue;
                }
                
-               TeXEnvironementData const data = prepareEnvironement(buf, text, par,
-                       os, texrow, runparams);
+               TeXEnvironementData const data =
+                       prepareEnvironement(buf, text, par, os, runparams);
                // pit can be changed in TeXEnvironment.
-               TeXEnvironment(buf, text, runparams, pit, os, texrow);
-               finishEnvironement(os, texrow, runparams, data);
+               TeXEnvironment(buf, text, runparams, pit, os);
+               finishEnvironement(os, runparams, data);
        }
 
        if (pit == runparams.par_end) {
@@ -1058,7 +1009,6 @@ void latexParagraphs(Buffer const & buf,
                        // correctly terminated (because TeXOnePar does
                        // not add a \n in this case)
                        //os << '\n';
-                       //texrow.newline();
        }
 
        // It might be that we only have a title in this document
@@ -1070,7 +1020,6 @@ void latexParagraphs(Buffer const & buf,
                        os << "\\" << from_ascii(tclass.titlename())
                           << "\n";
                }
-               texrow.newline();
        }
 
        // if "auto end" is switched off, explicitly close the language at the end
@@ -1083,14 +1032,12 @@ void latexParagraphs(Buffer const & buf,
                                        "$$lang",
                                        mainlang))
                        << '\n';
-               texrow.newline();
        }
 
        // If the last paragraph is an environment, we'll have to close
        // CJK at the very end to do proper nesting.
        if (maintext && !is_child && open_encoding_ == CJK) {
                os << "\\end{CJK}\n";
-               texrow.newline();
                open_encoding_ = none;
        }
 
index ebb299a83543f005cb2b9e0511a51c83da1de970..d29c4b7f4781281344091c1feb8758e1dd584168 100644 (file)
@@ -35,7 +35,7 @@ class Text;
 /// \p optargs optional ones. If not enough required
 /// ones are given, we'll output: {}. The optional ones
 /// must all come first.
-int latexArgInsets(Paragraph const & par,
+void latexArgInsets(Paragraph const & par,
                otexstream & os, OutputParams const & runparams,
                unsigned int reqargs, unsigned int optargs);
 
@@ -47,7 +47,6 @@ int latexArgInsets(Paragraph const & par,
 void latexParagraphs(Buffer const & buf,
                     Text const & text,
                     otexstream & ofs,
-                    TexRow & texrow,
                     OutputParams const &,
                     std::string const & everypar = std::string());
 
@@ -64,7 +63,7 @@ std::pair<bool, int> switchEncoding(odocstream & os,
 void TeXOnePar(Buffer const & buf,
                   Text const & text,
                   pit_type pit,
-                  otexstream & os, TexRow & texrow,
+                  otexstream & os,
                   OutputParams const & runparams,
                   std::string const & everypar = std::string(),
                   int start_pos = -1, int end_pos = -1);
index 38053606185077a13c4d69241b8d167617c9ac23..56a78e832500fb15bcad9508e7ecfc5750dfa211 100644 (file)
@@ -412,7 +412,7 @@ void otexstream::put(char_type const & c)
        }
        os_.put(c);
        if (c == '\n') {
-               ++lines_;
+               texrow_.newline();
                canbreakline_ = false;
        } else
                canbreakline_ = true;
@@ -428,7 +428,7 @@ otexstream & operator<<(otexstream & ots, BreakLine)
        if (ots.canBreakLine()) {
                ots.os().put('\n');
                ots.canBreakLine(false);
-               ots.addLines(1);
+               ots.texrow().newline();
        }
        ots.protectSpace(false);
        return ots;
@@ -440,7 +440,7 @@ otexstream & operator<<(otexstream & ots, SafeBreakLine)
        if (ots.canBreakLine()) {
                ots.os() << "%\n";
                ots.canBreakLine(false);
-               ots.addLines(1);
+               ots.texrow().newline();
        }
        ots.protectSpace(false);
        return ots;
@@ -461,7 +461,7 @@ otexstream & operator<<(otexstream & ots, docstring const & s)
                ots.protectSpace(false);
        }
        ots.os() << s;
-       ots.addLines(count(s.begin(), s.end(), '\n'));
+       ots.texrow().newlines(count(s.begin(), s.end(), '\n'));
        ots.canBreakLine(s[len - 1] != '\n');
        return ots;
 }
@@ -481,7 +481,7 @@ otexstream & operator<<(otexstream & ots, char const * s)
                ots.protectSpace(false);
        }
        ots.os() << s;
-       ots.addLines(count(s, s + len, '\n'));
+       ots.texrow().newlines(count(s, s + len, '\n'));
        ots.canBreakLine(s[len - 1] != '\n');
        return ots;
 }
@@ -496,7 +496,7 @@ otexstream & operator<<(otexstream & ots, char c)
        }
        ots.os() << c;
        if (c == '\n')
-               ots.addLines(1);
+               ots.texrow().newline();
        ots.canBreakLine(c != '\n');
        return ots;
 }
index 40f8e004dbceaf624469b2a81cf25912c55c4fd4..08d7dd0e744355830ce10b98008931ddd9b03452 100644 (file)
@@ -12,6 +12,7 @@
 #ifndef LYX_DOCSTREAM_H
 #define LYX_DOCSTREAM_H
 
+#include "TexRow.h"
 #include "support/docstring.h"
 
 #if defined(_MSC_VER) && (_MSC_VER >= 1600) 
@@ -83,28 +84,26 @@ typedef std::basic_istringstream<char_type> idocstringstream;
 typedef std::basic_ostringstream<char_type> odocstringstream;
 
 /** Wrapper class for odocstream.
-    This class helps ensuring that no blank lines may be inadvertently output.
-    Use the special variables "breakln" and "safebreakln" as if they were
-    iomanip's to ensure that the next output will start at the beginning of
-    a line. Using "breakln", a '\n' char will be output if needed, while
-    using "safebreakln", "%\n" will be output if needed.
-    Use countLines() to retrieve the number of \n output since previous call.
+    This class is used to automatically count the lines of the exported latex
+    code and also to ensure that no blank lines may be inadvertently output.
+    To this end, use the special variables "breakln" and "safebreakln" as if
+    they were iomanip's to ensure that the next output will start at the
+    beginning of a line. Using "breakln", a '\n' char will be output if needed,
+    while using "safebreakln", "%\n" will be output if needed.
   */
 
 class otexstream {
 public:
        ///
-       explicit otexstream(odocstream & os)
-               : os_(os), lines_(0), canbreakline_(false), protectspace_(false)
-       {}
+       otexstream(odocstream & os, TexRow & texrow)
+               : os_(os), texrow_(texrow),
+                 canbreakline_(false), protectspace_(false) {}
        ///
        odocstream & os() { return os_; }
        ///
-       void put(char_type const & c);
-       ///
-       size_t countLines() { size_t l = lines_; lines_ = 0; return l; }
+       TexRow & texrow() { return texrow_; }
        ///
-       void addLines(size_t n) { lines_ += n; }
+       void put(char_type const & c);
        ///
        void canBreakLine(bool breakline) { canbreakline_ = breakline; }
        ///
@@ -117,7 +116,7 @@ private:
        ///
        odocstream & os_;
        ///
-       size_t lines_;
+       TexRow & texrow_;
        ///
        bool canbreakline_;
        ///
index 8f373d83edb59a699e8ef5e4a22978dfcfd02f5a..3984742f0baf71e80c47d65fdf1d04ad22f90e89 100644 (file)
@@ -58,6 +58,15 @@ namespace Alert {
 }
 
 
+// Dummy texrow support
+void TexRow::newline()
+{}
+
+
+void TexRow::newlines(int)
+{}
+
+
 // Dummy translation support
 Messages messages_;
 Messages const & getMessages(std::string const &)