Fix some outline bugs:

http://bugzilla.lyx.org/show_bug.cgi?id=4686
http://bugzilla.lyx.org/show_bug.cgi?id=4703

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@24410 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Abdelrazak Younes 2008-04-21 08:22:52 +00:00
parent 012ef00a3f
commit 61c4dc2af8

View File

@ -286,6 +286,9 @@ static void outline(OutlineOp mode, Cursor & cur)
switch (mode) {
case OutlineUp: {
if (start == pars.begin())
// Nothing to move.
return;
ParagraphList::iterator dest = start;
// Move out (up) from this header
if (dest == bgn)
@ -311,10 +314,22 @@ static void outline(OutlineOp mode, Cursor & cur)
return;
}
case OutlineDown: {
ParagraphList::iterator dest = finish;
if (finish == end)
// Nothing to move.
return;
// Go one down from *this* header:
ParagraphList::iterator dest = boost::next(finish, 1);
// Go further down to find header to insert in front of:
for (; dest != end; ++dest) {
toclevel = dest->layout().toclevel;
if (toclevel != Layout::NOT_IN_TOC
&& toclevel <= thistoclevel) {
break;
}
}
// One such was found:
pit_type newpit = distance(bgn, dest);
pit_type const len = distance(start, finish);
pit_type newpit = std::distance(bgn, dest);
pit_type const len = std::distance(start, finish);
buf.undo().recordUndo(cur, ATOMIC_UNDO, pit, newpit - 1);
pars.insert(dest, start, finish);
start = boost::next(bgn, pit);