On Tue, Feb 19, 2002 at 03:10:44PM +0100, Juergen Vigna wrote: > On 19-Feb-2002 Martin Vermeer wrote: > > > Yes but, yes but... what happens if you cut&paste a float with a caption > > in it, is that it takes this branch (remember, one paragraph only in the > > main buffer), but THE CAPTION LAYOUT INFO IS COPIED TOO, UNCHANGED! > > You got me! I didn't think about that and I just saw that the function > is taking care of paragraphs inside insets too. So it seems your patch > is the right thing to do, only the SwitchLayoutsBetweenClasses() call HAS > to be AFTER the "Paragraph * tmpbuf = new Paragraph(*buf, false);" > otherwise we will change the original buffer layouts every time and may loose > some layout informations (think of using "Standard" if we don't find the > right layout)! > > Jürgen
Actually I removed the first branch (single paragraph) of the switch entirely, and your requirement Because you only copy the chars singularly from the source to the destination paragraph "without" changing the layout of the destination paragraph! So here you don't put into the original paragraph (with all it's informations) but only the contents! is still met... a layout style is only placed on the pasted characters *if the start of the paragraph they are in is inside the cut area*. Irrespective of how many paragraphs there are, one or many or part of one. So, if you have +-------------+ [Section] First |section title| ----------------+ +---------+ [Standard] some text some text some text| +-----------------+ [Subsection] First sub|section title ----------------------+ what gets pasted is [Standard] section title [Standard] some text some text some text [Subsection] First sub ...and if you were to take +-------+ [Section] First |section| title +-------+ it will be pasted as [Standard] section just as I suppose you meant. Try it! Do we really need the special case here? I have no strong feelings on this, but please verify for yourself if this branch code actually does anything above and beyond the alternative branch :-) Martin Patch attached.
Index: CutAndPaste.C =================================================================== RCS file: /cvs/lyx/lyx-devel/src/CutAndPaste.C,v retrieving revision 1.46 diff -u -b -B -p -r1.46 CutAndPaste.C --- CutAndPaste.C 2002/01/17 10:54:30 1.46 +++ CutAndPaste.C 2002/02/19 15:03:33 @@ -223,37 +223,6 @@ bool CutAndPaste::pasteSelection(Paragra Paragraph * tmppar = *par; int tmppos = pos; - // There are two cases: cutbuffer only one paragraph or many - if (!buf->next()) { - // only within a paragraph - Paragraph * tmpbuf = new Paragraph(*buf, false); - - // Some provisions should be done here for checking - // if we are inserting at the beginning of a - // paragraph. If there are a space at the beginning - // of the text to insert and we are inserting at - // the beginning of the paragraph the space should - // be removed. - while (buf->size()) { - // This is an attempt to fix the - // "never insert a space at the - // beginning of a paragraph" problem. - if (!tmppos && buf->isLineSeparator(0)) { - buf->erase(0); - } else { - buf->cutIntoMinibuffer(current_view->buffer()->params, 0); - buf->erase(0); - if (tmppar->insertFromMinibuffer(tmppos)) - ++tmppos; - } - } - delete buf; - buf = tmpbuf; - *endpar = tmppar->next(); - pos = tmppos; - } else { - // many paragraphs - // make a copy of the simple cut_buffer Paragraph * tmpbuf = buf; Paragraph * simple_cut_clone = new Paragraph(*tmpbuf, false); @@ -345,7 +314,6 @@ bool CutAndPaste::pasteSelection(Paragra } // restore the simple cut buffer buf = simple_cut_clone; - } return true; }
msg33200/pgp00000.pgp
Description: PGP signature