diff --git a/src/ChangeLog b/src/ChangeLog index 5ddbe2ce11..3b5eb6a648 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,11 @@ +2003-03-12 John Levon + + * author.h: + * author.C: + * bufferparams.h: + * bufferparams.C: + * paragraph_funcs.C: fix per-buffer authorlists + 2003-03-12 John Levon * text.C: fix newline in right address diff --git a/src/author.C b/src/author.C index aef006e535..45b36b4f15 100644 --- a/src/author.C +++ b/src/author.C @@ -12,20 +12,11 @@ #include "author.h" -#include "debug.h" - #include "support/LAssert.h" #include "support/LOstream.h" #include "support/LIstream.h" #include "support/lstrings.h" -using std::endl; - -namespace { - int cur_id; -} - - bool operator==(Author const & l, Author const & r) { return l.name() == r.name() && l.email() == r.email(); @@ -44,11 +35,16 @@ std::istream & operator>>(std::istream & is, Author & a) getline(is, s); a.name_ = trim(token(s, '\"', 1)); a.email_ = trim(token(s, '\"', 2)); - lyxerr << "Read name " << a.name_ << " email " << a.email_ << endl; return is; } +AuthorList::AuthorList() + : last_id_(0) +{ +} + + int AuthorList::record(Author const & a) { Authors::const_iterator it(authors_.begin()); @@ -59,16 +55,14 @@ int AuthorList::record(Author const & a) return it->first; } - lyxerr[Debug::CHANGES] << "Adding author " << a << endl; - - authors_[cur_id++] = a; - return cur_id - 1; + authors_[last_id_++] = a; + return last_id_ - 1; } void AuthorList::record(int id, Author const & a) { - lyx::Assert(id < authors_.size()); + lyx::Assert(unsigned(id) < authors_.size()); authors_[id] = a; } diff --git a/src/author.h b/src/author.h index 2764923d13..25421c6a1e 100644 --- a/src/author.h +++ b/src/author.h @@ -42,6 +42,8 @@ private: class AuthorList { public: + AuthorList(); + int record(Author const & a); void record(int id, Author const & a); @@ -55,6 +57,8 @@ public: Authors::const_iterator end() const; private: + int last_id_; + Authors authors_; }; diff --git a/src/bufferparams.C b/src/bufferparams.C index 3fc1794eb1..fd2a8eae06 100644 --- a/src/bufferparams.C +++ b/src/bufferparams.C @@ -189,7 +189,7 @@ string const BufferParams::readToken(LyXLex & lex, string const & token) istringstream ss(lex.getString()); Author a; ss >> a; - authorlist.record(a); + author_map.push_back(authorlist.record(a)); } else if (token == "\\paperorientation") { int tmpret = lex.findToken(string_orientation); if (tmpret == -1) diff --git a/src/bufferparams.h b/src/bufferparams.h index 8be76a23d0..cc81d5f816 100644 --- a/src/bufferparams.h +++ b/src/bufferparams.h @@ -24,6 +24,7 @@ #include "insets/insetquotes.h" #include +#include class LyXLex; class LatexFeatures; @@ -232,6 +233,9 @@ public: /// Time ago we agreed that this was a buffer property [ale990407] string parentname; + /// map of the file's author IDs to buffer author IDs + std::vector author_map; + private: /// the author list AuthorList authorlist; diff --git a/src/paragraph_funcs.C b/src/paragraph_funcs.C index 8fc4502846..271fbc20ce 100644 --- a/src/paragraph_funcs.C +++ b/src/paragraph_funcs.C @@ -945,7 +945,7 @@ int readParToken(Buffer & buf, Paragraph & par, LyXLex & lex, string const & tok lyx::time_type ct; istr >> aid; istr >> ct; - change = Change(Change::INSERTED, aid, ct); + change = Change(Change::INSERTED, bp.author_map[aid], ct); } else if (token == "\\change_deleted") { lex.nextToken(); istringstream istr(lex.getString()); @@ -953,7 +953,7 @@ int readParToken(Buffer & buf, Paragraph & par, LyXLex & lex, string const & tok lyx::time_type ct; istr >> aid; istr >> ct; - change = Change(Change::DELETED, aid, ct); + change = Change(Change::DELETED, bp.author_map[aid], ct); } else { lex.eatLine(); #if USE_BOOST_FORMAT