mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-06 00:10:59 +00:00
parlistize incDepth()
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6684 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
6ce86e2bfe
commit
436098170f
@ -1,3 +1,7 @@
|
|||||||
|
2003-04-02 John Levon <levon@movementarian.org>
|
||||||
|
|
||||||
|
* text2.C: make incDepth() use parlist
|
||||||
|
|
||||||
2003-04-02 Lars Gullik Bjønnes <larsbj@gullik.net>
|
2003-04-02 Lars Gullik Bjønnes <larsbj@gullik.net>
|
||||||
|
|
||||||
* undo_funcs.C (firstUndoParagraph): adjust
|
* undo_funcs.C (firstUndoParagraph): adjust
|
||||||
|
85
src/text2.C
85
src/text2.C
@ -456,63 +456,60 @@ void LyXText::setLayout(string const & layout)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// increment depth over selection and
|
void LyXText::incDepth()
|
||||||
// make a total rebreak of those paragraphs
|
|
||||||
void LyXText::incDepth()
|
|
||||||
{
|
{
|
||||||
// If there is no selection, just use the current paragraph
|
ParagraphList::iterator pit(cursor.par());
|
||||||
if (!selection.set()) {
|
ParagraphList::iterator end(cursor.par());
|
||||||
selection.start = cursor; // dummy selection
|
ParagraphList::iterator start = pit;
|
||||||
selection.end = cursor;
|
|
||||||
|
if (selection.set()) {
|
||||||
|
pit = selection.start.par();
|
||||||
|
end = selection.end.par();
|
||||||
|
start = pit;
|
||||||
}
|
}
|
||||||
|
|
||||||
// We end at the next paragraph with depth 0
|
ParagraphList::iterator pastend = end;
|
||||||
Paragraph * endpar = selection.end.par()->next();
|
++pastend;
|
||||||
|
setUndo(bv(), Undo::EDIT, &(*start), &(*pastend));
|
||||||
|
|
||||||
Paragraph * undoendpar = endpar;
|
int prev_after_depth = 0;
|
||||||
|
#warning parlist ... could be nicer ?
|
||||||
if (endpar && endpar->getDepth()) {
|
if (&(*start) != ownerParagraph())
|
||||||
while (endpar && endpar->getDepth()) {
|
prev_after_depth = boost::prior(start)->getMaxDepthAfter();
|
||||||
endpar = endpar->next();
|
|
||||||
undoendpar = endpar;
|
|
||||||
}
|
|
||||||
} else if (endpar) {
|
|
||||||
endpar = endpar->next(); // because of parindents etc.
|
|
||||||
}
|
|
||||||
|
|
||||||
setUndo(bv(), Undo::EDIT,
|
|
||||||
selection.start.par(), undoendpar);
|
|
||||||
|
|
||||||
LyXCursor tmpcursor = cursor; // store the current cursor
|
|
||||||
|
|
||||||
// ok we have a selection. This is always between sel_start_cursor
|
|
||||||
// and sel_end cursor
|
|
||||||
cursor = selection.start;
|
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
// NOTE: you can't change the depth of a bibliography entry
|
int const depth = pit->params().depth();
|
||||||
if (cursor.par()->layout()->labeltype != LABEL_BIBLIO) {
|
|
||||||
Paragraph * prev = cursor.par()->previous();
|
|
||||||
|
|
||||||
if (prev) {
|
if (depth < prev_after_depth
|
||||||
if (cursor.par()->getDepth()
|
&& pit->layout()->labeltype != LABEL_BIBLIO) {
|
||||||
< prev->getMaxDepthAfter()) {
|
pit->params().depth(depth + 1);
|
||||||
cursor.par()->params().depth(cursor.par()->getDepth() + 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (cursor.par() == selection.end.par())
|
|
||||||
|
prev_after_depth = pit->getMaxDepthAfter();
|
||||||
|
|
||||||
|
if (pit == end)
|
||||||
break;
|
break;
|
||||||
cursor.par(cursor.par()->next());
|
|
||||||
|
++pit;
|
||||||
}
|
}
|
||||||
|
|
||||||
redoParagraphs(selection.start, endpar);
|
// Wow, redoParagraphs is stupid.
|
||||||
|
LyXCursor tmpcursor;
|
||||||
|
setCursor(tmpcursor, &(*start), 0);
|
||||||
|
redoParagraphs(tmpcursor, &(*pastend));
|
||||||
|
|
||||||
// we have to reset visual the selection because the
|
// We need to actually move the text->cursor. I don't
|
||||||
|
// understand why ...
|
||||||
|
tmpcursor = cursor;
|
||||||
|
|
||||||
|
// we have to reset the visual selection because the
|
||||||
// geometry could have changed
|
// geometry could have changed
|
||||||
setCursor(selection.start.par(), selection.start.pos());
|
if (selection.set()) {
|
||||||
selection.cursor = cursor;
|
setCursor(selection.start.par(), selection.start.pos());
|
||||||
setCursor(selection.end.par(), selection.end.pos());
|
selection.cursor = cursor;
|
||||||
|
setCursor(selection.end.par(), selection.end.pos());
|
||||||
|
}
|
||||||
|
|
||||||
updateCounters();
|
updateCounters();
|
||||||
setSelection();
|
setSelection();
|
||||||
setCursor(tmpcursor.par(), tmpcursor.pos());
|
setCursor(tmpcursor.par(), tmpcursor.pos());
|
||||||
|
Loading…
Reference in New Issue
Block a user