]> git.lyx.org Git - features.git/commitdiff
mathed48.diff
authorLars Gullik Bjønnes <larsbj@gullik.org>
Thu, 8 Mar 2001 11:51:35 +0000 (11:51 +0000)
committerLars Gullik Bjønnes <larsbj@gullik.org>
Thu, 8 Mar 2001 11:51:35 +0000 (11:51 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1709 a592a061-630c-0410-9148-cb99ea01b6c8

src/mathed/ChangeLog
src/mathed/math_matrixinset.C
src/mathed/math_parser.C
src/mathed/math_rowst.h
src/mathed/math_xiter.C
src/mathed/math_xiter.h

index ef6f8866497d93bf3796d2e9b3846f0208179280..86046e7be04b73ec2dbd715776078b01bd463e06 100644 (file)
@@ -1,3 +1,9 @@
+2001-03-08  André Pönitz  <poenitz@htwm.de>
+       * math_rowst.h: give MathedRowContainer an 'insert' method. 
+
+       * math_xiter.C: new 'container()' method to encapsulated access to
+         the MathParInset's MathedRowContainer
+       
 2001-03-06  André Pönitz  <poenitz@htwm.de>
        * array.[Ch]: factor out deep_copy,
          remove third argument from raw_pointer_insert 
index ee3393d06ae20e9b358582c80ebd53a1219651f0..d791c11fe1d4b80eb425e75f374d3acf3a8f1f66 100644 (file)
@@ -52,7 +52,7 @@ MathMatrixInset::MathMatrixInset(MathMatrixInset const & mt)
                        if (!ro) 
                                row_ = r;
                        else
-                               ro->setNext(r);
+                               ro->next_ = r;
                        mrow = mrow->next_;
                        ro = r;
                        ++nr_;
index a4c33ef978609e682c4cb3fa60ab5fcfb3313251..ea084cc4943b44672e5dc3c7416c978679ada311 100644 (file)
@@ -603,8 +603,8 @@ void mathed_parse(MathedArray & array, unsigned flags = 0,
                        if (mt && (flags & FLAG_END)) {
                                if (mt->Permit(LMPF_ALLOW_CR)) {
                                        if (crow) {
-                                               crow->setNext(new MathedRowSt(mt->GetColumns() + 1)); // this leaks
-                                               crow = crow->getNext();
+                                               crow->next_ = new MathedRowSt(mt->GetColumns() + 1);
+                                               crow = crow->next_;
                                        }
                                        data.insert('K', LM_TC_CR);
                                } else 
index 602198d3095a07b660b9e9af2e520a4c3767844f..373aff6bcabb8c7c5dd923e7a772b91b954ccbb3 100644 (file)
@@ -69,11 +69,6 @@ public:
        explicit MathedRowSt(int n)
                        : MathedRowStruct(n), next_(0)
                {}
-       /// Should be const but...
-       MathedRowSt * getNext() const;
-       /// ...we couldn't use this.
-       void setNext(MathedRowSt * n);
-//private:
        ///
        MathedRowSt * next_;
 };
@@ -90,7 +85,7 @@ struct MathedRowContainer {
                iterator() : st_(0) {}
                ///
                explicit iterator(MathedRowSt * st) : st_(st) {}
-               /// "better" conversion to bool
+               ///
                explicit iterator(MathedRowContainer * m) : st_(m->data_) {}
                /// "better" conversion to bool
                operator void *() const { return st_; }
@@ -122,26 +117,30 @@ struct MathedRowContainer {
        ///
        bool empty() const { return data_ == 0; }
 
+       /// insert 'item' before 'iterator'
+       void insert(iterator const & pos, MathedRowSt const & item) {
+               MathedRowSt * st = new MathedRowSt(item);
+               link_before(pos, st);
+       }
+
+       void link_before(iterator const & it, MathedRowSt * r) {
+               if (data_ == it.st_)
+                       data_ = r;
+               else {
+                       MathedRowSt * pos = data_;
+                       if (pos->next_ == it.st_)
+                               pos->next_ = r;
+               }
+               r->next_  = it.st_;
+       }
+                       
+
        ///
        MathedRowSt * data_;
 };
 
 
 
-inline
-MathedRowSt * MathedRowSt::getNext() const
-{
-       return next_;
-}
-
-
-inline
-void MathedRowSt::setNext(MathedRowSt * n)
-{
-       next_ = n;
-}
-
-
 inline
 string const & MathedRowStruct::getLabel() const
 {
index bc91d0a1fd2f22394eb9c4e0e6dbbc06358b9ab4..9e54961bf77068f63ac31b54f5cb7590b8bcde3e 100644 (file)
@@ -36,6 +36,12 @@ MathParInset * MathedXIter::getPar() const
        return p_;
 }
 
+MathedRowContainer & MathedXIter::container()
+{
+       Assert(p_);
+       return p_->getRowSt();
+}
+
 
 void MathedXIter::GetPos(int & xx, int & yy) const
 { 
@@ -122,7 +128,7 @@ void MathedXIter::Clean(int pos2)
                                MathedRowContainer::iterator r = crow_;
                                ++r;
                                if (r) {
-                                       crow_.st_->setNext(r.st_->getNext());
+                                       crow_.st_->next_ = r.st_->next_;
                                        delete r.st_;
                                }          
                        }
@@ -160,10 +166,10 @@ void MathedXIter::Merge(MathedArray const & a)
                        if (p_ && p_->Permit(LMPF_ALLOW_CR)) {
                                MathedRowContainer::iterator r( new MathedRowSt(ncols + 1) );
                                if (crow_) {
-                                       r.st_->setNext(crow_.st_->getNext());
-                                       crow_.st_->setNext(r.st_);
+                                       r.st_->next_ = crow_.st_->next_;
+                                       crow_.st_->next_ = r.st_;
                                } else {
-                                       r.st_->setNext(0);
+                                       r.st_->next_ = 0;
                                }
                                crow_ = r;
                        } else {
@@ -186,7 +192,7 @@ void MathedXIter::SetData(MathParInset * pp)
        x_ = y_ = 0;
        array = &p_->GetData();
        ncols = p_->GetColumns();
-       crow_ = p_->getRowSt().begin();
+       crow_ = container().begin();
        if (p_->Permit(LMPF_ALLOW_CR))
                flags |= MthIF_CR;
        if (p_->Permit(LMPF_ALLOW_TAB))
@@ -240,7 +246,7 @@ bool MathedXIter::Next()
                        } else
                                if (c == LM_TC_CR && p_) {
                                        x_ = 0;
-                                       if (crow_ && crow_.st_->getNext()) {
+                                       if (crow_ && crow_.st_->next_) {
                                                ++crow_;
                                                y_ = crow_->getBaseline();
                                                w = crow_->getTab(0);
@@ -272,7 +278,7 @@ void MathedXIter::GoBegin()
        x_ = y_ = 0;   
        sw_ = sx_ = 0;
        if (p_) {
-               crow_ = p_->getRowSt().begin();
+               crow_ = container().begin();
                if (crow_) {
                        x_ = crow_->getTab(0);
                        y_ = crow_->getBaseline();
@@ -375,11 +381,11 @@ void MathedXIter::addRow()
        // Create new item for the structure    
        MathedRowContainer::iterator r( new MathedRowSt(ncols + 1) );
        if (crow_) {
-               r.st_->setNext(crow_.st_->getNext());
-               crow_.st_->setNext(r.st_);
+               r.st_->next_ = crow_.st_->next_;
+               crow_.st_->next_ = r.st_;
        } else {
                crow_ = r;
-               r.st_->setNext(0);
+               r.st_->next_ = 0;
        }    
        // Fill missed tabs in current row
        while (col < ncols - 1) 
@@ -419,9 +425,9 @@ void MathedXIter::delRow()
        
        if (line_empty) {
                
-               MathedRowContainer::iterator r( crow_.st_->getNext() );
+               MathedRowContainer::iterator r( crow_.st_->next_ );
                if (r) {
-                       crow_.st_->setNext(r.st_->getNext());
+                       crow_.st_->next_ = r.st_->next_;
                        delete r.st_;
                }
                join(p1);
@@ -447,7 +453,7 @@ void MathedXIter::ipop()
        x_ = stck.x;
        y_ = stck.y;
        if (p_) {
-               crow_ = p_->getRowSt().begin();
+               crow_ = container().begin();
                if (crow_)
                        for (int i = 0; i < row; ++i)
                                ++crow_;
@@ -599,7 +605,7 @@ MathedRowSt * MathedXIter::adjustVerticalSt()
                        if (col >= ncols) ncols = col + 1; 
                        MathedRowSt * r = new MathedRowSt(ncols + 1); // this leaks
 //         r->next = crow_->next;
-                       crow_.st_->setNext(r);
+                       crow_.st_->next_ = r;
                        crow_.st_ = r;
 //         lyxerr << " CX[" << crow_ << "]";
                }   
index f9ecd8c1294d68111f89eb725029fb822d1ace6a..fb5201aafbbe6cf6299cf66c247f31078b7462b9 100644 (file)
@@ -4,6 +4,7 @@
 
 #include "math_iter.h"
 #include "math_rowst.h"
+#include "math_rowst.h"
 
 class MathParInset;
 
@@ -86,6 +87,8 @@ public:
        }
        
 private:
+       ///
+       MathedRowContainer & container();
        /// This function is not recursive, as MathPar::Metrics is
        void IMetrics(int, int &, int &, int &);
        /// Font size (display, text, script, script2) 
@@ -106,7 +109,6 @@ private:
        bool limits_;
        /// 
        MathedRowContainer::iterator crow_;
-       
        ///
        //friend class MathedCursor;
 };