From 655e17854904a7b82a31fe545edd001fdf37009b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Lars=20Gullik=20Bj=C3=B8nnes?= Date: Tue, 20 Feb 2001 10:49:48 +0000 Subject: [PATCH] mathed30.diff git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1562 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/mathed/ChangeLog | 8 ++++++ src/mathed/math_decorationinset.C | 5 +--- src/mathed/math_deliminset.C | 5 +--- src/mathed/math_fracinset.C | 11 +++------ src/mathed/math_macro.C | 12 +++------ src/mathed/math_macro.h | 4 +-- src/mathed/math_matrixinset.C | 5 ++-- src/mathed/math_parinset.C | 41 +++++++++++-------------------- src/mathed/math_parinset.h | 3 ++- src/mathed/math_root.C | 10 +++----- src/mathed/math_sqrtinset.C | 5 +--- 11 files changed, 42 insertions(+), 67 deletions(-) diff --git a/src/mathed/ChangeLog b/src/mathed/ChangeLog index b55f21381d..15509bde45 100644 --- a/src/mathed/ChangeLog +++ b/src/mathed/ChangeLog @@ -1,3 +1,11 @@ +2001-02-14 André Pönitz + + * math_parinset.[Ch]: make array a real MathArray, not just a + pointer to one. + + * several files: subsequent changes + + 2001-02-19 Dekel Tsur * array.C (MathedArray): Fix compilation problem. diff --git a/src/mathed/math_decorationinset.C b/src/mathed/math_decorationinset.C index db3c44bc19..45bea19ae6 100644 --- a/src/mathed/math_decorationinset.C +++ b/src/mathed/math_decorationinset.C @@ -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); } diff --git a/src/mathed/math_deliminset.C b/src/mathed/math_deliminset.C index 0f340feeb2..0b8e11977b 100644 --- a/src/mathed/math_deliminset.C +++ b/src/mathed/math_deliminset.C @@ -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); } diff --git a/src/mathed/math_fracinset.C b/src/mathed/math_fracinset.C index 25869f4752..ecf2fcdaf0 100644 --- a/src/mathed/math_fracinset.C +++ b/src/mathed/math_fracinset.C @@ -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(); } diff --git a/src/mathed/math_macro.C b/src/mathed/math_macro.C index 93702f1526..d157513d0d 100644 --- a/src/mathed/math_macro.C +++ b/src/mathed/math_macro.C @@ -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; } diff --git a/src/mathed/math_macro.h b/src/mathed/math_macro.h index f44ac9de5a..24269eb366 100644 --- a/src/mathed/math_macro.h +++ b/src/mathed/math_macro.h @@ -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 args_; diff --git a/src/mathed/math_matrixinset.C b/src/mathed/math_matrixinset.C index 7fe259dfc3..3adde04632 100644 --- a/src/mathed/math_matrixinset.C +++ b/src/mathed/math_matrixinset.C @@ -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; } diff --git a/src/mathed/math_parinset.C b/src/mathed/math_parinset.C index 8b23756a8f..2ca3d14a09 100644 --- a/src/mathed/math_parinset.C +++ b/src/mathed/math_parinset.C @@ -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; } diff --git a/src/mathed/math_parinset.h b/src/mathed/math_parinset.h index d6583e8a11..5aa640a4cd 100644 --- a/src/mathed/math_parinset.h +++ b/src/mathed/math_parinset.h @@ -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; /// diff --git a/src/mathed/math_root.C b/src/mathed/math_root.C index 13ae9ab97c..5cfe9f692b 100644 --- a/src/mathed/math_root.C +++ b/src/mathed/math_root.C @@ -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(); } diff --git a/src/mathed/math_sqrtinset.C b/src/mathed/math_sqrtinset.C index fb29a477e6..a8c5cad14d 100644 --- a/src/mathed/math_sqrtinset.C +++ b/src/mathed/math_sqrtinset.C @@ -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); } -- 2.39.2