]> git.lyx.org Git - lyx.git/blobdiff - src/Buffer.cpp
Patch by Richard Heck:
[lyx.git] / src / Buffer.cpp
index 15246e680d45e7838bdc048e9f72f7ff896280a3..3fac1fc26e5c1fa535917414667f6217e2e21219 100644 (file)
@@ -142,7 +142,7 @@ using std::string;
 
 namespace {
 
-int const LYX_FORMAT = 271;
+int const LYX_FORMAT = 276;
 
 } // namespace anon
 
@@ -193,6 +193,9 @@ public:
 
        ///
        TocBackend toc_backend;
+
+       /// Container for all sort of Buffer dependant errors.
+       map<string, ErrorList> errorLists;
 };
 
 
@@ -433,7 +436,7 @@ int Buffer::readHeader(Lexer & lex)
                params().temp_bullet(i) = ITEMIZE_DEFAULTS[i];
        }
 
-       ErrorList & errorList = errorLists_["Parse"];
+       ErrorList & errorList = pimpl_->errorLists["Parse"];
 
        while (lex.isOK()) {
                lex.next();
@@ -484,7 +487,7 @@ int Buffer::readHeader(Lexer & lex)
 // Returns false if "\end_document" is not read (Asger)
 bool Buffer::readDocument(Lexer & lex)
 {
-       ErrorList & errorList = errorLists_["Parse"];
+       ErrorList & errorList = pimpl_->errorLists["Parse"];
        errorList.clear();
 
        lex.next();
@@ -843,6 +846,19 @@ bool Buffer::write(ostream & ofs) const
            << "\\lyxformat " << LYX_FORMAT << "\n"
            << "\\begin_document\n";
 
+
+       /// For each author, set 'used' to true if there is a change
+       /// by this author in the document; otherwise set it to 'false'.
+       AuthorList::Authors::const_iterator a_it = params().authors().begin();
+       AuthorList::Authors::const_iterator a_end = params().authors().end();
+       for (; a_it != a_end; ++a_it)
+               a_it->second.used(false);
+
+       ParIterator const end = par_iterator_end();
+       ParIterator it = par_iterator_begin();
+       for ( ; it != end; ++it)
+               it->checkAuthors(params().authors());
+
        // now write out the buffer parameters.
        ofs << "\\begin_header\n";
        params().writeFile(ofs);
@@ -1211,7 +1227,7 @@ int Buffer::runChktex()
                Alert::error(_("chktex failure"),
                             _("Could not run chktex successfully."));
        } else if (res > 0) {
-               ErrorList & errorList = errorLists_["ChkTeX"];
+               ErrorList & errorList = pimpl_->errorLists["ChkTeX"];
                // Clear out old errors
                errorList.clear();
                // Fill-in the error list with the TeX errors
@@ -1613,7 +1629,11 @@ bool Buffer::isReadonly() const
 
 void Buffer::setParentName(string const & name)
 {
-       params().parentname = name;
+       if (name == pimpl_->filename.absFilename())
+               // Avoids recursive include.
+               params().parentname.clear();
+       else
+               params().parentname = name;
 }
 
 
@@ -1774,8 +1794,8 @@ void Buffer::getSourceCode(odocstream & os, pit_type par_begin,
 ErrorList const & Buffer::errorList(string const & type) const
 {
        static ErrorList const emptyErrorList;
-       std::map<string, ErrorList>::const_iterator I = errorLists_.find(type);
-       if (I == errorLists_.end())
+       std::map<string, ErrorList>::const_iterator I = pimpl_->errorLists.find(type);
+       if (I == pimpl_->errorLists.end())
                return emptyErrorList;
 
        return I->second;
@@ -1784,7 +1804,7 @@ ErrorList const & Buffer::errorList(string const & type) const
 
 ErrorList & Buffer::errorList(string const & type)
 {
-       return errorLists_[type];
+       return pimpl_->errorLists[type];
 }