]> git.lyx.org Git - features.git/commitdiff
mathed33.diff
authorLars Gullik Bjønnes <larsbj@gullik.org>
Tue, 20 Feb 2001 16:00:22 +0000 (16:00 +0000)
committerLars Gullik Bjønnes <larsbj@gullik.org>
Tue, 20 Feb 2001 16:00:22 +0000 (16:00 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1577 a592a061-630c-0410-9148-cb99ea01b6c8

17 files changed:
src/mathed/formula.C
src/mathed/formulamacro.C
src/mathed/math_cursor.C
src/mathed/math_fracinset.C
src/mathed/math_fracinset.h
src/mathed/math_macro.C
src/mathed/math_macro.h
src/mathed/math_macrotable.C
src/mathed/math_macrotemplate.C
src/mathed/math_matrixinset.C
src/mathed/math_matrixinset.h
src/mathed/math_parinset.C
src/mathed/math_parinset.h
src/mathed/math_parser.C
src/mathed/math_root.C
src/mathed/math_root.h
src/mathed/math_xiter.C

index 19e1f78f489c5add63315c7f75f89c6e85be3555..c2e88945f8daeae4b212c11108dcac9df0f2282f 100644 (file)
@@ -1224,7 +1224,7 @@ InsetFormula::LocalDispatch(BufferView * bv, int action, string const & arg)
 static
 void mathedValidate(LaTeXFeatures & features, MathParInset * par)
 {
-       MathedIter it(par->GetData());
+       MathedIter it(&par->GetData());
 
        while (it.OK() && !(features.binom && features.boldsymbol)) {
                if (it.IsInset()) {
index e93d5ea8163d14b23dd382ec33ec1533a24037bc..ca8d0604f5e4e4d6430d959d198bc43638ff9cf1 100644 (file)
@@ -195,9 +195,6 @@ void InsetFormulaMacro::Edit(BufferView * bv, int x, int y,unsigned int button)
 void InsetFormulaMacro::InsetUnlock(BufferView * bv)
 {
        opened = false;
-       MathedArray * tarray = tmacro->GetData();
-       MathedIter it(tarray);
-       it.Clear();
        tmacro->setData(par->GetData());
        tmacro->setEditMode(false);
        InsetFormula::InsetUnlock(bv);
index ed18539c844894a00f3d3d4fb56fc508a4002f6c..e547399f65b85437c3990ed72131b6407731c25a 100644 (file)
@@ -452,7 +452,6 @@ void MathedCursor::Insert(byte c, MathedTextCodes t)
                        mt->SetStyle(LM_ST_DISPLAY);
                        mt->SetType(type);
                        mt->setData(p->GetData());
-                       p->setData(0);                          // BUG duda
                        delete p;
                        par = mt;
                        p = mt;
@@ -509,7 +508,7 @@ void MathedCursor::insertInset(MathedInset * p, int t)
        if (selection) {
                if (MathIsActive(t)) {
                        SelCut();
-                       static_cast<MathParInset*>(p)->setData(&selarray);
+                       static_cast<MathParInset*>(p)->setData(selarray);
                } else
                        SelDel();
        }
@@ -841,11 +840,11 @@ bool MathedCursor::pullArg()
                if (!p) 
                        return false;
                
-               MathedArray a = p->GetData();
+               MathedArray a = p->GetData();
                p->clear();
                Delete();
-               if (!a->empty()) {
-                       cursor->Merge(a);
+               if (!a.empty()) {
+                       cursor->Merge(&a);
                        cursor->Adjust();
                }
 
index 62768142e61fa35f87d3db0f6ec110652f607ff0..4ea4fb92781a855c432309fa8818c4a99e603048 100644 (file)
@@ -59,14 +59,14 @@ void MathFracInset::SetStyle(short st)
 }
 
 
-void MathFracInset::SetData(MathedArray * n, MathedArray * d)
+void MathFracInset::SetData(MathedArray const & n, MathedArray const & d)
 {
        den_->setData(d);
        MathParInset::setData(n);
 }
 
 
-void MathFracInset::setData(MathedArray * d)
+void MathFracInset::setData(MathedArray const & d)
 {
        if (idx_ == 0)
                MathParInset::setData(d);
@@ -85,10 +85,10 @@ void MathFracInset::GetXY(int & x, int & y) const
 }
 
 
-MathedArray * MathFracInset::GetData()
+MathedArray & MathFracInset::GetData()
 {
        if (idx_ == 0)
-               return &array;
+               return array;
        else
                return den_->GetData();
 }
index 071176b4373a920c72f234dcb5def9b6decc3463..1d51a41a06e67b1b957f2ec17425451ecfb525d3 100644 (file)
@@ -22,12 +22,12 @@ public:
        ///
        void Metrics();
        
-       /** This does the same that SetData(MathedArray*) but for both
+       /** This does the same that SetData(MathedArray const &) but for both
            numerator and denominator at once.
        */
-       void SetData(MathedArray *, MathedArray *);
+       void SetData(MathedArray const &, MathedArray const &);
        ///
-       void setData(MathedArray *);
+       void setData(MathedArray const &);
        ///
        void GetXY(int & x, int & y) const;
        ///
@@ -35,7 +35,7 @@ public:
        ///
        bool Inside(int, int);
        ///
-       MathedArray * GetData();
+       MathedArray & GetData();
        ///
        bool setArgumentIdx(int i); // was bool Up/down(void);
        ///
index d157513d0d8bc5569081d47809c04d1b0bacffa5..45b8e51255b0cedacc6b92ec27c8507fa7598ebc 100644 (file)
@@ -70,7 +70,7 @@ MathMacro::MathMacro(MathMacro * m):
        for (int i = 0; i < tmplate_->getNoArgs(); ++i) {
                m->setArgumentIdx(i);
                args_[i].row   = m->args_[i].row;
-               args_[i].array = *(m->GetData());
+               args_[i].array = m->GetData();
        }
 }
 
@@ -134,9 +134,9 @@ int MathMacro::getMaxArgumentIdx() const
 } 
 
 
-MathedArray * MathMacro::GetData() 
+MathedArray & MathMacro::GetData() 
 { 
-       return &args_[idx_].array; 
+       return args_[idx_].array; 
 } 
 
 
@@ -167,9 +167,9 @@ void MathMacro::SetFocus(int x, int y)
 }
 
 
-void MathMacro::setData(MathedArray * a)
+void MathMacro::setData(MathedArray const & a)
 {
-       args_[idx_].array = *a;
+       args_[idx_].array = a;
 }
 
 
index 24269eb3666657dd606f713416d9a54f544073ba..3604468d585332ee4ece78fd00667940b1769f4d 100644 (file)
@@ -63,11 +63,11 @@ public:
        ///
        void SetFocus(int, int);
        ///
-       MathedArray * GetData();
+       MathedArray & GetData();
        ///
        MathedRowSt * getRowSt() const;
        ///
-       void setData(MathedArray *);
+       void setData(MathedArray const &);
        ///
        MathedTextCodes getTCode() const;
        ///
index 29ecb06874a8753dc90ca6ef5608c750c95fb692..24be222fe35e9520402594618338d69c7f5785be 100644 (file)
@@ -59,8 +59,8 @@ void MathMacroTable::builtinMacros()
        MathMacroTemplate * m = new MathMacroTemplate("notin");  // this leaks
        addTemplate(m);
        {
-               MathedArray * array = new MathedArray; // this leaks
-               MathedIter iter(array);
+               MathedArray array;
+               MathedIter iter(&array);
                iter.insertInset(new MathAccentInset(LM_in, LM_TC_BOPS, LM_not),
                                 LM_TC_INSET); // this leaks
                m->setData(array);
@@ -70,8 +70,8 @@ void MathMacroTable::builtinMacros()
        m = new MathMacroTemplate("emptyset"); // this leaks
        addTemplate(m); 
        {
-               MathedArray * array = new MathedArray; // this leaks
-               MathedIter iter(array);
+               MathedArray array;
+               MathedIter iter(&array);
                iter.insertInset(new MathAccentInset('O', LM_TC_RM, LM_not),
                                 LM_TC_INSET); // this leaks
                m->setData(array);
@@ -80,8 +80,8 @@ void MathMacroTable::builtinMacros()
        m = new MathMacroTemplate("perp"); // this leaks
        addTemplate(m);
        {
-               MathedArray * array = new MathedArray; // this leaks
-               MathedIter iter(array);
+               MathedArray array;
+               MathedIter iter(&array);
                iter.insert(LM_bot, LM_TC_BOP);
                m->setData(array);
        }
@@ -90,21 +90,21 @@ void MathMacroTable::builtinMacros()
        m = new MathMacroTemplate("binom", 2);
        addTemplate(m);
        {
-               MathedArray * array = new MathedArray; 
+               MathedArray array;
                m->setData(array);
-               MathedIter iter(array);
+               MathedIter iter(&array);
                inset = new MathDelimInset('(', ')');
                iter.insertInset(inset, LM_TC_ACTIVE_INSET);
-               array = new MathedArray; 
-               MathedIter iter2(array);
+               array = MathedArray();
+               MathedIter iter2(&array);
                MathFracInset * frac = new MathFracInset(LM_OT_ATOP);
                iter2.insertInset(frac, LM_TC_ACTIVE_INSET);
                inset->setData(array);
-               array = new MathedArray;
-               MathedArray * array2 = new MathedArray;  
-               MathedIter iter3(array);
+               array = MathedArray();
+               MathedArray array2;
+               MathedIter iter3(&array);
                iter3.insertInset(m->getMacroPar(0), LM_TC_INSET);
-               MathedIter iter4(array2);
+               MathedIter iter4(&array2);
                iter4.insertInset(m->getMacroPar(1), LM_TC_INSET);
                frac->SetData(array, array2);
        }
index eeaede5705b3f5df527587e796fb66f374e41943..7f0589e666ab60fc4c32af0dabfbaf577751a0fa 100644 (file)
@@ -45,12 +45,7 @@ MathMacroTemplate::MathMacroTemplate(string const & nm, int na, int flg):
 
 
 MathMacroTemplate::~MathMacroTemplate()
-{
-       // prevent to delete already deleted objects
-       for (int i = 0; i < nargs_; ++i) {
-               args_[i].setData(0);
-       }
-}
+{}
 
 
 void MathMacroTemplate::setEditMode(bool ed)
@@ -154,7 +149,7 @@ void MathMacroTemplate::WriteDef(ostream & os, bool fragile)
 
 void MathMacroTemplate::setArgument(MathedArray * a, int i)
 {
-       args_[i].setData(a);
+       args_[i].setData(*a);
 }
 
 
index 3adde0463259fbf9a8082b8484b5b2b603b47e9d..8ba729f5cc6a14714fd668d589f85952ef11172f 100644 (file)
@@ -35,7 +35,7 @@ MathMatrixInset::MathMatrixInset(MathMatrixInset * mt)
          nc_(mt->nc_), nr_(0), ws_(mt->nc_),
          v_align_(mt->v_align_), h_align_(mt->h_align_)
 {
-       array = *(mt->GetData());
+       array = mt->GetData();
        if (mt->row_ != 0) {
                MathedRowSt * ro = 0;
                MathedRowSt * mrow = mt->row_;
@@ -84,10 +84,11 @@ void MathMatrixInset::SetAlign(char vv, string const & hh)
 
 
 // Check the number of tabs and crs
-void MathMatrixInset::setData(MathedArray * a)
+void MathMatrixInset::setData(MathedArray const & a)
 {
-       if (!a) return;
-       MathedIter it(a);
+       array = a;
+
+       MathedIter it(&array);
        int nn = nc_ - 1;
        nr_ = 1;
        // count tabs per row
@@ -115,7 +116,6 @@ void MathMatrixInset::setData(MathedArray * a)
        
        // Automatically inserts tabs around bops
        // DISABLED because it's very easy to insert tabs 
-       array = *a;
 }
 
 
index 2645611cf615a362b5c86c104f9029063559ba38..78603f1f8c5acc41286f0d0e96cf2d927f18f0ea 100644 (file)
@@ -30,7 +30,7 @@ public:
        ///
        void Metrics();
        ///
-       void setData(MathedArray *);
+       void setData(MathedArray const &);
        ///
        void SetAlign(char, string const &);
        ///
index 862f4554d043422a35f06192bb8fd51f80146bf1..1a0e01b25dd4cc1cbd0ad11881747762ef445bc7 100644 (file)
@@ -46,15 +46,9 @@ MathedInset * MathParInset::Clone()
 }
 
 
-void MathParInset::setData(MathedArray * a)
+void MathParInset::setData(MathedArray const & a)
 {
-       if (!a) {
-               lyxerr << "can't set Data from NULL pointer" << endl;
-               array = MathedArray();
-               return;
-       }
-
-       array = *a;
+       array = a;
        
        // A standard paragraph shouldn't have any tabs nor CRs.
        MathedIter it(&array);
@@ -430,9 +424,9 @@ bool MathParInset::Permit(short f) const
 }
 
 
-MathedArray * MathParInset::GetData()
+MathedArray & MathParInset::GetData()
 {
-       return &array;
+       return array;
 }
 
 
index ede21651d8be3a7a32fe8c07efd7f2ddeb4df304..539f569ec69ab1395709b3d4fc342dc144b47126 100644 (file)
@@ -31,9 +31,9 @@ public:
        ///
        virtual void UserSetSize(short);
        /// Data is stored in a LyXArray
-       virtual void setData(MathedArray *);
+       virtual void setData(MathedArray const &);
        ///
-       virtual MathedArray * GetData();
+       virtual MathedArray & GetData();
        /// Paragraph position
        virtual void GetXY(int &, int &) const;
        ///
index 3a2e90d73303206b9c0958ed81c2c9786031801d..b74cdd5a9799187cb63e5394a0de2df96df7e391 100644 (file)
@@ -469,7 +469,7 @@ MathedArray * mathed_parse(unsigned flags = 0, MathedArray * array = 0,
          macro = new MathMacroTemplate(name, na);
          flags = FLAG_BRACE|FLAG_BRACE_LAST;
          *mtx = macro;
-         macro->setData(array);
+         macro->setData(*array);
          break;
       }
     case LM_TK_SPECIAL:
@@ -560,7 +560,7 @@ MathedArray * mathed_parse(unsigned flags = 0, MathedArray * array = 0,
       {  
         MathParInset * p = new MathParInset(size, "", LM_OT_SCRIPT);
         MathedArray * ar = mathed_parse(FLAG_BRACE_OPT|FLAG_BRACE_LAST, 0);
-        p->setData(ar);
+        p->setData(*ar);
 //      lyxerr << "UP[" << p->GetStyle() << "]" << endl;
         data.insertInset(p, LM_TC_UP);
         break;
@@ -569,7 +569,7 @@ MathedArray * mathed_parse(unsigned flags = 0, MathedArray * array = 0,
       {
         MathParInset * p = new MathParInset(size, "", LM_OT_SCRIPT);
         MathedArray * ar = mathed_parse(FLAG_BRACE_OPT|FLAG_BRACE_LAST, 0);
-        p->setData(ar);
+        p->setData(*ar);
         data.insertInset(p, LM_TC_DOWN);
         break;
       }
@@ -672,7 +672,7 @@ MathedArray * mathed_parse(unsigned flags = 0, MathedArray * array = 0,
         MathFracInset * fc = new MathFracInset(fractype);
         MathedArray * num = mathed_parse(FLAG_BRACE|FLAG_BRACE_LAST);
         MathedArray * den = mathed_parse(FLAG_BRACE|FLAG_BRACE_LAST);
-        fc->SetData(num, den);
+        fc->SetData(*num, *den);
         data.insertInset(fc, LM_TC_ACTIVE_INSET);
         break;
       }
@@ -685,13 +685,13 @@ MathedArray * mathed_parse(unsigned flags = 0, MathedArray * array = 0,
         if (c == '[') {
             rt = new MathRootInset(size);
             rt->setArgumentIdx(0);
-            rt->setData(mathed_parse(FLAG_BRACK_END, 0, &rt));
+            rt->setData(*mathed_parse(FLAG_BRACK_END, 0, &rt));
             rt->setArgumentIdx(1);
         } else {
                 yyis->putback(c);
             rt = new MathSqrtInset(size);
         }
-        rt->setData(mathed_parse(FLAG_BRACE|FLAG_BRACE_LAST, 0, &rt));
+        rt->setData(*mathed_parse(FLAG_BRACE|FLAG_BRACE_LAST, 0, &rt));
         data.insertInset(rt, LM_TC_ACTIVE_INSET);
         break;
       }
@@ -708,7 +708,7 @@ MathedArray * mathed_parse(unsigned flags = 0, MathedArray * array = 0,
         if (rgd == LM_TK_SYM || rgd == LM_TK_STR || rgd == LM_TK_BOP || rgd == LM_TK_SPECIAL)
           rgd = (rgd == LM_TK_SYM) ? yylval.l->id: yylval.i;    
         MathDelimInset * dl = new MathDelimInset(lfd, rgd);
-        dl->setData(a);
+        dl->setData(*a);
         data.insertInset(dl, LM_TC_ACTIVE_INSET);
 //      lyxerr << "RL[" << lfd << " " << rgd << "]";
         break;
@@ -736,7 +736,7 @@ MathedArray * mathed_parse(unsigned flags = 0, MathedArray * array = 0,
       {  
         MathDecorationInset * sq = new MathDecorationInset(yylval.l->id,
                                                            size);
-        sq->setData(mathed_parse(FLAG_BRACE|FLAG_BRACE_LAST));
+        sq->setData(*mathed_parse(FLAG_BRACE|FLAG_BRACE_LAST));
         data.insertInset(sq, LM_TC_ACTIVE_INSET);
         break;
       }
@@ -781,7 +781,7 @@ MathedArray * mathed_parse(unsigned flags = 0, MathedArray * array = 0,
           else
             data.insertInset(p, p->getTCode());
           for (int i = 0; p->setArgumentIdx(i); ++i)
-            p->setData(mathed_parse(FLAG_BRACE|FLAG_BRACE_LAST));
+            p->setData(*mathed_parse(FLAG_BRACE|FLAG_BRACE_LAST));
        }
        else {
           MathedInset * q = new MathFuncInset(yylval.s, LM_OT_UNDEF);
@@ -802,7 +802,7 @@ MathedArray * mathed_parse(unsigned flags = 0, MathedArray * array = 0,
                 lyxerr << "[" << yylval.i << "]" << endl;
         --plevel;
         if (mt) { // && (flags & FLAG_END)) {
-           mt->setData(array);
+           mt->setData(*array);
            array = 0;
         }
         return array;
@@ -822,7 +822,7 @@ MathedArray * mathed_parse(unsigned flags = 0, MathedArray * array = 0,
            MathParInset * mm = new MathMatrixInset(nc, 0);
            mm->SetAlign(ar2[0], ar);
                    data.insertInset(mm, LM_TC_ACTIVE_INSET);
-            mathed_parse(FLAG_END, mm->GetData(), &mm);
+            mathed_parse(FLAG_END, &mm->GetData(), &mm);
         } else if (is_eqn_type(yylval.i)) {
             if (plevel!= 0) {
                 mathPrintError("Misplaced environment");
@@ -873,7 +873,7 @@ MathedArray * mathed_parse(unsigned flags = 0, MathedArray * array = 0,
             if (p) {
                 data.insertInset(p, p->getTCode());
                 p->setArgumentIdx(0);
-                mathed_parse(FLAG_END, p->GetData(), reinterpret_cast<MathParInset**>(&p));
+                mathed_parse(FLAG_END, &p->GetData(), reinterpret_cast<MathParInset**>(&p));
 //              for (int i = 0; p->setArgumentIdx(i); ++i)
 //                p->SetData(mathed_parse(FLAG_BRACE|FLAG_BRACE_LAST));
             } else 
index d22d6c60a06387ee0eecfc1ba222f6e8899bb392..4414c57d56b1961e7ec02e2e60ee8231a7c9bdc2 100644 (file)
@@ -48,7 +48,7 @@ MathedInset * MathRootInset::Clone()
 }
 
 
-void MathRootInset::setData(MathedArray * d)
+void MathRootInset::setData(MathedArray const & d)
 {
        if (idx_ == 1)
                MathParInset::setData(d);
@@ -77,10 +77,10 @@ void MathRootInset::GetXY(int & x, int & y) const
 }
 
 
-MathedArray * MathRootInset::GetData()
+MathedArray & MathRootInset::GetData()
 {
        if (idx_ == 1)
-               return &array;
+               return array;
        else
                return uroot_->GetData();
 }
index bddb171dcf8f6cfecb38a3855d22de8d9a664658..02c856911b9e493d83017d05264f5f4b3d30e2a7 100644 (file)
@@ -47,11 +47,11 @@ public:
        ///
        void SetFocus(int, int);
        ///
-       void setData(MathedArray *);
+       void setData(MathedArray const &);
        ///
        void GetXY(int & x, int & y) const;
        ///
-       MathedArray * GetData();
+       MathedArray & GetData();
        ///
        bool setArgumentIdx(int i);
        ///
index 6e449fe0bcfadc983fa51117a6f320d39dae38d9..860dfe89a80ca6f72c61eb633b6f1aaee898f7bb 100644 (file)
@@ -195,7 +195,7 @@ void MathedXIter::SetData(MathParInset * pp)
 {
        p_ = pp;
        x_ = y_ = 0;
-       array = p_->GetData();
+       array = &p_->GetData();
        ncols = p_->GetColumns();
        crow_ = p_->getRowSt();
        if (p_->Permit(LMPF_ALLOW_CR))
@@ -209,7 +209,7 @@ void MathedXIter::SetData(MathParInset * pp)
        } 
        if (!array) {
                array = new MathedArray; // this leaks
-               p_->setData(array);
+               p_->setData(*array);
        }
        size_ = p_->GetStyle();
        Reset();