- delete buf;
- buf = tmpbuf;
- *endpar = tmppar->next();
- pos = tmppos;
- } else {
- // many paragraphs
-
- // make a copy of the simple cut_buffer
- tmpbuf = buf;
- LyXParagraph * simple_cut_clone = tmpbuf->Clone();
- LyXParagraph * tmpbuf2 = simple_cut_clone;
-#ifndef NEW_INSETS
- if ((*par)->footnoteflag) {
- tmpbuf->footnoteflag = (*par)->footnoteflag;
- tmpbuf->footnotekind = (*par)->footnotekind;
- }
- while (tmpbuf->next_) {
- tmpbuf = tmpbuf->next_;
- tmpbuf2->next(tmpbuf->Clone());
- tmpbuf2->next_->previous(tmpbuf2);
- tmpbuf2 = tmpbuf2->next_;
- if ((*par)->footnoteflag){
- tmpbuf->footnoteflag = (*par)->footnoteflag;
- tmpbuf->footnotekind = (*par)->footnotekind;
- }
- }
-#else
- while (tmpbuf->next()) {
- tmpbuf = tmpbuf->next();
- tmpbuf2->next(tmpbuf->Clone());
- tmpbuf2->next()->previous(tmpbuf2);
- tmpbuf2 = tmpbuf2->next();
- }
-#endif
-
- // make sure there is no class difference
- SwitchLayoutsBetweenClasses(textclass, tc, buf);
-
- // make the buf exactly the same layout than
- // the cursor paragraph
- buf->MakeSameLayout(*par);
-
- // find the end of the buffer
- LyXParagraph * lastbuffer = buf;
- while (lastbuffer->next())
- lastbuffer = lastbuffer->next();
-
- bool paste_the_end = false;
-
-#ifndef NEW_INSETS
- // open the paragraph for inserting the buf
- // if necessary
- if (((*par)->Last() > pos) || !(*par)->next()) {
- (*par)->BreakParagraphConservative(current_view->buffer()->params,
- pos);
- paste_the_end = true;
- }
- // set the end for redoing later
- *endpar = (*par)->ParFromPos(pos)->next_->next();
-
- // paste it!
- lastbuffer->ParFromPos(lastbuffer->Last())->next(
- (*par)->ParFromPos(pos)->next_);
- (*par)->ParFromPos(pos)->next()->previous(
- lastbuffer->ParFromPos(lastbuffer->Last()));
-
- (*par)->ParFromPos(pos)->next(buf);
- buf->previous((*par)->ParFromPos(pos));
-
- if ((*par)->ParFromPos(pos)->next() == lastbuffer)
- lastbuffer = *par;
-
- (*par)->ParFromPos(pos)->PasteParagraph(current_view->buffer()->params);
- // store the new cursor position
- *par = lastbuffer;
- pos = lastbuffer->Last();
- // maybe some pasting
- if (lastbuffer->next() && paste_the_end) {
- if (lastbuffer->next()->HasSameLayout(lastbuffer)) {
- lastbuffer->ParFromPos(lastbuffer->Last())->PasteParagraph(current_view->buffer()->params);
- } else if (!lastbuffer->next()->Last()) {
- lastbuffer->next()->MakeSameLayout(lastbuffer);
- lastbuffer->ParFromPos(lastbuffer->Last())->PasteParagraph(current_view->buffer()->params);
- } else if (!lastbuffer->Last()) {
- lastbuffer->MakeSameLayout(lastbuffer->next_);
- lastbuffer->ParFromPos(lastbuffer->Last())->PasteParagraph(current_view->buffer()->params);
- } else
- lastbuffer->next()->StripLeadingSpaces(tc);
- }
- // restore the simple cut buffer
- buf = simple_cut_clone;