Get math macros working for MathML.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@32004 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Richard Heck 2009-11-15 12:30:26 +00:00
parent 8ad0e96631
commit ae60474513
2 changed files with 11 additions and 5 deletions

View File

@ -218,6 +218,8 @@ enum InsetCode {
MATH_XYMATRIX_CODE, MATH_XYMATRIX_CODE,
/// ///
MATH_MACRO_CODE, MATH_MACRO_CODE,
///
ARGUMENT_PROXY_CODE, // 100
}; };
} // namespace lyx } // namespace lyx

View File

@ -59,6 +59,8 @@ public:
asArray(def, def_); asArray(def, def_);
} }
/// ///
InsetCode lyxCode() const { return ARGUMENT_PROXY_CODE; }
///
void metrics(MetricsInfo & mi, Dimension & dim) const { void metrics(MetricsInfo & mi, Dimension & dim) const {
mathMacro_.macro()->unlock(); mathMacro_.macro()->unlock();
mathMacro_.cell(idx_).metrics(mi, dim); mathMacro_.cell(idx_).metrics(mi, dim);
@ -69,6 +71,9 @@ public:
mathMacro_.macro()->lock(); mathMacro_.macro()->lock();
} }
// FIXME Other external things need similar treatment.
///
void mathmlize(MathStream & ms) const { ms << mathMacro_.cell(idx_); }
/// ///
void draw(PainterInfo & pi, int x, int y) const { void draw(PainterInfo & pi, int x, int y) const {
if (mathMacro_.editMetrics(pi.base.bv)) { if (mathMacro_.editMetrics(pi.base.bv)) {
@ -127,7 +132,7 @@ Inset * MathMacro::clone() const
{ {
MathMacro * copy = new MathMacro(*this); MathMacro * copy = new MathMacro(*this);
copy->needsUpdate_ = true; copy->needsUpdate_ = true;
copy->expanded_.cell(0).clear(); //copy->expanded_.cell(0).clear();
return copy; return copy;
} }
@ -325,10 +330,9 @@ void MathMacro::updateRepresentation()
proxy = new ArgumentProxy(*this, i); proxy = new ArgumentProxy(*this, i);
values[i].insert(0, MathAtom(proxy)); values[i].insert(0, MathAtom(proxy));
} }
// expanding macro with the values // expanding macro with the values
macro_->expand(values, expanded_.cell(0)); macro_->expand(values, expanded_.cell(0));
// get definition for list edit mode // get definition for list edit mode
docstring const & display = macro_->display(); docstring const & display = macro_->display();
asArray(display.empty() ? macro_->definition() : display, definition_); asArray(display.empty() ? macro_->definition() : display, definition_);
} }
@ -710,7 +714,7 @@ void MathMacro::write(WriteStream & os) const
// skip the tailing empty optionals // skip the tailing empty optionals
i = optionals_; i = optionals_;
// Print remaining macros // Print remaining arguments
for (; i < cells_.size(); ++i) { for (; i < cells_.size(); ++i) {
if (cell(i).size() == 1 if (cell(i).size() == 1
&& cell(i)[0].nucleus()->asCharInset() && cell(i)[0].nucleus()->asCharInset()
@ -737,7 +741,7 @@ void MathMacro::maple(MapleStream & os) const
void MathMacro::mathmlize(MathStream & os) const void MathMacro::mathmlize(MathStream & os) const
{ {
lyx::mathmlize(expanded_.cell(0), os); os << expanded_.cell(0);
} }