From c0969f2933de9d533bbc83a014a36402b92885b4 Mon Sep 17 00:00:00 2001 From: Michael Schmitt Date: Tue, 7 Nov 2006 18:27:03 +0000 Subject: [PATCH] * CutAndPaste.C: simplify copySelectionHelper and copySelection; fix change tracking in pasteSelectionHelper; remove a few CT-related FIXMEs git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15788 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/CutAndPaste.C | 47 +++++++++++++++++++---------------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/CutAndPaste.C b/src/CutAndPaste.C index 72ec10d6de..654009914b 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 -- 2.39.2