]> git.lyx.org Git - features.git/commitdiff
uses references instead of returning vectors
authorAndré Pönitz <poenitz@gmx.net>
Fri, 2 Aug 2002 13:35:05 +0000 (13:35 +0000)
committerAndré Pönitz <poenitz@gmx.net>
Fri, 2 Aug 2002 13:35:05 +0000 (13:35 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@4840 a592a061-630c-0410-9148-cb99ea01b6c8

src/mathed/formula.C
src/mathed/math_gridinset.C
src/mathed/math_gridinset.h
src/mathed/math_hullinset.C
src/mathed/math_hullinset.h
src/mathed/math_inset.C
src/mathed/math_inset.h
src/mathed/math_nestinset.C

index 9d71398d28bef001e3e9daa682e242be74c0497e..a9683b2c52cad34918d2e81e5e15daf01522ae4a 100644 (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;
 }
 
 
index afe1739645d0c9d781de52ef8340c24bc5c8179d..9c90bbf8160438cc2d202c3a99adb586710b1217 100644 (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
-{
-       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;
+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;
 }
 
 
index 4e5689da5ecd06b4dc4d7155db6680c548b6bb6c..73f2b50d2e93d1442049422280e508dd5bab440a 100644 (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; }
        ///
index 504a86fea100f5d5e48cc0daf84be23348a6d538..1bff0d5fcc941400d5186f4e2639b9b1fa1d03be 100644 (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]);
 }
 
 
index 8a2a7b6cfb171aaa7e3b6817f08fb1caa5dc50cf..6a1095687fdcf05c8fb1e338138ed0d288867b11 100644 (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
index 77bdc707b40afb980e6cb0fac9c5250e957ef168..6daf362e673b7c42e6136b5567808ff165856c22 100644 (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");
index 5d49ce84b18e6eb47c269ed4a07f447cecce65a5..77a7f479c3a0fc316ed5646a763e25bbdb2029dd 100644 (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
index 91d84fd674da98ba8fd8ff4bf3640c10f25ec36e..1744ae3262712ff5b725a018dd0f475e9cb7643f 100644 (file)
@@ -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<MathInset::idx_type> 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);
+                       }
                }
        }
 }