From b08f5ad69ececc94791bdd42e9a2d878f7393494 Mon Sep 17 00:00:00 2001 From: Michael Schmitt Date: Fri, 20 Oct 2006 11:44:58 +0000 Subject: [PATCH] change tracking: * src/paragraph.h: insertXXX(...) requires either boolean parameter 'trackChanges' or a Change * src/insets/insettext.h: add trackChanges parameter to setText(...) * src/insets/*.C: * src/*.C: adjust properly & remove a couple of FIXMEs git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15399 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/CutAndPaste.C | 6 +++--- src/buffer.C | 9 +++------ src/insets/insettabular.C | 9 ++++++--- src/insets/insettext.C | 5 ++--- src/insets/insettext.h | 2 +- src/lyxfind.C | 4 +++- src/paragraph.C | 21 +++++++++++++++------ src/paragraph.h | 11 +++++++---- 8 files changed, 40 insertions(+), 27 deletions(-) diff --git a/src/CutAndPaste.C b/src/CutAndPaste.C index 827f441fbb..71d700aadc 100644 --- a/src/CutAndPaste.C +++ b/src/CutAndPaste.C @@ -610,7 +610,8 @@ void copySelection(LCursor & cur) BufferParams const & bp = cur.buffer().params(); pars.back().layout(bp.getLyXTextClass().defaultLayout()); for_each(pars.begin(), pars.end(), resetParagraph(cur.buffer())); - pars.back().insert(0, grabSelection(cur), LyXFont()); + // FIXME: change tracking (MG) + pars.back().insert(0, grabSelection(cur), LyXFont(), Change(Change::UNCHANGED)); theCuts.push(make_pair(pars, bp.textclass)); } // tell tabular that a recent copy happened @@ -679,8 +680,7 @@ void replaceSelectionWithString(LCursor & cur, string const & str, bool backward string::const_iterator cit = str.begin(); string::const_iterator end = str.end(); for (; cit != end; ++cit, ++pos) - // FIXME: change tracking (MG) - par.insertChar(pos, (*cit), font, Change(Change::INSERTED)); + par.insertChar(pos, (*cit), font, cur.buffer().params().trackChanges); // Cut the selection cutSelection(cur, true, false); diff --git a/src/buffer.C b/src/buffer.C index bacd13e81c..90ebfaeced 100644 --- a/src/buffer.C +++ b/src/buffer.C @@ -531,15 +531,13 @@ void Buffer::insertStringAsLines(ParagraphList & pars, } else if (*cit == '\t') { if (!par.isFreeSpacing()) { // tabs are like spaces here - // FIXME: change tracking (MG) - par.insertChar(pos, ' ', font, Change(Change::INSERTED)); + par.insertChar(pos, ' ', font, params().trackChanges); ++pos; space_inserted = true; } else { const pos_type n = 8 - pos % 8; for (pos_type i = 0; i < n; ++i) { - // FIXME: change tracking (MG) - par.insertChar(pos, ' ', font, Change(Change::INSERTED)); + par.insertChar(pos, ' ', font, params().trackChanges); ++pos; } space_inserted = true; @@ -551,8 +549,7 @@ void Buffer::insertStringAsLines(ParagraphList & pars, */ } else { // just insert the character - // FIXME: change tracking (MG) - par.insertChar(pos, *cit, font, Change(Change::INSERTED)); + par.insertChar(pos, *cit, font, params().trackChanges); ++pos; space_inserted = (*cit == ' '); } diff --git a/src/insets/insettabular.C b/src/insets/insettabular.C index 6b57b7a13c..d5e6dd5c0d 100644 --- a/src/insets/insettabular.C +++ b/src/insets/insettabular.C @@ -1983,7 +1983,8 @@ bool InsetTabular::insertAsciiString(BufferView & bv, docstring const & buf, inset->setViewCache(&bv); Paragraph & par = inset->text_.getPar(0); LyXFont const font = inset->text_.getFont(par, 0); - inset->setText(buf.substr(op, p - op), font); + inset->setText(buf.substr(op, p - op), font, + bv.buffer()->params().trackChanges); ++cols; ++cell; } @@ -1995,7 +1996,8 @@ bool InsetTabular::insertAsciiString(BufferView & bv, docstring const & buf, inset->setViewCache(&bv); Paragraph & par = inset->text_.getPar(0); LyXFont const font = inset->text_.getFont(par, 0); - inset->setText(buf.substr(op, p - op), font); + inset->setText(buf.substr(op, p - op), font, + bv.buffer()->params().trackChanges); } cols = ocol; ++row; @@ -2012,7 +2014,8 @@ bool InsetTabular::insertAsciiString(BufferView & bv, docstring const & buf, inset->setViewCache(&bv); Paragraph & par = inset->text_.getPar(0); LyXFont const font = inset->text_.getFont(par, 0); - inset->setText(buf.substr(op, len - op), font); + inset->setText(buf.substr(op, len - op), font, + bv.buffer()->params().trackChanges); } return true; } diff --git a/src/insets/insettext.C b/src/insets/insettext.C index 3194827386..3f22f7acda 100644 --- a/src/insets/insettext.C +++ b/src/insets/insettext.C @@ -329,13 +329,12 @@ bool InsetText::showInsetDialog(BufferView *) const } -void InsetText::setText(docstring const & data, LyXFont const & font) +void InsetText::setText(docstring const & data, LyXFont const & font, bool trackChanges) { clear(); Paragraph & first = paragraphs().front(); for (unsigned int i = 0; i < data.length(); ++i) - // FIXME: change tracking (MG) - first.insertChar(i, data[i], font, Change(Change::INSERTED)); + first.insertChar(i, data[i], font, trackChanges); } diff --git a/src/insets/insettext.h b/src/insets/insettext.h index 824dabe12f..2a3f7ea9b3 100644 --- a/src/insets/insettext.h +++ b/src/insets/insettext.h @@ -80,7 +80,7 @@ public: /// Code lyxCode() const { return TEXT_CODE; } /// - void setText(lyx::docstring const &, LyXFont const &); + void setText(lyx::docstring const &, LyXFont const &, bool trackChanges); /// void setAutoBreakRows(bool); /// diff --git a/src/lyxfind.C b/src/lyxfind.C index f69b4249b4..a48b5db8f8 100644 --- a/src/lyxfind.C +++ b/src/lyxfind.C @@ -186,7 +186,9 @@ int replaceAll(BufferView * bv, LyXFont const font = cur.paragraph().getFontSettings(buf.params(), pos); int striked = ssize - cur.paragraph().erase(pos, pos + ssize); - cur.paragraph().insert(pos, replacestr, font); + cur.paragraph().insert(pos, replacestr, font, + Change(buf.params().trackChanges ? + Change::INSERTED : Change::UNCHANGED)); for (int i = 0; i < rsize + striked; ++i) cur.forwardChar(); ++num; diff --git a/src/paragraph.C b/src/paragraph.C index e4664a1fec..72332c850c 100644 --- a/src/paragraph.C +++ b/src/paragraph.C @@ -251,23 +251,32 @@ int Paragraph::erase(pos_type start, pos_type end, bool trackChanges) void Paragraph::insert(pos_type start, string const & str, - LyXFont const & font) + LyXFont const & font, Change const & change) { for (size_t i = 0, n = str.size(); i != n ; ++i) - // FIXME: change tracking (MG) - insertChar(start + i, str[i], font, Change(Change::INSERTED)); + insertChar(start + i, str[i], font, change); } void Paragraph::insertChar(pos_type pos, Paragraph::value_type c, - Change const & change) + bool trackChanges) { - pimpl_->insertChar(pos, c, change); + pimpl_->insertChar(pos, c, Change(trackChanges ? + Change::INSERTED : Change::UNCHANGED)); } void Paragraph::insertChar(pos_type pos, Paragraph::value_type c, - LyXFont const & font, Change const & change) + LyXFont const & font, bool trackChanges) +{ + pimpl_->insertChar(pos, c, Change(trackChanges ? + Change::INSERTED : Change::UNCHANGED)); + setFont(pos, font); +} + + +void Paragraph::insertChar(pos_type pos, Paragraph::value_type c, + LyXFont const & font, Change const & change) { pimpl_->insertChar(pos, c, change); setFont(pos, font); diff --git a/src/paragraph.h b/src/paragraph.h index 142c8e49dd..a3cf57cd63 100644 --- a/src/paragraph.h +++ b/src/paragraph.h @@ -289,18 +289,21 @@ public: LyXFont_size def_size) const; /// void insert(lyx::pos_type pos, std::string const & str, - LyXFont const & font); + LyXFont const & font, Change const & change); /// - void insertChar(lyx::pos_type pos, value_type c, Change const & change); + void insertChar(lyx::pos_type pos, value_type c, bool trackChanges); /// void insertChar(lyx::pos_type pos, value_type c, - LyXFont const &, Change const & change); + LyXFont const &, bool trackChanges); + /// + void insertChar(lyx::pos_type pos, value_type c, + LyXFont const &, Change const & change); /// void insertInset(lyx::pos_type pos, InsetBase * inset, Change const & change); /// void insertInset(lyx::pos_type pos, InsetBase * inset, - LyXFont const &, Change const & change); + LyXFont const &, Change const & change); /// bool insetAllowed(InsetBase_code code); ///