change tracking:

* changes.h:
	* changes.C: remove record(), del(), and add()
	* paragraph_pimpl.C: comment out method calls
	


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15447 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Michael Schmitt 2006-10-21 12:54:29 +00:00
parent ccd9433f4c
commit f70d9515cb
3 changed files with 5 additions and 96 deletions

View File

@ -67,29 +67,6 @@ bool Changes::Range::intersects(Range const & r) const
}
void Changes::record(Change const & change, pos_type const pos)
{
if (lyxerr.debugging(Debug::CHANGES)) {
lyxerr[Debug::CHANGES] << "record " << change.type
<< " at pos " << pos << " with total "
<< table_.size() << " changes." << endl;
}
switch (change.type) {
case Change::INSERTED:
add(change, pos);
break;
case Change::DELETED:
del(change, pos);
break;
case Change::UNCHANGED:
// FIXME: change tracking (MG)
// set(Change::UNCHANGED, pos);
break;
}
}
void Changes::set(Change const & change, pos_type const pos)
{
set(change, pos, pos + 1);
@ -211,64 +188,6 @@ void Changes::erase(pos_type const pos)
}
void Changes::del(Change const & change, ChangeTable::size_type const pos)
{
// this case happens when building from .lyx
if (table_.empty()) {
set(change, pos);
return;
}
ChangeTable::iterator it = table_.begin();
for (; it != table_.end(); ++it) {
Range & range(it->range);
if (range.contains(pos)) {
if (it->change.type != Change::INSERTED) {
set(change, pos);
} else {
erase(pos);
}
break;
} 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;
}
}
}
void Changes::add(Change const & change, ChangeTable::size_type const pos)
{
ChangeTable::iterator it = table_.begin();
ChangeTable::iterator end = table_.end();
bool found = false;
for (; it != end; ++it) {
Range & range(it->range);
if (!found /* && range.containsOrPrecedes(pos)*/) { // FIXME: change tracking (MG)
found = true;
if (lyxerr.debugging(Debug::CHANGES)) {
lyxerr[Debug::CHANGES] << "Found range of "
<< range.start << "," << range.end << endl;
}
++range.end;
continue;
}
if (found) {
++range.start;
++range.end;
}
}
set(change, pos);
}
Change const Changes::lookup(pos_type const pos) const
{
ChangeTable::const_iterator it = table_.begin();

View File

@ -53,9 +53,6 @@ public:
/// set the range to the given change
void set(Change const & change, pos_type start, pos_type end);
/// mark the given change and adjust
void record(Change const & change, pos_type pos);
/// return the change at the given position
Change const lookup(pos_type pos) const;
@ -105,20 +102,13 @@ private:
Change change;
};
/// merge neighbouring ranges, assuming that they are abutting
void merge();
typedef std::vector<ChangeRange> ChangeTable;
/// our table of changes, every row a range and change descriptor
ChangeTable table_;
/// handle a delete, either logical or physical (see erase)
void del(Change const & change, ChangeTable::size_type pos);
/// handle an add, adjusting range bounds past it
void add(Change const & change, ChangeTable::size_type pos);
/// merge neighbouring ranges, assuming that they are abutting
/// (as done by set())
void merge();
};

View File

@ -218,7 +218,7 @@ void Paragraph::Pimpl::insertChar(pos_type pos, value_type c, Change const & cha
// FIXME: change tracking (MG)
if (false) {
changes_.record(change, pos);
// changes_.record(change, pos);
}
// This is actually very common when parsing buffers (and
@ -319,7 +319,7 @@ bool Paragraph::Pimpl::erase(pos_type pos, bool /*trackChanges*/)
// only allow the actual removal if it was /new/ text
if (changetype != Change::INSERTED) {
changes_.record(Change(Change::DELETED), pos);
// changes_.record(Change(Change::DELETED), pos);
if (pos < size() && owner_->isInset(pos))
// FIXME: change tracking (MG)
owner_->getInset(pos)->setChange(Change(Change::DELETED));