]> git.lyx.org Git - features.git/commitdiff
* src/Author.h:
authorMichael Schmitt <michael.schmitt@teststep.org>
Mon, 9 Jul 2007 20:52:34 +0000 (20:52 +0000)
committerMichael Schmitt <michael.schmitt@teststep.org>
Mon, 9 Jul 2007 20:52:34 +0000 (20:52 +0000)
* src/Changes.cpp:
* src/support/userinfo.cpp:
* src/Paragraph.cpp:
* src/Changes.h:
* src/Buffer.cpp:
* src/Paragraph.h:
* src/BufferParams.cpp: do not save the name of authors
in LyX documents, who have not made a single change in
change tracking mode

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@19019 a592a061-630c-0410-9148-cb99ea01b6c8

src/Author.h
src/Buffer.cpp
src/BufferParams.cpp
src/Changes.cpp
src/Changes.h
src/Paragraph.cpp
src/Paragraph.h
src/support/userinfo.cpp

index dea4c10b3419beb102f3679f26d3f217a821331e..6842cf35caa217ca9ce05cdb5511fa62f8c49f61 100644 (file)
@@ -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 99f11ea31eb2b7cd71d8b63d1d356ac7f78d95ba..3fac1fc26e5c1fa535917414667f6217e2e21219 100644 (file)
@@ -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 01e17f967a3187072f8e3186351aedbc587fec11..e2f5f2a26c487bd746bf68b005e76b0095d74a86 100644 (file)
@@ -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";
        }
 }
 
index 7ed02657a6a64c4eb681c8c69eb32fc39226a238..403009dd366db9dcffb40bab29442c8167a6e2a8 100644 (file)
@@ -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
index 1915533e960f4346654cf86f646a16b125774dc2..5305f55004ca6f52a075291aa9152203b8946f0d 100644 (file)
@@ -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 de4021db3be9e3f178119f467327a28d08e7c7c9..7a0c8bace260829a4311c1983ccf182f73a7f54c 100644 (file)
@@ -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
index ea1d679d7c056a425f8ce51d607d9c1876d7c8a2..8fd17c2897dacdda25679b6a518fcfba14e0d380 100644 (file)
@@ -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 a82c9592e5195066d9b1cd2e4d8578d2a2a3978c..c68d55ac3e02b27d001b1496259142bba74ff605 100644 (file)
@@ -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];