]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/MacroTable.cpp
Get rid of Inset::setPosCache
[lyx.git] / src / mathed / MacroTable.cpp
index 31118ac6e086968bb258183df5874f5bde6bd2c0..d23855c511f5bd3fadd26661f81fc2d0b97a9abf 100644 (file)
@@ -68,11 +68,10 @@ bool MacroData::expand(vector<MathData> const & args, MathData & to) const
        updateData();
 
        // Hack. Any inset with a cell would do.
-       static InsetMathSqrt inset(0);
-       inset.setBuffer(const_cast<Buffer &>(*buffer_));
+       InsetMathSqrt inset(const_cast<Buffer *>(buffer_));
 
        docstring const & definition(display_.empty() ? definition_ : display_);
-       asArray(definition, inset.cell(0));
+       asArray(definition, inset.cell(0), Parse::QUIET);
        //lyxerr << "MathData::expand: args: " << args << endl;
        //LYXERR0("MathData::expand: ar: " << inset.cell(0));
        for (DocIterator it = doc_iterator_begin(buffer_, &inset); it; it.forwardChar()) {
@@ -114,11 +113,33 @@ vector<docstring> const & MacroData::defaults() const
 string const MacroData::requires() const
 {
        if (sym_)
-               return to_utf8(sym_->requires);
+               return sym_->requires;
        return string();
 }
 
 
+bool MacroData::hidden() const
+{
+       if (sym_)
+               return sym_->hidden;
+       return false;
+}
+
+
+docstring const MacroData::xmlname() const
+{
+       if (sym_)
+               return sym_->xmlname;
+       return docstring();
+}
+
+
+char const * MacroData::MathMLtype() const
+{
+       return sym_ ? sym_->MathMLtype() : 0;
+}
+
+
 void MacroData::unlock() const
 {
        --lockCount_;
@@ -179,7 +200,8 @@ int MacroData::write(odocstream & os, bool overwriteRedefinition) const
        // output template
        MathMacroTemplate const & tmpl =
                static_cast<MathMacroTemplate const &>(*inset);
-       WriteStream wi(os, false, true, WriteStream::wsDefault);
+       otexrowstream ots(os);
+       WriteStream wi(ots, false, true, WriteStream::wsDefault);
        return tmpl.write(wi, overwriteRedefinition);
 }
 
@@ -222,16 +244,18 @@ MacroTable::iterator
 MacroTable::insert(Buffer * buf, docstring const & def)
 {
        //lyxerr << "MacroTable::insert, def: " << to_utf8(def) << endl;
-       MathMacroTemplate mac(buf, def);
+       MathMacroTemplate mac(buf);
+       mac.fromString(def);
        MacroData data(buf, mac);
        return insert(mac.name(), data);
 }
 
 
-void MacroTable::getMacroNames(std::set<docstring> & names) const
+void MacroTable::getMacroNames(std::set<docstring> & names, bool gethidden) const
 {
        for (const_iterator it = begin(); it != end(); ++it)
-               names.insert(it->first);
+               if (gethidden || !it->second.hidden())
+                       names.insert(it->first);
 }