From: André Pönitz Date: Fri, 2 Aug 2002 13:35:05 +0000 (+0000) Subject: uses references instead of returning vectors X-Git-Tag: 1.6.10~18701 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=28307966381dd022bfc2df3beb4a8cf0d8958f46;p=features.git uses references instead of returning vectors git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@4840 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/mathed/formula.C b/src/mathed/formula.C index 9d71398d28..a9683b2c52 100644 --- a/src/mathed/formula.C +++ b/src/mathed/formula.C @@ -249,7 +249,9 @@ void InsetFormula::draw(BufferView * bv, LyXFont const & font, vector const InsetFormula::getLabelList() const { - return par()->getLabelList(); + vector res; + par()->getLabelList(res); + return res; } diff --git a/src/mathed/math_gridinset.C b/src/mathed/math_gridinset.C index afe1739645..9c90bbf816 100644 --- a/src/mathed/math_gridinset.C +++ b/src/mathed/math_gridinset.C @@ -810,18 +810,15 @@ MathGridInset::RowInfo & MathGridInset::rowinfo(row_type row) } -vector - MathGridInset::idxBetween(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 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; +bool MathGridInset::idxBetween(idx_type idx, idx_type from, idx_type to) const +{ + 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; } diff --git a/src/mathed/math_gridinset.h b/src/mathed/math_gridinset.h index 4e5689da5e..73f2b50d2e 100644 --- a/src/mathed/math_gridinset.h +++ b/src/mathed/math_gridinset.h @@ -176,7 +176,7 @@ public: /// idx_type index(row_type r, col_type c) const; /// - std::vector 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; } /// diff --git a/src/mathed/math_hullinset.C b/src/mathed/math_hullinset.C index 504a86fea1..1bff0d5fcc 100644 --- a/src/mathed/math_hullinset.C +++ b/src/mathed/math_hullinset.C @@ -281,13 +281,11 @@ bool MathHullInset::display() const } -vector MathHullInset::getLabelList() const +void MathHullInset::getLabelList(std::vector & labels) const { - vector 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]); } diff --git a/src/mathed/math_hullinset.h b/src/mathed/math_hullinset.h index 8a2a7b6cfb..6a1095687f 100644 --- a/src/mathed/math_hullinset.h +++ b/src/mathed/math_hullinset.h @@ -47,7 +47,7 @@ public: /// bool ams() const; /// - std::vector getLabelList() const; + void getLabelList(std::vector &) const; /// void validate(LaTeXFeatures & features) const; /// identifies MatrixInsets diff --git a/src/mathed/math_inset.C b/src/mathed/math_inset.C index 77bdc707b4..6daf362e67 100644 --- a/src/mathed/math_inset.C +++ b/src/mathed/math_inset.C @@ -198,17 +198,9 @@ void MathInset::dump() const } -void MathInset::validate(LaTeXFeatures &) const -{} - - -vector - MathInset::idxBetween(idx_type from, idx_type to) const +bool MathInset::idxBetween(idx_type idx, idx_type from, idx_type to) const { - vector 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 MathInset::getLabelList() const -{ - return std::vector(); -} - - string const & MathInset::getType() const { static string t("none"); diff --git a/src/mathed/math_inset.h b/src/mathed/math_inset.h index 5d49ce84b1..77a7f479c3 100644 --- a/src/mathed/math_inset.h +++ b/src/mathed/math_inset.h @@ -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 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 getLabelList() const; + /// write labels into a list + virtual void getLabelList(std::vector &) const {} /// LyXInset stuff virtual bool numberedType() const { return false; } /// hull type diff --git a/src/mathed/math_nestinset.C b/src/mathed/math_nestinset.C index 91d84fd674..1744ae3262 100644 --- a/src/mathed/math_nestinset.C +++ b/src/mathed/math_nestinset.C @@ -192,14 +192,15 @@ void MathNestInset::drawSelection(MathPainterInfo & pi, int y2 = c.yo() + c.descent(); pi.pain.fillRectangle(x1, y1, x2 - x1, y2 - y1, LColor::selection); } else { - vector indices = idxBetween(idx1, idx2); - for (unsigned i = 0; i < indices.size(); ++i) { - MathXArray const & c = xcell(indices[i]); - int x1 = c.xo(); - int y1 = c.yo() - c.ascent(); - int x2 = c.xo() + c.width(); - int y2 = c.yo() + c.descent(); - pi.pain.fillRectangle(x1, y1, x2 - x1, y2 - y1, LColor::selection); + 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(); + int y2 = c.yo() + c.descent(); + pi.pain.fillRectangle(x1, y1, x2 - x1, y2 - y1, LColor::selection); + } } } }