From: Michael Schmitt Date: Tue, 24 Oct 2006 06:11:45 +0000 (+0000) Subject: change tracking: X-Git-Tag: 1.6.10~12211 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=00ffa3ca7c9c54fabe87acdee867b54974138174;p=features.git change tracking: * src/paragraph.h: rename acceptChange() to acceptChanges() * src/insets/insetbase.h: * src/insets/insettext.h: * src/insets/insettabular.h: add acceptChanges() * src/*.C: fix acceptChanges() (& also accept changes in nested insets) git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15520 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/insets/insetbase.h b/src/insets/insetbase.h index 538e99dfaf..eef82e0259 100644 --- a/src/insets/insetbase.h +++ b/src/insets/insetbase.h @@ -400,6 +400,8 @@ public: /// set the change for the entire inset virtual void setChange(Change const &) {} + /// accept the changes within the inset + virtual void acceptChanges() {}; /// pretty arbitrary virtual int width() const { return 10; } diff --git a/src/insets/insettabular.C b/src/insets/insettabular.C index 6fbbb1c706..c6f82d3a4c 100644 --- a/src/insets/insettabular.C +++ b/src/insets/insettabular.C @@ -1914,6 +1914,13 @@ void InsetTabular::setChange(Change const & change) } +void InsetTabular::acceptChanges() +{ + for (idx_type idx = 0; idx < nargs(); ++idx) + cell(idx)->acceptChanges(); +} + + bool InsetTabular::forceDefaultParagraphs(idx_type cell) const { return tabular.getPWidth(cell).zero(); diff --git a/src/insets/insettabular.h b/src/insets/insettabular.h index 47fa58b77a..469e3d27e4 100644 --- a/src/insets/insettabular.h +++ b/src/insets/insettabular.h @@ -117,6 +117,8 @@ public: /// set the change for the entire inset void setChange(Change const & change); + /// accept the changes within the inset + void acceptChanges(); // this should return true if we have a "normal" cell, otherwise false. // "normal" means without width set! diff --git a/src/insets/insettext.C b/src/insets/insettext.C index 8dcd726735..39fe2606a0 100644 --- a/src/insets/insettext.C +++ b/src/insets/insettext.C @@ -272,6 +272,18 @@ void InsetText::setChange(Change const & change) } +void InsetText::acceptChanges() +{ + ParagraphList::iterator pit = paragraphs().begin(); + ParagraphList::iterator end = paragraphs().end(); + for (; pit != end; ++pit) { + // FIXME: change tracking (MG) + // we must handle end-of-par chars! + pit->acceptChanges(0, pit->size() + 1); + } +} + + int InsetText::latex(Buffer const & buf, odocstream & os, OutputParams const & runparams) const { diff --git a/src/insets/insettext.h b/src/insets/insettext.h index 7c40354efa..34219d0bf6 100644 --- a/src/insets/insettext.h +++ b/src/insets/insettext.h @@ -104,6 +104,8 @@ public: /// set the change for the entire inset void setChange(Change const & change); + /// accept the changes within the inset + void acceptChanges(); /// append text onto the existing text void appendParagraphs(Buffer * bp, ParagraphList &); diff --git a/src/paragraph.C b/src/paragraph.C index cab8a1b26a..6f9701139c 100644 --- a/src/paragraph.C +++ b/src/paragraph.C @@ -1441,9 +1441,9 @@ void Paragraph::setChange(pos_type pos, Change const & change) } -void Paragraph::acceptChange(pos_type start, pos_type end) +void Paragraph::acceptChanges(pos_type start, pos_type end) { - return pimpl_->acceptChange(start, end); + return pimpl_->acceptChanges(start, end); } diff --git a/src/paragraph.h b/src/paragraph.h index be0d0b1ef7..60dd0fba93 100644 --- a/src/paragraph.h +++ b/src/paragraph.h @@ -217,8 +217,8 @@ public: /// set change at given pos void setChange(pos_type pos, Change const & change); - /// accept change - void acceptChange(pos_type start, pos_type end); + /// accept changes within the given range + void acceptChanges(pos_type start, pos_type end); /// reject change void rejectChange(pos_type start, pos_type end); diff --git a/src/paragraph_pimpl.C b/src/paragraph_pimpl.C index ff3bd2f2c3..1d9512a328 100644 --- a/src/paragraph_pimpl.C +++ b/src/paragraph_pimpl.C @@ -127,41 +127,33 @@ Change const Paragraph::Pimpl::lookupChange(pos_type pos) const } -void Paragraph::Pimpl::acceptChange(pos_type start, pos_type end) +void Paragraph::Pimpl::acceptChanges(pos_type start, pos_type end) { - // FIXME: change tracking (MG) - return; - - // care for empty pars - - lyxerr[Debug::CHANGES] << "acceptchange" << endl; - pos_type i = start; - - for (; i < end; ++i) { - switch (lookupChange(i).type) { + for (pos_type pos = start; pos < end; ++pos) { + switch (lookupChange(pos).type) { case Change::UNCHANGED: break; case Change::INSERTED: - // FIXME: change tracking (MG) - changes_.set(Change(Change::UNCHANGED), i); + changes_.set(Change(Change::UNCHANGED), pos); break; case Change::DELETED: // Suppress access to nonexistent // "end-of-paragraph char": - if (i < size()) { - eraseChar(i, false); + if (pos < size()) { + eraseChar(pos, false); --end; - --i; + --pos; } break; } - } - lyxerr[Debug::CHANGES] << "endacceptchange" << endl; - // FIXME: change tracking (MG) - // changes_.reset(Change::UNCHANGED); + // also accept changes in nested insets + if (pos < size() && owner_->isInset(pos)) { + owner_->getInset(pos)->acceptChanges(); + } + } } diff --git a/src/paragraph_pimpl.h b/src/paragraph_pimpl.h index aacf9bb3b5..facbcb22fc 100644 --- a/src/paragraph_pimpl.h +++ b/src/paragraph_pimpl.h @@ -49,8 +49,8 @@ public: void setChange(Change const & change); /// set change at given pos void setChange(pos_type pos, Change const & change); - /// accept change - void acceptChange(pos_type start, pos_type end); + /// accept changes within the given range + void acceptChanges(pos_type start, pos_type end); /// reject change void rejectChange(pos_type start, pos_type end); diff --git a/src/text.C b/src/text.C index 6b3c6f93c0..d953f955d3 100644 --- a/src/text.C +++ b/src/text.C @@ -1464,7 +1464,7 @@ void LyXText::acceptChange(LCursor & cur) pos_type left = ( pit == it.pit() ? it.pos() : 0 ); pos_type right = ( pit == et.pit() ? et.pos() : pars_[pit].size() + 1 ); - pars_[pit].acceptChange(left, right); + pars_[pit].acceptChanges(left, right); } if (isDeleted) { ParagraphList & plist = paragraphs();