]> git.lyx.org Git - lyx.git/blobdiff - src/CutAndPaste.C
Dekels tabular/textinset patches
[lyx.git] / src / CutAndPaste.C
index 0987745ca1f25f3c1f845b53b486918296d19fea..ef04824c567c1f18cbef1033357dc16deb3ee103 100644 (file)
@@ -85,28 +85,19 @@ bool CutAndPaste::cutSelection(LyXParagraph * startpar, LyXParagraph ** endpar,
 #else
        (startpar == (*endpar))
 #endif
-           ) {
+          ) {
        // only within one paragraph
        buf = new LyXParagraph;
        LyXParagraph::size_type i = start;
        if (end > startpar->Last())
            end = startpar->Last();
        for (; i < end; ++i) {
-           startpar->CopyIntoMinibuffer(current_view->buffer()->params,
-                                        start);
-#ifndef NEW_TABULAR
-           /* table stuff -- begin */
-           if (startpar->table && startpar->IsNewline(start)) {
-               ++start;
-           } else {
-               /* table stuff -- end */
-#endif
-               startpar->Erase(start);
-#ifndef NEW_TABULAR
-           }
-#endif
+           startpar->CopyIntoMinibuffer(*current_view->buffer(), start);
+           startpar->Erase(start);
+
            buf->InsertFromMinibuffer(buf->Last());
        }
+       end = start-1;
     } else {
        // more than one paragraph
        (*endpar)->BreakParagraphConservative(current_view->buffer()->params,
@@ -189,14 +180,14 @@ bool CutAndPaste::copySelection(LyXParagraph * startpar, LyXParagraph * endpar,
 #else
        (startpar == endpar)
 #endif
-           ) {
+          ) {
        // only within one paragraph
        buf = new LyXParagraph;
        LyXParagraph::size_type i = start;
        if (end > startpar->Last())
            end = startpar->Last();
        for (; i < end; ++i) {
-           startpar->CopyIntoMinibuffer(current_view->buffer()->params, i);
+           startpar->CopyIntoMinibuffer(*current_view->buffer(), i);
            buf->InsertFromMinibuffer(buf->Last());
        }
     } else {
@@ -275,59 +266,25 @@ bool CutAndPaste::pasteSelection(LyXParagraph ** par, LyXParagraph ** endpar,
     if (!buf->next) {
        // only within a paragraph
        tmpbuf = buf->Clone();
-#ifndef NEW_TABULAR
-       /* table stuff -- begin */
-       bool table_too_small = false;
-       if ((*par)->table) {
-           while (buf->size() && !table_too_small) {
-               if (buf->IsNewline(0)){
-                   while((tmppos < tmppar->Last()) &&
-                         !tmppar->IsNewline(tmppos))
-                       ++tmppos;
-                   buf->Erase(0);
-                   if (tmppos < tmppar->Last())
-                       ++tmppos;
-                   else
-                       table_too_small = true;
-               } else {
-                   // 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;
-                   }
-               }
-           }
-       } else {
-           /* table stuff -- end */
-#endif
-           // 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()) {
+       // 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);
+                       buf->Erase(0);
                } else {
-                   buf->CutIntoMinibuffer(current_view->buffer()->params, 0);
-                   buf->Erase(0);
-                   if (tmppar->InsertFromMinibuffer(tmppos))
-                       ++tmppos;
+                       buf->CutIntoMinibuffer(current_view->buffer()->params, 0);
+                       buf->Erase(0);
+                       if (tmppar->InsertFromMinibuffer(tmppos))
+                               ++tmppos;
                }
-           }
-#ifndef NEW_TABULAR
        }
-#endif
        delete buf;
        buf = tmpbuf;
        *endpar = tmppar->Next();
@@ -448,7 +405,7 @@ bool CutAndPaste::pasteSelection(LyXParagraph ** par, LyXParagraph ** endpar,
 }
 
 
-int CutAndPaste::nrOfParagraphs() const
+int CutAndPaste::nrOfParagraphs()
 {
        if (!buf) return 0;
 
@@ -503,7 +460,7 @@ int CutAndPaste::SwitchLayoutsBetweenClasses(LyXTextClassList::size_type c1,
 }
 
 
-bool CutAndPaste::checkPastePossible(LyXParagraph * par, int) const
+bool CutAndPaste::checkPastePossible(LyXParagraph * par, int)
 {
     if (!buf) return false;
 
@@ -522,18 +479,6 @@ bool CutAndPaste::checkPastePossible(LyXParagraph * par, int) const
            return false;
        }
     }
-#endif
-#ifndef NEW_TABULAR
-    /* table stuff -- begin */
-    if (par->table) {
-       if (buf->next) {
-           WriteAlert(_("Impossible operation"),
-                      _("Table cell cannot include more than one paragraph!"),
-                      _("Sorry."));
-           return false;
-       }
-    }
-    /* table stuff -- end */
 #endif
     return true;
 }