]> git.lyx.org Git - lyx.git/blobdiff - src/CutAndPaste.C
remove noload/don't typeset
[lyx.git] / src / CutAndPaste.C
index b7727b40406afd6785089fe6c7d001adc0b084f5..91601f293414cf69c270a98f792badeb26698232 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,15 +141,15 @@ bool CutAndPaste::cutSelection(Paragraph * startpar, Paragraph ** endpar,
                if (realcut) {
                        buf->params().clear();
                        buf->bibkey = 0;
-                       buf->layout(textclasslist[current_view->buffer()->params.textclass].defaultLayoutName());
+                       buf->layout(current_view->buffer()->params.getLyXTextClass().defaultLayout());
                }
 
                // paste the paragraphs again, if possible
                if (doclear)
-                       startpar->next()->stripLeadingSpaces(textclass);
+                       startpar->next()->stripLeadingSpaces();
                if (startpar->hasSameLayout(startpar->next()) ||
-                   !startpar->next()->size()) {
-                       startpar->pasteParagraph(current_view->buffer()->params);
+                   startpar->next()->empty()) {
+                       pasteParagraph(current_view->buffer()->params, startpar);
                        (*endpar) = startpar; // this because endpar gets deleted here!
                }
                // this paragraph's are of noone's owner!
@@ -288,7 +292,7 @@ bool CutAndPaste::pasteSelection(Paragraph ** par, Paragraph ** endpar,
                SwitchLayoutsBetweenClasses(textclass, tc, tmpbuf,
                                            current_view->buffer()->params);
 
-               Paragraph::depth_type max_depth = (*par)->getMaxDepthAfter(current_view->buffer());
+               Paragraph::depth_type max_depth = (*par)->getMaxDepthAfter();
 
                while(tmpbuf) {
                        // if we have a negative jump so that the depth would go below
@@ -304,7 +308,7 @@ bool CutAndPaste::pasteSelection(Paragraph ** par, Paragraph ** endpar,
                        // 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());
+                               max_depth = tmpbuf->getMaxDepthAfter();
                        // set the inset owner of this paragraph
                        tmpbuf->setInsetOwner((*par)->inInset());
                        for(pos_type i = 0; i < tmpbuf->size(); ++i) {
@@ -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
@@ -359,22 +365,22 @@ bool CutAndPaste::pasteSelection(Paragraph ** par, Paragraph ** endpar,
                if ((*par)->next() == lastbuffer)
                        lastbuffer = *par;
 
-               (*par)->pasteParagraph(current_view->buffer()->params);
+               pasteParagraph(current_view->buffer()->params, *par);
                // store the new cursor position
                *par = lastbuffer;
                pos = lastbuffer->size();
                // maybe some pasting
                if (lastbuffer->next() && paste_the_end) {
                        if (lastbuffer->next()->hasSameLayout(lastbuffer)) {
-                               lastbuffer->pasteParagraph(current_view->buffer()->params);
-                       } else if (!lastbuffer->next()->size()) {
+                               pasteParagraph(current_view->buffer()->params, lastbuffer);
+                       } else if (lastbuffer->next()->empty()) {
                                lastbuffer->next()->makeSameLayout(lastbuffer);
-                               lastbuffer->pasteParagraph(current_view->buffer()->params);
-                       } else if (!lastbuffer->size()) {
+                               pasteParagraph(current_view->buffer()->params, lastbuffer);
+                       } else if (lastbuffer->empty()) {
                                lastbuffer->makeSameLayout(lastbuffer->next());
-                               lastbuffer->pasteParagraph(current_view->buffer()->params);
+                               pasteParagraph(current_view->buffer()->params, lastbuffer);
                        } else
-                               lastbuffer->next()->stripLeadingSpaces(tc);
+                               lastbuffer->next()->stripLeadingSpaces();
                }
                // restore the simple cut buffer
                buf = simple_cut_clone;
@@ -413,20 +419,21 @@ int CutAndPaste::SwitchLayoutsBetweenClasses(textclass_type c1,
        ParIterator end = ParIterator();
        for (ParIterator it = ParIterator(par); it != end; ++it) {
                par = *it;
-               string const name = par->layout();
+               string const name = par->layout()->name();
                bool hasLayout = tclass2.hasLayout(name);
 
                if (!hasLayout)
-                       par->layout(tclass2.defaultLayoutName());
+                       par->layout(tclass2.defaultLayout());
 
                if (!hasLayout && name != tclass1.defaultLayoutName()) {
                        ++ret;
                        string const s = _("Layout had to be changed from\n")
                                + name + _(" to ")
-                               + par->layout()
+                               + 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;