-MathMacro::MathMacro(docstring const & name)
- : InsetMathNest(0), name_(name), displayMode_(DISPLAY_INIT),
- attachedArgsNum_(0), optionals_(0), nextFoldMode_(true),
- macro_(0), needsUpdate_(false)
+/// Private implementation of MathMacro
+class MathMacro::Private {
+public:
+ Private(Buffer * buf, docstring const & name)
+ : name_(name), displayMode_(DISPLAY_INIT),
+ expanded_(buf), definition_(buf), attachedArgsNum_(0),
+ optionals_(0), nextFoldMode_(true), macroBackup_(buf),
+ macro_(0), needsUpdate_(false), isUpdating_(false),
+ appetite_(9)
+ {
+ }
+ /// Update the pointers to our owner of all expanded macros.
+ /// This needs to be called every time a copy of the owner is created
+ /// (bug 9418).
+ void updateChildren(MathMacro * owner);
+ /// name of macro
+ docstring name_;
+ /// current display mode
+ DisplayMode displayMode_;
+ /// expanded macro with ArgumentProxies
+ MathData expanded_;
+ /// macro definition with #1,#2,.. insets
+ MathData definition_;
+ /// number of arguments that were really attached
+ size_t attachedArgsNum_;
+ /// optional argument attached? (only in DISPLAY_NORMAL mode)
+ size_t optionals_;
+ /// fold mode to be set in next metrics call?
+ bool nextFoldMode_;
+ /// if macro_ == true, then here is a copy of the macro
+ /// don't use it for locking
+ MacroData macroBackup_;
+ /// if macroNotFound_ == false, then here is a reference to the macro
+ /// this might invalidate after metrics was called
+ MacroData const * macro_;
+ ///
+ mutable std::map<BufferView const *, bool> editing_;
+ ///
+ std::string requires_;
+ /// update macro representation
+ bool needsUpdate_;
+ ///
+ bool isUpdating_;
+ /// maximal number of arguments the macro is greedy for
+ size_t appetite_;
+};
+
+
+void MathMacro::Private::updateChildren(MathMacro * owner)
+{
+ for (size_t i = 0; i < expanded_.size(); ++i) {
+ ArgumentProxy * p = dynamic_cast<ArgumentProxy *>(expanded_[i].nucleus());
+ if (p)
+ p->setOwner(owner);
+ }
+}
+
+
+MathMacro::MathMacro(Buffer * buf, docstring const & name)
+ : InsetMathNest(buf, 0), d(new Private(buf, name))