- par_type pit = startpit + 1;
-
- while (pit != endpit && pit != par_type(pars.size())) {
- par_type const next = pit + 1;
- // "erase" the contents of the par
- pars[pit].erase(0, pars[pit].size());
- if (!pars[pit].size()) {
- // remove the par if it's now empty
- pars.erase(pars.begin() + pit);
- } else
- all_erased = false;
- pit = next;
- }
-
-#if 0 // FIXME: why for cut but not copy ?
- // the cut selection should begin with standard layout
- if (realcut) {
- buf->params().clear();
- buf->bibkey = 0;
- buf->layout(textclasslist[buffer->params.textclass].defaultLayoutName());
- }
-#endif
-
- if (startpit + 1 == par_type(pars.size()))
- return PitPosPair(endpit, endpos);
-
- if (doclear) {
- pars[startpit + 1].stripLeadingSpaces();
- }
-
- // paste the paragraphs again, if possible
- if (all_erased &&
- (pars[startpit].hasSameLayout(pars[startpit + 1]) ||
- pars[startpit + 1].empty())) {
- mergeParagraph(params, pars, startpit);
- // this because endpar gets deleted here!
- endpit = startpit;
- endpos = startpos;
- }
-
- return PitPosPair(endpit, endpos);
-
-}
-
-
-bool copySelection(ParagraphList & pars,
- par_type startpit, par_type endpit,
- int start, int end, textclass_type tc)
-{
- BOOST_ASSERT(0 <= start && start <= pars[startpit].size());
- BOOST_ASSERT(0 <= end && end <= pars[endpit].size());
- BOOST_ASSERT(startpit != endpit || start <= end);
-
- // Clone the paragraphs within the selection.
- ParagraphList paragraphs(pars.begin() + startpit, pars.begin() + endpit + 1);
- for_each(paragraphs.begin(), paragraphs.end(), resetOwnerAndChanges());
-
- // Cut out the end of the last paragraph.
- Paragraph & back = paragraphs.back();
- back.erase(end, back.size());
-
- // Cut out the begin of the first paragraph
- Paragraph & front = paragraphs.front();
- front.erase(0, start);
-
- cuts.push(make_pair(paragraphs, tc));
-
- return true;
-}
-
-
-PitPosPair cutSelection(BufferParams const & params, ParagraphList & pars,
- par_type startpit, par_type endpit,
- int startpos, int endpos, textclass_type tc, bool doclear)
-{
- copySelection(pars, startpit, endpit, startpos, endpos, tc);
- return eraseSelection(params, pars, startpit, endpit, startpos,
- endpos, doclear);
-}
-
-
-pair<PitPosPair, par_type>
-pasteSelection(Buffer const & buffer, ParagraphList & pars,
- par_type pit, int pos,
- textclass_type tc, size_t cut_index, ErrorList & errorlist)
-{
- if (!checkPastePossible())