+ Paragraph::depth_type max_depth = (*par)->getMaxDepthAfter(current_view->buffer());
+
+ while(tmpbuf) {
+ // if we have a negative jump so that the depth would go below
+ // 0 depth then we have to redo the delta to this new max depth
+ // level so that subsequent paragraphs are aligned correctly to
+ // this paragraph at level 0.
+ if ((static_cast<int>(tmpbuf->params().depth()) + depth_delta) < 0)
+ depth_delta = 0;
+ // set the right depth so that we are not too deep or shallow.
+ tmpbuf->params().depth(tmpbuf->params().depth() + depth_delta);
+ if (tmpbuf->params().depth() > max_depth)
+ tmpbuf->params().depth(max_depth);
+ // only set this from the 2nd on as the 2nd depends for maxDepth
+ // still on *par
+ if (tmpbuf->previous() != (*par))
+ max_depth = tmpbuf->getMaxDepthAfter(current_view->buffer());
+ // set the inset owner of this paragraph
+ tmpbuf->setInsetOwner((*par)->inInset());
+ for(pos_type i = 0; i < tmpbuf->size(); ++i) {
+ if (tmpbuf->getChar(i) == Paragraph::META_INSET) {
+ if (!(*par)->insetAllowed(tmpbuf->getInset(i)->lyxCode()))
+ {
+ tmpbuf->erase(i--);
+ }
+ } else {
+ LyXFont f1 = tmpbuf->getFont(current_view->buffer()->params,i);
+ LyXFont f2 = f1;
+ if (!(*par)->checkInsertChar(f1)) {
+ tmpbuf->erase(i--);
+ } else if (f1 != f2) {
+ tmpbuf->setFont(i, f1);
+ }
+ }
+ }
+ tmpbuf = tmpbuf->next();
+ }
+ // now reset it to 0
+ buf->previous(0);
+