}
-bool Changes::Range::contained(Range const & r) const
-{
- return r.contains(*this);
-}
-
-
bool Changes::Range::contains(pos_type const pos) const
{
return pos >= start && pos < end;
}
-bool Changes::Range::containsOrPrecedes(pos_type const pos) const
-{
- return pos >= start && pos <= end;
-}
-
-
bool Changes::Range::intersects(Range const & r) const
{
- return contained(r) || contains(r)
- || contains(r.start) || contains(r.end);
+ return r.start < end && r.end > start; // end itself is not in the range!
}
del(change, pos);
break;
case Change::UNCHANGED:
- set(Change::UNCHANGED, pos);
+ // FIXME: change tracking (MG)
+ // set(Change::UNCHANGED, pos);
break;
}
}
}
-void Changes::set(Change::Type const type, pos_type const pos)
-{
- set(type, pos, pos + 1);
-}
-
-
-void Changes::set(Change::Type const type,
- pos_type const start, pos_type const end)
-{
- set(Change(type), start, end);
-}
-
-
void Changes::set(Change const & change,
pos_type const start, pos_type const end)
{
// remove all sub-ranges
for (; it != table_.end();) {
- if (new_range != it->range && it->range.contained(new_range)) {
+ if (new_range != it->range /*&& it->range.contained(new_range)*/) { // FIXME: change tracking (MG)
if (lyxerr.debugging(Debug::CHANGES)) {
lyxerr[Debug::CHANGES] << "Removing subrange "
<< it->range.start << "," << it->range.end << endl;
}
}
- check();
merge();
}
--range.end;
}
}
- check();
merge();
}
erase(pos);
}
break;
- } else if (range.containsOrPrecedes(pos) && it + 1 == table_.end()) {
+ } else if (/*range.containsOrPrecedes(pos) && it + 1 == table_.end()*/ true) { // FIXME: change tracking (MG)
// this case happens when building from .lyx
set(change, pos);
break;
for (; it != end; ++it) {
Range & range(it->range);
- if (!found && range.containsOrPrecedes(pos)) {
+ if (!found /* && range.containsOrPrecedes(pos)*/) { // FIXME: change tracking (MG)
found = true;
if (lyxerr.debugging(Debug::CHANGES)) {
lyxerr[Debug::CHANGES] << "Found range of "
return it->change;
}
- check();
BOOST_ASSERT(false && "missing changes for pos");
return Change(Change::UNCHANGED);
}
}
lyxerr[Debug::CHANGES] << "Merge ended" << endl;
- check();
-}
-
-
-void Changes::check() const
-{
- ChangeTable::const_iterator it = table_.begin();
- ChangeTable::const_iterator end = table_.end();
-
- bool dont_assert = true;
-
- lyxerr[Debug::CHANGES] << "Changelist:" << endl;
- for (; it != end; ++it) {
- if (lyxerr.debugging(Debug::CHANGES)) {
- lyxerr[Debug::CHANGES] << "Range of type " << it->change.type << " is "
- << it->range.start << "," << it->range.end << " author "
- << it->change.author << " time " << it->change.changetime << endl;
- }
-
- if (it + 1 == end)
- break;
-
- Range const & range(it->range);
- Range const & next((it + 1)->range);
- if (range.end != next.start)
- dont_assert = false;
- }
-
- if (lyxerr.debugging(Debug::CHANGES))
- lyxerr[Debug::CHANGES] << "End" << endl;
-
- BOOST_ASSERT(dont_assert);
}
* Licence details can be found in the file COPYING.
*
* \author John Levon
+ * \author Michael Gerz
*
* Full author contact details are available in file CREDITS.
*
empty_type_ = type;
}
- /// set the position to the given change
+ /// set the pos to the given change
void set(Change const & change, lyx::pos_type pos);
- /// set the position to the given change
- void set(Change::Type, lyx::pos_type pos);
-
- /// set the range to the given change
- void set(Change::Type, lyx::pos_type start, lyx::pos_type end);
-
/// set the range to the given change
void set(Change const & change, lyx::pos_type start, lyx::pos_type end);
// does this range contain pos ?
bool contains(lyx::pos_type pos) const;
- // does this range contain pos, or can it be appended ?
- bool containsOrPrecedes(lyx::pos_type pos) const;
-
- // is this range contained within r ?
- bool contained(Range const & r) const;
-
// do the ranges intersect ?
bool intersects(Range const & r) const;
lyx::pos_type start;
- lyx::pos_type end;
+ lyx::pos_type end; // Caution: end is not in the range!
};
friend bool operator==(Range const & r1, Range const & r2);
/// merge neighbouring ranges, assuming that they are abutting
/// (as done by set())
void merge();
-
- /// consistency check, needed before merge()
- void check() const;
-
};
#endif // CHANGES_H