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

src/mathed/math_matrixinset.C
src/mathed/math_matrixinset.h
src/mathed/math_parinset.h
src/mathed/math_rowst.h
src/mathed/math_xiter.C

index d791c11fe1d4b80eb425e75f374d3acf3a8f1f66..cd9d291a3117b7d80213300bf201ade0ce9a2e37 100644 (file)
@@ -15,20 +15,21 @@ extern int number_of_newlines;
 
 MathMatrixInset::MathMatrixInset(int m, int n, short st)
        : MathParInset(st, "array", LM_OT_MATRIX), nc_(m), nr_(0), ws_(m),
-         v_align_(0), h_align_(nc_, 'c'), row_(0)
+         v_align_(0), h_align_(nc_, 'c')
 {
        flag = 15;
        if (n > 0) {
-               row_ = new MathedRowSt(nc_ + 1);
+               row_.data_ = new MathedRowSt(nc_ + 1);
                MathedXIter it(this);
-               for (int j = 1; j < n; ++j) it.addRow();
+               for (int j = 1; j < n; ++j)
+                       it.addRow();
                nr_ = n;
                if (nr_ == 1 && nc_ > 1) {
                        for (int j = 0; j < nc_ - 1; ++j) 
                                it.insert('T', LM_TC_TAB);
                }
        } else if (n < 0) {
-               row_ = new MathedRowSt(nc_ + 1);
+               row_.data_ = new MathedRowSt(nc_ + 1);
                nr_ = 1;
        }
 }
@@ -50,7 +51,7 @@ MathMatrixInset::MathMatrixInset(MathMatrixInset const & mt)
                        //if (mrow->label) 
                        r->setLabel(mrow->getLabel());
                        if (!ro) 
-                               row_ = r;
+                               row_.data_ = r;
                        else
                                ro->next_ = r;
                        mrow = mrow->next_;
@@ -58,7 +59,7 @@ MathMatrixInset::MathMatrixInset(MathMatrixInset const & mt)
                        ++nr_;
                }
        } else   
-               row_ = 0;
+               row_.data_ = 0;
        flag = mt.flag;
 }
 
@@ -136,7 +137,7 @@ void MathMatrixInset::Metrics()
        if (row_.empty()) {
                // lyxerr << " MIDA ";
                MathedXIter it(this);
-               row_ = it.adjustVerticalSt();
+               row_.data_ = it.adjustVerticalSt();
        } 
        
        // Clean the arrays      
index 6ee2478ec02f26c5a2c261b4fe6c8ddb39d79347..8561d72a3b5dd6ebb17468087281c692da0732cf 100644 (file)
@@ -46,8 +46,6 @@ public:
        
        /// Use this to manage the extra information independently of paragraph
        MathedRowContainer & getRowSt();
-       ///
-       void setRowSt(MathedRowContainer & r);
 private:
        ///  Number of columns & rows
        int nc_;
@@ -91,11 +89,4 @@ MathedRowContainer & MathMatrixInset::getRowSt()
 {
        return row_;
 }
-
-
-inline
-void MathMatrixInset::setRowSt(MathedRowContainer & r)
-{
-       row_ = r;
-}
 #endif
index b3d8bc7d06e8f2723d933d95ecdf9cacd2098751..fc332c64e9b41d4a490779ef6948cc8c189c997c 100644 (file)
@@ -69,8 +69,6 @@ public:
        ///
        virtual MathedRowContainer & getRowSt();
        ///
-       virtual void setRowSt(MathedRowContainer &);
-       ///
        virtual bool Permit(short f) const;
        ///
        int xo() const;
@@ -149,11 +147,6 @@ int MathParInset::getMaxArgumentIdx() const
 }
 
 
-inline
-void MathParInset::setRowSt(MathedRowContainer &)
-{}
-
-
 inline
 int MathParInset::xo() const
 {
index 373aff6bcabb8c7c5dd923e7a772b91b954ccbb3..488967e4faa4b7f1461a11847b45f76ce511d2bc 100644 (file)
@@ -63,14 +63,20 @@ protected:
        bool numbered_;
 };
 
+
+class MathedRowContainer;
+
 class MathedRowSt : public MathedRowStruct {
 public:
        ///
        explicit MathedRowSt(int n)
                        : MathedRowStruct(n), next_(0)
                {}
+//private:
        ///
        MathedRowSt * next_;
+       ///
+       friend class MathedRowContainer;
 };
 
 
@@ -109,8 +115,6 @@ struct MathedRowContainer {
 
        ///
        MathedRowContainer() : data_(0) {}
-       ///
-       MathedRowContainer(MathedRowSt * data) : data_(data) {}
 
        ///
        iterator begin() { return iterator(this); }
@@ -118,12 +122,8 @@ 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) {
+       void insert(iterator const & it, MathedRowSt const & item) {
+               MathedRowSt * r = new MathedRowSt(item);
                if (data_ == it.st_)
                        data_ = r;
                else {
@@ -134,9 +134,25 @@ struct MathedRowContainer {
                r->next_  = it.st_;
        }
                        
+       /// insert 'item' after 'iterator'
+       void insert_after(iterator & it, MathedRowSt const & item) {
+               MathedRowSt * r = new MathedRowSt(item);
+               if (it) {
+                       r->next_ = it.st_->next_;
+                       it.st_->next_ = r;
+               } else {
+                       it.st_ = r;
+                       r->next_ = 0;
+               }
+       }
 
        ///
        MathedRowSt * data_;
+
+private:
+       // currently unimplemented just to make sure it's not used
+       MathedRowContainer(MathedRowContainer const &); // unimplemented
+       void operator=(MathedRowContainer const &); // unimplemented
 };
 
 
index 9e54961bf77068f63ac31b54f5cb7590b8bcde3e..d2204c111370d59d62dbf50f7ca23a30de1d7a76 100644 (file)
@@ -164,14 +164,8 @@ void MathedXIter::Merge(MathedArray const & a)
        while (pos < pos2 && OK()) {
                if (IsCR()) {
                        if (p_ && p_->Permit(LMPF_ALLOW_CR)) {
-                               MathedRowContainer::iterator r( new MathedRowSt(ncols + 1) );
-                               if (crow_) {
-                                       r.st_->next_ = crow_.st_->next_;
-                                       crow_.st_->next_ = r.st_;
-                               } else {
-                                       r.st_->next_ = 0;
-                               }
-                               crow_ = r;
+                               container().insert_after(crow_, MathedRowSt(ncols + 1));
+                               ++crow_;
                        } else {
                                Delete();
                                --pos2;
@@ -378,15 +372,9 @@ void MathedXIter::addRow()
                
                return;
        }
+
        // Create new item for the structure    
-       MathedRowContainer::iterator r( new MathedRowSt(ncols + 1) );
-       if (crow_) {
-               r.st_->next_ = crow_.st_->next_;
-               crow_.st_->next_ = r.st_;
-       } else {
-               crow_ = r;
-               r.st_->next_ = 0;
-       }    
+       container().insert_after(crow_, MathedRowSt(ncols + 1));
        // Fill missed tabs in current row
        while (col < ncols - 1) 
                insert('T', LM_TC_TAB); 
@@ -595,19 +583,16 @@ MathedRowSt * MathedXIter::adjustVerticalSt()
 {
        GoBegin();
        if (!crow_) {
-//     lyxerr << " CRW" << ncols << " ";
                crow_.st_ = new MathedRowSt(ncols + 1); // this leaks
        }
-//    lyxerr<< " CRW[" << crow_ << "] ";
        MathedRowSt * mrow = crow_.st_;
        while (OK()) {
                if (IsCR()) {
-                       if (col >= ncols) ncols = col + 1; 
+                       if (col >= ncols)
+                               ncols = col + 1; 
                        MathedRowSt * r = new MathedRowSt(ncols + 1); // this leaks
-//         r->next = crow_->next;
                        crow_.st_->next_ = r;
                        crow_.st_ = r;
-//         lyxerr << " CX[" << crow_ << "]";
                }   
                Next(); 
        }