From: André Pönitz Date: Wed, 26 Sep 2001 15:20:45 +0000 (+0000) Subject: further code uglification to make Jean-Marc's compiler happy X-Git-Tag: 1.6.10~20553 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=7435fca771bf7c8b4ca5d1801162f8c23112f3cf;p=features.git further code uglification to make Jean-Marc's compiler happy git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2803 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/mathed/formula.C b/src/mathed/formula.C index ca63b9210f..b99d255eb9 100644 --- a/src/mathed/formula.C +++ b/src/mathed/formula.C @@ -188,7 +188,7 @@ InsetFormula::localDispatch(BufferView * bv, kb_action action, if (display()) { bv->lockedInsetStoreUndo(Undo::INSERT); bool old = par_->numberedType(); - for (int row = 0; row < par_->nrows(); ++row) + for (unsigned int row = 0; row < par_->nrows(); ++row) par_->numbered(row, !old); bv->owner()->message(old ? _("No number") : _("Number")); updateLocal(bv, true); diff --git a/src/mathed/formulabase.C b/src/mathed/formulabase.C index a9b75d324d..4b963fb02e 100644 --- a/src/mathed/formulabase.C +++ b/src/mathed/formulabase.C @@ -91,7 +91,7 @@ bool openNewInset(BufferView * bv, UpdatableInset * new_inset) // returns the nearest enclosing grid -MathArrayInset * matrixpar(int & idx) +MathArrayInset * matrixpar(unsigned int & idx) { idx = 0; return (mathcursor ? mathcursor->enclosingArray(idx) : 0); @@ -555,7 +555,7 @@ InsetFormulaBase::localDispatch(BufferView * bv, kb_action action, { bv->lockedInsetStoreUndo(Undo::INSERT); lyxerr << "handling halign '" << arg << "'\n"; - int idx; + unsigned int idx; MathArrayInset * p = matrixpar(idx); if (!p) break; @@ -568,7 +568,7 @@ InsetFormulaBase::localDispatch(BufferView * bv, kb_action action, { bv->lockedInsetStoreUndo(Undo::INSERT); lyxerr << "handling valign '" << arg << "'\n"; - int idx; + unsigned int idx; MathArrayInset * p = matrixpar(idx); if (!p) break; @@ -580,7 +580,7 @@ InsetFormulaBase::localDispatch(BufferView * bv, kb_action action, case LFUN_MATH_ROW_INSERT: { bv->lockedInsetStoreUndo(Undo::INSERT); - int idx; + unsigned int idx; MathArrayInset * p = matrixpar(idx); lyxerr << " calling LFUN_MATH_ROW_INSERT on " << p << endl; if (!p) @@ -593,7 +593,7 @@ InsetFormulaBase::localDispatch(BufferView * bv, kb_action action, case LFUN_MATH_ROW_DELETE: { bv->lockedInsetStoreUndo(Undo::INSERT); - int idx; + unsigned int idx; MathArrayInset * p = matrixpar(idx); lyxerr << " calling LFUN_MATH_ROW_DELETE on " << p << endl; if (!p) @@ -606,7 +606,7 @@ InsetFormulaBase::localDispatch(BufferView * bv, kb_action action, case LFUN_MATH_COLUMN_INSERT: { bv->lockedInsetStoreUndo(Undo::INSERT); - int idx; + unsigned int idx; MathArrayInset * p = matrixpar(idx); if (!p) break; @@ -618,7 +618,7 @@ InsetFormulaBase::localDispatch(BufferView * bv, kb_action action, case LFUN_MATH_COLUMN_DELETE: { bv->lockedInsetStoreUndo(Undo::INSERT); - int idx; + unsigned int idx; MathArrayInset * p = matrixpar(idx); if (!p) break; diff --git a/src/mathed/math_arrayinset.C b/src/mathed/math_arrayinset.C index 6567535121..8e49f00026 100644 --- a/src/mathed/math_arrayinset.C +++ b/src/mathed/math_arrayinset.C @@ -27,7 +27,7 @@ void MathArrayInset::write(std::ostream & os, bool fragile) const os << '[' << char(v_align_) << ']'; os << '{'; - for (int col = 0; col < ncols(); ++col) + for (unsigned int col = 0; col < ncols(); ++col) os << colinfo_[col].align_; os << "}\n"; diff --git a/src/mathed/math_cursor.C b/src/mathed/math_cursor.C index b30a0f00d6..92843e5349 100644 --- a/src/mathed/math_cursor.C +++ b/src/mathed/math_cursor.C @@ -40,13 +40,14 @@ #include "math_specialcharinset.h" #include "math_parser.h" +#define FILEDEBUG 0 + using std::endl; using std::min; using std::max; using std::swap; using std::isalnum; - namespace { struct Selection @@ -60,7 +61,7 @@ struct Selection if (i1.idx_ == i2.idx_) data_.push_back(MathArray(i1.cell(), i1.pos_, i2.pos_)); else { - std::vector indices = i1.par_->idxBetween(i1.idx_, i2.idx_); + std::vector indices = i1.par_->idxBetween(i1.idx_, i2.idx_); for (unsigned i = 0; i < indices.size(); ++i) data_.push_back(i1.cell(indices[i])); } @@ -74,7 +75,7 @@ struct Selection if (i1.idx_ == i2.idx_) i1.cell().erase(i1.pos_, i2.pos_); else { - std::vector indices = i1.par_->idxBetween(i1.idx_, i2.idx_); + std::vector indices = i1.par_->idxBetween(i1.idx_, i2.idx_); for (unsigned i = 0; i < indices.size(); ++i) i1.cell(indices[i]).erase(); } @@ -107,12 +108,14 @@ struct Selection Selection theSelection; +#if FILEDEBUG std::ostream & operator<<(std::ostream & os, MathCursorPos const & p) { os << "(par: " << p.par_ << " idx: " << p.idx_ << " pos: " << p.pos_ << ")"; return os; } +#endif } @@ -176,9 +179,9 @@ MathInset * MathCursor::parInset(int i) const } +#if FILEDEBUG void MathCursor::dump(char const *) const { -#if 0 lyxerr << "MC: " << what << "\n"; for (unsigned i = 0; i < Cursor_.size(); ++i) lyxerr << " i: " << i @@ -186,15 +189,12 @@ void MathCursor::dump(char const *) const << " idx: " << Cursor_[i].idx_ << " par: " << Cursor_[i].par_ << "\n"; //lyxerr << " sel: " << selection_ << " data: " << array() << "\n"; -#endif } - void MathCursor::seldump(char const * str) const { //lyxerr << "SEL: " << str << ": '" << theSelection << "'\n"; //dump(" Pos"); - return; lyxerr << "\n\n\n=================vvvvvvvvvvvvv======================= " << str << "\ntheSelection: " << selection_ @@ -209,6 +209,13 @@ void MathCursor::seldump(char const * str) const lyxerr << "\n===================^^^^^^^^^^^^=====================\n\n\n"; } +#else + +void MathCursor::seldump(char const *) const {} +void MathCursor::dump(char const *) const {} + +#endif + bool MathCursor::isInside(MathInset const * p) const { @@ -355,11 +362,11 @@ void MathCursor::setPos(int x, int y) cursor().par_ = outerPar(); while (1) { - idx() = -1; - cursor().pos_ = -1; + idx() = 0; + cursor().pos_ = 0; //lyxerr << "found idx: " << idx() << " cursor: " << pos() << "\n"; int distmin = 1 << 30; // large enough - for (int i = 0; i < par()->nargs(); ++i) { + for (unsigned int i = 0; i < par()->nargs(); ++i) { MathXArray const & ar = par()->xcell(i); int x1 = x - ar.xo(); int y1 = y - ar.yo(); @@ -745,7 +752,7 @@ void MathCursor::drawSelection(Painter & pain) const int y2 = c.yo() + c.descent(); pain.fillRectangle(x1, y1, x2 - x1, y2 - y1, LColor::selection); } else { - std::vector indices = i1.par_->idxBetween(i1.idx_, i2.idx_); + std::vector indices = i1.par_->idxBetween(i1.idx_, i2.idx_); for (unsigned i = 0; i < indices.size(); ++i) { MathXArray & c = i1.xcell(indices[i]); int x1 = c.xo(); @@ -774,7 +781,7 @@ void MathCursor::handleFont(MathTextCodes t) getSelection(i1, i2); if (i1.idx_ == i2.idx_) { MathArray & ar = i1.cell(); - for (int pos = i1.pos_; pos != i2.pos_; ++pos) { + for (unsigned int pos = i1.pos_; pos != i2.pos_; ++pos) { MathInset * p = ar.at(pos)->nucleus(); if (p) p->handleFont(t); @@ -825,25 +832,25 @@ InsetFormulaBase const * MathCursor::formula() } -int MathCursor::idx() const +unsigned int MathCursor::idx() const { return cursor().idx_; } -int & MathCursor::idx() +unsigned int & MathCursor::idx() { return cursor().idx_; } -int MathCursor::pos() const +unsigned int MathCursor::pos() const { return cursor().pos_; } -int & MathCursor::pos() +unsigned int & MathCursor::pos() { return cursor().pos_; } @@ -861,7 +868,7 @@ bool MathCursor::selection() const } -MathArrayInset * MathCursor::enclosingArray(int & idx) const +MathArrayInset * MathCursor::enclosingArray(unsigned int & idx) const { for (int i = Cursor_.size() - 1; i >= 0; --i) { if (Cursor_[i].par_->isArray()) { @@ -900,41 +907,35 @@ void MathCursor::normalize() const #endif MathCursor * it = const_cast(this); - if (idx() < 0) - lyxerr << "this should not really happen - 1: " << idx() << "\n"; if (idx() >= par()->nargs()) { - lyxerr << "this should not really happen - 2: " + lyxerr << "this should not really happen - 1: " << idx() << " " << par()->nargs() << "\n"; dump("error 2"); } - it->idx() = max(idx(), 0); it->idx() = min(idx(), par()->nargs() - 1); - if (pos() < 0) - lyxerr << "this should not really happen - 3: " << pos() << "\n"; if (pos() > size()) { - lyxerr << "this should not really happen - 4: " + lyxerr << "this should not really happen - 2: " << pos() << " " << size() << "\n"; dump("error 4"); } - it->pos() = max(pos(), 0); it->pos() = min(pos(), size()); } -int MathCursor::size() const +unsigned int MathCursor::size() const { return array().size(); } -int MathCursor::col() const +unsigned int MathCursor::col() const { return par()->col(idx()); } -int MathCursor::row() const +unsigned int MathCursor::row() const { return par()->row(idx()); } @@ -1010,7 +1011,7 @@ MathArray & MathCursor::array() const return dummy; } - if (idx() < 0 || idx() >= par()->nargs()) { + if (idx() >= par()->nargs()) { lyxerr << "############ idx_ " << idx() << " not valid\n"; return dummy; } @@ -1065,10 +1066,10 @@ void MathCursor::breakLine() p->addRow(row()); // split line - const int r = row(); - for (int c = col() + 1; c < p->ncols(); ++c) { - const int i1 = p->index(r, c); - const int i2 = p->index(r + 1, c); + const unsigned int r = row(); + for (unsigned int c = col() + 1; c < p->ncols(); ++c) { + const unsigned int i1 = p->index(r, c); + const unsigned int i2 = p->index(r + 1, c); lyxerr << "swapping cells " << i1 << " and " << i2 << "\n"; p->cell(i1).swap(p->cell(i2)); } @@ -1082,7 +1083,7 @@ void MathCursor::breakLine() char MathCursor::valign() const { - int idx; + unsigned int idx; MathArrayInset * p = enclosingArray(idx); return p ? p->valign() : 0; } @@ -1090,7 +1091,7 @@ char MathCursor::valign() const char MathCursor::halign() const { - int idx; + unsigned int idx; MathArrayInset * p = enclosingArray(idx); return p ? p->halign(idx % p->ncols()) : 0; } @@ -1121,13 +1122,13 @@ MathCursorPos const & MathCursor::cursor() const } -int MathCursor::cellXOffset() const +unsigned int MathCursor::cellXOffset() const { return par()->cellXOffset(idx()); } -int MathCursor::cellYOffset() const +unsigned int MathCursor::cellYOffset() const { return par()->cellYOffset(idx()); } @@ -1248,14 +1249,14 @@ void MathCursor::interpret(string const & s) //lyxerr << "trans: '" << c << "' int: " << int(c) << endl; if (s.size() > 7 && s.substr(0, 7) == "matrix ") { - int m = 1; - int n = 1; + unsigned int m = 1; + unsigned int n = 1; string v_align; string h_align; istringstream is(s.substr(7).c_str()); is >> m >> n >> v_align >> h_align; - m = std::max(1, m); - n = std::max(1, n); + m = std::max(1u, m); + n = std::max(1u, n); v_align += 'c'; MathArrayInset * p = new MathArrayInset(m, n); p->valign(v_align[0]); @@ -1423,7 +1424,7 @@ bool operator<(MathCursorPos const & ti, MathCursorPos const & it) } -MathArray & MathCursorPos::cell(int idx) const +MathArray & MathCursorPos::cell(unsigned int idx) const { return par_->cell(idx); } @@ -1435,7 +1436,7 @@ MathArray & MathCursorPos::cell() const } -MathXArray & MathCursorPos::xcell(int idx) const +MathXArray & MathCursorPos::xcell(unsigned int idx) const { return par_->xcell(idx); } diff --git a/src/mathed/math_cursor.h b/src/mathed/math_cursor.h index 09b98ec2fd..978da16e40 100644 --- a/src/mathed/math_cursor.h +++ b/src/mathed/math_cursor.h @@ -41,17 +41,17 @@ struct MathCursorPos { /// inset MathInset * par_; /// cell index - int idx_; + unsigned int idx_; /// cell position - int pos_; + unsigned int pos_; /// returns cell corresponding to this position MathArray & cell() const; /// returns cell corresponding to this position - MathArray & cell(int idx) const; + MathArray & cell(unsigned int idx) const; /// returns xcell corresponding to this position MathXArray & xcell() const; /// returns xcell corresponding to this position - MathXArray & xcell(int idx) const; + MathXArray & xcell(unsigned int idx) const; }; /// @@ -120,15 +120,15 @@ public: /// MathInset * par() const; /// return the next enclosing grid inset and the cursor's index in it - MathArrayInset * enclosingArray(int &) const; + MathArrayInset * enclosingArray(unsigned int &) const; /// InsetFormulaBase const * formula(); /// - int pos() const; + unsigned int pos() const; /// - int idx() const; + unsigned int idx() const; /// - int size() const; + unsigned int size() const; /// void interpret(string const &); /// @@ -183,9 +183,9 @@ public: /// char halign() const; /// - int col() const; + unsigned int col() const; /// - int row() const; + unsigned int row() const; /// MathStyles style() const; @@ -231,7 +231,7 @@ public: /// - int last() const; + unsigned int last() const; /// MathInset * parInset(int i) const; /// @@ -261,13 +261,13 @@ private: /// can the setPos routine enter that inset? MathInset * positionable(MathAtom *, int x, int y) const; /// write access to cursor cell position - int & pos(); + unsigned int & pos(); /// write access to cursor cell index - int & idx(); + unsigned int & idx(); /// x-offset of current cell relative to par xo - int cellXOffset() const; + unsigned int cellXOffset() const; /// y-offset of current cell relative to par yo - int cellYOffset() const; + unsigned int cellYOffset() const; /// current x position relative to par xo int xpos() const; /// current y position relative to par yo diff --git a/src/mathed/math_fracinset.h b/src/mathed/math_fracinset.h index 5db6f340c7..d60ca9bd08 100644 --- a/src/mathed/math_fracinset.h +++ b/src/mathed/math_fracinset.h @@ -26,9 +26,6 @@ public: /// void draw(Painter &, int x, int y) const; public: - /// - char const name() const; - /// const bool atop_; }; diff --git a/src/mathed/math_gridinset.C b/src/mathed/math_gridinset.C index 658f68477b..8f66538195 100644 --- a/src/mathed/math_gridinset.C +++ b/src/mathed/math_gridinset.C @@ -40,7 +40,7 @@ MathGridInset::ColInfo::ColInfo() {} -MathGridInset::MathGridInset(int m, int n) +MathGridInset::MathGridInset(unsigned int m, unsigned int n) : MathNestInset(m * n), rowinfo_(n), colinfo_(m), v_align_('c') { if (m <= 0) @@ -51,7 +51,7 @@ MathGridInset::MathGridInset(int m, int n) } -int MathGridInset::index(int row, int col) const +unsigned int MathGridInset::index(unsigned int row, unsigned int col) const { return col + ncols() * row; } @@ -59,7 +59,7 @@ int MathGridInset::index(int row, int col) const void MathGridInset::setDefaults() { - for (int col = 0; col < ncols(); ++col) { + for (unsigned int col = 0; col < ncols(); ++col) { colinfo_[col].align_ = defaultColAlign(col); colinfo_[col].skip_ = defaultColSpace(col); } @@ -68,21 +68,21 @@ void MathGridInset::setDefaults() void MathGridInset::halign(string const & hh) { - int n = hh.size(); + unsigned int n = hh.size(); if (n > ncols()) n = ncols(); - for (int i = 0; i < n; ++i) + for (unsigned int i = 0; i < n; ++i) colinfo_[i].align_ = hh[i]; } -void MathGridInset::halign(char h, int col) +void MathGridInset::halign(char h, unsigned int col) { colinfo_[col].align_ = h; } -char MathGridInset::halign(int col) const +char MathGridInset::halign(unsigned int col) const { return colinfo_[col].align_; } @@ -102,13 +102,13 @@ char MathGridInset::valign() const -void MathGridInset::vskip(LyXLength const & skip, int row) +void MathGridInset::vskip(LyXLength const & skip, unsigned int row) { rowinfo_[row].skip_ = skip; } -LyXLength MathGridInset::vskip(int row) const +LyXLength MathGridInset::vskip(unsigned int row) const { return rowinfo_[row].skip_; } @@ -121,10 +121,10 @@ void MathGridInset::metrics(MathStyles st) const size_ = st; // adjust vertical structure - for (int row = 0; row < nrows(); ++row) { + for (unsigned int row = 0; row < nrows(); ++row) { int asc = 0; int desc = 0; - for (int col = 0; col < ncols(); ++col) { + for (unsigned int col = 0; col < ncols(); ++col) { MathXArray const & c = xcell(index(row, col)); asc = std::max(asc, c.ascent()); desc = std::max(desc, c.descent()); @@ -156,15 +156,15 @@ void MathGridInset::metrics(MathStyles st) const h = rowinfo_.back().offset_ / 2; } - for (int row = 0; row < nrows(); ++row) { + for (unsigned int row = 0; row < nrows(); ++row) { rowinfo_[row].offset_ -= h; rowinfo_[row].offset_ += MATH_BORDER; } // adjust horizontal structure - for (int col = 0; col < ncols(); ++col) { + for (unsigned int col = 0; col < ncols(); ++col) { int wid = 0; - for (int row = 0; row < nrows(); ++row) + for (unsigned int row = 0; row < nrows(); ++row) wid = std::max(wid, xcell(index(row, col)).width()); colinfo_[col].width_ = wid; colinfo_[col].offset_ = colinfo_[col].width_; @@ -241,15 +241,15 @@ void MathGridInset::draw(Painter & pain, int x, int y) const { xo(x); yo(y); - for (int idx = 0; idx < nargs(); ++idx) + for (unsigned int idx = 0; idx < nargs(); ++idx) xcell(idx).draw(pain, x + cellXOffset(idx), y + cellYOffset(idx)); } void MathGridInset::write(std::ostream & os, bool fragile) const { - for (int row = 0; row < nrows(); ++row) { - for (int col = 0; col < ncols(); ++col) { + for (unsigned int row = 0; row < nrows(); ++row) { + for (unsigned int col = 0; col < ncols(); ++col) { cell(index(row, col)).write(os, fragile); os << eocString(col); } @@ -258,9 +258,9 @@ void MathGridInset::write(std::ostream & os, bool fragile) const } -string MathGridInset::eolString(int row) const +string MathGridInset::eolString(unsigned int row) const { - if (row == nrows() - 1) + if (row + 1 == nrows()) return ""; if (rowinfo_[row].skip_.value() != 0) @@ -275,15 +275,15 @@ string MathGridInset::eolString(int row) const } -string MathGridInset::eocString(int col) const +string MathGridInset::eocString(unsigned int col) const { - if (col == ncols() - 1) + if (col + 1 == ncols()) return ""; return " & "; } -void MathGridInset::addRow(int row) +void MathGridInset::addRow(unsigned int row) { rowinfo_.insert(rowinfo_.begin() + row + 1, RowInfo()); cells_.insert(cells_.begin() + (row + 1) * ncols(), ncols(), MathXArray()); @@ -293,12 +293,12 @@ void MathGridInset::addRow(int row) void MathGridInset::appendRow() { rowinfo_.push_back(RowInfo()); - for (int i = 0; i < ncols(); ++i) + for (unsigned int i = 0; i < ncols(); ++i) cells_.push_back(cells_type::value_type()); } -void MathGridInset::delRow(int row) +void MathGridInset::delRow(unsigned int row) { if (nrows() == 1) return; @@ -310,14 +310,14 @@ void MathGridInset::delRow(int row) } -void MathGridInset::addCol(int newcol) +void MathGridInset::addCol(unsigned int newcol) { - int const nc = ncols(); - int const nr = nrows(); + unsigned int const nc = ncols(); + unsigned int const nr = nrows(); cells_type new_cells((nc + 1) * nr); - for (int row = 0; row < nr; ++row) - for (int col = 0; col < nc; ++col) + for (unsigned int row = 0; row < nr; ++row) + for (unsigned int col = 0; col < nc; ++col) new_cells[row * (nc + 1) + col + (col > newcol)] = cells_[row * nc + col]; std::swap(cells_, new_cells); @@ -329,13 +329,13 @@ void MathGridInset::addCol(int newcol) } -void MathGridInset::delCol(int col) +void MathGridInset::delCol(unsigned int col) { if (ncols() == 1) return; cells_type tmpcells; - for (int i = 0; i < nargs(); ++i) + for (unsigned int i = 0; i < nargs(); ++i) if (i % ncols() != col) tmpcells.push_back(cells_[i]); std::swap(cells_, tmpcells); @@ -344,9 +344,9 @@ void MathGridInset::delCol(int col) } -int MathGridInset::cellXOffset(int idx) const +int MathGridInset::cellXOffset(unsigned int idx) const { - int c = col(idx); + unsigned int c = col(idx); int x = colinfo_[c].offset_; char align = colinfo_[c].align_; if (align == 'r' || align == 'R') @@ -357,13 +357,13 @@ int MathGridInset::cellXOffset(int idx) const } -int MathGridInset::cellYOffset(int idx) const +int MathGridInset::cellYOffset(unsigned int idx) const { return rowinfo_[row(idx)].offset_; } -bool MathGridInset::idxUp(int & idx, int & pos) const +bool MathGridInset::idxUp(unsigned int & idx, unsigned int & pos) const { if (idx < ncols()) return false; @@ -373,7 +373,7 @@ bool MathGridInset::idxUp(int & idx, int & pos) const } -bool MathGridInset::idxDown(int & idx, int & pos) const +bool MathGridInset::idxDown(unsigned int & idx, unsigned int & pos) const { if (idx >= ncols() * (nrows() - 1)) return false; @@ -383,7 +383,7 @@ bool MathGridInset::idxDown(int & idx, int & pos) const } -bool MathGridInset::idxLeft(int & idx, int & pos) const +bool MathGridInset::idxLeft(unsigned int & idx, unsigned int & pos) const { // leave matrix if on the left hand edge if (col(idx) == 0) @@ -394,7 +394,7 @@ bool MathGridInset::idxLeft(int & idx, int & pos) const } -bool MathGridInset::idxRight(int & idx, int & pos) const +bool MathGridInset::idxRight(unsigned int & idx, unsigned int & pos) const { // leave matrix if on the right hand edge if (col(idx) == ncols() - 1) @@ -405,7 +405,7 @@ bool MathGridInset::idxRight(int & idx, int & pos) const } -bool MathGridInset::idxFirst(int & idx, int & pos) const +bool MathGridInset::idxFirst(unsigned int & idx, unsigned int & pos) const { switch (v_align_) { case 't': @@ -422,7 +422,7 @@ bool MathGridInset::idxFirst(int & idx, int & pos) const } -bool MathGridInset::idxLast(int & idx, int & pos) const +bool MathGridInset::idxLast(unsigned int & idx, unsigned int & pos) const { switch (v_align_) { case 't': @@ -439,7 +439,7 @@ bool MathGridInset::idxLast(int & idx, int & pos) const } -void MathGridInset::idxDelete(int & idx, bool & popit, bool & deleteit) +void MathGridInset::idxDelete(unsigned int & idx, bool & popit, bool & deleteit) { popit = false; deleteit = false; @@ -447,7 +447,7 @@ void MathGridInset::idxDelete(int & idx, bool & popit, bool & deleteit) // delete entire row if in first cell of empty row if (col(idx) == 0 && nrows() > 1) { bool deleterow = true; - for (int i = idx; i < idx + ncols(); ++i) + for (unsigned int i = idx; i < idx + ncols(); ++i) if (cell(i).size()) { deleterow = false; break; @@ -466,7 +466,7 @@ void MathGridInset::idxDelete(int & idx, bool & popit, bool & deleteit) } -void MathGridInset::idxDeleteRange(int /*from*/, int /*to*/) +void MathGridInset::idxDeleteRange(unsigned int /*from*/, unsigned int /*to*/) { // leave this unimplemented unless someone wants to have it. /* @@ -482,27 +482,28 @@ void MathGridInset::idxDeleteRange(int /*from*/, int /*to*/) } -MathGridInset::RowInfo const & MathGridInset::rowinfo(int i) const +MathGridInset::RowInfo const & MathGridInset::rowinfo(unsigned int i) const { return rowinfo_[i]; } -MathGridInset::RowInfo & MathGridInset::rowinfo(int i) +MathGridInset::RowInfo & MathGridInset::rowinfo(unsigned int i) { return rowinfo_[i]; } -std::vector MathGridInset::idxBetween(int from, int to) const +std::vector + MathGridInset::idxBetween(unsigned int from, unsigned int to) const { - int r1 = std::min(row(from), row(to)); - int r2 = std::max(row(from), row(to)); - int c1 = std::min(col(from), col(to)); - int c2 = std::max(col(from), col(to)); - std::vector res; - for (int i = r1; i <= r2; ++i) - for (int j = c1; j <= c2; ++j) + unsigned int r1 = std::min(row(from), row(to)); + unsigned int r2 = std::max(row(from), row(to)); + unsigned int c1 = std::min(col(from), col(to)); + unsigned int c2 = std::max(col(from), col(to)); + std::vector res; + for (unsigned int i = r1; i <= r2; ++i) + for (unsigned int j = c1; j <= c2; ++j) res.push_back(index(i, j)); return res; } diff --git a/src/mathed/math_gridinset.h b/src/mathed/math_gridinset.h index 25555c1e91..2bea095771 100644 --- a/src/mathed/math_gridinset.h +++ b/src/mathed/math_gridinset.h @@ -60,7 +60,7 @@ class MathGridInset : public MathNestInset { public: /// - MathGridInset(int m, int n); + MathGridInset(unsigned int m, unsigned int n); /// void write(std::ostream &, bool fragile) const; /// @@ -70,82 +70,82 @@ public: /// void halign(string const &); /// - void halign(char c, int col); + void halign(char c, unsigned int col); /// - char halign(int col) const; + char halign(unsigned int col) const; /// void valign(char c); /// char valign() const; /// - void vskip(LyXLength const &, int row); + void vskip(LyXLength const &, unsigned int row); /// - LyXLength vskip(int row) const; + LyXLength vskip(unsigned int row) const; /// - void resize(short int type, int cols); + void resize(short int type, unsigned int cols); /// - const RowInfo & rowinfo(int row) const; + const RowInfo & rowinfo(unsigned int row) const; /// - RowInfo & rowinfo(int row); + RowInfo & rowinfo(unsigned int row); /// bool isGrid() const { return true; } /// - int ncols() const { return colinfo_.size(); } + unsigned int ncols() const { return colinfo_.size(); } /// - int nrows() const { return rowinfo_.size(); } + unsigned int nrows() const { return rowinfo_.size(); } /// - int col(int idx) const { return idx % ncols(); } + unsigned int col(unsigned int idx) const { return idx % ncols(); } /// - int row(int idx) const { return idx / ncols(); } + unsigned int row(unsigned int idx) const { return idx / ncols(); } /// - int cellXOffset(int idx) const; + int cellXOffset(unsigned int idx) const; /// - int cellYOffset(int idx) const; + int cellYOffset(unsigned int idx) const; /// - bool idxUp(int &, int &) const; + bool idxUp(unsigned int &, unsigned int &) const; /// - bool idxDown(int &, int &) const; + bool idxDown(unsigned int &, unsigned int &) const; /// - bool idxLeft(int &, int &) const; + bool idxLeft(unsigned int &, unsigned int &) const; /// - bool idxRight(int &, int &) const; + bool idxRight(unsigned int &, unsigned int &) const; /// - bool idxFirst(int &, int &) const; + bool idxFirst(unsigned int &, unsigned int &) const; /// - bool idxLast(int &, int &) const; + bool idxLast(unsigned int &, unsigned int &) const; /// - void idxDelete(int &, bool &, bool &); + void idxDelete(unsigned int &, bool &, bool &); /// - void idxDeleteRange(int, int); + void idxDeleteRange(unsigned int, unsigned int); /// - void addRow(int); + void addRow(unsigned int); /// - void delRow(int); + void delRow(unsigned int); /// - void addCol(int); + void addCol(unsigned int); /// - void delCol(int); + void delCol(unsigned int); /// virtual void appendRow(); /// - int index(int row, int col) const; + unsigned int index(unsigned int row, unsigned int col) const; /// - std::vector idxBetween(int from, int to) const; + std::vector idxBetween(unsigned int from, unsigned int to) const; /// - virtual int defaultColSpace(int) { return 10; } + virtual int defaultColSpace(unsigned int) { return 10; } /// - virtual char defaultColAlign(int) { return 'c'; } + virtual char defaultColAlign(unsigned int) { return 'c'; } /// void setDefaults(); protected: /// returns proper 'end of line' code for LaTeX - string eolString(int row) const; + string eolString(unsigned int row) const; /// returns proper 'end of column' code for LaTeX - string eocString(int col) const; + string eocString(unsigned int col) const; /// row info std::vector rowinfo_; diff --git a/src/mathed/math_inset.C b/src/mathed/math_inset.C index 25f194aed3..2b42db7948 100644 --- a/src/mathed/math_inset.C +++ b/src/mathed/math_inset.C @@ -85,7 +85,7 @@ void MathInset::yo(int y) const } -int MathInset::nargs() const +unsigned int MathInset::nargs() const { return 0; } @@ -93,28 +93,28 @@ int MathInset::nargs() const MathXArray dummyCell; -MathXArray & MathInset::xcell(int) +MathXArray & MathInset::xcell(unsigned int) { lyxerr << "I don't have a cell\n"; return dummyCell; } -MathXArray const & MathInset::xcell(int) const +MathXArray const & MathInset::xcell(unsigned int) const { lyxerr << "I don't have a cell\n"; return dummyCell; } -MathArray & MathInset::cell(int) +MathArray & MathInset::cell(unsigned int) { lyxerr << "I don't have a cell\n"; return dummyCell.data_; } -MathArray const & MathInset::cell(int) const +MathArray const & MathInset::cell(unsigned int) const { lyxerr << "I don't have a cell\n"; return dummyCell.data_; @@ -125,74 +125,74 @@ void MathInset::substitute(MathMacro const &) {} -bool MathInset::idxNext(int &, int &) const +bool MathInset::idxNext(unsigned int &, unsigned int &) const { return false; } -bool MathInset::idxRight(int &, int &) const +bool MathInset::idxRight(unsigned int &, unsigned int &) const { return false; } -bool MathInset::idxPrev(int &, int &) const +bool MathInset::idxPrev(unsigned int &, unsigned int &) const { return false; } -bool MathInset::idxLeft(int &, int &) const +bool MathInset::idxLeft(unsigned int &, unsigned int &) const { return false; } -bool MathInset::idxUp(int &, int &) const +bool MathInset::idxUp(unsigned int &, unsigned int &) const { return false; } -bool MathInset::idxDown(int &, int &) const +bool MathInset::idxDown(unsigned int &, unsigned int &) const { return false; } -bool MathInset::idxFirst(int &, int &) const +bool MathInset::idxFirst(unsigned int &, unsigned int &) const { return false; } -bool MathInset::idxLast(int &, int &) const +bool MathInset::idxLast(unsigned int &, unsigned int &) const { return false; } -bool MathInset::idxHome(int &, int &) const +bool MathInset::idxHome(unsigned int &, unsigned int &) const { return false; } -bool MathInset::idxEnd(int &, int &) const +bool MathInset::idxEnd(unsigned int &, unsigned int &) const { return false; } -void MathInset::idxDelete(int &, bool & popit, bool & deleteit) +void MathInset::idxDelete(unsigned int &, bool & popit, bool & deleteit) { popit = false; deleteit = false; } -void MathInset::idxDeleteRange(int, int) +void MathInset::idxDeleteRange(unsigned int, unsigned int) {} @@ -255,10 +255,11 @@ void MathInset::validate(LaTeXFeatures &) const {} -std::vector MathInset::idxBetween(int from, int to) const +std::vector + MathInset::idxBetween(unsigned int from, unsigned int to) const { - std::vector res; - for (int i = from; i <= to; ++i) + std::vector res; + for (unsigned int i = from; i <= to; ++i) res.push_back(i); return res; } diff --git a/src/mathed/math_inset.h b/src/mathed/math_inset.h index f95a3b8716..a9733845da 100644 --- a/src/mathed/math_inset.h +++ b/src/mathed/math_inset.h @@ -75,50 +75,51 @@ public: virtual MathStyles size() const; /// Where should we go when we press the up cursor key? - virtual bool idxUp(int & idx, int & pos) const; + virtual bool idxUp(unsigned int & idx, unsigned int & pos) const; /// The down key - virtual bool idxDown(int & idx, int & pos) const; + virtual bool idxDown(unsigned int & idx, unsigned int & pos) const; /// The left key - virtual bool idxLeft(int & idx, int & pos) const; + virtual bool idxLeft(unsigned int & idx, unsigned int & pos) const; /// The right key - virtual bool idxRight(int & idx, int & pos) const; + virtual bool idxRight(unsigned int & idx, unsigned int & pos) const; /// Move one physical cell up - virtual bool idxNext(int & idx, int & pos) const; + virtual bool idxNext(unsigned int & idx, unsigned int & pos) const; /// Move one physical cell down - virtual bool idxPrev(int & idx, int & pos) const; + virtual bool idxPrev(unsigned int & idx, unsigned int & pos) const; /// Target pos when we enter the inset from the left by pressing "Right" - virtual bool idxFirst(int & idx, int & pos) const; + virtual bool idxFirst(unsigned int & idx, unsigned int & pos) const; /// Target pos when we enter the inset from the right by pressing "Left" - virtual bool idxLast(int & idx, int & pos) const; + virtual bool idxLast(unsigned int & idx, unsigned int & pos) const; /// Where should we go if we press home? - virtual bool idxHome(int & idx, int & pos) const; + virtual bool idxHome(unsigned int & idx, unsigned int & pos) const; /// Where should we go if we press end? - virtual bool idxEnd(int & idx, int & pos) const; + virtual bool idxEnd(unsigned int & idx, unsigned int & pos) const; /// Delete a cell and move cursor // the return value indicates whether the cursor should leave the inset // and/or the whole inset should be deleted - virtual void idxDelete(int & idx, bool & popit, bool & deleteit); + virtual void idxDelete(unsigned int & idx, bool & popit, bool & deleteit); // deletes a cell range and moves the cursor - virtual void idxDeleteRange(int from, int to); + virtual void idxDeleteRange(unsigned int from, unsigned int to); // returns list of cell indices that are "between" from and to for // selection purposes - virtual std::vector idxBetween(int from, int to) const; + virtual std::vector + idxBetween(unsigned int from, unsigned int to) const; /// - virtual int nargs() const; + virtual unsigned int nargs() const; /// - virtual MathArray & cell(int); + virtual MathArray & cell(unsigned int); /// - virtual MathArray const & cell(int) const; + virtual MathArray const & cell(unsigned int) const; /// - virtual MathXArray & xcell(int); + virtual MathXArray & xcell(unsigned int); /// - virtual MathXArray const & xcell(int) const; + virtual MathXArray const & xcell(unsigned int) const; /// virtual int xo() const; @@ -131,25 +132,25 @@ public: /// /// - virtual int ncols() const { return 1; } + virtual unsigned int ncols() const { return 1; } /// - virtual int nrows() const { return 1; } + virtual unsigned int nrows() const { return 1; } /// - virtual int col(int) const { return 0; } + virtual unsigned int col(unsigned int) const { return 0; } /// - virtual int row(int) const { return 0; } + virtual unsigned int row(unsigned int) const { return 0; } /// - virtual int cellXOffset(int) const { return 0; } + virtual int cellXOffset(unsigned int) const { return 0; } /// - virtual int cellYOffset(int) const { return 0; } + virtual int cellYOffset(unsigned int) const { return 0; } /// - virtual void addRow(int) {} + virtual void addRow(unsigned int) {} /// - virtual void delRow(int) {} + virtual void delRow(unsigned int) {} /// - virtual void addCol(int) {} + virtual void addCol(unsigned int) {} /// - virtual void delCol(int) {} + virtual void delCol(unsigned int) {} /// virtual void userSetSize(MathStyles &) {} diff --git a/src/mathed/math_macro.C b/src/mathed/math_macro.C index 48506e8594..56c5cb9c42 100644 --- a/src/mathed/math_macro.C +++ b/src/mathed/math_macro.C @@ -72,7 +72,7 @@ void MathMacro::metrics(MathStyles st) const int lwid; mathed_string_dim(LM_TC_TEXTRM, size_, "#1: ", lasc, ldes, lwid); - for (int i = 0; i < nargs(); ++i) { + for (unsigned int i = 0; i < nargs(); ++i) { MathXArray const & c = xcell(i); c.metrics(st); width_ = std::max(width_, c.width() + lwid); @@ -114,7 +114,7 @@ void MathMacro::draw(Painter & pain, int x, int y) const int lwid; mathed_string_dim(LM_TC_TEXTRM, size_, "#1: ", lasc, ldes, lwid); - for (int i = 0; i < nargs(); ++i) { + for (unsigned int i = 0; i < nargs(); ++i) { MathXArray const & c = xcell(i); h += std::max(c.ascent(), lasc) + 5; c.draw(pain, x + lwid, h); @@ -134,20 +134,20 @@ void MathMacro::draw(Painter & pain, int x, int y) const } -void MathMacro::dump(std::ostream & os) const +void MathMacro::dump() const { MathMacroTable::dump(); - os << "\n macro: '" << this << "'\n"; - os << " name: '" << name() << "'\n"; - os << " template: '" << tmplate_ << "'\n"; - os << " template: '" << *tmplate_ << "'\n"; - os << endl; + lyxerr << "\n macro: '" << this << "'\n"; + lyxerr << " name: '" << name() << "'\n"; + lyxerr << " template: '" << tmplate_ << "'\n"; + lyxerr << " template: '" << *tmplate_ << "'\n"; + lyxerr << endl; } void MathMacro::write(std::ostream & os, bool fragile) const { os << '\\' << name(); - for (int i = 0; i < nargs(); ++i) { + for (unsigned int i = 0; i < nargs(); ++i) { os << '{'; cell(i).write(os, fragile); os << '}'; @@ -160,7 +160,7 @@ void MathMacro::write(std::ostream & os, bool fragile) const void MathMacro::writeNormal(std::ostream & os) const { os << "[macro " << name() << " "; - for (int i = 0; i < nargs(); ++i) { + for (unsigned int i = 0; i < nargs(); ++i) { cell(i).writeNormal(os); os << ' '; } @@ -168,25 +168,25 @@ void MathMacro::writeNormal(std::ostream & os) const } -bool MathMacro::idxUp(int & idx, int & pos) const +bool MathMacro::idxUp(unsigned int & idx, unsigned int & pos) const { return MathNestInset::idxLeft(idx, pos); } -bool MathMacro::idxDown(int & idx, int & pos) const +bool MathMacro::idxDown(unsigned int & idx, unsigned int & pos) const { return MathNestInset::idxRight(idx, pos); } -bool MathMacro::idxLeft(int &, int &) const +bool MathMacro::idxLeft(unsigned int &, unsigned int &) const { return false; } -bool MathMacro::idxRight(int &, int &) const +bool MathMacro::idxRight(unsigned int &, unsigned int &) const { return false; } diff --git a/src/mathed/math_macro.h b/src/mathed/math_macro.h index 30872fcdb3..ed8067bde5 100644 --- a/src/mathed/math_macro.h +++ b/src/mathed/math_macro.h @@ -51,16 +51,16 @@ public: /// void writeNormal(std::ostream &) const; /// - void dump(std::ostream & os) const; + void dump() const; /// - bool idxUp(int &, int &) const; + bool idxUp(unsigned int &, unsigned int &) const; /// - bool idxDown(int &, int &) const; + bool idxDown(unsigned int &, unsigned int &) const; /// - bool idxLeft(int &, int &) const; + bool idxLeft(unsigned int &, unsigned int &) const; /// - bool idxRight(int &, int &) const; + bool idxRight(unsigned int &, unsigned int &) const; /// void validate(LaTeXFeatures &) const; @@ -80,9 +80,4 @@ private: }; -inline std::ostream & operator<<(std::ostream & os, MathMacro const & m) -{ - m.dump(os); - return os; -} #endif diff --git a/src/mathed/math_matrixinset.C b/src/mathed/math_matrixinset.C index cc2610e369..29ae980d20 100644 --- a/src/mathed/math_matrixinset.C +++ b/src/mathed/math_matrixinset.C @@ -64,7 +64,7 @@ MathMatrixInset::MathMatrixInset(MathInsetTypes t) } -MathMatrixInset::MathMatrixInset(MathInsetTypes t, int cols) +MathMatrixInset::MathMatrixInset(MathInsetTypes t, unsigned int cols) : MathGridInset(cols, 1), objtype_(t), nonum_(1), label_(1) { setDefaults(); @@ -77,7 +77,7 @@ MathInset * MathMatrixInset::clone() const } -char MathMatrixInset::defaultColAlign(int col) +char MathMatrixInset::defaultColAlign(unsigned int col) { switch (getType()) { case LM_OT_ALIGN: @@ -93,7 +93,7 @@ char MathMatrixInset::defaultColAlign(int col) } -int MathMatrixInset::defaultColSpace(int col) +int MathMatrixInset::defaultColSpace(unsigned int col) { switch (getType()) { case LM_OT_ALIGN: @@ -123,7 +123,7 @@ void MathMatrixInset::metrics(MathStyles) const if (numberedType()) { int l = 0; - for (int row = 0; row < nrows(); ++row) + for (unsigned int row = 0; row < nrows(); ++row) l = std::max(l, mathed_string_width(LM_TC_BF, size(), nicelabel(row))); if (l) @@ -148,7 +148,7 @@ void MathMatrixInset::draw(Painter & pain, int x, int y) const if (numberedType()) { int xx = x + colinfo_.back().offset_ + colinfo_.back().width_ + 20; - for (int row = 0; row < nrows(); ++row) { + for (unsigned int row = 0; row < nrows(); ++row) { int yy = y + rowinfo_[row].offset_; drawStr(pain, LM_TC_BF, size(), xx, yy, nicelabel(row)); } @@ -162,8 +162,8 @@ void MathMatrixInset::write(std::ostream & os, bool fragile) const bool n = numberedType(); - for (int row = 0; row < nrows(); ++row) { - for (int col = 0; col < ncols(); ++col) { + for (unsigned int row = 0; row < nrows(); ++row) { + for (unsigned int col = 0; col < ncols(); ++col) { cell(index(row, col)).write(os, fragile); os << eocString(col); } @@ -180,25 +180,25 @@ void MathMatrixInset::write(std::ostream & os, bool fragile) const } -string MathMatrixInset::label(int row) const +string MathMatrixInset::label(unsigned int row) const { return label_[row]; } -void MathMatrixInset::label(int row, string const & label) +void MathMatrixInset::label(unsigned int row, string const & label) { label_[row] = label; } -void MathMatrixInset::numbered(int row, bool num) +void MathMatrixInset::numbered(unsigned int row, bool num) { nonum_[row] = !num; } -bool MathMatrixInset::numbered(int row) const +bool MathMatrixInset::numbered(unsigned int row) const { return !nonum_[row]; } @@ -219,7 +219,7 @@ bool MathMatrixInset::display() const std::vector const MathMatrixInset::getLabelList() const { std::vector res; - for (int row = 0; row < nrows(); ++row) + for (unsigned int row = 0; row < nrows(); ++row) if (!label_[row].empty() && nonum_[row] != 1) res.push_back(label_[row]); return res; @@ -230,7 +230,7 @@ bool MathMatrixInset::numberedType() const { if (getType() == LM_OT_SIMPLE || getType() == LM_OT_XXALIGNAT) return false; - for (int row = 0; row < nrows(); ++row) + for (unsigned int row = 0; row < nrows(); ++row) if (!nonum_[row]) return true; return false; @@ -355,7 +355,7 @@ void MathMatrixInset::footer_write(std::ostream & os) const } -void MathMatrixInset::addRow(int row) +void MathMatrixInset::addRow(unsigned int row) { nonum_.insert(nonum_.begin() + row + 1, !numberedType()); label_.insert(label_.begin() + row + 1, string()); @@ -371,7 +371,7 @@ void MathMatrixInset::appendRow() } -void MathMatrixInset::delRow(int row) +void MathMatrixInset::delRow(unsigned int row) { MathGridInset::delRow(row); nonum_.erase(nonum_.begin() + row); @@ -379,7 +379,7 @@ void MathMatrixInset::delRow(int row) } -void MathMatrixInset::addCol(int col) +void MathMatrixInset::addCol(unsigned int col) { switch (getType()) { case LM_OT_EQUATION: @@ -409,7 +409,7 @@ void MathMatrixInset::addCol(int col) } -void MathMatrixInset::delCol(int col) +void MathMatrixInset::delCol(unsigned int col) { switch (getType()) { case LM_OT_ALIGNAT: @@ -424,7 +424,7 @@ void MathMatrixInset::delCol(int col) } -string MathMatrixInset::nicelabel(int row) const +string MathMatrixInset::nicelabel(unsigned int row) const { if (nonum_[row]) return string(); @@ -459,6 +459,7 @@ namespace { } } + void MathMatrixInset::mutate(string const & newtype) { if (newtype == "dump") { @@ -469,10 +470,11 @@ void MathMatrixInset::mutate(string const & newtype) mutate(typecode(newtype)); } + void MathMatrixInset::glueall() { MathArray ar; - for (int i = 0; i < nargs(); ++i) + for (unsigned int i = 0; i < nargs(); ++i) ar.push_back(cell(i)); *this = MathMatrixInset(LM_OT_SIMPLE); cell(0) = ar; @@ -521,7 +523,7 @@ void MathMatrixInset::mutate(MathInsetTypes newtype) MathGridInset::addCol(1); // split it "nicely" - int pos = firstRelOp(cell(0)); + unsigned int pos = firstRelOp(cell(0)); cell(1) = cell(0); cell(0).erase(pos, cell(0).size()); cell(1).erase(0, pos); @@ -536,7 +538,7 @@ void MathMatrixInset::mutate(MathInsetTypes newtype) MathGridInset::addCol(1); // split it "nicely" on the firest relop - int pos = firstRelOp(cell(0)); + unsigned int pos = firstRelOp(cell(0)); cell(1) = cell(0); cell(0).erase(pos, cell(0).size()); cell(1).erase(0, pos); @@ -559,16 +561,16 @@ void MathMatrixInset::mutate(MathInsetTypes newtype) case LM_OT_EQUATION: { // set correct (no)numbering bool allnonum = true; - for (int r = 0; r < nrows(); ++r) { - if (!nonum_[r]) + for (unsigned int row = 0; row < nrows(); ++row) { + if (!nonum_[row]) allnonum = false; } // set first non-empty label string label; - for (int r = 0; r < nrows(); ++r) { - if (!label_[r].empty()) { - label = label_[r]; + for (unsigned int row = 0; row < nrows(); ++row) { + if (!label_[row].empty()) { + label = label_[row]; break; } } @@ -586,8 +588,8 @@ void MathMatrixInset::mutate(MathInsetTypes newtype) case LM_OT_XALIGNAT: case LM_OT_XXALIGNAT: default: { - for (int row = 0; row < nrows(); ++row) { - int c = 3 * row + 1; + for (unsigned int row = 0; row < nrows(); ++row) { + unsigned int c = 3 * row + 1; cell(c).push_back(cell(c + 1)); } MathGridInset::delCol(2); diff --git a/src/mathed/math_matrixinset.h b/src/mathed/math_matrixinset.h index 0bacd40534..823eab9bbd 100644 --- a/src/mathed/math_matrixinset.h +++ b/src/mathed/math_matrixinset.h @@ -23,7 +23,7 @@ public: /// explicit MathMatrixInset(MathInsetTypes t); /// - MathMatrixInset(MathInsetTypes t, int cols); + MathMatrixInset(MathInsetTypes t, unsigned int cols); /// MathInset * clone() const; /// @@ -33,13 +33,13 @@ public: /// void draw(Painter &, int x, int y) const; /// - string label(int row) const; + string label(unsigned int row) const; /// - void label(int row, string const & label); + void label(unsigned int row, string const & label); /// - void numbered(int row, bool num); + void numbered(unsigned int row, bool num); /// - bool numbered(int row) const; + bool numbered(unsigned int row) const; /// bool numberedType() const; /// @@ -52,13 +52,13 @@ public: void validate(LaTeXFeatures & features) const; /// - void addRow(int); + void addRow(unsigned int); /// - void delRow(int); + void delRow(unsigned int); /// - void addCol(int); + void addCol(unsigned int); /// - void delCol(int); + void delCol(unsigned int); /// void appendRow(); @@ -68,9 +68,9 @@ public: void mutate(MathInsetTypes); /// - int defaultColSpace(int col); + int defaultColSpace(unsigned int col); /// - char defaultColAlign(int col); + char defaultColAlign(unsigned int col); /// MathInsetTypes getType() const; @@ -87,7 +87,7 @@ private: /// void glueall(); /// - string nicelabel(int row) const; + string nicelabel(unsigned int row) const; /// MathInsetTypes objtype_; diff --git a/src/mathed/math_nestinset.C b/src/mathed/math_nestinset.C index aae1db633d..fc316df70c 100644 --- a/src/mathed/math_nestinset.C +++ b/src/mathed/math_nestinset.C @@ -6,36 +6,36 @@ #include "debug.h" -MathNestInset::MathNestInset(int nargs) +MathNestInset::MathNestInset(unsigned int nargs) : MathDimInset(), cells_(nargs) {} -int MathNestInset::nargs() const +unsigned int MathNestInset::nargs() const { return cells_.size(); } -MathXArray & MathNestInset::xcell(int i) +MathXArray & MathNestInset::xcell(unsigned int i) { return cells_[i]; } -MathXArray const & MathNestInset::xcell(int i) const +MathXArray const & MathNestInset::xcell(unsigned int i) const { return cells_[i]; } -MathArray & MathNestInset::cell(int i) +MathArray & MathNestInset::cell(unsigned int i) { return cells_[i].data_; } -MathArray const & MathNestInset::cell(int i) const +MathArray const & MathNestInset::cell(unsigned int i) const { return cells_[i].data_; } @@ -43,7 +43,7 @@ MathArray const & MathNestInset::cell(int i) const void MathNestInset::substitute(MathMacro const & m) { - for (int i = 0; i < nargs(); ++i) + for (unsigned int i = 0; i < nargs(); ++i) cell(i).substitute(m); } @@ -51,7 +51,7 @@ void MathNestInset::substitute(MathMacro const & m) void MathNestInset::metrics(MathStyles st) const { size_ = st; - for (int i = 0; i < nargs(); ++i) + for (unsigned int i = 0; i < nargs(); ++i) xcell(i).metrics(st); } @@ -60,12 +60,12 @@ void MathNestInset::draw(Painter & pain, int x, int y) const { xo(x); yo(y); - for (int i = 0; i < nargs(); ++i) + for (unsigned int i = 0; i < nargs(); ++i) xcell(i).draw(pain, x + xcell(i).xo(), y + xcell(i).yo()); } -bool MathNestInset::idxNext(int & idx, int & pos) const +bool MathNestInset::idxNext(unsigned int & idx, unsigned int & pos) const { if (idx + 1 >= nargs()) return false; @@ -75,13 +75,13 @@ bool MathNestInset::idxNext(int & idx, int & pos) const } -bool MathNestInset::idxRight(int & idx, int & pos) const +bool MathNestInset::idxRight(unsigned int & idx, unsigned int & pos) const { return idxNext(idx, pos); } -bool MathNestInset::idxPrev(int & idx, int & pos) const +bool MathNestInset::idxPrev(unsigned int & idx, unsigned int & pos) const { if (idx == 0) return false; @@ -91,13 +91,13 @@ bool MathNestInset::idxPrev(int & idx, int & pos) const } -bool MathNestInset::idxLeft(int & idx, int & pos) const +bool MathNestInset::idxLeft(unsigned int & idx, unsigned int & pos) const { return idxPrev(idx, pos); } -bool MathNestInset::idxFirst(int & i, int & pos) const +bool MathNestInset::idxFirst(unsigned int & i, unsigned int & pos) const { if (nargs() == 0) return false; @@ -107,7 +107,7 @@ bool MathNestInset::idxFirst(int & i, int & pos) const } -bool MathNestInset::idxLast(int & i, int & pos) const +bool MathNestInset::idxLast(unsigned int & i, unsigned int & pos) const { if (nargs() == 0) return false; @@ -117,7 +117,7 @@ bool MathNestInset::idxLast(int & i, int & pos) const } -bool MathNestInset::idxHome(int & /* idx */, int & pos) const +bool MathNestInset::idxHome(unsigned int & /* idx */, unsigned int & pos) const { if (pos == 0) return false; @@ -126,9 +126,9 @@ bool MathNestInset::idxHome(int & /* idx */, int & pos) const } -bool MathNestInset::idxEnd(int & idx, int & pos) const +bool MathNestInset::idxEnd(unsigned int & idx, unsigned int & pos) const { - int n = cell(idx).size(); + unsigned int n = cell(idx).size(); if (pos == n) return false; @@ -142,7 +142,7 @@ void MathNestInset::dump() const lyxerr << "---------------------------------------------\n"; write(lyxerr, false); lyxerr << "\n"; - for (int i = 0; i < nargs(); ++i) + for (unsigned int i = 0; i < nargs(); ++i) lyxerr << cell(i) << "\n"; lyxerr << "---------------------------------------------\n"; } @@ -159,6 +159,6 @@ void MathNestInset::push_back(MathInset * p) void MathNestInset::validate(LaTeXFeatures & features) const { - for (int i = 0; i < nargs(); ++i) + for (unsigned int i = 0; i < nargs(); ++i) cell(i).validate(features); } diff --git a/src/mathed/math_nestinset.h b/src/mathed/math_nestinset.h index 123fc26749..5a69d88be9 100644 --- a/src/mathed/math_nestinset.h +++ b/src/mathed/math_nestinset.h @@ -16,7 +16,7 @@ class LaTeXFeatures; class MathNestInset : public MathDimInset { public: /// - explicit MathNestInset(int ncells); + explicit MathNestInset(unsigned int ncells); /// void metrics(MathStyles st) const; @@ -26,36 +26,36 @@ public: void substitute(MathMacro const & macro); /// The left key - bool idxLeft(int & idx, int & pos) const; + bool idxLeft(unsigned int & idx, unsigned int & pos) const; /// The right key - bool idxRight(int & idx, int & pos) const; + bool idxRight(unsigned int & idx, unsigned int & pos) const; /// Move one physical cell up - bool idxNext(int & idx, int & pos) const; + bool idxNext(unsigned int & idx, unsigned int & pos) const; /// Move one physical cell down - bool idxPrev(int & idx, int & pos) const; + bool idxPrev(unsigned int & idx, unsigned int & pos) const; /// Target pos when we enter the inset from the left by pressing "Right" - bool idxFirst(int & idx, int & pos) const; + bool idxFirst(unsigned int & idx, unsigned int & pos) const; /// Target pos when we enter the inset from the right by pressing "Left" - bool idxLast(int & idx, int & pos) const; + bool idxLast(unsigned int & idx, unsigned int & pos) const; /// Where should we go if we press home? - bool idxHome(int & idx, int & pos) const; + bool idxHome(unsigned int & idx, unsigned int & pos) const; /// Where should we go if we press end? - bool idxEnd(int & idx, int & pos) const; + bool idxEnd(unsigned int & idx, unsigned int & pos) const; /// - int nargs() const; + unsigned int nargs() const; /// - MathArray & cell(int); + MathArray & cell(unsigned int); /// - MathArray const & cell(int) const; + MathArray const & cell(unsigned int) const; /// - MathXArray & xcell(int); + MathXArray & xcell(unsigned int); /// - MathXArray const & xcell(int) const; + MathXArray const & xcell(unsigned int) const; /// bool isActive() const { return nargs() > 0; } diff --git a/src/mathed/math_parser.C b/src/mathed/math_parser.C index a63b0b0fba..18766700e3 100644 --- a/src/mathed/math_parser.C +++ b/src/mathed/math_parser.C @@ -880,7 +880,7 @@ void Parser::parse_into(MathArray & array, unsigned flags, MathTextCodes code) else { MathInset * p = createMathInset(t.cs()); - for (int i = 0; i < p->nargs(); ++i) + for (unsigned int i = 0; i < p->nargs(); ++i) parse_into(p->cell(i), FLAG_ITEM); array.push_back(p); } @@ -889,7 +889,7 @@ void Parser::parse_into(MathArray & array, unsigned flags, MathTextCodes code) else { MathInset * p = createMathInset(t.cs()); if (p) { - for (int i = 0; i < p->nargs(); ++i) + for (unsigned int i = 0; i < p->nargs(); ++i) parse_into(p->cell(i), FLAG_ITEM); array.push_back(p); } else {