]> git.lyx.org Git - lyx.git/blobdiff - src/buffer.C
"Inter-word Space"
[lyx.git] / src / buffer.C
index 2e915abc33c2c44b86aa9d24414eb01518b040ff..2200f0dc84d9835d1c34e356a3d5ff6634ea5bf5 100644 (file)
@@ -368,16 +368,17 @@ int Buffer::readParagraph(LyXLex & lex, string const & token,
        if (token == "\\layout") {
                lex.pushToken(token);
 
-               Paragraph * par = new Paragraph();
-               par->params().depth(depth);
+               Paragraph par;
+               par.owningBuffer(*this);
+               par.params().depth(depth);
                if (params.tracking_changes)
-                       par->trackChanges();
+                       par.trackChanges();
                LyXFont f(LyXFont::ALL_INHERIT, params.language);
-               par->setFont(0, f);
+               par.setFont(0, f);
 
                // FIXME: goddamn InsetTabular makes us pass a Buffer
                // not BufferParams
-               unknown += ::readParagraph(*this, *par, lex);
+               unknown += ::readParagraph(*this, par, lex);
 
                // insert after
                if (pit != pars.end())
@@ -680,8 +681,8 @@ bool Buffer::writeFile(string const & fname) const
 
        // this will write out all the paragraphs
        // using recursive descent.
-       ParagraphList::iterator pit = paragraphs.begin();
-       ParagraphList::iterator pend = paragraphs.end();
+       ParagraphList::const_iterator pit = paragraphs.begin();
+       ParagraphList::const_iterator pend = paragraphs.end();
        for (; pit != pend; ++pit)
                pit->write(this, ofs, params, depth);
 
@@ -952,7 +953,7 @@ void Buffer::writeFileAscii(ostream & os, int linelen)
 void Buffer::makeLaTeXFile(string const & fname,
                           string const & original_path,
                           LatexRunParams const & runparams,
-                          bool nice, bool only_body, bool only_preamble)
+                          bool only_body, bool only_preamble)
 {
        lyxerr[Debug::LATEX] << "makeLaTeXFile..." << endl;
 
@@ -966,7 +967,7 @@ void Buffer::makeLaTeXFile(string const & fname,
        }
 
        makeLaTeXFile(ofs, original_path,
-                     runparams, nice, only_body, only_preamble);
+                     runparams, only_body, only_preamble);
 
        ofs.close();
        if (ofs.fail()) {
@@ -977,10 +978,11 @@ void Buffer::makeLaTeXFile(string const & fname,
 
 void Buffer::makeLaTeXFile(ostream & os,
                           string const & original_path,
-                          LatexRunParams const & runparams,
-                          bool nice, bool only_body, bool only_preamble)
+                          LatexRunParams const & runparams_in,
+                          bool only_body, bool only_preamble)
 {
-       niceFile = nice; // this will be used by Insetincludes.
+       LatexRunParams runparams = runparams_in;
+       niceFile = runparams.nice; // this will be used by Insetincludes.
 
        // validate the buffer.
        lyxerr[Debug::LATEX] << "  Validating buffer..." << endl;
@@ -993,7 +995,7 @@ void Buffer::makeLaTeXFile(ostream & os,
        // first paragraph of the document. (Asger)
        texrow.start(paragraphs.begin()->id(), 0);
 
-       if (!only_body && nice) {
+       if (!only_body && runparams.nice) {
                os << "%% " << lyx_docversion << " created this file.  "
                        "For more info, see http://www.lyx.org/.\n"
                        "%% Do not edit unless you really know what "
@@ -1010,7 +1012,7 @@ void Buffer::makeLaTeXFile(ostream & os,
        // original_path is set. This is done for usual tex-file, but not
        // for nice-latex-file. (Matthias 250696)
        if (!only_body) {
-               if (!nice) {
+               if (!runparams.nice) {
                        // code for usual, NOT nice-latex-file
                        os << "\\batchmode\n"; // changed
                        // from \nonstopmode
@@ -1029,7 +1031,7 @@ void Buffer::makeLaTeXFile(ostream & os,
                }
 
                // Write the preamble
-               params.writeLaTeX(os, features, texrow);
+               runparams.use_babel = params.writeLaTeX(os, features, texrow);
 
                if (only_preamble)
                        return;
@@ -1047,7 +1049,7 @@ void Buffer::makeLaTeXFile(ostream & os,
                texrow.newline();
        }
 
-       latexParagraphs(this, paragraphs, os, texrow, runparams, false);
+       latexParagraphs(this, paragraphs, os, texrow, runparams);
 
        // add this just in case after all the paragraphs
        os << endl;
@@ -1957,13 +1959,11 @@ int Buffer::runChktex()
        Path p(path); // path to LaTeX file
        users->owner()->message(_("Running chktex..."));
 
-       // Remove all error insets
-       bool const removedErrorInsets = users->removeAutoInsets();
-
        // Generate the LaTeX file if neccessary
        LatexRunParams runparams;
        runparams.flavor = LatexRunParams::LATEX;
-       makeLaTeXFile(name, org_path, runparams, false);
+       runparams.nice = false;
+       makeLaTeXFile(name, org_path, runparams);
 
        TeXErrors terr;
        Chktex chktex(lyxrc.chktex_command, name, filePath());
@@ -1979,13 +1979,6 @@ int Buffer::runChktex()
                users->showErrorList(_("ChkTeX"));
        }
 
-       // if we removed error insets before we ran chktex or if we inserted
-       // error insets after we ran chktex, this must be run:
-       if (removedErrorInsets || res) {
-#warning repaint needed here, or do you mean update() ?
-               users->repaint();
-               users->fitCursor();
-       }
        users->owner()->busy(false);
 
        return res;
@@ -2211,8 +2204,8 @@ Inset * Buffer::getInsetFromID(int id_arg) const
 ParIterator Buffer::getParFromID(int id) const
 {
 #warning FIXME: const correctness! (Andre)
-       ParIterator it(const_cast<Buffer*>(this)->par_iterator_begin());
-       ParIterator end(const_cast<Buffer*>(this)->par_iterator_end());
+       ParIterator it = const_cast<Buffer*>(this)->par_iterator_begin();
+       ParIterator end = const_cast<Buffer*>(this)->par_iterator_end();
 
 #warning FIXME, perhaps this func should return a ParIterator? (Lgb)
        if (id < 0) {
@@ -2261,13 +2254,13 @@ ParIterator Buffer::par_iterator_end()
 
 ParConstIterator Buffer::par_iterator_begin() const
 {
-       return ParConstIterator(paragraphs.begin(), paragraphs);
+       return ParConstIterator(const_cast<ParagraphList&>(paragraphs).begin(), paragraphs);
 }
 
 
 ParConstIterator Buffer::par_iterator_end() const
 {
-       return ParConstIterator(paragraphs.end(), paragraphs);
+       return ParConstIterator(const_cast<ParagraphList&>(paragraphs).end(), paragraphs);
 }
 
 
@@ -2390,7 +2383,7 @@ void Buffer::setParentName(string const & name)
 
 
 Buffer::inset_iterator::inset_iterator()
-       : pit(0), pend(0)
+       : pit(), pend()
 {}
 
 
@@ -2424,13 +2417,13 @@ Buffer::inset_iterator Buffer::inset_iterator::operator++(int)
 
 Buffer::inset_iterator::reference Buffer::inset_iterator::operator*()
 {
-       return *it.getInset();
+       return *it->inset;
 }
 
 
 Buffer::inset_iterator::pointer Buffer::inset_iterator::operator->()
 {
-       return it.getInset();
+       return it->inset;
 }
 
 
@@ -2442,7 +2435,7 @@ ParagraphList::iterator Buffer::inset_iterator::getPar() const
 
 lyx::pos_type Buffer::inset_iterator::getPos() const
 {
-       return it.getPos();
+       return it->pos;
 }