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"
29 /// the type of change
31 UNCHANGED, // no change
33 DELETED // deleted text
36 explicit Change(Type t, int a = 0, time_type ct = current_time())
37 : type(t), author(a), changetime(ct) {}
39 /// is the change similar to the given change such that both can be merged?
40 bool isSimilarTo(Change const & change);
49 bool operator==(Change const & l, Change const & r);
50 bool operator!=(Change const & l, Change const & r);
54 /// set the pos to the given change
55 void set(Change const & change, pos_type pos);
56 /// set the range (excluding end) to the given change
57 void set(Change const & change, pos_type start, pos_type end);
59 /// erase the entry at pos and adjust all range bounds past it
60 /// (assumes that a character was deleted at pos)
61 void erase(lyx::pos_type pos);
63 /// insert a new entry at pos and adjust all range bounds past it
64 /// (assumes that a character was inserted at pos)
65 void insert(Change const & change, lyx::pos_type pos);
69 /// return the change at the given pos
70 Change const lookup(pos_type pos) const;
72 /// return true if there is a change in the given range (excluding end)
73 bool isChanged(pos_type start, pos_type end) const;
77 /// output latex to mark a transition between two change types
78 /// returns length of text outputted
79 static int latexMarkChange(odocstream & os, Change::Type oldChangeType,
80 Change::Type changeType, bool const & output);
82 /// output .lyx file format for transitions between changes
83 static void lyxMarkChange(std::ostream & os, int & column,
84 Change const & old, Change const & change);
89 Range(pos_type s, pos_type e)
92 // does this range contain r ?
93 bool contains(Range const & r) const;
95 // does this range contain pos ?
96 bool contains(pos_type pos) const;
98 // do the ranges intersect ?
99 bool intersects(Range const & r) const;
102 pos_type end; // Caution: end is not in the range!
105 friend bool operator==(Range const & r1, Range const & r2);
106 friend bool operator!=(Range const & r1, Range const & r2);
110 ChangeRange(Change const & c, Range const & r)
111 : change(c), range(r) {}
117 /// merge equal changes with adjoining ranges
120 typedef std::vector<ChangeRange> ChangeTable;
122 /// table of changes, every row a change and range descriptor