]> git.lyx.org Git - lyx.git/blobdiff - src/CutAndPaste.C
Remove the inset and view member functions from PreviewedInset.
[lyx.git] / src / CutAndPaste.C
index 54ae59110bd5089a809690c9e2c16ca81bd908f8..776600b22b2fff61cf302019fca5587c75e52010 100644 (file)
@@ -1,46 +1,44 @@
-/* \file CutAndPaste.C
+/*
+ * \file CutAndPaste.C
  * This file is part of LyX, the document processor.
  * Licence details can be found in the file COPYING.
  *
- * \author Juergen Vigna
+ * \author Jürgen Vigna
  * \author Lars Gullik Bjønnes
  * \author Alfredo Braunstein
  *
- * Full author contact details are available in file CREDITS
+ * Full author contact details are available in file CREDITS.
  */
 
 #include <config.h>
 
 #include "CutAndPaste.h"
-#include "BufferView.h"
+
 #include "buffer.h"
+#include "bufferparams.h"
 #include "errorlist.h"
-#include "paragraph.h"
-#include "ParagraphParameters.h"
-#include "lyxtext.h"
-#include "lyxcursor.h"
+#include "gettext.h"
 #include "iterators.h"
 #include "lyxtextclasslist.h"
-#include "undo_funcs.h"
-#include "gettext.h"
+#include "paragraph.h"
 #include "paragraph_funcs.h"
-#include "debug.h"
-#include "insets/insetinclude.h"
+#include "ParagraphParameters.h"
+
 #include "insets/insettabular.h"
 
-#include "support/LAssert.h"
 #include "support/lstrings.h"
-#include "support/limited_stack.h"
-
-using std::endl;
-using std::pair;
-using std::make_pair;
-using std::for_each;
-using std::vector;
 
 using lyx::pos_type;
 using lyx::textclass_type;
 
+using lyx::support::bformat;
+
+using std::for_each;
+using std::make_pair;
+using std::pair;
+using std::vector;
+using std::string;
+
 
 typedef limited_stack<pair<ParagraphList, textclass_type> > CutStack;
 
@@ -51,7 +49,7 @@ CutStack cuts(10);
 } // namespace anon
 
 
-std::vector<string>
+std::vector<string> const
 CutAndPaste::availableSelections(Buffer const & buffer)
 {
        vector<string> selList;
@@ -66,7 +64,7 @@ CutAndPaste::availableSelections(Buffer const & buffer)
                ParagraphList::const_iterator pit = pars.begin();
                ParagraphList::const_iterator pend = pars.end();
                for (; pit != pend; ++pit) {
-                       asciiSel += pit->asString(&buffer, false);
+                       asciiSel += pit->asString(buffer, false);
                        if (asciiSel.size() > 25) {
                                asciiSel.replace(22, string::npos, "...");
                                break;
@@ -180,11 +178,9 @@ bool CutAndPaste::copySelection(ParagraphList::iterator startpit,
                                ParagraphList::iterator endpit,
                                int start, int end, textclass_type tc)
 {
-       lyx::Assert(&*startpit);
-       lyx::Assert(&*endpit);
-       lyx::Assert(0 <= start && start <= startpit->size());
-       lyx::Assert(0 <= end && end <= endpit->size());
-       lyx::Assert(startpit != endpit || start <= end);
+       BOOST_ASSERT(0 <= start && start <= startpit->size());
+       BOOST_ASSERT(0 <= end && end <= endpit->size());
+       BOOST_ASSERT(startpit != endpit || start <= end);
 
        ParagraphList paragraphs;
 
@@ -229,7 +225,7 @@ CutAndPaste::pasteSelection(Buffer const & buffer,
        if (!checkPastePossible())
                return make_pair(PitPosPair(pit, pos), pit);
 
-       lyx::Assert (pos <= pit->size());
+       BOOST_ASSERT (pos <= pit->size());
 
        // Make a copy of the CaP paragraphs.
        ParagraphList simple_cut_clone = cuts[cut_index].first;
@@ -274,7 +270,7 @@ CutAndPaste::pasteSelection(Buffer const & buffer,
                                        tmpbuf->erase(i--);
                                }
                        } else {
-                               LyXFont f1 = tmpbuf->getFont(buffer.params, i, outerFont(pit, pars));
+                               LyXFont f1 = tmpbuf->getFont(buffer.params(), i, outerFont(pit, pars));
                                LyXFont f2 = f1;
                                if (!pit->checkInsertChar(f1)) {
                                        tmpbuf->erase(i--);
@@ -301,15 +297,7 @@ CutAndPaste::pasteSelection(Buffer const & buffer,
 
                for (; lit != eit; ++lit) {
                        switch (lit->inset->lyxCode()) {
-                       case Inset::INCLUDE_CODE: {
-                               InsetInclude * ii = static_cast<InsetInclude*>(lit->inset);
-                               InsetInclude::Params ip = ii->params();
-                               ip.masterFilename_ = buffer.fileName();
-                               ii->set(ip);
-                               break;
-                       }
-
-                       case Inset::TABULAR_CODE: {
+                       case InsetOld::TABULAR_CODE: {
                                InsetTabular * it = static_cast<InsetTabular*>(lit->inset);
                                it->buffer(const_cast<Buffer*>(&buffer));
                                break;
@@ -326,7 +314,7 @@ CutAndPaste::pasteSelection(Buffer const & buffer,
        // Open the paragraph for inserting the buf
        // if necessary.
        if (pit->size() > pos || boost::next(pit) == pars.end()) {
-               breakParagraphConservative(buffer.params,
+               breakParagraphConservative(buffer.params(),
                                           pars, pit, pos);
                paste_the_end = true;
        }
@@ -344,26 +332,25 @@ CutAndPaste::pasteSelection(Buffer const & buffer,
        if (boost::next(pit) == last_paste)
                last_paste = pit;
 
-       mergeParagraph(buffer.params, pars, pit);
+       mergeParagraph(buffer.params(), pars, pit);
 
        // Store the new cursor position.
        pit = last_paste;
        pos = last_paste->size();
 
        // Maybe some pasting.
-#warning CHECK! Are we comparing last_paste to the wrong list here? (Lgb)
        if (boost::next(last_paste) != pars.end() &&
            paste_the_end) {
                if (boost::next(last_paste)->hasSameLayout(*last_paste)) {
-                       mergeParagraph(buffer.params, pars,
+                       mergeParagraph(buffer.params(), pars,
                                       last_paste);
                } else if (boost::next(last_paste)->empty()) {
                        boost::next(last_paste)->makeSameLayout(*last_paste);
-                       mergeParagraph(buffer.params, pars,
+                       mergeParagraph(buffer.params(), pars,
                                       last_paste);
                } else if (last_paste->empty()) {
                        last_paste->makeSameLayout(*boost::next(last_paste));
-                       mergeParagraph(buffer.params, pars,
+                       mergeParagraph(buffer.params(), pars,
                                       last_paste);
                } else
                        boost::next(last_paste)->stripLeadingSpaces();
@@ -384,7 +371,7 @@ int CutAndPaste::SwitchLayoutsBetweenClasses(textclass_type c1,
                                             ParagraphList & pars,
                                             ErrorList & errorlist)
 {
-       lyx::Assert(!pars.empty());
+       BOOST_ASSERT(!pars.empty());
 
        int ret = 0;
        if (c1 == c2)