]> git.lyx.org Git - lyx.git/blobdiff - src/CutAndPaste.C
move breakParagraph and breakParagraphConservative out of Paragraph
[lyx.git] / src / CutAndPaste.C
index 9d72add1a89a2246fed8b2e8d421069657c70351..230648add52e499f208bd11d6ac3f6cf310f91bc 100644 (file)
@@ -24,6 +24,8 @@
 #include "gettext.h"
 #include "iterators.h"
 #include "lyxtextclasslist.h"
+#include "undo_funcs.h"
+#include "paragraph_funcs.h"
 
 #include "insets/inseterror.h"
 
@@ -111,13 +113,15 @@ bool CutAndPaste::cutSelection(Paragraph * startpar, Paragraph ** endpar,
                end = start - 1;
        } else {
                // more than one paragraph
-               (*endpar)->breakParagraphConservative(current_view->buffer()->params,
-                                                     end);
+               breakParagraphConservative(current_view->buffer()->params,
+                                          *endpar,
+                                          end);
                *endpar = (*endpar)->next();
                end = 0;
 
-               startpar->breakParagraphConservative(current_view->buffer()->params,
-                                                    start);
+               breakParagraphConservative(current_view->buffer()->params,
+                                          startpar,
+                                          start);
 
                // store the selection
                if (realcut) {
@@ -137,14 +141,14 @@ bool CutAndPaste::cutSelection(Paragraph * startpar, Paragraph ** endpar,
                if (realcut) {
                        buf->params().clear();
                        buf->bibkey = 0;
-                       buf->layout(textclasslist[current_view->buffer()->params.textclass].defaultLayout());
+                       buf->layout(current_view->buffer()->params.getLyXTextClass().defaultLayout());
                }
 
                // paste the paragraphs again, if possible
                if (doclear)
                        startpar->next()->stripLeadingSpaces();
                if (startpar->hasSameLayout(startpar->next()) ||
-                   !startpar->next()->size()) {
+                   startpar->next()->empty()) {
                        startpar->pasteParagraph(current_view->buffer()->params);
                        (*endpar) = startpar; // this because endpar gets deleted here!
                }
@@ -342,8 +346,10 @@ bool CutAndPaste::pasteSelection(Paragraph ** par, Paragraph ** endpar,
                // open the paragraph for inserting the buf
                // if necessary
                if (((*par)->size() > pos) || !(*par)->next()) {
-                       (*par)->breakParagraphConservative(current_view->buffer()->params,
-                                                          pos);
+                       breakParagraphConservative(
+                               current_view->buffer()->params,
+                               *par,
+                               pos);
                        paste_the_end = true;
                }
                // set the end for redoing later
@@ -367,10 +373,10 @@ bool CutAndPaste::pasteSelection(Paragraph ** par, Paragraph ** endpar,
                if (lastbuffer->next() && paste_the_end) {
                        if (lastbuffer->next()->hasSameLayout(lastbuffer)) {
                                lastbuffer->pasteParagraph(current_view->buffer()->params);
-                       } else if (!lastbuffer->next()->size()) {
+                       } else if (lastbuffer->next()->empty()) {
                                lastbuffer->next()->makeSameLayout(lastbuffer);
                                lastbuffer->pasteParagraph(current_view->buffer()->params);
-                       } else if (!lastbuffer->size()) {
+                       } else if (lastbuffer->empty()) {
                                lastbuffer->makeSameLayout(lastbuffer->next());
                                lastbuffer->pasteParagraph(current_view->buffer()->params);
                        } else
@@ -425,8 +431,9 @@ int CutAndPaste::SwitchLayoutsBetweenClasses(textclass_type c1,
                                + name + _(" to ")
                                + par->layout()->name()
                                + _("\nbecause of class conversion from\n")
-                               + textclasslist[c1].name() + _(" to ")
-                               + textclasslist[c2].name();
+                               + tclass1.name() + _(" to ")
+                               + tclass2.name();
+                       freezeUndo();
                        InsetError * new_inset = new InsetError(s);
                        LyXText * txt = current_view->getLyXText();
                        LyXCursor cur = txt->cursor;
@@ -434,6 +441,7 @@ int CutAndPaste::SwitchLayoutsBetweenClasses(textclass_type c1,
                        txt->insertInset(current_view, new_inset);
                        txt->fullRebreak(current_view);
                        txt->setCursorIntern(current_view, cur.par(), cur.pos());
+                       unFreezeUndo();
                }
        }
        return ret;