Compare: simplify the step functions.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@32927 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Vincent van Ravesteijn 2010-01-09 23:56:46 +00:00
parent 28b0075b11
commit c49dea81a9

View File

@ -34,35 +34,22 @@ enum Direction {
}; };
void step_forward(DocIterator & dit) static void step(DocIterator & dit, Direction direction)
{ {
if (direction == Forward)
dit.top().forwardPos(); dit.top().forwardPos();
} else
void step_backward(DocIterator & dit)
{
dit.top().backwardPos(); dit.top().backwardPos();
} }
bool step_forward(DocIterator & dit, DocIterator const & end) static void step(DocIterator & dit, DocIterator const & end, Direction direction)
{ {
if (dit == end) if (dit != end)
return false; step(dit, direction);
step_forward(dit);
return true;
} }
bool step_backward(DocIterator & dit, DocIterator const & beg)
{
if (dit == beg)
return false;
step_backward(dit);
return true;
}
/** /**
* A pair of two DocIterators that form a range. * A pair of two DocIterators that form a range.
*/ */
@ -138,15 +125,15 @@ public:
DocPair & operator++() DocPair & operator++()
{ {
step_forward(o); step(o, Forward);
step_forward(n); step(n, Forward);
return *this; return *this;
} }
DocPair & operator--() DocPair & operator--()
{ {
step_backward(o); step(o, Backward);
step_backward(n); step(n, Backward);
return *this; return *this;
} }
/// ///
@ -188,8 +175,8 @@ DocRangePair stepIntoInset(DocPair const & inset_location)
DocRangePair rp(inset_location, inset_location); DocRangePair rp(inset_location, inset_location);
rp.o.from.forwardPos(); rp.o.from.forwardPos();
rp.n.from.forwardPos(); rp.n.from.forwardPos();
step_forward(rp.o.to); step(rp.o.to, Forward);
step_forward(rp.n.to); step(rp.n.to, Forward);
rp.o.to.backwardPos(); rp.o.to.backwardPos();
rp.n.to.backwardPos(); rp.n.to.backwardPos();
return rp; return rp;