mathed33.diff

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1577 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Lars Gullik Bjønnes 2001-02-20 16:00:22 +00:00
parent 7511cc189e
commit 04a2d2ddb0
17 changed files with 67 additions and 82 deletions

View 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()) {

View 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);

View 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();
}

View 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();
}

View 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);
///

View 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;
}

View 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;
///

View 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);
}

View 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);
}

View 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;
}

View File

@ -30,7 +30,7 @@ public:
///
void Metrics();
///
void setData(MathedArray *);
void setData(MathedArray const &);
///
void SetAlign(char, string const &);
///

View 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;
}

View 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;
///

View 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

View 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();
}

View 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);
///

View 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();