mathed30.diff

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1562 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Lars Gullik Bjønnes 2001-02-20 10:49:48 +00:00
parent 9a70b28af5
commit 655e178549
11 changed files with 42 additions and 67 deletions

View 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.

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

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

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

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

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

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

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

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

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

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