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()) {
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);
mt->SetStyle(LM_ST_DISPLAY);
mt->SetType(type);
mt->setData(p->GetData());
- p->setData(0); // BUG duda
delete p;
par = mt;
p = mt;
if (selection) {
if (MathIsActive(t)) {
SelCut();
- static_cast<MathParInset*>(p)->setData(&selarray);
+ static_cast<MathParInset*>(p)->setData(selarray);
} else
SelDel();
}
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();
}
}
-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);
}
-MathedArray * MathFracInset::GetData()
+MathedArray & MathFracInset::GetData()
{
if (idx_ == 0)
- return &array;
+ return array;
else
return den_->GetData();
}
///
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;
///
///
bool Inside(int, int);
///
- MathedArray * GetData();
+ MathedArray & GetData();
///
bool setArgumentIdx(int i); // was bool Up/down(void);
///
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();
}
}
}
-MathedArray * MathMacro::GetData()
+MathedArray & MathMacro::GetData()
{
- return &args_[idx_].array;
+ return args_[idx_].array;
}
}
-void MathMacro::setData(MathedArray * a)
+void MathMacro::setData(MathedArray const & a)
{
- args_[idx_].array = *a;
+ args_[idx_].array = a;
}
///
void SetFocus(int, int);
///
- MathedArray * GetData();
+ MathedArray & GetData();
///
MathedRowSt * getRowSt() const;
///
- void setData(MathedArray *);
+ void setData(MathedArray const &);
///
MathedTextCodes getTCode() const;
///
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);
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);
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);
}
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);
}
MathMacroTemplate::~MathMacroTemplate()
-{
- // prevent to delete already deleted objects
- for (int i = 0; i < nargs_; ++i) {
- args_[i].setData(0);
- }
-}
+{}
void MathMacroTemplate::setEditMode(bool ed)
void MathMacroTemplate::setArgument(MathedArray * a, int i)
{
- args_[i].setData(a);
+ args_[i].setData(*a);
}
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_;
// 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
// Automatically inserts tabs around bops
// DISABLED because it's very easy to insert tabs
- array = *a;
}
///
void Metrics();
///
- void setData(MathedArray *);
+ void setData(MathedArray const &);
///
void SetAlign(char, string const &);
///
}
-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);
}
-MathedArray * MathParInset::GetData()
+MathedArray & MathParInset::GetData()
{
- return &array;
+ return array;
}
///
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;
///
macro = new MathMacroTemplate(name, na);
flags = FLAG_BRACE|FLAG_BRACE_LAST;
*mtx = macro;
- macro->setData(array);
+ macro->setData(*array);
break;
}
case LM_TK_SPECIAL:
{
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;
{
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;
}
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;
}
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;
}
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;
{
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;
}
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);
lyxerr << "[" << yylval.i << "]" << endl;
--plevel;
if (mt) { // && (flags & FLAG_END)) {
- mt->setData(array);
+ mt->setData(*array);
array = 0;
}
return array;
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");
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
}
-void MathRootInset::setData(MathedArray * d)
+void MathRootInset::setData(MathedArray const & d)
{
if (idx_ == 1)
MathParInset::setData(d);
}
-MathedArray * MathRootInset::GetData()
+MathedArray & MathRootInset::GetData()
{
if (idx_ == 1)
- return &array;
+ return array;
else
return uroot_->GetData();
}
///
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);
///
{
p_ = pp;
x_ = y_ = 0;
- array = p_->GetData();
+ array = &p_->GetData();
ncols = p_->GetColumns();
crow_ = p_->getRowSt();
if (p_->Permit(LMPF_ALLOW_CR))
}
if (!array) {
array = new MathedArray; // this leaks
- p_->setData(array);
+ p_->setData(*array);
}
size_ = p_->GetStyle();
Reset();