]> git.lyx.org Git - lyx.git/blobdiff - src/CutAndPaste.C
the Paragraph::inInset() changes
[lyx.git] / src / CutAndPaste.C
index e3063113dcd9e5cbd549aef6429bf091ee1fea65..0cd4a1a33418087d0b6e78f120d94efcdca53b42 100644 (file)
 #include "cursor.h"
 #include "errorlist.h"
 #include "gettext.h"
-#include "iterators.h"
 #include "lyxtext.h"
 #include "lyxtextclasslist.h"
 #include "paragraph.h"
 #include "paragraph_funcs.h"
 #include "ParagraphParameters.h"
 #include "ParagraphList_fwd.h"
+#include "pariterator.h"
 #include "undo.h"
 
 #include "insets/insettabular.h"
@@ -81,8 +81,12 @@ int SwitchLayoutsBetweenClasses(textclass_type c1, textclass_type c2,
 
        LyXTextClass const & tclass1 = textclasslist[c1];
        LyXTextClass const & tclass2 = textclasslist[c2];
-       ParIterator end = ParIterator(pars.size(), pars);
-       for (ParIterator it = ParIterator(0, pars); it != end; ++it) {
+
+       InsetText in;
+       std::swap(in.paragraphs(), pars);
+
+       ParIterator end = par_iterator_end(in);
+       for (ParIterator it = par_iterator_begin(in); it != end; ++it) {
                string const name = it->layout()->name();
                bool hasLayout = tclass2.hasLayout(name);
 
@@ -103,6 +107,7 @@ int SwitchLayoutsBetweenClasses(textclass_type c1, textclass_type c2,
                                                      it->size()));
                }
        }
+       std::swap(in.paragraphs(), pars);
        return ret;
 }
 
@@ -301,8 +306,11 @@ pasteSelection(Buffer const & buffer, ParagraphList & pars,
 
        // Prepare the paragraphs and insets for insertion.
        // A couple of insets store buffer references so need updating.
-       ParIterator fpit(0, insertion);
-       ParIterator fend(insertion.size(), insertion);
+       InsetText in;
+       std::swap(in.paragraphs(), insertion);
+
+       ParIterator fpit = par_iterator_begin(in);
+       ParIterator fend = par_iterator_end(in);
 
        for (; fpit != fend; ++fpit) {
                InsetList::iterator lit = fpit->insetlist.begin();
@@ -321,6 +329,7 @@ pasteSelection(Buffer const & buffer, ParagraphList & pars,
                        }
                }
        }
+       std::swap(in.paragraphs(), insertion);
 
        // Split the paragraph for inserting the buf if necessary.
        bool did_split = false;
@@ -334,7 +343,7 @@ pasteSelection(Buffer const & buffer, ParagraphList & pars,
        mergeParagraph(buffer.params(), pars, pit);
 
        par_type last_paste = pit + insertion.size() - 1;
-       
+
        // Store the new cursor position.
        pit = last_paste;
        pos = pars[last_paste].size();
@@ -407,7 +416,7 @@ void cutSelection(LCursor & cur, bool doclear, bool realcut)
 
        int endpos = cur.selEnd().pos();
 
-       BufferParams const & bufparams = cur.bv().buffer()->params();
+       BufferParams const & bufparams = cur.buffer().params();
        boost::tie(endpit, endpos) = realcut ?
                cutSelection(bufparams,
                                          text->paragraphs(),
@@ -461,7 +470,7 @@ void copySelection(LCursor & cur)
                ++pos;
 
        copySelection(pars, par, cur.selEnd().par(),
-               pos, cur.selEnd().pos(), cur.bv().buffer()->params().textclass);
+               pos, cur.selEnd().pos(), cur.buffer().params().textclass);
 }
 
 
@@ -481,13 +490,13 @@ void pasteSelection(LCursor & cur, size_t sel_index)
        ErrorList el;
 
        boost::tie(ppp, endpit) =
-               pasteSelection(*cur.bv().buffer(),
+               pasteSelection(cur.buffer(),
                                            text->paragraphs(),
                                            cur.par(), cur.pos(),
-                                           cur.bv().buffer()->params().textclass,
+                                           cur.buffer().params().textclass,
                                            sel_index, el);
-       bufferErrors(*cur.bv().buffer(), el);
-       text->bv()->showErrorList(_("Paste"));
+       bufferErrors(cur.buffer(), el);
+       cur.bv().showErrorList(_("Paste"));
 
        text->redoParagraphs(cur.par(), endpit);
 
@@ -522,7 +531,7 @@ void replaceSelectionWithString(LCursor & cur, string const & str)
        // Get font setting before we cut
        pos_type pos = cur.selEnd().pos();
        LyXFont const font = text->getPar(cur.selBegin().par()).
-               getFontSettings(cur.bv().buffer()->params(), cur.selBegin().pos());
+               getFontSettings(cur.buffer().params(), cur.selBegin().pos());
 
        // Insert the new string
        string::const_iterator cit = str.begin();