>>>>> "Jean-Marc" == Jean-Marc Lasgouttes <[EMAIL PROTECTED]> writes:
>>>>> "Jean-Marc" == Jean-Marc Lasgouttes <[EMAIL PROTECTED]> writes: Jean-Marc> A const method should return a const object. If you want to Jean-Marc> go this route, the best may be to declare 'used_' as Jean-Marc> mutable. Jean-Marc> Something like that. I tested briefly with 3 different Jean-Marc> authors, and I think something is wrong (I think it was Jean-Marc> already wrong before, actually). I do not see how current Jean-Marc> author could always be index 0 (which is written in the Jean-Marc> file) if the file is really edited by several authors. I meant like _that_. JMarc
Index: src/Author.h =================================================================== --- src/Author.h (révision 18984) +++ src/Author.h (copie de travail) @@ -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_; }; Index: src/Changes.cpp =================================================================== --- src/Changes.cpp (révision 18984) +++ src/Changes.cpp (copie de travail) @@ -357,4 +357,13 @@ void Changes::lyxMarkChange(std::ostream } +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 Index: src/support/userinfo.cpp =================================================================== --- src/support/userinfo.cpp (révision 18984) +++ src/support/userinfo.cpp (copie de travail) @@ -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]; Index: src/Paragraph.cpp =================================================================== --- src/Paragraph.cpp (révision 18984) +++ src/Paragraph.cpp (copie de travail) @@ -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 @@ -2670,4 +2670,10 @@ int Paragraph::checkBiblio(bool track_ch return 1; } + +void Paragraph::checkAuthors(AuthorList const & authorList) +{ + pimpl_->changes_.checkAuthors(authorList); +} + } // namespace lyx Index: src/Changes.h =================================================================== --- src/Changes.h (révision 18984) +++ src/Changes.h (copie de travail) @@ -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: Index: src/Buffer.cpp =================================================================== --- src/Buffer.cpp (révision 18984) +++ src/Buffer.cpp (copie de travail) @@ -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); Index: src/Paragraph.h =================================================================== --- src/Paragraph.h (révision 18984) +++ src/Paragraph.h (copie de travail) @@ -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; Index: src/BufferParams.cpp =================================================================== --- src/BufferParams.cpp (révision 18984) +++ src/BufferParams.cpp (copie de travail) @@ -766,7 +766,10 @@ void BufferParams::writeFile(ostream & o 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"; } }