diff --git a/src/Author.h b/src/Author.h index dea4c10b34..6842cf35ca 100644 --- a/src/Author.h +++ b/src/Author.h @@ -26,7 +26,7 @@ public: Author() {} Author(docstring const & name, docstring const & email) - : name_(name), email_(email) {} + : name_(name), email_(email), used_(true) {} docstring const name() const { return name_; @@ -36,12 +36,22 @@ public: return email_; } + void used(bool u) const { + used_ = u; + } + + bool used() const { + return used_; + } + friend std::istream & operator>>(std::istream & os, Author & a); private: docstring name_; docstring email_; + + mutable bool used_; }; diff --git a/src/Buffer.cpp b/src/Buffer.cpp index 99f11ea31e..3fac1fc26e 100644 --- a/src/Buffer.cpp +++ b/src/Buffer.cpp @@ -846,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); diff --git a/src/BufferParams.cpp b/src/BufferParams.cpp index 01e17f967a..e2f5f2a26c 100644 --- a/src/BufferParams.cpp +++ b/src/BufferParams.cpp @@ -766,7 +766,10 @@ void BufferParams::writeFile(ostream & os) const AuthorList::Authors::const_iterator a_it = pimpl_->authorlist.begin(); AuthorList::Authors::const_iterator a_end = pimpl_->authorlist.end(); for (; a_it != a_end; ++a_it) { - os << "\\author " << a_it->second << "\n"; + if (a_it->second.used()) + os << "\\author " << a_it->second << "\n"; + else + os << "\\author " << Author() << "\n"; } } diff --git a/src/Changes.cpp b/src/Changes.cpp index 7ed02657a6..403009dd36 100644 --- a/src/Changes.cpp +++ b/src/Changes.cpp @@ -357,4 +357,13 @@ void Changes::lyxMarkChange(std::ostream & os, int & column, } +void Changes::checkAuthors(AuthorList const & authorList) +{ + ChangeTable::const_iterator it = table_.begin(); + ChangeTable::const_iterator endit = table_.end(); + for ( ; it != endit ; ++it) + if (it->change.type != Change::UNCHANGED) + authorList.get(it->change.author).used(true); +} + } // namespace lyx diff --git a/src/Changes.h b/src/Changes.h index 1915533e96..5305f55004 100644 --- a/src/Changes.h +++ b/src/Changes.h @@ -23,6 +23,7 @@ namespace lyx { +class AuthorList; class Change { public: @@ -85,6 +86,9 @@ public: static void lyxMarkChange(std::ostream & os, int & column, Change const & old, Change const & change); + /// + void checkAuthors(AuthorList const & authorList); + private: class Range { public: diff --git a/src/Paragraph.cpp b/src/Paragraph.cpp index de4021db3b..7a0c8bace2 100644 --- a/src/Paragraph.cpp +++ b/src/Paragraph.cpp @@ -210,7 +210,7 @@ public: /// ParagraphParameters params; -private: +//private: /// pos_type size() const { return owner_->size(); } /// match a string against a particular point in the paragraph @@ -2682,4 +2682,10 @@ int Paragraph::checkBiblio(bool track_changes) return 1; } + +void Paragraph::checkAuthors(AuthorList const & authorList) +{ + pimpl_->changes_.checkAuthors(authorList); +} + } // namespace lyx diff --git a/src/Paragraph.h b/src/Paragraph.h index ea1d679d7c..8fd17c2897 100644 --- a/src/Paragraph.h +++ b/src/Paragraph.h @@ -368,6 +368,10 @@ public: /// was previously past that position. Return 0 otherwise. int checkBiblio(bool track_changes); + /// For each author, set 'used' to true if there is a change + /// by this author in the paragraph. + void checkAuthors(AuthorList const & authorList); + public: /// InsetList insetlist; diff --git a/src/support/userinfo.cpp b/src/support/userinfo.cpp index a82c9592e5..c68d55ac3e 100644 --- a/src/support/userinfo.cpp +++ b/src/support/userinfo.cpp @@ -36,11 +36,6 @@ namespace support { docstring const user_name() { - //FIXME: quick fix wrt bug #3764; only Anonymous is detected now. - //The code after should be used only after user approval. - return from_ascii("Anonymous"); - - #if defined (_WIN32) char name[UNLEN + 1];