]> git.lyx.org Git - lyx.git/blobdiff - src/CutAndPaste.C
Fixed cut&paste bugs and added freespacing for ERT Insets.
[lyx.git] / src / CutAndPaste.C
index fbfa1689821e7efea37f047a0f817e834cafb1e7..80c62c28f2b6892cb04e4339af04a63bec782279 100644 (file)
@@ -23,6 +23,7 @@
 #endif
 
 using std::pair;
+using lyx::pos_type;
 
 extern BufferView * current_view;
 
@@ -88,7 +89,7 @@ bool CutAndPaste::cutSelection(Paragraph * startpar, Paragraph ** endpar,
                // only within one paragraph
                if (realcut)
                        buf = new Paragraph;
-               Paragraph::size_type i = start;
+               pos_type i = start;
                if (end > startpar->size())
                        end = startpar->size();
                for (; i < end; ++i) {
@@ -136,6 +137,12 @@ bool CutAndPaste::cutSelection(Paragraph * startpar, Paragraph ** endpar,
                        startpar->pasteParagraph(current_view->buffer()->params);
                        (*endpar) = startpar; // this because endpar gets deleted here!
                }
+               // this paragraph's are of noone's owner!
+               Paragraph * p = buf;
+               while(p) {
+                       p->setInsetOwner(0);
+                       p = p->next();
+               }
        }
        return true;
 }
@@ -151,11 +158,10 @@ bool CutAndPaste::copySelection(Paragraph * startpar, Paragraph * endpar,
        
        textclass = tc;
        
-       if (!endpar ||
-           startpar == endpar) {
+       if (!endpar || startpar == endpar) {
                // only within one paragraph
                buf = new Paragraph;
-               Paragraph::size_type i = start;
+               pos_type i = start;
                if (end > startpar->size())
                        end = startpar->size();
                for (; i < end; ++i) {
@@ -179,7 +185,7 @@ bool CutAndPaste::copySelection(Paragraph * startpar, Paragraph * endpar,
                tmppar2->next(0);
                
                // the buf paragraph is too big
-               Paragraph::size_type tmpi2 = start;
+               pos_type tmpi2 = start;
                for (; tmpi2; --tmpi2)
                        buf->erase(0);
                
@@ -188,6 +194,12 @@ bool CutAndPaste::copySelection(Paragraph * startpar, Paragraph * endpar,
                while (tmppar2->size() > tmpi2) {
                        tmppar2->erase(tmppar2->size() - 1);
                }
+               // this paragraph's are of noone's owner!
+               tmppar = buf;
+               while(tmppar) {
+                       tmppar->setInsetOwner(0);
+                       tmppar = tmppar->next();
+               }
        }
        return true;
 }