change tracking:

* src/paragraph.h: rename erase() to eraseChars()
	for consistency with eraseChar()
	* src/paragraph_pimpl.h: dito; merge the two erase() methods
	* src/*.C: adjust properly


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15478 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Michael Schmitt 2006-10-22 14:36:08 +00:00
parent a10629dfc6
commit 0aaa8c5bcc
6 changed files with 42 additions and 45 deletions

View File

@ -309,7 +309,7 @@ PitPosPair eraseSelectionHelper(BufferParams const & params,
// Start and end is inside same paragraph
if (endpit == pit_type(pars.size()) ||
startpit == endpit) {
endpos -= pars[startpit].erase(startpos, endpos, false);
endpos -= pars[startpit].eraseChars(startpos, endpos, false);
return PitPosPair(endpit, endpos);
}
@ -325,7 +325,7 @@ PitPosPair eraseSelectionHelper(BufferParams const & params,
pos_type const right = ( pit == endpit ? endpos :
pars[pit].size() + 1 );
// Logical erase only:
pars[pit].erase(left, right, false);
pars[pit].eraseChars(left, right, false);
// Separate handling of para break:
if (merge && pit != endpit &&
(pit + 1 != endpit || pars[pit].hasSameLayout(pars[pit + 1]))) {
@ -363,11 +363,13 @@ void copySelectionHelper(Buffer const & buf, ParagraphList & pars,
// Cut out the end of the last paragraph.
Paragraph & back = paragraphs.back();
back.erase(end, back.size(), false);
// do not track deletion here; it is an internal action not visible to the user
back.eraseChars(end, back.size(), false);
// Cut out the begin of the first paragraph
Paragraph & front = paragraphs.front();
front.erase(0, start, false);
// again, do not track deletion
front.eraseChars(0, start, false);
theCuts.push(make_pair(paragraphs, tc));
}

View File

@ -184,7 +184,7 @@ int replaceAll(BufferView * bv,
pos_type pos = cur.pos();
LyXFont const font
= cur.paragraph().getFontSettings(buf.params(), pos);
int striked = ssize - cur.paragraph().erase(pos, pos + ssize,
int striked = ssize - cur.paragraph().eraseChars(pos, pos + ssize,
buf.params().trackChanges);
cur.paragraph().insert(pos, from_utf8(replacestr), font,
Change(buf.params().trackChanges ?

View File

@ -241,9 +241,9 @@ bool Paragraph::eraseChar(pos_type pos, bool trackChanges)
}
int Paragraph::erase(pos_type start, pos_type end, bool trackChanges)
int Paragraph::eraseChars(pos_type start, pos_type end, bool trackChanges)
{
return pimpl_->erase(start, end, trackChanges);
return pimpl_->eraseChars(start, end, trackChanges);
}

View File

@ -240,10 +240,10 @@ public:
///
void applyLayout(LyXLayout_ptr const & new_layout);
/// erase the char at the given position
/// (logically) erase the char at pos; return true if it was actually erased
bool eraseChar(pos_type pos, bool trackChanges);
/// erase the given range. Returns the number of chars actually erased
int erase(pos_type start, pos_type end, bool trackChanges);
/// (logically) erase the given range; return the number of chars actually erased
int eraseChars(pos_type start, pos_type end, bool trackChanges);
/** Get uninstantiated font setting. Returns the difference
between the characters font and the layoutfont.

View File

@ -151,7 +151,7 @@ void Paragraph::Pimpl::acceptChange(pos_type start, pos_type end)
// Suppress access to nonexistent
// "end-of-paragraph char":
if (i < size()) {
eraseChar(i);
eraseChar(i, false);
--end;
--i;
}
@ -181,7 +181,7 @@ void Paragraph::Pimpl::rejectChange(pos_type start, pos_type end)
case Change::INSERTED:
if (i < size()) {
eraseChar(i);
eraseChar(i, false);
--end;
--i;
}
@ -253,8 +253,29 @@ void Paragraph::Pimpl::insertInset(pos_type pos, InsetBase * inset,
}
void Paragraph::Pimpl::eraseChar(pos_type pos)
bool Paragraph::Pimpl::eraseChar(pos_type pos, bool trackChanges)
{
BOOST_ASSERT(pos <= size());
if (trackChanges) {
Change::Type changetype(changes_.lookup(pos).type);
if (changetype == Change::UNCHANGED) {
setChange(pos, Change(Change::DELETED));
return false;
}
if (changetype == Change::DELETED)
return false;
}
// Don't physically access nonexistent end-of-paragraph char
if (pos == size()) {
// FIXME: change tracking (MG)
// how do we handle end-of-pars previously marked inserted?
return false;
}
// track change
changes_.erase(pos);
@ -297,36 +318,12 @@ void Paragraph::Pimpl::eraseChar(pos_type pos)
// Update the insetlist
owner_->insetlist.decreasePosAfterPos(pos);
return true;
}
bool Paragraph::Pimpl::eraseChar(pos_type pos, bool trackChanges)
{
BOOST_ASSERT(pos <= size());
if (trackChanges) {
Change::Type changetype(changes_.lookup(pos).type);
if (changetype == Change::UNCHANGED) {
setChange(pos, Change(Change::DELETED));
return false;
}
if (changetype == Change::DELETED)
return false;
}
// Don't physically access nonexistent end-of-paragraph char
if (pos < size()) {
eraseChar(pos);
return true;
}
return false;
}
int Paragraph::Pimpl::erase(pos_type start, pos_type end, bool trackChanges)
int Paragraph::Pimpl::eraseChars(pos_type start, pos_type end, bool trackChanges)
{
pos_type i = start;
for (pos_type count = end - start; count; --count) {

View File

@ -60,12 +60,10 @@ public:
void insertChar(pos_type pos, value_type c, Change const & change);
///
void insertInset(pos_type pos, InsetBase * inset, Change const & change);
/// definite erase
void eraseChar(pos_type pos);
/// erase the given position. Returns true if it was actually erased
/// (logically) erase the char at pos; return true if it was actually erased
bool eraseChar(pos_type pos, bool trackChanges);
/// erase the given range
int erase(pos_type start, pos_type end, bool trackChanges);
/// (logically) erase the given range; return the number of chars actually erased
int eraseChars(pos_type start, pos_type end, bool trackChanges);
///
InsetBase * inset_owner;