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 = 0)
37 : type(t), author(a), changetime(ct) {}
46 bool operator==(Change const & l, Change const & r);
47 bool operator!=(Change const & l, Change const & r);
51 /// set the pos to the given change
52 void set(Change const & change, pos_type pos);
53 /// set the range to the given change
54 void set(Change const & change, pos_type start, pos_type end);
56 /// return the change at the given position
57 Change const lookup(pos_type pos) const;
59 /// return true if there is a change in the given range
60 bool isChanged(pos_type start, pos_type end) const;
62 /// remove the given entry. This implies that a character was
63 /// deleted at pos, and will adjust all range bounds past it
64 void erase(pos_type pos);
66 /// output latex to mark a transition between two changetypes
67 /// returns length of text outputted
68 static int latexMarkChange(odocstream & os, Change::Type old,
69 Change::Type change, bool const & output);
71 /// output .lyx file format for transitions between changes
72 static void lyxMarkChange(std::ostream & os, int & column,
73 time_type curtime, Change const & old, Change const & change);
78 Range(pos_type s, pos_type e)
81 // does this range contain r ?
82 bool contains(Range const & r) const;
84 // does this range contain pos ?
85 bool contains(pos_type pos) const;
87 // do the ranges intersect ?
88 bool intersects(Range const & r) const;
91 pos_type end; // Caution: end is not in the range!
94 friend bool operator==(Range const & r1, Range const & r2);
95 friend bool operator!=(Range const & r1, Range const & r2);
99 ChangeRange(Change const & c, Range const & r)
100 : change(c), range(r) {}
106 /// merge neighbouring ranges, assuming that they are abutting
109 typedef std::vector<ChangeRange> ChangeTable;
111 /// table of changes, every row a change and range descriptor