mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-23 16:52:02 +00:00
a bit more const correctness
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@4905 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
fe5cc4b241
commit
73b1ac43f4
@ -396,13 +396,19 @@ bool InsetFormula::display() const
|
||||
}
|
||||
|
||||
|
||||
MathHullInset * InsetFormula::hull() const
|
||||
MathHullInset const * InsetFormula::hull() const
|
||||
{
|
||||
lyx::Assert(par_->asHullInset());
|
||||
return par_->asHullInset();
|
||||
}
|
||||
|
||||
|
||||
MathHullInset * InsetFormula::hull()
|
||||
{
|
||||
lyx::Assert(par_->asHullInset());
|
||||
return par_->asHullInset();
|
||||
}
|
||||
|
||||
Inset::Code InsetFormula::lyxCode() const
|
||||
{
|
||||
return Inset::MATH_CODE;
|
||||
|
@ -94,7 +94,9 @@ private:
|
||||
/// available in AMS only?
|
||||
bool ams() const;
|
||||
/// access to hull
|
||||
MathHullInset * hull() const;
|
||||
MathHullInset const * hull() const;
|
||||
/// access to hull
|
||||
MathHullInset * hull();
|
||||
///
|
||||
void handleExtern(string const & arg);
|
||||
|
||||
|
@ -50,7 +50,8 @@ public:
|
||||
/// change inset under the hood
|
||||
void reset(MathInset * p);
|
||||
/// access to the inset (checked with gprof)
|
||||
MathInset * nucleus() const { return nucleus_; }
|
||||
MathInset const * nucleus() const { return nucleus_; }
|
||||
MathInset * nucleus() { return nucleus_; }
|
||||
/// access to the inset
|
||||
MathInset * operator->() const { return nucleus_; }
|
||||
|
||||
|
@ -135,7 +135,7 @@ bool MathCharInset::isRelOp() const
|
||||
}
|
||||
|
||||
|
||||
bool MathCharInset::match(MathInset * p) const
|
||||
bool MathCharInset::match(MathInset const * p) const
|
||||
{
|
||||
MathCharInset const * q = p->asCharInset();
|
||||
return q && char_ == q->char_;
|
||||
|
@ -39,7 +39,7 @@ public:
|
||||
///
|
||||
bool isRelOp() const;
|
||||
///
|
||||
bool match(MathInset *) const;
|
||||
bool match(MathInset const *) const;
|
||||
|
||||
private:
|
||||
/// the character
|
||||
|
@ -587,7 +587,7 @@ bool MathCursor::toggleLimits()
|
||||
|
||||
void MathCursor::macroModeClose()
|
||||
{
|
||||
MathUnknownInset * p = inMacroMode();
|
||||
MathUnknownInset const * p = inMacroMode();
|
||||
if (!p)
|
||||
return;
|
||||
p->finalize();
|
||||
@ -688,7 +688,6 @@ void MathCursor::selGet(MathArray & ar)
|
||||
}
|
||||
|
||||
|
||||
|
||||
void MathCursor::drawSelection(MathPainterInfo & pi) const
|
||||
{
|
||||
if (!selection_)
|
||||
@ -702,7 +701,10 @@ void MathCursor::drawSelection(MathPainterInfo & pi) const
|
||||
|
||||
void MathCursor::handleNest(MathAtom const & at)
|
||||
{
|
||||
at->cell(0) = grabAndEraseSelection().glue();
|
||||
#ifdef WITH_WARNINGS
|
||||
#warning temporarily disabled
|
||||
//at->cell(0) = grabAndEraseSelection().glue();
|
||||
#endif
|
||||
insert(at);
|
||||
pushRight(prevAtom());
|
||||
}
|
||||
@ -750,11 +752,11 @@ MathCursor::pos_type & MathCursor::pos()
|
||||
}
|
||||
|
||||
|
||||
MathUnknownInset * MathCursor::inMacroMode() const
|
||||
MathUnknownInset const * MathCursor::inMacroMode() const
|
||||
{
|
||||
if (!hasPrevAtom())
|
||||
return 0;
|
||||
MathUnknownInset * p = prevAtom()->asUnknownInset();
|
||||
MathUnknownInset const * p = prevAtom()->asUnknownInset();
|
||||
return (p && !p->final()) ? p : 0;
|
||||
}
|
||||
|
||||
|
@ -134,7 +134,7 @@ public:
|
||||
/// interpret name a name of a macro
|
||||
void macroModeClose();
|
||||
/// are we currently typing the name of a macro?
|
||||
MathUnknownInset * inMacroMode() const;
|
||||
MathUnknownInset const * inMacroMode() const;
|
||||
/// are we currently typing '#1' or '#2' or...?
|
||||
bool inMacroArgMode() const;
|
||||
/// are we in math mode (1), text mode (-1) or unsure?
|
||||
|
@ -154,8 +154,11 @@ void MathArray::replace(ReplaceData & rep)
|
||||
}
|
||||
}
|
||||
|
||||
for (const_iterator it = begin(); it != end(); ++it)
|
||||
it->nucleus()->replace(rep);
|
||||
#ifdef WITH_WARNINGS
|
||||
#warning temporarily disabled
|
||||
// for (const_iterator it = begin(); it != end(); ++it)
|
||||
// it->nucleus()->replace(rep);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
@ -44,7 +44,7 @@ ostream & operator<<(ostream & os, MathArray const & ar)
|
||||
|
||||
|
||||
// define a function for tests
|
||||
typedef bool TestItemFunc(MathInset *);
|
||||
typedef bool TestItemFunc(MathInset const *);
|
||||
|
||||
// define a function for replacing subexpressions
|
||||
typedef MathInset * ReplaceArgumentFunc(const MathArray & ar);
|
||||
@ -132,14 +132,14 @@ void extractStrings(MathArray & ar)
|
||||
if (!ar[i]->asCharInset())
|
||||
continue;
|
||||
string s = charSequence(ar.begin() + i, ar.end());
|
||||
ar[i].reset(new MathStringInset(s));
|
||||
ar[i] = MathAtom(new MathStringInset(s));
|
||||
ar.erase(i + 1, i + s.size());
|
||||
}
|
||||
//lyxerr << "\nStrings to: " << ar << "\n";
|
||||
}
|
||||
|
||||
|
||||
MathInset * singleItem(MathArray & ar)
|
||||
MathInset const * singleItem(MathArray const & ar)
|
||||
{
|
||||
return ar.size() == 1 ? ar.begin()->nucleus() : 0;
|
||||
}
|
||||
@ -153,7 +153,7 @@ void extractMatrices(MathArray & ar)
|
||||
MathDelimInset * del = (*it)->asDelimInset();
|
||||
if (!del)
|
||||
continue;
|
||||
MathInset * arr = singleItem(del->cell(0));
|
||||
MathInset const * arr = singleItem(del->cell(0));
|
||||
if (!arr || !arr->asGridInset())
|
||||
continue;
|
||||
*it = MathAtom(new MathMatrixInset(*(arr->asGridInset())));
|
||||
@ -171,7 +171,7 @@ void extractMatrices(MathArray & ar)
|
||||
|
||||
|
||||
// convert this inset somehow to a string
|
||||
bool extractString(MathInset * p, string & str)
|
||||
bool extractString(MathInset const * p, string & str)
|
||||
{
|
||||
if (!p)
|
||||
return false;
|
||||
@ -204,7 +204,7 @@ bool extractNumber(MathArray const & ar, double & d)
|
||||
}
|
||||
|
||||
|
||||
bool testString(MathInset * p, const string & str)
|
||||
bool testString(MathInset const * p, const string & str)
|
||||
{
|
||||
string s;
|
||||
return extractString(p, s) && str == s;
|
||||
@ -257,7 +257,7 @@ void replaceNested(
|
||||
|
||||
// replace the original stuff by the new inset
|
||||
ar.erase(it + 1, jt + 1);
|
||||
(*it).reset(p);
|
||||
*it = MathAtom(p);
|
||||
}
|
||||
}
|
||||
|
||||
@ -319,7 +319,7 @@ void extractExps(MathArray & ar)
|
||||
continue;
|
||||
|
||||
// create a proper exp-inset as replacement
|
||||
*it = new MathExFuncInset("exp", sup->cell(1));
|
||||
*it = MathAtom(new MathExFuncInset("exp", sup->cell(1)));
|
||||
ar.erase(it + 1);
|
||||
}
|
||||
//lyxerr << "\nExps to: " << ar << "\n";
|
||||
@ -338,7 +338,7 @@ void extractDets(MathArray & ar)
|
||||
continue;
|
||||
if (!del->isAbs())
|
||||
continue;
|
||||
*it = new MathExFuncInset("det", del->cell(0));
|
||||
*it = MathAtom(new MathExFuncInset("det", del->cell(0)));
|
||||
}
|
||||
//lyxerr << "\ndet to: " << ar << "\n";
|
||||
}
|
||||
@ -379,7 +379,7 @@ void extractNumbers(MathArray & ar)
|
||||
|
||||
string s = digitSequence(ar.begin() + i, ar.end());
|
||||
|
||||
ar[i].reset(new MathNumberInset(s));
|
||||
ar[i] = MathAtom(new MathNumberInset(s));
|
||||
ar.erase(i + 1, i + s.size());
|
||||
}
|
||||
//lyxerr << "\nNumbers to: " << ar << "\n";
|
||||
@ -391,13 +391,13 @@ void extractNumbers(MathArray & ar)
|
||||
// search deliminiters
|
||||
//
|
||||
|
||||
bool testOpenParan(MathInset * p)
|
||||
bool testOpenParan(MathInset const * p)
|
||||
{
|
||||
return testString(p, "(");
|
||||
}
|
||||
|
||||
|
||||
bool testCloseParan(MathInset * p)
|
||||
bool testCloseParan(MathInset const * p)
|
||||
{
|
||||
return testString(p, ")");
|
||||
}
|
||||
@ -470,7 +470,7 @@ void extractFunctions(MathArray & ar)
|
||||
MathArray::iterator st = extractArgument(p->cell(0), jt, ar.end());
|
||||
|
||||
// replace the function name by a real function inset
|
||||
(*it).reset(p);
|
||||
*it = MathAtom(p);
|
||||
|
||||
// remove the source of the argument from the array
|
||||
ar.erase(it + 1, st);
|
||||
@ -486,19 +486,19 @@ void extractFunctions(MathArray & ar)
|
||||
// search integrals
|
||||
//
|
||||
|
||||
bool testSymbol(MathInset * p, string const & name)
|
||||
bool testSymbol(MathInset const * p, string const & name)
|
||||
{
|
||||
return p->asSymbolInset() && p->asSymbolInset()->name() == name;
|
||||
}
|
||||
|
||||
|
||||
bool testIntSymbol(MathInset * p)
|
||||
bool testIntSymbol(MathInset const * p)
|
||||
{
|
||||
return testSymbol(p, "int");
|
||||
}
|
||||
|
||||
|
||||
bool testIntegral(MathInset * p)
|
||||
bool testIntegral(MathInset const * p)
|
||||
{
|
||||
return
|
||||
testIntSymbol(p) ||
|
||||
@ -509,7 +509,7 @@ bool testIntegral(MathInset * p)
|
||||
|
||||
|
||||
|
||||
bool testIntDiff(MathInset * p)
|
||||
bool testIntDiff(MathInset const * p)
|
||||
{
|
||||
return testString(p, "d");
|
||||
}
|
||||
@ -554,7 +554,7 @@ void extractIntegrals(MathArray & ar)
|
||||
|
||||
// remove used parts
|
||||
ar.erase(it + 1, tt);
|
||||
(*it).reset(p);
|
||||
*it = MathAtom(p);
|
||||
}
|
||||
//lyxerr << "\nIntegrals to: " << ar << "\n";
|
||||
}
|
||||
@ -571,13 +571,13 @@ bool testEqualSign(MathAtom const & at)
|
||||
}
|
||||
|
||||
|
||||
bool testSumSymbol(MathInset * p)
|
||||
bool testSumSymbol(MathInset const * p)
|
||||
{
|
||||
return testSymbol(p, "sum");
|
||||
}
|
||||
|
||||
|
||||
bool testSum(MathInset * p)
|
||||
bool testSum(MathInset const * p)
|
||||
{
|
||||
return
|
||||
testSumSymbol(p) ||
|
||||
@ -633,7 +633,7 @@ void extractSums(MathArray & ar)
|
||||
|
||||
// cleanup
|
||||
ar.erase(it + 1, tt);
|
||||
(*it).reset(p);
|
||||
*it = MathAtom(p);
|
||||
}
|
||||
//lyxerr << "\nSums to: " << ar << "\n";
|
||||
}
|
||||
@ -656,9 +656,9 @@ bool testDiffArray(MathArray const & ar)
|
||||
}
|
||||
|
||||
|
||||
bool testDiffFrac(MathInset * p)
|
||||
bool testDiffFrac(MathInset const * p)
|
||||
{
|
||||
MathFracInset * f = p->asFracInset();
|
||||
MathFracInset const * f = p->asFracInset();
|
||||
return f && testDiffArray(f->cell(0)) && testDiffArray(f->cell(1));
|
||||
}
|
||||
|
||||
@ -743,7 +743,7 @@ void extractDiff(MathArray & ar)
|
||||
|
||||
// cleanup
|
||||
ar.erase(it + 1, jt);
|
||||
(*it).reset(diff);
|
||||
*it = MathAtom(diff);
|
||||
}
|
||||
//lyxerr << "\nDiffs to: " << ar << "\n";
|
||||
}
|
||||
@ -798,12 +798,11 @@ void extractLims(MathArray & ar)
|
||||
MathArray f;
|
||||
MathArray::iterator tt = extractArgument(f, it + 2, ar.end());
|
||||
|
||||
// create a proper inset as replacement
|
||||
MathLimInset * p = new MathLimInset(f, x, x0);
|
||||
|
||||
// cleanup
|
||||
ar.erase(it + 1, tt);
|
||||
(*it).reset(p);
|
||||
|
||||
// create a proper inset as replacement
|
||||
*it = MathAtom(new MathLimInset(f, x, x0));
|
||||
}
|
||||
//lyxerr << "\nLimits to: " << ar << "\n";
|
||||
}
|
||||
|
@ -29,6 +29,12 @@ MathFracInset * MathFracInset::asFracInset()
|
||||
}
|
||||
|
||||
|
||||
MathFracInset const * MathFracInset::asFracInset() const
|
||||
{
|
||||
return atop_ ? 0 : this;
|
||||
}
|
||||
|
||||
|
||||
void MathFracInset::metrics(MathMetricsInfo & mi) const
|
||||
{
|
||||
MathFracChanger dummy(mi.base);
|
||||
|
@ -25,8 +25,10 @@ public:
|
||||
void metricsT(TextMetricsInfo const & mi) const;
|
||||
///
|
||||
void drawT(TextPainter &, int x, int y) const;
|
||||
///
|
||||
/// identifies FracInsets
|
||||
MathFracInset * asFracInset();
|
||||
/// identifies FracInsets
|
||||
MathFracInset const * asFracInset() const;
|
||||
///
|
||||
string name() const;
|
||||
|
||||
|
@ -125,7 +125,9 @@ public:
|
||||
///
|
||||
CellInfo & cellinfo(idx_type idx) { return cellinfo_[idx]; }
|
||||
/// identifies GridInset
|
||||
virtual MathGridInset * asGridInset() { return this; }
|
||||
MathGridInset * asGridInset() { return this; }
|
||||
/// identifies GridInset
|
||||
MathGridInset const * asGridInset() const { return this; }
|
||||
|
||||
///
|
||||
col_type ncols() const;
|
||||
|
@ -516,9 +516,8 @@ void MathHullInset::mutate(string const & newtype)
|
||||
setType("eqnarray");
|
||||
mutate(newtype);
|
||||
} else if (newtype == "multline" || newtype == "gather") {
|
||||
setType("multline");
|
||||
setType(newtype);
|
||||
numbered(0, false);
|
||||
mutate(newtype);
|
||||
} else {
|
||||
MathGridInset::addCol(1);
|
||||
// split it "nicely"
|
||||
|
@ -195,17 +195,21 @@ public:
|
||||
virtual MathDelimInset * asDelimInset() { return 0; }
|
||||
virtual MathDelimInset const * asDelimInset() const { return 0; }
|
||||
virtual MathFracInset * asFracInset() { return 0; }
|
||||
virtual MathFracInset const * asFracInset() const { return 0; }
|
||||
virtual MathGridInset * asGridInset() { return 0; }
|
||||
virtual MathGridInset const * asGridInset() const { return 0; }
|
||||
virtual MathHullInset * asHullInset() { return 0; }
|
||||
virtual MathHullInset const * asHullInset() const { return 0; }
|
||||
virtual MathMacroTemplate * asMacroTemplate() { return 0; }
|
||||
virtual MathMatrixInset const * asMatrixInset() const { return 0; }
|
||||
virtual MathNestInset * asNestInset() { return 0; }
|
||||
virtual MathNestInset const * asNestInset() const { return 0; }
|
||||
virtual MathParboxInset * asParboxInset() { return 0; }
|
||||
virtual MathScriptInset * asScriptInset() { return 0; }
|
||||
virtual MathScriptInset const * asScriptInset() const { return 0; }
|
||||
virtual MathSpaceInset * asSpaceInset() { return 0; }
|
||||
virtual MathStringInset * asStringInset() { return 0; }
|
||||
virtual MathStringInset const * asStringInset() const { return 0; }
|
||||
virtual MathSymbolInset const * asSymbolInset() const { return 0; }
|
||||
virtual MathUnknownInset * asUnknownInset() { return 0; }
|
||||
virtual MathUnknownInset const * asUnknownInset() const { return 0; }
|
||||
@ -236,11 +240,11 @@ public:
|
||||
/// char char code if possible
|
||||
virtual void handleFont(string const &) {}
|
||||
/// is this inset equal to a given other inset?
|
||||
virtual bool match(MathInset *) const { return false; }
|
||||
virtual bool match(MathInset const *) const { return false; }
|
||||
/// replace things by other things
|
||||
virtual void replace(ReplaceData &) {}
|
||||
/// do we contain a given subsequence?
|
||||
virtual bool contains(MathArray const &) { return false; }
|
||||
virtual bool contains(MathArray const &) const { return false; }
|
||||
/// access to the lock (only nest array have one)
|
||||
virtual bool lock() const { return false; }
|
||||
/// access to the lock (only nest array have one)
|
||||
|
@ -74,7 +74,7 @@ void MathIterator::goEnd()
|
||||
void MathIterator::operator++()
|
||||
{
|
||||
MathCursorPos & top = back();
|
||||
MathArray const & ar = top.par_->cell(top.idx_);
|
||||
MathArray & ar = top.par_->cell(top.idx_);
|
||||
|
||||
// move into the current inset if possible
|
||||
// it is impossible for pos() == size()!
|
||||
|
@ -60,7 +60,7 @@ public:
|
||||
///
|
||||
bool isMacro() const { return true; }
|
||||
///
|
||||
bool match(MathInset *) const { return false; }
|
||||
bool match(MathInset const *) const { return false; }
|
||||
|
||||
///
|
||||
void maplize(MapleStream &) const;
|
||||
|
@ -228,7 +228,7 @@ void MathNestInset::validate(LaTeXFeatures & features) const
|
||||
}
|
||||
|
||||
|
||||
bool MathNestInset::match(MathInset * p) const
|
||||
bool MathNestInset::match(MathInset const * p) const
|
||||
{
|
||||
if (nargs() != p->nargs())
|
||||
return false;
|
||||
@ -246,7 +246,7 @@ void MathNestInset::replace(ReplaceData & rep)
|
||||
}
|
||||
|
||||
|
||||
bool MathNestInset::contains(MathArray const & ar)
|
||||
bool MathNestInset::contains(MathArray const & ar) const
|
||||
{
|
||||
for (idx_type i = 0; i < nargs(); ++i)
|
||||
if (cell(i).contains(ar))
|
||||
|
@ -38,6 +38,8 @@ public:
|
||||
void substitute(MathMacro const & macro);
|
||||
/// identifies NestInsets
|
||||
MathNestInset * asNestInset() { return this; }
|
||||
/// identifies NestInsets
|
||||
MathNestInset const * asNestInset() const { return this; }
|
||||
/// get cursor position
|
||||
void getPos(idx_type idx, pos_type pos, int & x, int & y) const;
|
||||
|
||||
@ -81,11 +83,11 @@ public:
|
||||
void validate(LaTeXFeatures & features) const;
|
||||
|
||||
/// match in all cells
|
||||
bool match(MathInset *) const;
|
||||
bool match(MathInset const *) const;
|
||||
/// replace in all cells
|
||||
void replace(ReplaceData &);
|
||||
/// do we contain a given pattern?
|
||||
bool contains(MathArray const &);
|
||||
bool contains(MathArray const &) const;
|
||||
/// glue everything to a single cell
|
||||
MathArray glue() const;
|
||||
|
||||
|
@ -140,7 +140,7 @@ char const * MathMLtype(string const & s)
|
||||
}
|
||||
|
||||
|
||||
bool MathSymbolInset::match(MathInset * p) const
|
||||
bool MathSymbolInset::match(MathInset const * p) const
|
||||
{
|
||||
MathSymbolInset const * q = p->asSymbolInset();
|
||||
return q && name() == q->name();
|
||||
|
@ -34,7 +34,7 @@ public:
|
||||
/// the LaTeX name of the symbol (without the backslash)
|
||||
string name() const;
|
||||
///
|
||||
bool match(MathInset *) const;
|
||||
bool match(MathInset const *) const;
|
||||
/// request "external features"
|
||||
void validate(LaTeXFeatures & features) const;
|
||||
|
||||
|
@ -27,13 +27,13 @@ string MathUnknownInset::name() const
|
||||
}
|
||||
|
||||
|
||||
void MathUnknownInset::setName(string const & name)
|
||||
void MathUnknownInset::setName(string const & name) const
|
||||
{
|
||||
name_ = name;
|
||||
}
|
||||
|
||||
|
||||
bool MathUnknownInset::match(MathInset * p) const
|
||||
bool MathUnknownInset::match(MathInset const * p) const
|
||||
{
|
||||
MathUnknownInset const * q = p->asUnknownInset();
|
||||
return q && name_ == q->name_;
|
||||
@ -61,7 +61,7 @@ void MathUnknownInset::draw(MathPainterInfo & pi, int x, int y) const
|
||||
}
|
||||
|
||||
|
||||
void MathUnknownInset::finalize()
|
||||
void MathUnknownInset::finalize() const
|
||||
{
|
||||
final_ = true;
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ public:
|
||||
///
|
||||
void draw(MathPainterInfo & pi, int x, int y) const;
|
||||
///
|
||||
void setName(string const & name);
|
||||
void setName(string const & name) const;
|
||||
///
|
||||
string name() const;
|
||||
/// identifies UnknownInsets
|
||||
@ -31,7 +31,7 @@ public:
|
||||
/// identifies UnknownInsets
|
||||
MathUnknownInset * asUnknownInset() { return this; }
|
||||
///
|
||||
bool match(MathInset * p) const;
|
||||
bool match(MathInset const * p) const;
|
||||
|
||||
///
|
||||
void normalize(NormalStream &) const;
|
||||
@ -44,14 +44,14 @@ public:
|
||||
///
|
||||
void octavize(OctaveStream &) const;
|
||||
///
|
||||
void finalize();
|
||||
void finalize() const;
|
||||
///
|
||||
bool final() const;
|
||||
private:
|
||||
///
|
||||
string name_;
|
||||
mutable string name_;
|
||||
/// are we finished creating the name?
|
||||
bool final_;
|
||||
mutable bool final_;
|
||||
///
|
||||
bool black_;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user