mathed29.diff

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1560 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Lars Gullik Bjønnes 2001-02-19 18:29:10 +00:00
parent 71794f7d81
commit 8d7fe83bf5
6 changed files with 66 additions and 64 deletions

View File

@ -8,6 +8,9 @@
* math_iter.[Ch]: seperate Copy() from Copy(int, int)
* math_iter.[Ch]: remove SetData
several files: subsequent changes
2001-02-14 André Pönitz <poenitz@htwm.de>
* array.[Ch]: remove constructor and enums ARRAY_MIN_SIZE and ARRAY_STEP

View File

@ -24,6 +24,7 @@ MathedArray::MathedArray()
: bf_(1, '\0'), last_(0)
{}
MathedArray::~MathedArray()
{
// deep destruction
@ -55,8 +56,7 @@ MathedArray::MathedArray(MathedArray const & array)
// deep copy
// we'll not yet get exeption safety
MathedIter it;
it.SetData(this);
MathedIter it(this);
while (it.OK()) {
if (it.IsInset()) {
MathedInset * inset = it.GetInset();

View File

@ -43,11 +43,6 @@ MathedIter::MathedIter()
{}
void MathedIter::SetData(MathedArray * a)
{
array = a; Reset();
}
MathedArray * MathedIter::GetData() const
{
@ -403,11 +398,11 @@ MathedArray * MathedIter::Copy(int pos1, int pos2)
return 0;
}
ipush();
MathedArray * t = array;
MathedArray * a;
if (pos1 > 0 || pos2 <= array->last()) {
ipush();
MathedArray * t = array;
MathedArray * a;
short fc = 0;
if (pos1 > 0 && (*array)[pos1] > ' ') {
for (int p = pos1; p >= 0; --p) {
@ -436,25 +431,26 @@ MathedArray * MathedIter::Copy(int pos1, int pos2)
}
a->last(dx);
(*a)[dx] = '\0';
} else
a = new MathedArray(*array);
// this should be unnecessary and leak in some (most?) cases since
// a = new MathedArray(*array); makes already a deep copy...
// I guess it'll go soon... (Andre')
array = a;
Reset();
SetData(a);
while (OK()) {
if (IsInset()) {
MathedInset * inset = GetInset();
inset = inset->Clone();
array->raw_pointer_insert(inset, pos + 1, sizeof(inset));
while (OK()) {
if (IsInset()) {
MathedInset * inset = GetInset();
inset = inset->Clone();
array->raw_pointer_insert(inset, pos + 1, sizeof(inset));
}
Next();
}
Next();
array = t;
ipop();
return a;
}
array = t;
ipop();
return a;
// otherwise: full copy
return new MathedArray(*array);
}

View File

@ -109,8 +109,6 @@ public:
///
void setNumCols(int n) { ncols = n; }
///
void SetData(MathedArray * a);
///
MathedArray * GetData() const;
/// Copy every object
MathedArray * Copy();

View File

@ -49,9 +49,7 @@ void MathMacroTable::addTemplate(MathMacroTemplate * m)
void MathMacroTable::builtinMacros()
{
MathedIter iter;
MathParInset * inset;// *arg;
MathedArray * array2;
built = true;
@ -60,48 +58,56 @@ void MathMacroTable::builtinMacros()
// This macro doesn't have arguments
MathMacroTemplate * m = new MathMacroTemplate("notin"); // this leaks
addTemplate(m);
MathedArray * array = new MathedArray; // this leaks
iter.SetData(array);
iter.insertInset(new MathAccentInset(LM_in, LM_TC_BOPS, LM_not),
LM_TC_INSET); // this leaks
m->setData(array);
{
MathedArray * array = new MathedArray; // this leaks
MathedIter iter(array);
iter.insertInset(new MathAccentInset(LM_in, LM_TC_BOPS, LM_not),
LM_TC_INSET); // this leaks
m->setData(array);
}
// These two are only while we are still with LyX 2.x
m = new MathMacroTemplate("emptyset"); // this leaks
addTemplate(m);
array = new MathedArray; // this leaks
iter.SetData(array);
iter.insertInset(new MathAccentInset('O', LM_TC_RM, LM_not),
LM_TC_INSET); // this leaks
m->setData(array);
addTemplate(m);
{
MathedArray * array = new MathedArray; // this leaks
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);
array = new MathedArray; // this leaks
iter.SetData(array);
iter.insert(LM_bot, LM_TC_BOP);
m->setData(array);
{
MathedArray * array = new MathedArray; // this leaks
MathedIter iter(array);
iter.insert(LM_bot, LM_TC_BOP);
m->setData(array);
}
// binom has two arguments
m = new MathMacroTemplate("binom", 2);
addTemplate(m);
array = new MathedArray;
m->setData(array);
iter.SetData(array);
inset = new MathDelimInset('(', ')');
iter.insertInset(inset, LM_TC_ACTIVE_INSET);
array = new MathedArray;
iter.SetData(array);
MathFracInset * frac = new MathFracInset(LM_OT_ATOP);
iter.insertInset(frac, LM_TC_ACTIVE_INSET);
inset->setData(array);
array = new MathedArray;
array2 = new MathedArray;
iter.SetData(array);
iter.insertInset(m->getMacroPar(0), LM_TC_INSET);
iter.SetData(array2);
iter.insertInset(m->getMacroPar(1), LM_TC_INSET);
frac->SetData(array, array2);
{
MathedArray * array = new MathedArray;
m->setData(array);
MathedIter iter(array);
inset = new MathDelimInset('(', ')');
iter.insertInset(inset, LM_TC_ACTIVE_INSET);
array = new 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);
iter3.insertInset(m->getMacroPar(0), LM_TC_INSET);
MathedIter iter4(array2);
iter4.insertInset(m->getMacroPar(1), LM_TC_INSET);
frac->SetData(array, array2);
}
/*
// Cases has 1 argument

View 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;
it.SetData(mt->GetData());
MathedIter it(mt->GetData());
array = it.Copy();
if (mt->row_ != 0) {
MathedRowSt * ro = 0;