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

src/mathed/ChangeLog
src/mathed/math_decorationinset.C
src/mathed/math_deliminset.C
src/mathed/math_fracinset.C
src/mathed/math_macro.C
src/mathed/math_macro.h
src/mathed/math_matrixinset.C
src/mathed/math_parinset.C
src/mathed/math_parinset.h
src/mathed/math_root.C
src/mathed/math_sqrtinset.C

index b55f21381d3aed02da253ad849395689028fb2ab..15509bde45c7b06edb2d713e16a3db8d64413fe6 100644 (file)
@@ -1,3 +1,11 @@
+2001-02-14  André Pönitz  <poenitz@htwm.de>
+
+       * math_parinset.[Ch]: make array a real MathArray, not just a
+         pointer to one.
+
+       * several files: subsequent changes
+
+
 2001-02-19  Dekel Tsur  <dekelts@tau.ac.il>
 
        * array.C (MathedArray): Fix compilation problem.
index db3c44bc1931783d67afc86568424637418ca941..45bea19ae6331d70e32d966d786b7c08ca86bcf9 100644 (file)
@@ -24,10 +24,7 @@ bool MathDecorationInset::GetLimits() const
 
 MathedInset * MathDecorationInset::Clone()
 {   
-   MathDecorationInset * p = new MathDecorationInset(deco_, GetStyle());
-   MathedIter it(array);
-   p->setData(it.Copy());
-   return p;
+       return new MathDecorationInset(*this);
 }
 
 
index 0f340feeb222b08dbf1247a19b2a40ea23fa9462..0b8e11977b56469645f357b3c8698a1847dba10f 100644 (file)
@@ -17,10 +17,7 @@ MathDelimInset::MathDelimInset(int l, int r, short st)
 
 MathedInset * MathDelimInset::Clone()
 {   
-       MathDelimInset * p = new MathDelimInset(left_, right_, GetStyle());
-       MathedIter it(array);
-       p->setData(it.Copy());
-       return p;
+       return new MathDelimInset(*this);
 }
 
 
index 25869f4752bf6e3d364a430556bd45264f29dd5e..ecf2fcdaf0675412ff76738791c93ef7e8a19c2f 100644 (file)
@@ -32,12 +32,9 @@ MathFracInset::~MathFracInset()
 
 MathedInset * MathFracInset::Clone()
 {   
-       MathFracInset * p = new MathFracInset(GetType());
-       MathedIter itn(array);
-       MathedIter itd(den_->GetData());
-       p->SetData(itn.Copy(), itd.Copy());
-       p->idx_ = idx_;
-       p->dh_ = dh_;
+       MathFracInset * p = new MathFracInset(*this);
+       // this cast will go again...
+       p->den_ = (MathParInset*) (p->den_->Clone());
        return p;
 }
 
@@ -91,7 +88,7 @@ void MathFracInset::GetXY(int & x, int & y) const
 MathedArray * MathFracInset::GetData()
 {
        if (idx_ == 0)
-               return array;
+               return &array;
        else
                return den_->GetData();
 }
index 93702f15260c4488bef3f44cafbe67a34a938516..d157513d0d8bc5569081d47809c04d1b0bacffa5 100644 (file)
@@ -69,20 +69,14 @@ MathMacro::MathMacro(MathMacro * m):
        SetName(tmplate_->GetName());
        for (int i = 0; i < tmplate_->getNoArgs(); ++i) {
                m->setArgumentIdx(i);
-               MathedIter it(m->GetData());
                args_[i].row   = m->args_[i].row;
-               args_[i].array = it.Copy();
+               args_[i].array = *(m->GetData());
        }
 }
 
 
 MathMacro::~MathMacro()
 {
-       for (idx_ = 0; idx_ < nargs_; ++idx_) {
-               MathedIter it(args_[idx_].array);
-               it.Clear();
-               delete args_[idx_].row;
-       }
 }
 
 
@@ -142,7 +136,7 @@ int MathMacro::getMaxArgumentIdx() const
 
 MathedArray * MathMacro::GetData() 
 { 
-       return args_[idx_].array; 
+       return &args_[idx_].array; 
 } 
 
 
@@ -175,7 +169,7 @@ void MathMacro::SetFocus(int x, int y)
 
 void MathMacro::setData(MathedArray * a)
 {
-       args_[idx_].array = a;
+       args_[idx_].array = *a;
 }
 
 
index f44ac9de5a132f85e9f7c275eb1eda116d02fdf5..24269eb3666657dd606f713416d9a54f544073ba 100644 (file)
@@ -84,10 +84,10 @@ private:
                ///
                MathedRowSt * row;
                ///
-               MathedArray array;
+               MathedArray array;
                ///
                MacroArgumentBase()
-                       : x(0), y(0), row(0), array(0)
+                       : x(0), y(0), row(0)
                        {}
        };
        std::vector<MacroArgumentBase> args_;
index 7fe259dfc3881bf448c6dff52423f60dac5320db..3adde0463259fbf9a8082b8484b5b2b603b47e9d 100644 (file)
@@ -35,8 +35,7 @@ MathMatrixInset::MathMatrixInset(MathMatrixInset * mt)
          nc_(mt->nc_), nr_(0), ws_(mt->nc_),
          v_align_(mt->v_align_), h_align_(mt->h_align_)
 {
-       MathedIter it(mt->GetData());
-       array = it.Copy();
+       array = *(mt->GetData());
        if (mt->row_ != 0) {
                MathedRowSt * ro = 0;
                MathedRowSt * mrow = mt->row_;
@@ -116,7 +115,7 @@ void MathMatrixInset::setData(MathedArray * a)
        
        // Automatically inserts tabs around bops
        // DISABLED because it's very easy to insert tabs 
-       array = a;
+       array = *a;
 }
 
 
index 8b23756a8f9d02aee3ac7da941827760267d8ef9..2ca3d14a092101296a04a7769d87f2810c1350d0 100644 (file)
@@ -26,7 +26,6 @@ MathedRowSt * MathParInset::getRowSt() const
 MathParInset::MathParInset(short st, string const & nm, short ot)
        : MathedInset(nm, ot, st)
 {
-       array = 0;
        ascent = 8;
        width = 4;
        descent = 0;
@@ -48,11 +47,6 @@ MathParInset::MathParInset(MathParInset * p)
 
 MathParInset::~MathParInset()
 {
-       if (array) {
-               MathedIter it(array);
-               it.Clear();
-               delete array;
-       }
 }
 
 
@@ -64,18 +58,16 @@ MathedInset * MathParInset::Clone()
 
 void MathParInset::setData(MathedArray * a)
 {
-       array = a;
+       array = *a;
        
        // A standard paragraph shouldn't have any tabs nor CRs.
-       if (array) {
-               MathedIter it(array);
-               while (it.OK()) {
-                       char c = it.GetChar();
-                       if (c == LM_TC_TAB || c == LM_TC_CR) 
-                               it.Delete();
-                       else
-                               it.Next();
-               }
+       MathedIter it(&array);
+       while (it.OK()) {
+               char c = it.GetChar();
+               if (c == LM_TC_TAB || c == LM_TC_CR) 
+                       it.Delete();
+               else
+                       it.Next();
        }
 }
 
@@ -91,11 +83,9 @@ MathParInset::draw(Painter & pain, int x, int y)
        
        xo_ = x;
        yo_ = y; 
-       if (!array || array->empty()) {
-               if (array) {
-                       MathedXIter data(this);
-                       data.GetPos(x, y);
-               }
+       if (array.empty()) {
+               MathedXIter data(this);
+               data.GetPos(x, y);
                pain.rectangle(x, y - df_asc, df_width, df_asc, LColor::mathline);
                return;
        }  
@@ -187,8 +177,7 @@ MathParInset::Metrics()
        ascent = df_asc;//mathed_char_height(LM_TC_VAR, size, 'I', asc, des); 
        width = df_width;
        descent = 0;
-       if (!array) return;
-       if (array->empty()) return;
+       if (array.empty()) return;
        
        ascent = 0;
        MathedXIter data(this);
@@ -284,10 +273,10 @@ MathParInset::Metrics()
 
 void MathParInset::Write(ostream & os, bool fragile)
 {
-       if (!array) return;
+       if (array.empty()) return;
        int brace = 0;
        latexkeys const * l;
-       MathedIter data(array);
+       MathedIter data(&array);
        // hack
        MathedRowSt const * crow = getRowSt();   
        data.Reset();
@@ -442,7 +431,7 @@ bool MathParInset::Permit(short f) const
 
 MathedArray * MathParInset::GetData()
 {
-       return array;
+       return &array;
 }
 
 
index d6583e8a11e2b73405049f11b47d3aed77dce6c8..5aa640a4cd7b77aa1a8bef8d37e168a063f715e0 100644 (file)
@@ -2,6 +2,7 @@
 #ifndef MATH_PARINSET_H
 #define MATH_PARINSET_H
 
+#include "array.h"
 #include "math_inset.h"
 #include "math_defs.h"
 
@@ -80,7 +81,7 @@ public:
        }
 protected:
        /// Paragraph data is stored here
-       MathedArray array;
+       MathedArray array;
        /// 
        short flag;
        ///
index 13ae9ab97c03e20ec46c7bc6badb4377e0b5737b..5cfe9f692bd506fadfa76e5034bc66c0819855b5 100644 (file)
@@ -41,13 +41,9 @@ MathRootInset::~MathRootInset()
 
 MathedInset * MathRootInset::Clone()
 {
-       MathRootInset * p = new MathRootInset(GetStyle());
-       MathedIter it(array);
-       MathedIter itr(uroot_->GetData());
-       p->setData(it.Copy());
+       MathRootInset * p = new MathRootInset(*this);
+       p->uroot_ = (MathParInset *) p->uroot_->Clone();
        p->setArgumentIdx(0);
-       p->setData(itr.Copy());
-       
        return p;
 }
 
@@ -84,7 +80,7 @@ void MathRootInset::GetXY(int & x, int & y) const
 MathedArray * MathRootInset::GetData()
 {
        if (idx_ == 1)
-               return array;
+               return &array;
        else
                return uroot_->GetData();
 }
index fb29a477e6cf1c94798d6dff88448207db1752ce..a8c5cad14dde84f67555d834b2e8d429421745c9 100644 (file)
@@ -15,10 +15,7 @@ MathSqrtInset::MathSqrtInset(short st)
 
 MathedInset * MathSqrtInset::Clone()
 {   
-       MathSqrtInset * p = new MathSqrtInset(GetStyle());
-       MathedIter it(array);
-       p->setData(it.Copy());
-       return p;
+       return new MathSqrtInset(*this);
 }