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/docstream.h"
19 #include "support/lyxtime.h"
30 /// the type of change
32 UNCHANGED, // no change
34 DELETED // deleted text
37 explicit Change(Type t, int a = 0, time_type ct = current_time())
38 : type(t), author(a), changetime(ct) {}
40 /// is the change similar to the given change such that both can be merged?
41 bool isSimilarTo(Change const & change);
50 bool operator==(Change const & l, Change const & r);
51 bool operator!=(Change const & l, Change const & r);
57 /// set the pos to the given change
58 void set(Change const & change, pos_type pos);
59 /// set the range (excluding end) to the given change
60 void set(Change const & change, pos_type start, pos_type end);
62 /// erase the entry at pos and adjust all range bounds past it
63 /// (assumes that a character was deleted at pos)
64 void erase(lyx::pos_type pos);
66 /// insert a new entry at pos and adjust all range bounds past it
67 /// (assumes that a character was inserted at pos)
68 void insert(Change const & change, lyx::pos_type pos);
72 /// return the change at the given pos
73 Change const & lookup(pos_type pos) const;
75 /// return true if there is a change in the given range (excluding end)
76 bool isChanged(pos_type start, pos_type end) const;
80 /// output latex to mark a transition between two change types
81 /// returns length of text outputted
82 static int latexMarkChange(odocstream & os, BufferParams const & bparams,
83 Change const & oldChange, Change const & change);
85 /// output .lyx file format for transitions between changes
86 static void lyxMarkChange(std::ostream & os, int & column,
87 Change const & old, Change const & change);
90 void checkAuthors(AuthorList const & authorList);
95 Range(pos_type s, pos_type e)
98 // does this range contain r ? (inlined as the result of profiling)
99 bool contains(Range const & r) const {
100 return r.start >= start && r.end <= end;
103 // does this range contain pos ? (inlined as the result of profiling)
104 bool contains(pos_type pos) const {
105 return pos >= start && pos < end;
108 // do the ranges intersect ?
109 bool intersects(Range const & r) const;
112 pos_type end; // Caution: end is not in the range!
115 friend bool operator==(Range const & r1, Range const & r2);
116 friend bool operator!=(Range const & r1, Range const & r2);
120 ChangeRange(Change const & c, Range const & r)
121 : change(c), range(r) {}
127 /// merge equal changes with adjoining ranges
130 typedef std::vector<ChangeRange> ChangeTable;
132 /// table of changes, every row a change and range descriptor