]> git.lyx.org Git - features.git/commitdiff
change tracking:
authorMichael Schmitt <michael.schmitt@teststep.org>
Tue, 24 Oct 2006 06:11:45 +0000 (06:11 +0000)
committerMichael Schmitt <michael.schmitt@teststep.org>
Tue, 24 Oct 2006 06:11:45 +0000 (06:11 +0000)
        * 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

src/insets/insetbase.h
src/insets/insettabular.C
src/insets/insettabular.h
src/insets/insettext.C
src/insets/insettext.h
src/paragraph.C
src/paragraph.h
src/paragraph_pimpl.C
src/paragraph_pimpl.h
src/text.C

index 538e99dfaffe89e9d05b04b8f5bc42587b56375a..eef82e0259df1bfa646f3fe8e1ca144ab56c9de9 100644 (file)
@@ -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; }
index 6fbbb1c706b631031a8de3de6dd518d306214285..c6f82d3a4c3ca1234bec2c3b34f212377bfdc006 100644 (file)
@@ -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();
index 47fa58b77a6350313d87916ec894c17fe7915bb5..469e3d27e4d9c577279bfedaa8ed290910d39dd1 100644 (file)
@@ -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!
index 8dcd7267350a590e2195050bcd682ce452a3cd94..39fe2606a0dec3944c94069f30013c23009e9b87 100644 (file)
@@ -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
 {
index 7c40354efa78f1c06228ea906b505c2d82948fce..34219d0bf65bdb2d8fbc290cf8485bb7f2216807 100644 (file)
@@ -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 &);
index cab8a1b26a04ef32af01750ff206a9bfa51c8c83..6f9701139c36bad41940c77842a640bcb16ffdd0 100644 (file)
@@ -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);
 }
 
 
index be0d0b1ef7df8dbfb3fd900d3adea8bd334531b8..60dd0fba9366799e9bd4b439982fa5a884b0442e 100644 (file)
@@ -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);
index ff3bd2f2c3f2d729762577d8d5e2797fbfd83a1c..1d9512a328e87d4da8f2cfd9ff783066401d6dfd 100644 (file)
@@ -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();
+               }
+       }
 }
 
 
index aacf9bb3b52c868a23ace0fbec940bf6a2f8c5d4..facbcb22fcb69c48c74c7325c1ce465af68f305e 100644 (file)
@@ -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);
 
index 6b3c6f93c05a4ddb648f6f9809f3d478afd8e62f..d953f955d376a33bca846f1153e0060a34d7cbf1 100644 (file)
@@ -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();