}
-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;
/// 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);
/// 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_; }
}
-bool MathCharInset::match(MathInset * p) const
+bool MathCharInset::match(MathInset const * p) const
{
MathCharInset const * q = p->asCharInset();
return q && char_ == q->char_;
///
bool isRelOp() const;
///
- bool match(MathInset *) const;
+ bool match(MathInset const *) const;
private:
/// the character
void MathCursor::macroModeClose()
{
- MathUnknownInset * p = inMacroMode();
+ MathUnknownInset const * p = inMacroMode();
if (!p)
return;
p->finalize();
}
-
void MathCursor::drawSelection(MathPainterInfo & pi) const
{
if (!selection_)
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());
}
}
-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;
}
/// 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?
}
}
- 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
}
// 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);
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;
}
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())));
// convert this inset somehow to a string
-bool extractString(MathInset * p, string & str)
+bool extractString(MathInset const * p, string & str)
{
if (!p)
return false;
}
-bool testString(MathInset * p, const string & str)
+bool testString(MathInset const * p, const string & str)
{
string s;
return extractString(p, s) && str == s;
// replace the original stuff by the new inset
ar.erase(it + 1, jt + 1);
- (*it).reset(p);
+ *it = MathAtom(p);
}
}
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";
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";
}
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";
// 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, ")");
}
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);
// 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) ||
-bool testIntDiff(MathInset * p)
+bool testIntDiff(MathInset const * p)
{
return testString(p, "d");
}
// remove used parts
ar.erase(it + 1, tt);
- (*it).reset(p);
+ *it = MathAtom(p);
}
//lyxerr << "\nIntegrals to: " << ar << "\n";
}
}
-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) ||
// cleanup
ar.erase(it + 1, tt);
- (*it).reset(p);
+ *it = MathAtom(p);
}
//lyxerr << "\nSums to: " << ar << "\n";
}
}
-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));
}
// cleanup
ar.erase(it + 1, jt);
- (*it).reset(diff);
+ *it = MathAtom(diff);
}
//lyxerr << "\nDiffs to: " << ar << "\n";
}
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";
}
}
+MathFracInset const * MathFracInset::asFracInset() const
+{
+ return atop_ ? 0 : this;
+}
+
+
void MathFracInset::metrics(MathMetricsInfo & mi) const
{
MathFracChanger dummy(mi.base);
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;
///
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;
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"
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; }
/// 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)
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()!
///
bool isMacro() const { return true; }
///
- bool match(MathInset *) const { return false; }
+ bool match(MathInset const *) const { return false; }
///
void maplize(MapleStream &) const;
}
-bool MathNestInset::match(MathInset * p) const
+bool MathNestInset::match(MathInset const * p) const
{
if (nargs() != p->nargs())
return false;
}
-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))
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;
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;
}
-bool MathSymbolInset::match(MathInset * p) const
+bool MathSymbolInset::match(MathInset const * p) const
{
MathSymbolInset const * q = p->asSymbolInset();
return q && name() == q->name();
/// 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;
}
-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_;
}
-void MathUnknownInset::finalize()
+void MathUnknownInset::finalize() const
{
final_ = true;
}
///
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
/// identifies UnknownInsets
MathUnknownInset * asUnknownInset() { return this; }
///
- bool match(MathInset * p) const;
+ bool match(MathInset const * p) const;
///
void normalize(NormalStream &) const;
///
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_;
};