X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FCutAndPaste.C;h=88fbbb6141900187a35658d9131614bb2bbb425f;hb=0049b4d3e46a36bd4d5ce07a54555cfba2295cfd;hp=72ec10d6de0de65de65af172fc50886ae45bb2f9;hpb=048122515d70392c0807b56365ed7612dec1732c;p=lyx.git diff --git a/src/CutAndPaste.C b/src/CutAndPaste.C index 72ec10d6de..88fbbb6141 100644 --- a/src/CutAndPaste.C +++ b/src/CutAndPaste.C @@ -75,26 +75,6 @@ CutStack theCuts(10); // when we (hopefully) have a one-for-all paste mechanism. bool dirty_tabular_stack_; -class resetParagraph : public std::unary_function { -public: - resetParagraph(Buffer const & b) : buffer_(b) {} - void operator()(Paragraph & p) const { - // FIXME: change tracking (MG) - // set p's text to INSERTED in CT mode; clear CT info otherwise - - // ERT paragraphs have the Language latex_language. - // This is invalid outside of ERT, so we need to change it - // to the buffer language. - if (p.ownerCode() == InsetBase::ERT_CODE) { - p.changeLanguage(buffer_.params(), latex_language, - buffer_.getLanguage()); - } - p.setInsetOwner(0); - } -private: - Buffer const & buffer_; -}; - void region(CursorSlice const & i1, CursorSlice const & i2, InsetBase::row_type & r1, InsetBase::row_type & r2, @@ -210,8 +190,8 @@ pasteSelectionHelper(LCursor & cur, ParagraphList const & parlist, tmpbuf->eraseChar(i--, false); } - // FIXME: Change tracking (MG) - // set tmpbuf's text to INSERTED in CT mode; clear CT info otherwise + tmpbuf->setChange(Change(buffer.params().trackChanges ? + Change::INSERTED : Change::UNCHANGED)); } bool const empty = pars[pit].empty(); @@ -357,7 +337,19 @@ void copySelectionHelper(Buffer const & buf, ParagraphList & pars, ParagraphList paragraphs(boost::next(pars.begin(), startpit), boost::next(pars.begin(), endpit + 1)); - for_each(paragraphs.begin(), paragraphs.end(), resetParagraph(buf)); + ParagraphList::iterator it = paragraphs.begin(); + ParagraphList::iterator it_end = paragraphs.end(); + + for (; it != it_end; it++) { + // ERT paragraphs have the Language latex_language. + // This is invalid outside of ERT, so we need to change it + // to the buffer language. + if (it->ownerCode() == InsetBase::ERT_CODE) { + it->changeLanguage(buf.params(), latex_language, + buf.getLanguage()); + } + it->setInsetOwner(0); + } // Cut out the end of the last paragraph. Paragraph & back = paragraphs.back(); @@ -602,12 +594,11 @@ void copySelection(LCursor & cur) if (cur.inMathed()) { //lyxerr << "copySelection in mathed" << endl; ParagraphList pars; - pars.push_back(Paragraph()); + Paragraph par; BufferParams const & bp = cur.buffer().params(); - pars.back().layout(bp.getLyXTextClass().defaultLayout()); - for_each(pars.begin(), pars.end(), resetParagraph(cur.buffer())); - // FIXME: change tracking (MG) - pars.back().insert(0, grabSelection(cur), LyXFont(), Change(Change::UNCHANGED)); + par.layout(bp.getLyXTextClass().defaultLayout()); + par.insert(0, grabSelection(cur), LyXFont(), Change(Change::UNCHANGED)); + pars.push_back(par); theCuts.push(make_pair(pars, bp.textclass)); } // tell tabular that a recent copy happened @@ -630,8 +621,6 @@ void pasteParagraphList(LCursor & cur, ParagraphList const & parlist, LyXText * text = cur.text(); BOOST_ASSERT(text); - recordUndo(cur); - pit_type endpit; PitPosPair ppp; @@ -654,6 +643,7 @@ void pasteSelection(LCursor & cur, ErrorList & errorList, size_t sel_index) if (!checkPastePossible(sel_index)) return; + recordUndo(cur); pasteParagraphList(cur, theCuts[sel_index].first, theCuts[sel_index].second, errorList); cur.setSelection();