+ updateData();
+ return optionals_;
+}
+
+
+vector<docstring> const & MacroData::defaults() const
+{
+ updateData();
+ return defaults_;
+}
+
+
+void MacroData::unlock() const
+{
+ --lockCount_;
+ LASSERT(lockCount_ >= 0, /**/);
+}
+
+
+void MacroData::queryData(MathMacroTemplate const & macro) const
+{
+ if (queried_)
+ return;
+
+ queried_ = true;
+ definition_ = macro.definition();
+ numargs_ = macro.numArgs();
+ display_ = macro.displayDefinition();
+ redefinition_ = macro.redefinition();
+ type_ = macro.type();
+ optionals_ = macro.numOptionals();
+
+ macro.getDefaults(defaults_);
+}
+
+
+void MacroData::updateData() const
+{
+ if (queried_)
+ return;
+
+ LASSERT(buffer_ != 0, /**/);
+
+ // Try to fix position DocIterator. Should not do anything in theory.
+ pos_.fixIfBroken();
+
+ // find macro template
+ Inset * inset = pos_.nextInset();
+ if (inset == 0 || inset->lyxCode() != MATHMACRO_CODE) {
+ lyxerr << "BUG: No macro template found by MacroData" << endl;
+ return;
+ }
+
+ // query the data from the macro template
+ queryData(static_cast<MathMacroTemplate const &>(*inset));