4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
10 * Full author contact details are available in file CREDITS.
12 * Record changes in a paragraph.
18 #include "support/strfwd.h"
19 #include "support/types.h"
20 #include "support/lyxtime.h"
31 /// the type of change
33 UNCHANGED, // no change
35 DELETED // deleted text
38 explicit Change(Type t, int a = 0, time_t ct = current_time())
39 : type(t), author(a), changetime(ct) {}
41 /// is the change similar to the given change such that both can be merged?
42 bool isSimilarTo(Change const & change);
51 bool operator==(Change const & l, Change const & r);
52 bool operator!=(Change const & l, Change const & r);
58 /// set the pos to the given change
59 void set(Change const & change, pos_type pos);
60 /// set the range (excluding end) to the given change
61 void set(Change const & change, pos_type start, pos_type end);
63 /// erase the entry at pos and adjust all range bounds past it
64 /// (assumes that a character was deleted at pos)
65 void erase(lyx::pos_type pos);
67 /// insert a new entry at pos and adjust all range bounds past it
68 /// (assumes that a character was inserted at pos)
69 void insert(Change const & change, lyx::pos_type pos);
73 /// return the change at the given pos
74 Change const & lookup(pos_type pos) const;
76 /// return true if there is a change in the given range (excluding end)
77 bool isChanged(pos_type start, pos_type end) const;
81 /// output latex to mark a transition between two change types
82 /// returns length of text outputted
83 static int latexMarkChange(odocstream & os, BufferParams const & bparams,
84 Change const & oldChange, Change const & change);
86 /// output .lyx file format for transitions between changes
87 static void lyxMarkChange(std::ostream & os, int & column,
88 Change const & old, Change const & change);
91 void checkAuthors(AuthorList const & authorList);
96 Range(pos_type s, pos_type e)
99 // does this range contain r ? (inlined as the result of profiling)
100 bool contains(Range const & r) const {
101 return r.start >= start && r.end <= end;
104 // does this range contain pos ? (inlined as the result of profiling)
105 bool contains(pos_type pos) const {
106 return pos >= start && pos < end;
109 // do the ranges intersect ?
110 bool intersects(Range const & r) const;
113 pos_type end; // Caution: end is not in the range!
116 friend bool operator==(Range const & r1, Range const & r2);
117 friend bool operator!=(Range const & r1, Range const & r2);
121 ChangeRange(Change const & c, Range const & r)
122 : change(c), range(r) {}
128 /// merge equal changes with adjoining ranges
131 typedef std::vector<ChangeRange> ChangeTable;
133 /// table of changes, every row a change and range descriptor