From a7a622e888b913336fa5b95c4ec8af1968d4b6a8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=BCrgen=20Vigna?= Date: Tue, 5 Mar 2002 10:53:46 +0000 Subject: [PATCH] Fix the paste bug with different depths. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3661 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/ChangeLog | 4 ++++ src/CutAndPaste.C | 27 +++++++++++++++++++++++++-- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index e6422fae8d..1dfb88f7df 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,7 @@ +2002-03-05 Juergen Vigna + + * CutAndPaste.C (pasteSelection): fix the depth level on paste. + 2002-03-04 Juergen Vigna * lyx_cb.C (getContentsOfAsciiFile): new helper function. diff --git a/src/CutAndPaste.C b/src/CutAndPaste.C index 0ad7fe6162..34dbf7ed11 100644 --- a/src/CutAndPaste.C +++ b/src/CutAndPaste.C @@ -14,9 +14,11 @@ #endif #include "CutAndPaste.h" +//#include "debug.h" #include "BufferView.h" #include "buffer.h" #include "paragraph.h" +#include "ParagraphParameters.h" #include "lyxcursor.h" #include "gettext.h" #include "iterators.h" @@ -270,7 +272,26 @@ bool CutAndPaste::pasteSelection(Paragraph ** par, Paragraph ** endpar, // now remove all out of the buffer which is NOT allowed in the // new environment and set also another font if that is required tmpbuf = buf; + int depth_delta = (*par)->params().depth() - tmpbuf->params().depth(); + // temporary set *par as previous of tmpbuf as we might have to realize + // the font. + tmpbuf->previous(*par); + 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(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) { @@ -291,10 +312,12 @@ bool CutAndPaste::pasteSelection(Paragraph ** par, Paragraph ** endpar, } tmpbuf = tmpbuf->next(); } + // now reset it to 0 + buf->previous(0); // make sure there is no class difference SwitchLayoutsBetweenClasses(textclass, tc, buf, - current_view->buffer()->params); + current_view->buffer()->params); // make the buf exactly the same layout than // the cursor paragraph @@ -311,7 +334,7 @@ bool CutAndPaste::pasteSelection(Paragraph ** par, Paragraph ** endpar, // if necessary if (((*par)->size() > pos) || !(*par)->next()) { (*par)->breakParagraphConservative(current_view->buffer()->params, - pos); + pos); paste_the_end = true; } // set the end for redoing later -- 2.39.2