uses references instead of returning vectors

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@4840 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
André Pönitz 2002-08-02 13:35:05 +00:00
parent 6f5140a97b
commit 2830796638
8 changed files with 30 additions and 45 deletions

View File

@ -249,7 +249,9 @@ void InsetFormula::draw(BufferView * bv, LyXFont const & font,
vector<string> const InsetFormula::getLabelList() const
{
return par()->getLabelList();
vector<string> res;
par()->getLabelList(res);
return res;
}

View File

@ -810,18 +810,15 @@ MathGridInset::RowInfo & MathGridInset::rowinfo(row_type row)
}
vector<MathInset::idx_type>
MathGridInset::idxBetween(idx_type from, idx_type to) const
bool MathGridInset::idxBetween(idx_type idx, idx_type from, idx_type to) const
{
row_type r1 = min(row(from), row(to));
row_type r2 = max(row(from), row(to));
col_type c1 = min(col(from), col(to));
col_type c2 = max(col(from), col(to));
vector<idx_type> res;
for (row_type i = r1; i <= r2; ++i)
for (col_type j = c1; j <= c2; ++j)
res.push_back(index(i, j));
return res;
row_type const ri = row(idx);
row_type const r1 = min(row(from), row(to));
row_type const r2 = max(row(from), row(to));
col_type const ci = col(idx);
col_type const c1 = min(col(from), col(to));
col_type const c2 = max(col(from), col(to));
return r1 <= ri && ri <= r2 && c1 <= ci && ci <= c2;
}

View File

@ -176,7 +176,7 @@ public:
///
idx_type index(row_type r, col_type c) const;
///
std::vector<idx_type> idxBetween(idx_type from, idx_type to) const;
bool idxBetween(idx_type idx, idx_type from, idx_type to) const;
///
virtual int defaultColSpace(col_type) { return 0; }
///

View File

@ -281,13 +281,11 @@ bool MathHullInset::display() const
}
vector<string> MathHullInset::getLabelList() const
void MathHullInset::getLabelList(std::vector<string> & labels) const
{
vector<string> res;
for (row_type row = 0; row < nrows(); ++row)
if (!label_[row].empty() && nonum_[row] != 1)
res.push_back(label_[row]);
return res;
labels.push_back(label_[row]);
}

View File

@ -47,7 +47,7 @@ public:
///
bool ams() const;
///
std::vector<string> getLabelList() const;
void getLabelList(std::vector<string> &) const;
///
void validate(LaTeXFeatures & features) const;
/// identifies MatrixInsets

View File

@ -198,17 +198,9 @@ void MathInset::dump() const
}
void MathInset::validate(LaTeXFeatures &) const
{}
vector<MathInset::idx_type>
MathInset::idxBetween(idx_type from, idx_type to) const
bool MathInset::idxBetween(idx_type idx, idx_type from, idx_type to) const
{
vector<idx_type> res;
for (idx_type i = from; i <= to; ++i)
res.push_back(i);
return res;
return from <= idx && idx <= to;
}
@ -306,12 +298,6 @@ int MathInset::dispatch(string const &, idx_type, pos_type)
}
std::vector<string> MathInset::getLabelList() const
{
return std::vector<string>();
}
string const & MathInset::getType() const
{
static string t("none");

View File

@ -161,7 +161,7 @@ public:
virtual void idxGlue(idx_type) {}
// returns list of cell indices that are "between" from and to for
// selection purposes
virtual std::vector<idx_type> idxBetween(idx_type from, idx_type to) const;
virtual bool idxBetween(idx_type idx, idx_type from, idx_type to) const;
/// the number of nested cells this inset owns
virtual idx_type nargs() const;
@ -239,7 +239,7 @@ public:
virtual void edit(BufferView *, int, int, mouse_button::state) {}
/// request "external features"
virtual void validate(LaTeXFeatures & features) const;
virtual void validate(LaTeXFeatures &) const {}
/// char char code if possible
virtual void handleFont(string const &) {}
/// is this inset equal to a given other inset?
@ -282,7 +282,8 @@ public:
virtual int dispatch(string const & cmd, idx_type idx, pos_type pos);
/// LyXInset stuff
virtual std::vector<string> getLabelList() const;
/// write labels into a list
virtual void getLabelList(std::vector<string> &) const {}
/// LyXInset stuff
virtual bool numberedType() const { return false; }
/// hull type

View File

@ -192,9 +192,9 @@ void MathNestInset::drawSelection(MathPainterInfo & pi,
int y2 = c.yo() + c.descent();
pi.pain.fillRectangle(x1, y1, x2 - x1, y2 - y1, LColor::selection);
} else {
vector<MathInset::idx_type> indices = idxBetween(idx1, idx2);
for (unsigned i = 0; i < indices.size(); ++i) {
MathXArray const & c = xcell(indices[i]);
for (idx_type i = 0; i < nargs(); ++i) {
if (idxBetween(i, idx1, idx2)) {
MathXArray const & c = xcell(i);
int x1 = c.xo();
int y1 = c.yo() - c.ascent();
int x2 = c.xo() + c.width();
@ -203,6 +203,7 @@ void MathNestInset::drawSelection(MathPainterInfo & pi,
}
}
}
}
void MathNestInset::drawMarkers(MathPainterInfo & pi, int x, int y) const