]> git.lyx.org Git - lyx.git/commitdiff
Make Buffer argument mandatory in most of the InsetMath based class... boring work...
authorAbdelrazak Younes <younes@lyx.org>
Sun, 8 Nov 2009 11:45:46 +0000 (11:45 +0000)
committerAbdelrazak Younes <younes@lyx.org>
Sun, 8 Nov 2009 11:45:46 +0000 (11:45 +0000)
Math manual loads and save correctly it seems but expect some instability period.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@31898 a592a061-630c-0410-9148-cb99ea01b6c8

99 files changed:
src/Buffer.cpp
src/Cursor.cpp
src/CutAndPaste.cpp
src/Text3.cpp
src/TextMetrics.cpp
src/insets/Inset.h
src/mathed/CommandInset.cpp
src/mathed/CommandInset.h
src/mathed/InsetFormulaMacro.h
src/mathed/InsetMath.cpp
src/mathed/InsetMath.h
src/mathed/InsetMathAMSArray.cpp
src/mathed/InsetMathAMSArray.h
src/mathed/InsetMathArray.cpp
src/mathed/InsetMathArray.h
src/mathed/InsetMathBoldSymbol.cpp
src/mathed/InsetMathBoldSymbol.h
src/mathed/InsetMathBox.cpp
src/mathed/InsetMathBox.h
src/mathed/InsetMathBrace.cpp
src/mathed/InsetMathBrace.h
src/mathed/InsetMathCases.cpp
src/mathed/InsetMathCases.h
src/mathed/InsetMathColor.cpp
src/mathed/InsetMathColor.h
src/mathed/InsetMathComment.cpp
src/mathed/InsetMathComment.h
src/mathed/InsetMathDecoration.cpp
src/mathed/InsetMathDecoration.h
src/mathed/InsetMathDelim.cpp
src/mathed/InsetMathDelim.h
src/mathed/InsetMathDiff.cpp
src/mathed/InsetMathDiff.h
src/mathed/InsetMathEnsureMath.cpp
src/mathed/InsetMathEnsureMath.h
src/mathed/InsetMathEnv.cpp
src/mathed/InsetMathEnv.h
src/mathed/InsetMathExFunc.cpp
src/mathed/InsetMathExFunc.h
src/mathed/InsetMathExInt.cpp
src/mathed/InsetMathExInt.h
src/mathed/InsetMathFont.cpp
src/mathed/InsetMathFont.h
src/mathed/InsetMathFontOld.cpp
src/mathed/InsetMathFontOld.h
src/mathed/InsetMathFrac.cpp
src/mathed/InsetMathFrac.h
src/mathed/InsetMathGrid.cpp
src/mathed/InsetMathGrid.h
src/mathed/InsetMathHull.cpp
src/mathed/InsetMathHull.h
src/mathed/InsetMathLefteqn.cpp
src/mathed/InsetMathLefteqn.h
src/mathed/InsetMathLim.cpp
src/mathed/InsetMathLim.h
src/mathed/InsetMathMatrix.h
src/mathed/InsetMathNest.cpp
src/mathed/InsetMathNest.h
src/mathed/InsetMathOverset.h
src/mathed/InsetMathPar.cpp
src/mathed/InsetMathPar.h
src/mathed/InsetMathPhantom.cpp
src/mathed/InsetMathPhantom.h
src/mathed/InsetMathRef.cpp
src/mathed/InsetMathRef.h
src/mathed/InsetMathRoot.cpp
src/mathed/InsetMathRoot.h
src/mathed/InsetMathScript.cpp
src/mathed/InsetMathScript.h
src/mathed/InsetMathSize.cpp
src/mathed/InsetMathSize.h
src/mathed/InsetMathSplit.cpp
src/mathed/InsetMathSplit.h
src/mathed/InsetMathSqrt.cpp
src/mathed/InsetMathSqrt.h
src/mathed/InsetMathStackrel.cpp
src/mathed/InsetMathStackrel.h
src/mathed/InsetMathSubstack.cpp
src/mathed/InsetMathSubstack.h
src/mathed/InsetMathTabular.cpp
src/mathed/InsetMathTabular.h
src/mathed/InsetMathUnderset.h
src/mathed/InsetMathXArrow.cpp
src/mathed/InsetMathXArrow.h
src/mathed/InsetMathXYMatrix.cpp
src/mathed/InsetMathXYMatrix.h
src/mathed/MacroTable.cpp
src/mathed/MacroTable.h
src/mathed/MathData.cpp
src/mathed/MathData.h
src/mathed/MathExtern.cpp
src/mathed/MathFactory.cpp
src/mathed/MathFactory.h
src/mathed/MathMacro.cpp
src/mathed/MathMacro.h
src/mathed/MathMacroTemplate.cpp
src/mathed/MathMacroTemplate.h
src/mathed/MathParser.cpp
src/mathed/MathParser.h

index f9c62110619061e0d23875c697b33faf21b4f342..e2618b43dcd8328539ed2850e9f76c397352c6d8 100644 (file)
@@ -2569,7 +2569,7 @@ void Buffer::updateMacros(DocIterator & it, DocIterator & scope) const
                        // get macro data
                        MathMacroTemplate & macroTemplate =
                                static_cast<MathMacroTemplate &>(*iit->inset);
-                       MacroContext mc(*this, it);
+                       MacroContext mc(this, it);
                        macroTemplate.updateToContext(mc);
 
                        // valid?
@@ -2581,8 +2581,10 @@ void Buffer::updateMacros(DocIterator & it, DocIterator & scope) const
                                continue;
 
                        // register macro
+                       // FIXME (Abdel), I don't understandt why we pass 'it' here
+                       // instead of 'macroTemplate' defined above... is this correct?
                        d->macros[macroTemplate.name()][it] =
-                               Impl::ScopeMacro(scope, MacroData(*this, it));
+                               Impl::ScopeMacro(scope, MacroData(const_cast<Buffer *>(this), it));
                }
 
                // next paragraph
@@ -2662,7 +2664,7 @@ void Buffer::updateMacroInstances() const
 
                // update macro in all cells of the InsetMathNest
                DocIterator::idx_type n = minset->nargs();
-               MacroContext mc = MacroContext(*this, it);
+               MacroContext mc = MacroContext(this, it);
                for (DocIterator::idx_type i = 0; i < n; ++i) {
                        MathData & data = minset->cell(i);
                        data.updateMacros(0, mc);
index 72afe067596210c8dff268244cacf323f5ff6915..a9c07f21aa4b1b7ad79eb522ae4b29106973c4db 100644 (file)
@@ -1441,7 +1441,7 @@ bool Cursor::macroModeClose()
        if (in && in->interpretString(*this, s))
                return true;
        MathAtom atom = buffer()->getMacro(name, *this, false) ?
-               MathAtom(new MathMacro(name)) : createInsetMath(name);
+               MathAtom(new MathMacro(buffer(), name)) : createInsetMath(name, buffer());
 
        // try to put argument into macro, if we just inserted a macro
        bool macroArg = false;
@@ -1895,8 +1895,8 @@ void Cursor::handleFont(string const & font)
                } else {
                        // cursor in between. split cell
                        MathData::iterator bt = cell().begin();
-                       MathAtom at = createInsetMath(from_utf8(font));
-                       at.nucleus()->cell(0) = MathData(bt, bt + pos());
+                       MathAtom at = createInsetMath(from_utf8(font), buffer());
+                       at.nucleus()->cell(0) = MathData(buffer(), bt, bt + pos());
                        cell().erase(bt, bt + pos());
                        popBackward();
                        plainInsert(at);
index 944119f96554305f3e6408843db76e0508ed29d5..2fb55173e88412c0dd7dcc952825009da744ae18 100644 (file)
@@ -1104,7 +1104,8 @@ docstring grabSelection(Cursor const & cur)
        if (i1.idx() == i2.idx()) {
                if (i1.inset().asInsetMath()) {
                        MathData::const_iterator it = i1.cell().begin();
-                       return asString(MathData(it + i1.pos(), it + i2.pos()));
+                       Buffer * buf = cur.buffer();
+                       return asString(MathData(buf, it + i1.pos(), it + i2.pos()));
                } else {
                        return from_ascii("unknown selection 1");
                }
index fa6c6e4ab3624584fbb424e2703b14bc8981b95a..e1ec72d0786045fcc0dac3b0eac1664efe9e4f63 100644 (file)
@@ -141,7 +141,7 @@ static void mathDispatch(Cursor & cur, FuncRequest const & cmd, bool display)
 #ifdef ENABLE_ASSERTIONS
                const int old_pos = cur.pos();
 #endif
-               cur.insert(new InsetMathHull(hullSimple, cur.buffer()));
+               cur.insert(new InsetMathHull(cur.buffer(), hullSimple));
 #ifdef ENABLE_ASSERTIONS
                LASSERT(old_pos == cur.pos(), /**/);
 #endif
@@ -184,7 +184,7 @@ static void mathDispatch(Cursor & cur, FuncRequest const & cmd, bool display)
                        } else
                                cur.insert(formula);
                } else {
-                       cur.insert(new MathMacroTemplate(sel, cur.buffer()));
+                       cur.insert(new MathMacroTemplate(cur.buffer(), sel));
                }
        }
        if (valid)
@@ -207,7 +207,7 @@ void regexpDispatch(Cursor & cur, FuncRequest const & cmd)
        // It may happen that sel is empty but there is a selection
        replaceSelection(cur);
 
-       cur.insert(new InsetMathHull(hullRegexp, cur.buffer()));
+       cur.insert(new InsetMathHull(cur.buffer(), hullRegexp));
        cur.nextInset()->edit(cur, true);
        cur.niceInsert(sel);
 
@@ -1753,7 +1753,8 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
                        MacroType type = MacroTypeNewcommand;
                        if (s2 == "def")
                                type = MacroTypeDef;
-                       MathMacroTemplate * inset = new MathMacroTemplate(from_utf8(token(s, ' ', 0)), nargs, false, type, cur.buffer());
+                       MathMacroTemplate * inset = new MathMacroTemplate(cur.buffer(),
+                               from_utf8(token(s, ' ', 0)), nargs, false, type);
                        inset->setBuffer(bv->buffer());
                        insertInset(cur, inset);
 
@@ -1781,7 +1782,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
        case LFUN_MATH_BIGDELIM: {
                cur.recordUndo();
                cap::replaceSelection(cur);
-               cur.insert(new InsetMathHull(hullSimple, cur.buffer()));
+               cur.insert(new InsetMathHull(cur.buffer(), hullSimple));
                checkAndActivateInset(cur, true);
                LASSERT(cur.inMathed(), /**/);
                cur.dispatch(cmd);
index 8a62776f39d2bf61758c967a4f6d6df21ef54025..8a7d281e713c95164d29471835c22ecece403394 100644 (file)
@@ -447,7 +447,7 @@ bool TextMetrics::redoParagraph(pit_type const pit)
                        - right_margin;
                Font const & font = ii->inset->noFontChange() ?
                        bufferfont : displayFont(pit, ii->pos);
-               MacroContext mc(buffer, parPos);
+               MacroContext mc(&buffer, parPos);
                MetricsInfo mi(bv_, font.fontInfo(), w, mc);
                ii->inset->metrics(mi, dim);
                Dimension const old_dim = pm.insetDimension(ii->inset);
index e5a11df800bf43615031f11c0a3b1701f120aa76..9cf6cf2b30ed6b618980ce614074cafc03fae2d3 100644 (file)
@@ -506,7 +506,7 @@ public:
 
 protected:
        /// Constructors
-       Inset() : buffer_(0) {}
+       Inset(Buffer * buf = 0) : buffer_(buf) {}
        Inset(Inset const &) : buffer_(0) {}
 
        /// replicate ourselves
index 84894adf2f9a8c4e5b5046fd416845076b9eb647..be67c3d52e63d0316361b711ff0b11a1d3bbb532 100644 (file)
@@ -23,8 +23,8 @@ using namespace std;
 namespace lyx {
 
 
-CommandInset::CommandInset(docstring const & name, bool needs_math_mode)
-       : InsetMathNest(2), name_(name), needs_math_mode_(needs_math_mode),
+CommandInset::CommandInset(Buffer * buf, docstring const & name, bool needs_math_mode)
+       : InsetMathNest(buf, 2), name_(name), needs_math_mode_(needs_math_mode),
          set_label_(false)
 {
        lock_ = true;
index 73f938df22e46db88fb40b3e9e9356584d2dfe49..770ecb388d78d6e98808d5a2446157599376a6f8 100644 (file)
@@ -25,7 +25,8 @@ namespace lyx {
 class CommandInset : public InsetMathNest {
 public:
        ///
-       explicit CommandInset(docstring const & name, bool needs_math_mode = true);
+       explicit CommandInset(Buffer * buf, docstring const & name,
+               bool needs_math_mode = true);
        ///
        void metrics(MetricsInfo & mi, Dimension & dim) const;
        ///
index 7d08dc3d754abbd7a2cf1d5bc7729afa57a96290..6e3752a36d749666ff5dad3db9836c2e951ce510 100644 (file)
@@ -29,9 +29,9 @@ class Lexer;
 class InsetFormulaMacro : public InsetMathNest {
 public:
        ///
-       InsetFormulaMacro();
+       InsetFormulaMacro(Buffer * buf);
        /// construct a macro hull from its name and the number of arguments
-       InsetFormulaMacro(docstring const & name, int nargs, docstring const & t);
+       InsetFormulaMacro(Buffer * buf, docstring const & name, int nargs, docstring const & t);
        /// constructs a mocro from its LaTeX definition
        explicit InsetFormulaMacro(docstring const & s);
        ///
index d6c40d7e30343f3133c9d4abd830a871292099e8..51b4deee709e484cf55c3411e111ba0a83d18461 100644 (file)
@@ -29,7 +29,7 @@ namespace lyx {
 
 MathData & InsetMath::cell(idx_type)
 {
-       static MathData dummyCell;
+       static MathData dummyCell(&buffer());
        LYXERR0("I don't have any cell");
        return dummyCell;
 }
index 538b0b63cc04e35aec4edbe1b46bb23759724ce4..555762c8c7bab3e568b8d9247475e612b1c96ef5 100644 (file)
@@ -93,6 +93,8 @@ class ReplaceData;
 
 class InsetMath : public Inset {
 public:
+       ///
+       InsetMath(Buffer * buf = 0) : Inset(buf) {}
        /// identification as math inset
        InsetMath * asInsetMath() { return this; }
        /// identification as math inset
index 9bcff0c41ffdd742b613262f4d969aecfdf9ce51..b9efc3d0e2853631d2c20c98e3cf0e97312cdb60 100644 (file)
@@ -32,13 +32,14 @@ namespace lyx {
 using support::bformat;
 
 
-InsetMathAMSArray::InsetMathAMSArray(docstring const & name, int m, int n)
-       : InsetMathGrid(m, n), name_(name)
+InsetMathAMSArray::InsetMathAMSArray(Buffer * buf, docstring const & name,
+               int m, int n)
+       : InsetMathGrid(buf, m, n), name_(name)
 {}
 
 
-InsetMathAMSArray::InsetMathAMSArray(docstring const & name)
-       : InsetMathGrid(1, 1), name_(name)
+InsetMathAMSArray::InsetMathAMSArray(Buffer * buf, docstring const & name)
+       : InsetMathGrid(buf, 1, 1), name_(name)
 {}
 
 
index 9cf98a5cd7c7f1dcaad0e8a7a53c49ea0d19cdb9..76ca3208fbf4387e6b1520db6eea3dbf9d7b8eb9 100644 (file)
@@ -21,9 +21,9 @@ namespace lyx {
 class InsetMathAMSArray : public InsetMathGrid {
 public:
        ///
-       InsetMathAMSArray(docstring const &, int m, int n);
+       InsetMathAMSArray(Buffer * buf, docstring const &, int m, int n);
        ///
-       InsetMathAMSArray(docstring const &);
+       InsetMathAMSArray(Buffer * buf, docstring const &);
        ///
        void metrics(MetricsInfo & mi, Dimension & dim) const;
        ///
index f8cc87e7726f92e6e64a24fbd1b75cf9cd0a8e95..fd7ceebe31c8634089204d583bd4d1ee1bcdd985 100644 (file)
@@ -28,19 +28,21 @@ using namespace std;
 namespace lyx {
 
 
-InsetMathArray::InsetMathArray(docstring const & name, int m, int n)
-       : InsetMathGrid(m, n), name_(name)
+InsetMathArray::InsetMathArray(Buffer * buf, docstring const & name, int m,
+               int n)
+       : InsetMathGrid(buf, m, n), name_(name)
 {}
 
 
-InsetMathArray::InsetMathArray(docstring const & name, int m, int n,
-               char valign, docstring const & halign)
-       : InsetMathGrid(m, n, valign, halign), name_(name)
+InsetMathArray::InsetMathArray(Buffer * buf, docstring const & name, int m,
+               int n, char valign, docstring const & halign)
+       : InsetMathGrid(buf, m, n, valign, halign), name_(name)
 {}
 
 
-InsetMathArray::InsetMathArray(docstring const & name, docstring const & str)
-       : InsetMathGrid(1, 1), name_(name)
+InsetMathArray::InsetMathArray(Buffer * buf, docstring const & name,
+               docstring const & str)
+       : InsetMathGrid(buf, 1, 1), name_(name)
 {
        vector< vector<string> > dat;
        istringstream is(to_utf8(str));
@@ -60,8 +62,7 @@ InsetMathArray::InsetMathArray(docstring const & name, docstring const & str)
        for (row_type row = 0; row < dat.size(); ++row)
                for (col_type col = 0; col < dat[0].size(); ++col)
                        mathed_parse_cell(cell(index(row, col)),
-                                         from_utf8(dat[row][col]),
-                                         Parse::NORMAL, &buffer());
+                                         from_utf8(dat[row][col]), Parse::NORMAL);
 }
 
 
index 8768b3ed0f96e358c0a9f501a313861592bd69e9..79236882c7198ed87f9ed857567aa19704e29130 100644 (file)
@@ -22,12 +22,12 @@ namespace lyx {
 class InsetMathArray : public InsetMathGrid {
 public:
        ///
-       InsetMathArray(docstring const &, int m, int n);
+       InsetMathArray(Buffer * buf, docstring const &, int m, int n);
        ///
-       InsetMathArray(docstring const &, int m, int n,
+       InsetMathArray(Buffer * buf, docstring const &, int m, int n,
                char valign, docstring const & halign);
        /// convenience constructor from whitespace/newline separated data
-       InsetMathArray(docstring const &, docstring const & str);
+       InsetMathArray(Buffer * buf, docstring const &, docstring const & str);
        ///
        void metrics(MetricsInfo & mi, Dimension & dim) const;
        ///
index e53ff6c6cd5fdaec92bd8c42ddf7a22dcc95b9fc..7382dc4dae30eaf6d1c927369cb789ba734a9f72 100644 (file)
@@ -21,8 +21,8 @@
 
 namespace lyx {
 
-InsetMathBoldSymbol::InsetMathBoldSymbol(Kind kind)
-       : InsetMathNest(1), kind_(kind)
+InsetMathBoldSymbol::InsetMathBoldSymbol(Buffer * buf, Kind kind)
+       : InsetMathNest(buf, 1), kind_(kind)
 {}
 
 
index 67b0dfa4b7e08b7ced17ba85a91d55ba6d324a87..77d27bc965cb95a26650afffd9c823c2b17eff8b 100644 (file)
@@ -27,7 +27,7 @@ public:
                BM_HEAVY
        };
        ///
-       InsetMathBoldSymbol(Kind kind = AMS_BOLD);
+       InsetMathBoldSymbol(Buffer * buf, Kind kind = AMS_BOLD);
        ///
        docstring name() const;
        ///
index ab73d914486b4d91ec7143f3085dd786294a243e..07866610dec3dab37593738d6cb5136887475721 100644 (file)
@@ -32,8 +32,8 @@ namespace lyx {
 //
 /////////////////////////////////////////////////////////////////////
 
-InsetMathBox::InsetMathBox(docstring const & name)
-       : InsetMathNest(1), name_(name)
+InsetMathBox::InsetMathBox(Buffer * buf, docstring const & name)
+       : InsetMathNest(buf, 1), name_(name)
 {}
 
 
@@ -90,8 +90,8 @@ void InsetMathBox::validate(LaTeXFeatures & features) const
 /////////////////////////////////////////////////////////////////////
 
 
-InsetMathFBox::InsetMathFBox()
-       : InsetMathNest(1)
+InsetMathFBox::InsetMathFBox(Buffer * buf)
+       : InsetMathNest(buf, 1)
 {}
 
 
@@ -140,8 +140,8 @@ void InsetMathFBox::infoize(odocstream & os) const
 /////////////////////////////////////////////////////////////////////
 
 
-InsetMathMakebox::InsetMathMakebox(bool framebox)
-       : InsetMathNest(3), framebox_(framebox)
+InsetMathMakebox::InsetMathMakebox(Buffer * buf, bool framebox)
+       : InsetMathNest(buf, 3), framebox_(framebox)
 {}
 
 
@@ -245,8 +245,8 @@ void InsetMathMakebox::infoize(odocstream & os) const
 //
 /////////////////////////////////////////////////////////////////////
 
-InsetMathBoxed::InsetMathBoxed()
-       : InsetMathNest(1)
+InsetMathBoxed::InsetMathBoxed(Buffer * buf)
+       : InsetMathNest(buf, 1)
 {}
 
 
index 5839439ed7e3a07bab54b39e16a372fda0a5ab99..fd8cc4ffb38014d78fba10d8c6edfcc6859ee0bb 100644 (file)
@@ -23,7 +23,7 @@ namespace lyx {
 class InsetMathBox : public InsetMathNest {
 public:
        ///
-       explicit InsetMathBox(docstring const & name);
+       explicit InsetMathBox(Buffer * buf, docstring const & name);
        ///
        mode_type currentMode() const { return TEXT_MODE; }
        ///
@@ -52,7 +52,7 @@ private:
 class InsetMathFBox : public InsetMathNest {
 public:
        ///
-       InsetMathFBox();
+       InsetMathFBox(Buffer * buf);
        ///
        mode_type currentMode() const { return TEXT_MODE; }
        ///
@@ -75,7 +75,7 @@ private:
 class InsetMathMakebox : public InsetMathNest {
 public:
        ///
-       InsetMathMakebox(bool framebox);
+       InsetMathMakebox(Buffer * buf, bool framebox);
        ///
        void metrics(MetricsInfo & mi, Dimension & dim) const;
        ///
@@ -100,7 +100,7 @@ private:
 class InsetMathBoxed : public InsetMathNest {
 public:
        ///
-       InsetMathBoxed();
+       InsetMathBoxed(Buffer * buf);
        ///
        void validate(LaTeXFeatures & features) const;
        ///
index d2d2e3fc162f0badeb9275fdc3c8dabb0e031eaf..c1034c9aeeb1f662e48478c7b8fb7e25493b6d2e 100644 (file)
@@ -26,13 +26,13 @@ using namespace std;
 
 namespace lyx {
 
-InsetMathBrace::InsetMathBrace()
-       : InsetMathNest(1)
+InsetMathBrace::InsetMathBrace(Buffer * buf)
+       : InsetMathNest(buf, 1)
 {}
 
 
 InsetMathBrace::InsetMathBrace(MathData const & ar)
-       : InsetMathNest(1)
+       : InsetMathNest(const_cast<Buffer *>(ar.buffer()), 1)
 {
        cell(0) = ar;
 }
index 4893db7c695a703fa8a336bbddbdc74bdb871f5d..e8e3ea955766283a5019ef0e2e5dec1e9c36fefd 100644 (file)
@@ -22,7 +22,7 @@ namespace lyx {
 class InsetMathBrace : public InsetMathNest {
 public:
        ///
-       InsetMathBrace();
+       InsetMathBrace(Buffer * buf);
        ///
        InsetMathBrace(MathData const & ar);
        /// identifies brace insets
index 32aa5a5e0fa56e7f3dfb5d2b8ef7b9ce97bceb05..5e1ee21fdb6ce446af87adab85bce699dd9a8d1c 100644 (file)
@@ -32,8 +32,8 @@ using namespace lyx::support;
 namespace lyx {
 
 
-InsetMathCases::InsetMathCases(row_type n)
-       : InsetMathGrid(2, n, 'c', from_ascii("ll"))
+InsetMathCases::InsetMathCases(Buffer * buf, row_type n)
+       : InsetMathGrid(buf, 2, n, 'c', from_ascii("ll"))
 {}
 
 
index 9ceac475ea237b822bbbeb2cd5423525ca03f4eb..d5abb1eea69e7f317fdc6908246d1216279f6138 100644 (file)
@@ -23,7 +23,7 @@ class LaTeXFeatures;
 class InsetMathCases : public InsetMathGrid {
 public:
        ///
-       explicit InsetMathCases(row_type rows = 1u);
+       explicit InsetMathCases(Buffer * buf, row_type rows = 1u);
        ///
        void metrics(MetricsInfo & mi, Dimension & dim) const;
        ///
index 233a38090c2cb252e80453378576e3b7fef700b2..7d005621e6aeee9f42657017019bb7517cbd6495 100644 (file)
 
 namespace lyx {
 
-InsetMathColor::InsetMathColor(bool oldstyle, ColorCode color)
-       : InsetMathNest(1), oldstyle_(oldstyle),
+InsetMathColor::InsetMathColor(Buffer * buf, bool oldstyle, ColorCode color)
+       : InsetMathNest(buf, 1), oldstyle_(oldstyle),
          color_(from_utf8(lcolor.getLaTeXName(color)))
 {}
 
 
-InsetMathColor::InsetMathColor(bool oldstyle, docstring const & color)
-       : InsetMathNest(1), oldstyle_(oldstyle), color_(color)
+InsetMathColor::InsetMathColor(Buffer * buf, bool oldstyle,
+               docstring const & color)
+       : InsetMathNest(buf, 1), oldstyle_(oldstyle), color_(color)
 {}
 
 
index 19f1636b17b5bca4756dd9accb744f32ec89f434..848a46fc7c53bdca9626699b191d5a091a2245bf 100644 (file)
@@ -23,10 +23,9 @@ namespace lyx {
 class InsetMathColor : public InsetMathNest {
 public:
        /// Create a color inset from LyX color number
-       explicit InsetMathColor(bool oldstyle,
-               ColorCode color = Color_none);
+       InsetMathColor(Buffer * buf, bool oldstyle, ColorCode color = Color_none);
        /// Create a color inset from LaTeX color name
-       explicit InsetMathColor(bool oldstyle, docstring const & color);
+       InsetMathColor(Buffer * buf, bool oldstyle, docstring const & color);
        ///
        void metrics(MetricsInfo & mi, Dimension & dim) const;
        /// we write extra braces in any case...
index f64f3729007c1f7fd7f40164641dd726b1662f94..ebfba7a859918e35fc00b064334ebcd47c80a6ac 100644 (file)
 
 namespace lyx {
 
-InsetMathComment::InsetMathComment()
-       : InsetMathNest(1)
+InsetMathComment::InsetMathComment(Buffer * buf)
+       : InsetMathNest(buf, 1)
 {}
 
 
-InsetMathComment::InsetMathComment(docstring const & str)
-       : InsetMathNest(1)
+InsetMathComment::InsetMathComment(Buffer * buf, docstring const & str)
+       : InsetMathNest(buf, 1)
 {
        // FIXME UNICODE
        asArray(str, cell(0));
index 8699cedbbad5bdeb99baaec796a7bd4a44e22caf..bb775a74cb13e82fa94455faf68b5e9cc61258aa 100644 (file)
@@ -23,9 +23,9 @@ class latexkeys;
 class InsetMathComment : public InsetMathNest {
 public:
        ///
-       InsetMathComment();
+       InsetMathComment(Buffer * buf);
        ///
-       explicit InsetMathComment(docstring const &);
+       explicit InsetMathComment(Buffer * buf, docstring const &);
        ///
        void metrics(MetricsInfo & mi, Dimension & dim) const;
        ///
index 026b3da672d8b8b0dce1e42e853b0fc38eea48b4..0ece491a7d8b94e4a2d44e55e0ca6d7f9385551f 100644 (file)
@@ -29,8 +29,8 @@
 namespace lyx {
 
 
-InsetMathDecoration::InsetMathDecoration(latexkeys const * key)
-       : InsetMathNest(1), key_(key)
+InsetMathDecoration::InsetMathDecoration(Buffer * buf, latexkeys const * key)
+       : InsetMathNest(buf, 1), key_(key)
 {
 //     lyxerr << " creating deco " << key->name << endl;
 }
index 3fa1be7075d2174ce75a13e15f4541a32d6dfe82..a8106d4889ff4aea770fc82e744be9077f8e00b6 100644 (file)
@@ -24,7 +24,7 @@ class latexkeys;
 class InsetMathDecoration : public InsetMathNest {
 public:
        ///
-       explicit InsetMathDecoration(latexkeys const * key);
+       explicit InsetMathDecoration(Buffer * buf, latexkeys const * key);
        ///
        void draw(PainterInfo &, int x, int y) const;
        ///
index 95a172ea64afff055fcef0c0c1463e230f9c4ac5..4c873f15e8ea1f1fd9b923ee13d9e84a975efea3 100644 (file)
@@ -38,14 +38,15 @@ static docstring convertDelimToLatexName(docstring const & name)
 }
 
 
-InsetMathDelim::InsetMathDelim(docstring const & l, docstring const & r)
-       : InsetMathNest(1), left_(l), right_(r)
+InsetMathDelim::InsetMathDelim(Buffer * buf, docstring const & l,
+               docstring const & r)
+       : InsetMathNest(buf, 1), left_(l), right_(r)
 {}
 
 
-InsetMathDelim::InsetMathDelim
-               (docstring const & l, docstring const & r, MathData const & ar)
-       : InsetMathNest(1), left_(l), right_(r)
+InsetMathDelim::InsetMathDelim(Buffer * buf, docstring const & l, docstring const & r,
+       MathData const & ar)
+       : InsetMathNest(buf, 1), left_(l), right_(r)
 {
        cell(0) = ar;
 }
index de7f11442b0f7962728f2165054a51831c30abd1..67e1db09063db2ea4494fbbd354d710ab9761732 100644 (file)
@@ -24,9 +24,10 @@ namespace lyx {
 class InsetMathDelim : public InsetMathNest {
 public:
        ///
-       InsetMathDelim(docstring const & left, docstring const & right);
+       InsetMathDelim(Buffer * buf, docstring const & left, docstring const & right);
        ///
-       InsetMathDelim(docstring const & left, docstring const & right, MathData const &);
+       InsetMathDelim(Buffer * buf, docstring const & left, docstring const & right,
+               MathData const &);
        ///
        InsetMathDelim * asDelimInset() { return this; }
        ///
index f4d544bbb6250ed313c4734f691473221d298604..1e990d7ffb15a4a05a83054335ddcb79bed97304 100644 (file)
@@ -19,8 +19,8 @@
 
 namespace lyx {
 
-InsetMathDiff::InsetMathDiff()
-       : InsetMathNest(1)
+InsetMathDiff::InsetMathDiff(Buffer * buf)
+       : InsetMathNest(buf, 1)
 {}
 
 
index 557f16fed24580b03a2e88cb0a8761a8db681c4e..6253168397abb059845f58e296fdbaf5e7a1096f 100644 (file)
@@ -24,7 +24,7 @@ namespace lyx {
 class InsetMathDiff : public InsetMathNest {
 public:
        ///
-       InsetMathDiff();
+       InsetMathDiff(Buffer * buf);
        ///
        void addDer(MathData const & der);
        ///
index eb8da978277e6eb212c52414cceeacda1fdf24b2..f06cbe5552f18a5c6d4914bef3e47619e1843323 100644 (file)
@@ -21,8 +21,8 @@
 
 namespace lyx {
 
-InsetMathEnsureMath::InsetMathEnsureMath()
-       : InsetMathNest(1)
+InsetMathEnsureMath::InsetMathEnsureMath(Buffer * buf)
+       : InsetMathNest(buf, 1)
 {}
 
 
index d6e9a242b5d4c316baba9ff0a696533d9cb05555..1bad7c8fb6c4ec5a9da29a4a3069efaec2af1a45 100644 (file)
@@ -22,7 +22,7 @@ namespace lyx {
 /// Inset for ensuring math mode
 class InsetMathEnsureMath : public InsetMathNest {
 public:
-       InsetMathEnsureMath();
+       InsetMathEnsureMath(Buffer * buf);
        ///
        mode_type currentMode() const { return MATH_MODE; }
        ///
index e350d19a986b96520d7c8a910ff3bd86aba53c89..a7fb33c69d408ac0e7aa704b879dd3d19698f5dd 100644 (file)
@@ -21,8 +21,8 @@
 
 namespace lyx {
 
-InsetMathEnv::InsetMathEnv(docstring const & name)
-       : InsetMathNest(1), name_(name)
+InsetMathEnv::InsetMathEnv(Buffer * buf, docstring const & name)
+       : InsetMathNest(buf, 1), name_(name)
 {}
 
 
index 035aa68e5c18469e61142f1e2e890a816d1948cb..14b72072bc8100b2504a77c1ff883f2fbd65e3a1 100644 (file)
@@ -24,7 +24,7 @@ namespace lyx {
 class InsetMathEnv : public InsetMathNest {
 public:
        ///
-       InsetMathEnv(docstring const & name_);
+       InsetMathEnv(Buffer * buf, docstring const & name_);
        ///
        void draw(PainterInfo &, int x, int y) const;
        ///
index 990040ef7c91001ba3ec030790ff3731f3f8b26b..3398e9049addec135e74611d96ed394d5c492e40 100644 (file)
@@ -24,13 +24,13 @@ using namespace std;
 namespace lyx {
 
 
-InsetMathExFunc::InsetMathExFunc(docstring const & name)
-       : InsetMathNest(1), name_(name)
+InsetMathExFunc::InsetMathExFunc(Buffer * buf, docstring const & name)
+       : InsetMathNest(buf, 1), name_(name)
 {}
 
 
-InsetMathExFunc::InsetMathExFunc(docstring const & name, MathData const & ar)
-       : InsetMathNest(1), name_(name)
+InsetMathExFunc::InsetMathExFunc(Buffer * buf, docstring const & name, MathData const & ar)
+       : InsetMathNest(buf, 1), name_(name)
 {
        cell(0) = ar;
 }
index 7a5b25310f62e51622226035249492ea4ae46b39..fb6dda8b360e2e84f7b68cab4bebcc1d98ee47fc 100644 (file)
@@ -26,9 +26,9 @@ namespace lyx {
 class InsetMathExFunc : public InsetMathNest {
 public:
        ///
-       explicit InsetMathExFunc(docstring const & name);
+       InsetMathExFunc(Buffer * buf, docstring const & name);
        ///
-       InsetMathExFunc(docstring const & name, MathData const & ar);
+       InsetMathExFunc(Buffer * buf, docstring const & name, MathData const & ar);
        ///
        void metrics(MetricsInfo & mi, Dimension & dim) const;
        ///
index d3753de9db8d347f29653c7f61de477727cd5dd3..5313f0adc306b171f9a2d29c34b650b420fedc13 100644 (file)
@@ -22,8 +22,8 @@
 
 namespace lyx {
 
-InsetMathExInt::InsetMathExInt(docstring const & name)
-       : InsetMathNest(4), symbol_(name)
+InsetMathExInt::InsetMathExInt(Buffer * buf, docstring const & name)
+       : InsetMathNest(buf, 4), symbol_(name)
 {}
 
 // 0 - core
index 00f7ed9f578554020a98acc169ea123b38a7b0c3..a4d2e8e90dcc655e856ace2ab78a2f5c5c531cc5 100644 (file)
@@ -25,7 +25,7 @@ namespace lyx {
 class InsetMathExInt : public InsetMathNest {
 public:
        ///
-       explicit InsetMathExInt(docstring const & name_);
+       explicit InsetMathExInt(Buffer * buf, docstring const & name_);
        ///
        void symbol(docstring const &);
        ///
index 7f55851d21d18f922ebb3e73081dcfb5a0b6aa6a..57078817d6166c6901e863544ffb488f4ca23cf2 100644 (file)
@@ -23,8 +23,8 @@
 
 namespace lyx {
 
-InsetMathFont::InsetMathFont(latexkeys const * key)
-       : InsetMathNest(1), key_(key)
+InsetMathFont::InsetMathFont(Buffer * buf, latexkeys const * key)
+       : InsetMathNest(buf, 1), key_(key)
 {}
 
 
index e002ad1a11e42e264bb49ba73cb95554814fd3ef..e687bc0ede2b861de3119fcc0b51090e20493310 100644 (file)
@@ -24,7 +24,7 @@ class latexkeys;
 class InsetMathFont : public InsetMathNest {
 public:
        ///
-       explicit InsetMathFont(latexkeys const * key);
+       explicit InsetMathFont(Buffer * buf, latexkeys const * key);
        ///
        InsetMathFont * asFontInset() { return this; }
        ///
index 6b132cfc2706c1055c8c6d3834633861e5d12fc0..f4b87ba4c6229dad09254b55423ad550b318892a 100644 (file)
@@ -22,8 +22,8 @@
 
 namespace lyx {
 
-InsetMathFontOld::InsetMathFontOld(latexkeys const * key)
-       : InsetMathNest(1), key_(key)
+InsetMathFontOld::InsetMathFontOld(Buffer * buf, latexkeys const * key)
+       : InsetMathNest(buf, 1), key_(key)
 {
        //lock(true);
 }
index 61d55b0e7561bd55c49e7c4cd5390d9ff7287667..c27bfa6658b7a39b9c13407324f9454f46df7de5 100644 (file)
@@ -24,7 +24,7 @@ class latexkeys;
 class InsetMathFontOld : public InsetMathNest {
 public:
        ///
-       explicit InsetMathFontOld(latexkeys const * key);
+       explicit InsetMathFontOld(Buffer * buf, latexkeys const * key);
        /// we are in text mode.
        mode_type currentMode() const { return TEXT_MODE; }
        /// we write extra braces in any case...
index 2c2d6975436349626d510ad0cda9ef46ae2881b7..7f5323b8d611548a3f38201fe7ca8f100ffabe36 100644 (file)
@@ -35,8 +35,8 @@ namespace lyx {
 /////////////////////////////////////////////////////////////////////
 
 
-InsetMathFracBase::InsetMathFracBase(idx_type ncells)
-       : InsetMathNest(ncells)
+InsetMathFracBase::InsetMathFracBase(Buffer * buf, idx_type ncells)
+       : InsetMathNest(buf, ncells)
 {}
 
 
@@ -59,8 +59,8 @@ bool InsetMathFracBase::idxUpDown(Cursor & cur, bool up) const
 /////////////////////////////////////////////////////////////////////
 
 
-InsetMathFrac::InsetMathFrac(Kind kind, InsetMath::idx_type ncells)
-       : InsetMathFracBase(ncells), kind_(kind)
+InsetMathFrac::InsetMathFrac(Buffer * buf, Kind kind, InsetMath::idx_type ncells)
+       : InsetMathFracBase(buf, ncells), kind_(kind)
 {}
 
 
@@ -417,8 +417,8 @@ void InsetMathFrac::validate(LaTeXFeatures & features) const
 /////////////////////////////////////////////////////////////////////
 
 
-InsetMathBinom::InsetMathBinom(Kind kind)
-       : kind_(kind)
+InsetMathBinom::InsetMathBinom(Buffer * buf, Kind kind)
+       : InsetMathFracBase(buf), kind_(kind)
 {}
 
 
index 3d9b3854e27f08a57479c2d76c8050248bd797df..36e7ba363b808cb07320a83195f90bba360c1f1d 100644 (file)
@@ -23,7 +23,7 @@ namespace lyx {
 class InsetMathFracBase : public InsetMathNest {
 public:
        ///
-       explicit InsetMathFracBase(idx_type ncells = 2);
+       InsetMathFracBase(Buffer * buf, idx_type ncells = 2);
        ///
        bool idxUpDown(Cursor &, bool up) const;
        ///
@@ -52,7 +52,7 @@ public:
                UNIT
        };
        ///
-       explicit InsetMathFrac(Kind kind = FRAC, idx_type ncells = 2);
+       explicit InsetMathFrac(Buffer * buf, Kind kind = FRAC, idx_type ncells = 2);
        ///
        bool idxForward(Cursor &) const;
        ///
@@ -106,7 +106,7 @@ public:
                BRACK
        };
        ///
-       explicit InsetMathBinom(Kind kind = BINOM);
+       explicit InsetMathBinom(Buffer * buf, Kind kind = BINOM);
        ///
        void write(WriteStream & os) const;
        ///
index 4a7a685c1aed3f19430176511aa80958664f1bb8..46148a662888e050995abf2d684520a15b9fa4b4 100644 (file)
@@ -112,8 +112,8 @@ InsetMathGrid::ColInfo::ColInfo()
 //////////////////////////////////////////////////////////////
 
 
-InsetMathGrid::InsetMathGrid()
-       : InsetMathNest(1),
+InsetMathGrid::InsetMathGrid(Buffer * buf)
+       : InsetMathNest(buf, 1),
          rowinfo_(1 + 1),
                colinfo_(1 + 1),
                cellinfo_(1),
@@ -123,8 +123,8 @@ InsetMathGrid::InsetMathGrid()
 }
 
 
-InsetMathGrid::InsetMathGrid(col_type m, row_type n)
-       : InsetMathNest(m * n),
+InsetMathGrid::InsetMathGrid(Buffer * buf, col_type m, row_type n)
+       : InsetMathNest(buf, m * n),
          rowinfo_(n + 1),
                colinfo_(m + 1),
                cellinfo_(m * n),
@@ -134,8 +134,9 @@ InsetMathGrid::InsetMathGrid(col_type m, row_type n)
 }
 
 
-InsetMathGrid::InsetMathGrid(col_type m, row_type n, char v, docstring const & h)
-       : InsetMathNest(m * n),
+InsetMathGrid::InsetMathGrid(Buffer * buf, col_type m, row_type n, char v,
+       docstring const & h)
+       : InsetMathNest(buf, m * n),
          rowinfo_(n + 1),
          colinfo_(m + 1),
                cellinfo_(m * n),
@@ -1273,15 +1274,12 @@ void InsetMathGrid::doDispatch(Cursor & cur, FuncRequest & cmd)
                        is >> n;
                        topaste = cap::selection(n);
                }
-               InsetMathGrid grid(1, 1);
+               InsetMathGrid grid(buffer_, 1, 1);
                if (!topaste.empty())
                        if ((topaste.size() == 1 && topaste.at(0) < 0x80)
-                           || !mathed_parse_normal(grid, topaste, parseflg,
-                                                   cur.buffer())) {
+                           || !mathed_parse_normal(grid, topaste, parseflg)) {
                                resetGrid(grid);
-                               mathed_parse_normal(grid, topaste,
-                                                   parseflg | Parse::VERBATIM,
-                                                   cur.buffer());
+                               mathed_parse_normal(grid, topaste, parseflg | Parse::VERBATIM);
                        }
 
                if (grid.nargs() == 1) {
index a512969afbcf9e13b745c6df0fe68dd497f18d4e..926216ea1cdca3967a63b2c301c7b0172bf97434 100644 (file)
@@ -92,11 +92,12 @@ public:
 
 public:
        /// sets nrows and ncols to 1, vertical alingment to 'c'
-       InsetMathGrid();
+       InsetMathGrid(Buffer * buf);
        /// Note: columns first!
-       InsetMathGrid(col_type m, row_type n);
+       InsetMathGrid(Buffer * buf, col_type m, row_type n);
        ///
-       InsetMathGrid(col_type m, row_type n, char valign, docstring const & halign);
+       InsetMathGrid(Buffer * buf, col_type m, row_type n, char valign,
+               docstring const & halign);
        ///
        void metrics(MetricsInfo & mi, Dimension &) const;
        ///
index 92fa33ecdfaf18a3a1dff4b85a78ec77aaf3b68e..d7e085582a96f535905292753af39fc00006381b 100644 (file)
@@ -136,7 +136,7 @@ docstring hullName(HullType type)
 static InsetLabel * dummy_pointer = 0;
 
 InsetMathHull::InsetMathHull(Buffer * buf)
-       : InsetMathGrid(1, 1), type_(hullNone), nonum_(1, false),
+       : InsetMathGrid(buf, 1, 1), type_(hullNone), nonum_(1, false),
          label_(1, dummy_pointer), preview_(new RenderPreview(this))
 {
        //lyxerr << "sizeof InsetMath: " << sizeof(InsetMath) << endl;
@@ -149,8 +149,8 @@ InsetMathHull::InsetMathHull(Buffer * buf)
 }
 
 
-InsetMathHull::InsetMathHull(HullType type, Buffer * buf)
-       : InsetMathGrid(getCols(type), 1), type_(type), nonum_(1, false),
+InsetMathHull::InsetMathHull(Buffer * buf, HullType type)
+       : InsetMathGrid(buf, getCols(type), 1), type_(type), nonum_(1, false),
          label_(1, dummy_pointer), preview_(new RenderPreview(this))
 {
        buffer_ = buf;
@@ -159,7 +159,7 @@ InsetMathHull::InsetMathHull(HullType type, Buffer * buf)
 }
 
 
-InsetMathHull::InsetMathHull(InsetMathHull const & other) : InsetMathGrid()
+InsetMathHull::InsetMathHull(InsetMathHull const & other) : InsetMathGrid(other)
 {
        operator=(other);
 }
@@ -800,7 +800,7 @@ void InsetMathHull::glueall()
        MathData ar;
        for (idx_type i = 0; i < nargs(); ++i)
                ar.append(cell(i));
-       *this = InsetMathHull(hullSimple, &buffer());
+       *this = InsetMathHull(buffer_, hullSimple);
        cell(0) = ar;
        setDefaults();
 }
@@ -813,7 +813,7 @@ void InsetMathHull::splitTo2Cols()
        for (row_type row = 0; row < nrows(); ++row) {
                idx_type const i = 2 * row;
                pos_type pos = firstRelOp(cell(i));
-               cell(i + 1) = MathData(cell(i).begin() + pos, cell(i).end());
+               cell(i + 1) = MathData(buffer_, cell(i).begin() + pos, cell(i).end());
                cell(i).erase(pos, cell(i).size());
        }
 }
@@ -828,7 +828,7 @@ void InsetMathHull::splitTo3Cols()
        for (row_type row = 0; row < nrows(); ++row) {
                idx_type const i = 3 * row + 1;
                if (cell(i).size()) {
-                       cell(i + 1) = MathData(cell(i).begin() + 1, cell(i).end());
+                       cell(i + 1) = MathData(buffer_, cell(i).begin() + 1, cell(i).end());
                        cell(i).erase(1, cell(i).size());
                }
        }
@@ -1107,7 +1107,7 @@ void InsetMathHull::doExtern(Cursor & cur, FuncRequest & func)
                        ar = cur.cell();
                        lyxerr << "use whole cell: " << ar << endl;
                } else {
-                       ar = MathData(cur.cell().begin() + pos + 1, cur.cell().end());
+                       ar = MathData(buffer_, cur.cell().begin() + pos + 1, cur.cell().end());
                        lyxerr << "use partial cell form pos: " << pos << endl;
                }
                cur.cell().append(eq);
@@ -1512,7 +1512,7 @@ void InsetMathHull::handleFont(Cursor & cur, docstring const & arg,
        if (cur.inset().asInsetMath()->name() == font)
                cur.handleFont(to_utf8(font));
        else {
-               cur.handleNest(createInsetMath(font));
+               cur.handleNest(createInsetMath(font, cur.buffer()));
                cur.insert(arg);
        }
 }
@@ -1525,7 +1525,7 @@ void InsetMathHull::handleFont2(Cursor & cur, docstring const & arg)
        bool b;
        font.fromString(to_utf8(arg), b);
        if (font.fontInfo().color() != Color_inherit) {
-               MathAtom at = MathAtom(new InsetMathColor(true, font.fontInfo().color()));
+               MathAtom at = MathAtom(new InsetMathColor(buffer_, true, font.fontInfo().color()));
                cur.handleNest(at, 0);
        }
 }
@@ -1637,7 +1637,7 @@ void InsetMathHull::write(ostream & os) const
 void InsetMathHull::read(Lexer & lex)
 {
        MathAtom at;
-       mathed_parse_normal(at, lex, Parse::NORMAL, &buffer());
+       mathed_parse_normal(buffer_, at, lex, Parse::NORMAL);
        operator=(*at->asHullInset());
 }
 
@@ -1645,7 +1645,7 @@ void InsetMathHull::read(Lexer & lex)
 bool InsetMathHull::readQuiet(Lexer & lex)
 {
        MathAtom at;
-       bool success = mathed_parse_normal(at, lex, Parse::QUIET, &buffer());
+       bool success = mathed_parse_normal(buffer_, at, lex, Parse::QUIET);
        if (success)
                operator=(*at->asHullInset());
        return success;
index bde73af1b9478fd5d9ac424cdeadc530ac12dacf..4cdb1b4f88ad1d53194230d4900faa54fb8cecbe 100644 (file)
@@ -28,9 +28,9 @@ class RenderPreview;
 class InsetMathHull : public InsetMathGrid {
 public:
        ///
-       InsetMathHull(Buffer * buf = 0);
+       InsetMathHull(Buffer * buf);
        ///
-       explicit InsetMathHull(HullType type, Buffer * buf = 0);
+       InsetMathHull(Buffer * buf, HullType type);
        ///
        ~InsetMathHull();
        ///
index 838ff25080f2861004a48e05c00a3d39a9f6e086..ec4fe7e9b0f74f6927c42cb7f333665b13ca2795 100644 (file)
@@ -17,8 +17,8 @@
 
 namespace lyx {
 
-InsetMathLefteqn::InsetMathLefteqn()
-       : InsetMathNest(1)
+InsetMathLefteqn::InsetMathLefteqn(Buffer * buf)
+       : InsetMathNest(buf, 1)
 {}
 
 
index 6742e7327e26b42d1b4d66b6bbda9dad15a5781f..1adb0bd4001de7ecc8723d1dddb7b269a732ebfa 100644 (file)
@@ -23,7 +23,7 @@ namespace lyx {
 class InsetMathLefteqn : public InsetMathNest {
 public:
        ///
-       InsetMathLefteqn();
+       InsetMathLefteqn(Buffer * buf);
        ///
        docstring name() const;
        ///
index 508acc237e6c0daf17e4e8ef0a7371e9dbb36e7a..892cded83ddf9d34dd0b322381364f490b4022a2 100644 (file)
@@ -19,9 +19,9 @@
 
 namespace lyx {
 
-InsetMathLim::InsetMathLim
-       (MathData const & f, MathData const & x, MathData const & x0)
-       : InsetMathNest(3)
+InsetMathLim::InsetMathLim(Buffer * buf, MathData const & f, MathData const & x,
+       MathData const & x0)
+       : InsetMathNest(buf, 3)
 {
        cell(0) = f;
        cell(1) = x;
index f10055b4362d792b409c4aa9eda3c5a8ba65e3d6..11d18dc06e2765e596535e28d718176b3e4c69e3 100644 (file)
@@ -24,7 +24,8 @@ namespace lyx {
 class InsetMathLim : public InsetMathNest {
 public:
        ///
-       InsetMathLim(MathData const & f, MathData const & x, MathData const & x0);
+       InsetMathLim(Buffer * buf, MathData const & f, MathData const & x,
+               MathData const & x0);
        ///
        void metrics(MetricsInfo & mi, Dimension & dim) const;
        ///
index 11fa18349c0bd9750c61724235f7c1fc06753bd4..570b39b0815f3ddaedfc0120524faca1f1b827ad 100644 (file)
@@ -25,7 +25,7 @@ public:
        ///
        explicit InsetMathMatrix(InsetMathGrid const &);
        ///
-       explicit InsetMathMatrix(docstring const & str);
+       explicit InsetMathMatrix(Buffer * buf, docstring const & str);
        /// identifies MatrixInsets
        InsetMathMatrix const * asMatrixInset() const { return this; }
 
index c1fbc12e0be417ff26f31b3f9264c0667d6e1952..d49b9af500e7202f4fbf128dcc4aecd02568a479 100644 (file)
@@ -79,9 +79,11 @@ using cap::replaceSelection;
 using cap::selClearOrDel;
 
 
-InsetMathNest::InsetMathNest(idx_type nargs)
-       : cells_(nargs), lock_(false), mouse_hover_(false)
-{}
+InsetMathNest::InsetMathNest(Buffer * buf, idx_type nargs)
+       : InsetMath(buf), cells_(nargs), lock_(false), mouse_hover_(false)
+{
+       setBuffer(*buf);
+}
 
 
 InsetMathNest::InsetMathNest(InsetMathNest const & inset)
@@ -440,7 +442,7 @@ void InsetMathNest::handleFont(Cursor & cur, docstring const & arg,
        if (cur.inset().asInsetMath()->name() == font)
                cur.handleFont(to_utf8(font));
        else
-               handleNest(cur, createInsetMath(font), arg);
+               handleNest(cur, createInsetMath(font, cur.buffer()), arg);
 }
 
 
@@ -520,7 +522,7 @@ void InsetMathNest::handleFont2(Cursor & cur, docstring const & arg)
        font.fromString(to_utf8(arg), b);
        if (font.fontInfo().color() != Color_inherit &&
            font.fontInfo().color() != Color_ignore)
-               handleNest(cur, MathAtom(new InsetMathColor(true, font.fontInfo().color())));
+               handleNest(cur, MathAtom(new InsetMathColor(buffer_, true, font.fontInfo().color())));
 
        // FIXME: support other font changes here as well?
 }
@@ -955,7 +957,7 @@ void InsetMathNest::doDispatch(Cursor & cur, FuncRequest & cmd)
 
        case LFUN_FONT_UNDERLINE:
                cur.recordUndo();
-               cur.handleNest(createInsetMath("underline"));
+               cur.handleNest(createInsetMath("underline", cur.buffer()));
                break;
        case LFUN_MATH_MODE: {
 #if 1
@@ -968,9 +970,9 @@ void InsetMathNest::doDispatch(Cursor & cur, FuncRequest & cmd)
                selClearOrDel(cur);
                //cur.plainInsert(MathAtom(new InsetMathMBox(cur.bv())));
                if (currentMode() <= Inset::TEXT_MODE)
-                       cur.plainInsert(MathAtom(new InsetMathEnsureMath));
+                       cur.plainInsert(MathAtom(new InsetMathEnsureMath(buffer_)));
                else
-                       cur.plainInsert(MathAtom(new InsetMathBox(from_ascii("mbox"))));
+                       cur.plainInsert(MathAtom(new InsetMathBox(buffer_, from_ascii("mbox"))));
                cur.posBackward();
                cur.pushBackward(*cur.nextInset());
                cur.niceInsert(save_selection);
@@ -996,7 +998,7 @@ void InsetMathNest::doDispatch(Cursor & cur, FuncRequest & cmd)
                cur.macroModeClose();
                docstring const save_selection = grabAndEraseSelection(cur);
                selClearOrDel(cur);
-               cur.plainInsert(MathAtom(new InsetMathHull(hullRegexp, cur.buffer())));
+               cur.plainInsert(MathAtom(new InsetMathHull(buffer_, hullRegexp)));
                cur.posBackward();
                cur.pushBackward(*cur.nextInset());
                cur.niceInsert(save_selection);
@@ -1029,8 +1031,8 @@ void InsetMathNest::doDispatch(Cursor & cur, FuncRequest & cmd)
                if (n < 1)
                        n = 1;
                v_align += 'c';
-               cur.niceInsert(
-                       MathAtom(new InsetMathArray(from_ascii("array"), m, n, (char)v_align[0], h_align)));
+               cur.niceInsert(MathAtom(new InsetMathArray(buffer_,
+                       from_ascii("array"), m, n, (char)v_align[0], h_align)));
                break;
        }
 
@@ -1046,7 +1048,7 @@ void InsetMathNest::doDispatch(Cursor & cur, FuncRequest & cmd)
                if (n < 1)
                        n = 1;
                cur.niceInsert(
-                       MathAtom(new InsetMathAMSArray(name, m, n)));
+                       MathAtom(new InsetMathAMSArray(buffer_, name, m, n)));
                break;
        }
 
@@ -1059,7 +1061,7 @@ void InsetMathNest::doDispatch(Cursor & cur, FuncRequest & cmd)
                if (rs.empty())
                        rs = ')';
                cur.recordUndo();
-               cur.handleNest(MathAtom(new InsetMathDelim(ls, rs)));
+               cur.handleNest(MathAtom(new InsetMathDelim(buffer_, ls, rs)));
                break;
        }
 
@@ -1173,7 +1175,7 @@ void InsetMathNest::doDispatch(Cursor & cur, FuncRequest & cmd)
                docstring const & name = cmd.argument();
                string data;
                if (name == "ref") {
-                       InsetMathRef tmp(name);
+                       InsetMathRef tmp(buffer_, name);
                        data = tmp.createDialogStr(to_utf8(name));
                } else if (name == "mathspace") {
                        InsetMathSpace tmp;
@@ -1473,6 +1475,7 @@ bool InsetMathNest::interpretChar(Cursor & cur, char_type const c)
                save_selection = grabAndEraseSelection(cur);
 
        cur.clearTargetX();
+       Buffer * buf = cur.buffer();
 
        // handle macroMode
        if (cur.inMacroMode()) {
@@ -1503,24 +1506,24 @@ bool InsetMathNest::interpretChar(Cursor & cur, char_type const c)
                        if (c == '\\') {
                                cur.backspace();
                                if (currentMode() <= InsetMath::TEXT_MODE)
-                                       cur.niceInsert(createInsetMath("textbackslash"));
+                                       cur.niceInsert(createInsetMath("textbackslash", buf));
                                else
-                                       cur.niceInsert(createInsetMath("backslash"));
+                                       cur.niceInsert(createInsetMath("backslash", buf));
                        } else if (c == '^' && currentMode() == InsetMath::MATH_MODE) {
                                cur.backspace();
-                               cur.niceInsert(createInsetMath("mathcircumflex"));
+                               cur.niceInsert(createInsetMath("mathcircumflex", buf));
                        } else if (c == '{') {
                                cur.backspace();
-                               cur.niceInsert(MathAtom(new InsetMathBrace));
+                               cur.niceInsert(MathAtom(new InsetMathBrace(buf)));
                        } else if (c == '%') {
                                cur.backspace();
-                               cur.niceInsert(MathAtom(new InsetMathComment));
+                               cur.niceInsert(MathAtom(new InsetMathComment(buf)));
                        } else if (c == '#') {
                                LASSERT(cur.activeMacro(), /**/);
                                cur.activeMacro()->setName(name + docstring(1, c));
                        } else {
                                cur.backspace();
-                               cur.niceInsert(createInsetMath(docstring(1, c)));
+                               cur.niceInsert(createInsetMath(docstring(1, c), buf));
                        }
                        return true;
                }
@@ -1564,7 +1567,7 @@ bool InsetMathNest::interpretChar(Cursor & cur, char_type const c)
                        }
                }
                if (c == '{')
-                       cur.niceInsert(MathAtom(new InsetMathBrace));
+                       cur.niceInsert(MathAtom(new InsetMathBrace(buf)));
                else if (c != ' ')
                        interpretChar(cur, c);
                return true;
@@ -1657,11 +1660,11 @@ bool InsetMathNest::interpretChar(Cursor & cur, char_type const c)
                        return true;
                }
                if (c == '~') {
-                       cur.niceInsert(createInsetMath("sim"));
+                       cur.niceInsert(createInsetMath("sim", buf));
                        return true;
                }
                if (currentMode() == InsetMath::MATH_MODE && !isAsciiOrMathAlpha(c)) {
-                       MathAtom at = createInsetMath("text");
+                       MathAtom at = createInsetMath("text", buf);
                        at.nucleus()->cell(0).push_back(MathAtom(new InsetMathChar(c)));
                        cur.niceInsert(at);
                        cur.posForward();
@@ -1669,18 +1672,18 @@ bool InsetMathNest::interpretChar(Cursor & cur, char_type const c)
                }
        } else {
                if (c == '^') {
-                       cur.niceInsert(createInsetMath("textasciicircum"));
+                       cur.niceInsert(createInsetMath("textasciicircum", buf));
                        return true;
                }
                if (c == '~') {
-                       cur.niceInsert(createInsetMath("textasciitilde"));
+                       cur.niceInsert(createInsetMath("textasciitilde", buf));
                        return true;
                }
        }
 
        if (c == '{' || c == '}' || c == '&' || c == '$' || c == '#' ||
            c == '%' || c == '_') {
-               cur.niceInsert(createInsetMath(docstring(1, c)));
+               cur.niceInsert(createInsetMath(docstring(1, c), buf));
                return true;
        }
 
@@ -1738,7 +1741,7 @@ bool InsetMathNest::script(Cursor & cur, bool up,
        //lyxerr << "handling script: up: " << up << endl;
        if (cur.inMacroMode() && cur.macroName() == "\\") {
                if (up)
-                       cur.niceInsert(createInsetMath("mathcircumflex"));
+                       cur.niceInsert(createInsetMath("mathcircumflex", cur.buffer()));
                else
                        interpretChar(cur, '_');
                return true;
@@ -1764,10 +1767,10 @@ bool InsetMathNest::script(Cursor & cur, bool up,
                // one if in the very first position of the array
                if (cur.pos() == 0) {
                        //lyxerr << "new scriptinset" << endl;
-                       cur.insert(new InsetMathScript(up));
+                       cur.insert(new InsetMathScript(buffer_, up));
                } else {
                        //lyxerr << "converting prev atom " << endl;
-                       cur.prevAtom() = MathAtom(new InsetMathScript(cur.prevAtom(), up));
+                       cur.prevAtom() = MathAtom(new InsetMathScript(buffer_, cur.prevAtom(), up));
                }
                --cur.pos();
                InsetMathScript * inset = cur.nextAtom().nucleus()->asScriptInset();
index 2607f5bbbb63e61ec27daecbb8ba3aa734217601..59c60d98d3a6e09240523ba6a52b5d87452fe8de 100644 (file)
@@ -27,7 +27,7 @@ namespace lyx {
 class InsetMathNest : public InsetMath {
 public:
        /// nestinsets have a fixed size to start with
-       explicit InsetMathNest(idx_type ncells);
+       InsetMathNest(Buffer * buf, idx_type ncells);
        ///
        virtual ~InsetMathNest() {}
        ///
index 07386935506ce6de73f75f0ac98e333e1aee7f6d..edcdd020e2f727739c76206cfc66977d40ecac34 100644 (file)
@@ -21,6 +21,8 @@ namespace lyx {
 /// Inset for overset
 class InsetMathOverset : public InsetMathFracBase {
 public:
+       ///
+       InsetMathOverset(Buffer * buf) : InsetMathFracBase(buf) {}
        ///
        void metrics(MetricsInfo & mi, Dimension & dim) const;
        ///
index 26445c2d0de8e5b71f10f8839a28dfe0f902632f..0638b8eb6cfeb7a4371acab33b1e6e24564e42e2 100644 (file)
@@ -19,7 +19,8 @@
 
 namespace lyx {
 
-InsetMathPar::InsetMathPar(MathData const & ar)
+InsetMathPar::InsetMathPar(Buffer * buf, MathData const & ar)
+       : InsetMathHull(buf)
 {
        cells_[0] = ar;
 }
index 05d2dabdb09a2aeb859378f96fcd014d38bb0e93..0a178f439642951f2c6a46bde0a247f286c27b2c 100644 (file)
@@ -21,9 +21,9 @@ namespace lyx {
 class InsetMathPar : public InsetMathHull {
 public:
        ///
-       InsetMathPar() {}
+       InsetMathPar(Buffer * buf) : InsetMathHull(buf) {}
        ///
-       InsetMathPar(MathData const & ar);
+       InsetMathPar(Buffer * buf, MathData const & ar);
        ///
        mode_type currentMode() const { return TEXT_MODE; }
        ///
index f070e5505350041ab7e5b6681593a0616cc148fa..d6cd1b24469fa1282ed66cc4eca9373fe0e27706 100644 (file)
@@ -20,8 +20,8 @@
 namespace lyx {
 
 
-InsetMathPhantom::InsetMathPhantom(Kind k)
-       : InsetMathNest(1), kind_(k)
+InsetMathPhantom::InsetMathPhantom(Buffer * buf, Kind k)
+       : InsetMathNest(buf, 1), kind_(k)
 {}
 
 
index 9d21bbdeff3e2ecb5a43bbb56d266b7f2d8c86fd..cbc01b0435ca056b9904ff383b19dba85d69785f 100644 (file)
@@ -26,7 +26,7 @@ public:
                hphantom
        };
        ///
-       explicit InsetMathPhantom(Kind);
+       explicit InsetMathPhantom(Buffer * buf, Kind);
        ///
        void metrics(MetricsInfo & mi, Dimension & dim) const;
        ///
index 7dace38d1bb197db9ac99d7c7626e36420094ee7..4fda1197cf97ddec254f106b9223fee7c8096a5a 100644 (file)
@@ -35,13 +35,13 @@ using namespace std;
 
 namespace lyx {
 
-InsetMathRef::InsetMathRef()
-       : CommandInset(from_ascii("ref"), false)
+InsetMathRef::InsetMathRef(Buffer * buf)
+       : CommandInset(buf, from_ascii("ref"), false)
 {}
 
 
-InsetMathRef::InsetMathRef(docstring const & data)
-       : CommandInset(data, false)
+InsetMathRef::InsetMathRef(Buffer * buf, docstring const & data)
+       : CommandInset(buf, data, false)
 {}
 
 
index b26678ce66f7b5de411f32248d2fd8848cf14d61..7b788c78145cdda6d94153cbcc06f63a4479e16a 100644 (file)
@@ -23,9 +23,9 @@ class Buffer;
 class InsetMathRef : public CommandInset {
 public:
        ///
-       InsetMathRef();
+       InsetMathRef(Buffer * buf);
        ///
-       explicit InsetMathRef(docstring const & data);
+       explicit InsetMathRef(Buffer * buf, docstring const & data);
        ///
        //void write(WriteStream & os) const;
        ///
index 0a6759c2af1df5247b9af577c7576a03e0c4e47a..38c09469c90473840745c441e2b1fe307c47ce6c 100644 (file)
@@ -23,8 +23,8 @@ using namespace std;
 namespace lyx {
 
 
-InsetMathRoot::InsetMathRoot()
-       : InsetMathNest(2)
+InsetMathRoot::InsetMathRoot(Buffer * buf)
+       : InsetMathNest(buf, 2)
 {}
 
 
index 1fd6e08d0d35d96a145ad3d049ffe62bd3c947bc..cfcac0a7f3189b68bf368cbd8fd6093e3009c7ae 100644 (file)
@@ -23,7 +23,7 @@ namespace lyx {
 class InsetMathRoot : public InsetMathNest {
 public:
        ///
-       InsetMathRoot();
+       InsetMathRoot(Buffer * buf);
        ///
        bool idxUpDown(Cursor & cur, bool up) const;
        ///
index b445de9473bdb8421707f02965a991cde31cfd94..8fde3ec81b329149c82e573ae68493acb24b8570 100644 (file)
@@ -32,18 +32,18 @@ using namespace std;
 namespace lyx {
 
 
-InsetMathScript::InsetMathScript()
-       : InsetMathNest(1), cell_1_is_up_(false), limits_(0)
+InsetMathScript::InsetMathScript(Buffer * buf)
+       : InsetMathNest(buf, 1), cell_1_is_up_(false), limits_(0)
 {}
 
 
-InsetMathScript::InsetMathScript(bool up)
-       : InsetMathNest(2), cell_1_is_up_(up), limits_(0)
+InsetMathScript::InsetMathScript(Buffer * buf, bool up)
+       : InsetMathNest(buf, 2), cell_1_is_up_(up), limits_(0)
 {}
 
 
-InsetMathScript::InsetMathScript(MathAtom const & at, bool up)
-       : InsetMathNest(2), cell_1_is_up_(up), limits_(0)
+InsetMathScript::InsetMathScript(Buffer * buf, MathAtom const & at, bool up)
+       : InsetMathNest(buf, 2), cell_1_is_up_(up), limits_(0)
 {
        LASSERT(nargs() >= 1, /**/);
        cell(0).push_back(at);
index 7917f0cd8c96091879bf49f29f4e708640150819..569bc79f3531da354073db0b74a23391ec16fe86 100644 (file)
@@ -25,11 +25,11 @@ namespace lyx {
 class InsetMathScript : public InsetMathNest {
 public:
        /// create inset without scripts
-       InsetMathScript();
+       InsetMathScript(Buffer * buf);
        /// create inset with single script
-       explicit InsetMathScript(bool up);
+       explicit InsetMathScript(Buffer * buf, bool up);
        /// create inset with single script and given nucleus
-       InsetMathScript(MathAtom const & at, bool up);
+       InsetMathScript(Buffer * buf, MathAtom const & at, bool up);
        ///
        mode_type currentMode() const { return MATH_MODE; }
        ///
index d1f34c831e119850a4d8f80f56aa48731ccb4cd5..d3a16317baa2178a10eacab63097bf3b80a64220 100644 (file)
@@ -23,8 +23,8 @@
 
 namespace lyx {
 
-InsetMathSize::InsetMathSize(latexkeys const * l)
-       : InsetMathNest(1), key_(l), style_(Styles(convert<int>(l->extra)))
+InsetMathSize::InsetMathSize(Buffer * buf, latexkeys const * l)
+       : InsetMathNest(buf, 1), key_(l), style_(Styles(convert<int>(l->extra)))
 {}
 
 
index 855b3185598ff9e678d075cbce81f25faee895ba..714ae97fb95b710e24b4b313dd970a013be0d0c9 100644 (file)
@@ -25,7 +25,7 @@ class latexkeys;
 class InsetMathSize : public InsetMathNest {
 public:
        ///
-       explicit InsetMathSize(latexkeys const * l);
+       explicit InsetMathSize(Buffer * buf, latexkeys const * l);
        /// we write extra braces in any case...
        bool extraBraces() const { return true; }
        ///
index 93799d88371a3bdf92dea8e8d576b7bda12d1ff1..3f7478321e5766054cb05a1bd5d290b0cc427c4a 100644 (file)
@@ -32,8 +32,9 @@ namespace lyx {
 using support::bformat;
 
 
-InsetMathSplit::InsetMathSplit(docstring const & name, char valign)
-       : InsetMathGrid(1, 1, valign, docstring()), name_(name)
+InsetMathSplit::InsetMathSplit(Buffer * buf, docstring const & name,
+       char valign)
+       : InsetMathGrid(buf, 1, 1, valign, docstring()), name_(name)
 {
 }
 
index 9a8d4b93d4e7056695dc1e0371247945000b0acf..123f9258690e28a099c1c817430368cddab264a8 100644 (file)
@@ -21,7 +21,8 @@ namespace lyx {
 class InsetMathSplit : public InsetMathGrid {
 public:
        ///
-       explicit InsetMathSplit(docstring const & name, char valign = 'c');
+       explicit InsetMathSplit(Buffer * buf, docstring const & name,
+               char valign = 'c');
        ///
        void draw(PainterInfo & pi, int x, int y) const;
        ///
index 7fff18f6f10a726d7ee198eb11e19fa57febd062..f738e2c17bc516db242b681850146839f7050244 100644 (file)
@@ -19,8 +19,8 @@
 
 namespace lyx {
 
-InsetMathSqrt::InsetMathSqrt()
-       : InsetMathNest(1)
+InsetMathSqrt::InsetMathSqrt(Buffer * buf)
+       : InsetMathNest(buf, 1)
 {}
 
 
index aaa1ac03c087c1c5580b7a0b7db6b70d1f454f05..485f66a574d856016365d63128e1b2dbf3747839 100644 (file)
@@ -23,7 +23,7 @@ namespace lyx {
 class InsetMathSqrt : public InsetMathNest {
 public:
        ///
-       InsetMathSqrt();
+       InsetMathSqrt(Buffer * buf);
        ///
        void draw(PainterInfo &, int x, int y) const;
        ///
index d67d9fed8f421ed3dba31b553020b1706641a6bf..0a934f21d29424d293bf75e72f80e87f38ffbdca 100644 (file)
@@ -18,7 +18,7 @@ using namespace std;
 
 namespace lyx {
 
-InsetMathStackrel::InsetMathStackrel()
+InsetMathStackrel::InsetMathStackrel(Buffer * buf) : InsetMathFracBase(buf)
 {}
 
 
index b27f1cd8b7487e817c59e6b821702df204ec3082..87397f3bbfed60b12ddd843873636c9adb7196e0 100644 (file)
@@ -26,7 +26,7 @@ namespace lyx {
 class InsetMathStackrel : public InsetMathFracBase {
 public:
        ///
-       InsetMathStackrel();
+       InsetMathStackrel(Buffer * buf);
        ///
        void metrics(MetricsInfo & mi, Dimension & dim) const;
        ///
index e4abe635e485e14119ace550cce47008ae3fe479..1736da409fa6ac16cfa52e95a3188ded9ab364cd 100644 (file)
@@ -31,8 +31,8 @@ namespace lyx {
 using support::bformat;
 
 
-InsetMathSubstack::InsetMathSubstack()
-       : InsetMathGrid(1, 1)
+InsetMathSubstack::InsetMathSubstack(Buffer * buf)
+       : InsetMathGrid(buf, 1, 1)
 {}
 
 
index c0576aaa6bd16253d5195df4b7f711529eb8f380..fbf5f756cc18f9669591bd69949488a9d2b31998 100644 (file)
@@ -23,7 +23,7 @@ namespace lyx {
 class InsetMathSubstack : public InsetMathGrid {
 public:
        ///
-       InsetMathSubstack();
+       InsetMathSubstack(Buffer * buf);
        ///
        void metrics(MetricsInfo & mi, Dimension & dim) const;
        ///
index fcdd32c99389218bba12c0ccaba240174e62e353..083b0e5ef52d99b4d6bd59886ed5f0ed53edea4a 100644 (file)
 
 namespace lyx {
 
-InsetMathTabular::InsetMathTabular(docstring const & name, int m, int n)
-       : InsetMathGrid(m, n), name_(name)
+InsetMathTabular::InsetMathTabular(Buffer * buf, docstring const & name, int m,
+               int n)
+       : InsetMathGrid(buf, m, n), name_(name)
 {}
 
 
-InsetMathTabular::InsetMathTabular(docstring const & name, int m, int n,
-               char valign, docstring const & halign)
-       : InsetMathGrid(m, n, valign, halign), name_(name)
+InsetMathTabular::InsetMathTabular(Buffer * buf, docstring const & name, int m,
+               int n, char valign, docstring const & halign)
+       : InsetMathGrid(buf, m, n, valign, halign), name_(name)
 {}
 
 
index 0fb6c27961cc96b31b0f2b1cb5d5fa2858e8f335..a4aa50f1b9137874e4d7f8c7c40dfe686a28e017 100644 (file)
@@ -22,9 +22,9 @@ namespace lyx {
 class InsetMathTabular : public InsetMathGrid {
 public:
        ///
-       InsetMathTabular(docstring const &, int m, int n);
+       InsetMathTabular(Buffer * buf, docstring const &, int m, int n);
        ///
-       InsetMathTabular(docstring const &, int m, int n,
+       InsetMathTabular(Buffer * buf, docstring const &, int m, int n,
                char valign, docstring const & halign);
        ///
        void metrics(MetricsInfo & mi, Dimension & dim) const;
index 321f26fef0cbd3d9d1d8c44fd0b0f4272f9ba62f..0f298e1f73f40f32faef044a96d8f2a507e7e821 100644 (file)
@@ -21,6 +21,8 @@ namespace lyx {
 /// Inset for underset
 class InsetMathUnderset : public InsetMathFracBase {
 public:
+       ///
+       InsetMathUnderset(Buffer * buf) : InsetMathFracBase(buf) {}
        ///
        void metrics(MetricsInfo & mi, Dimension & dim) const;
        ///
index d2b1199187fa9b77e0e2072c9849f0969c6ef116..d9579ba5cf5996ec452626d4e4103746076dded5 100644 (file)
@@ -23,8 +23,8 @@ using namespace std;
 namespace lyx {
 
 
-InsetMathXArrow::InsetMathXArrow(docstring const & name)
-       : InsetMathFracBase(), name_(name)
+InsetMathXArrow::InsetMathXArrow(Buffer * buf, docstring const & name)
+       : InsetMathFracBase(buf), name_(name)
 {}
 
 
index d21dd422224422e14ab9e78c7126ed32a05b7afe..469bec1d0baa1e6af51d86d6ea7005126f249876 100644 (file)
@@ -22,7 +22,7 @@ namespace lyx {
 class InsetMathXArrow : public InsetMathFracBase {
 public:
        ///
-       explicit InsetMathXArrow(docstring const & name);
+       explicit InsetMathXArrow(Buffer * buf, docstring const & name);
        ///
        void draw(PainterInfo & pi, int x, int y) const;
        ///
index 6b11ac2415fd9261508c766c1993fd991df16aff..39ac88586ab88dd458957c2e6a70b23b15474147 100644 (file)
 namespace lyx {
 
 
-InsetMathXYMatrix::InsetMathXYMatrix(Length const & s, char c)
-       : InsetMathGrid(1, 1), spacing_(s), spacing_code_(c)
-{}
+InsetMathXYMatrix::InsetMathXYMatrix(Buffer * buf, Length const & s, char c)
+       : InsetMathGrid(buf, 1, 1), spacing_(s), spacing_code_(c)
+{
+}
 
 
 Inset * InsetMathXYMatrix::clone() const
index 8e11a0b489bf64c4d344448d10975fb9adc24081..ee20149d30d31f29ea61ca2ac8713111698ef685 100644 (file)
@@ -22,7 +22,7 @@ namespace lyx {
 class InsetMathXYMatrix : public InsetMathGrid {
 public:
        ///
-       InsetMathXYMatrix(Length const & = Length(), char c = '\0');
+       InsetMathXYMatrix(Buffer * buf, Length const & = Length(), char c = '\0');
        ///
        void metrics(MetricsInfo &, Dimension &) const;
        ///
index 1a7ba802959b80f17d8af6e86247c746b9429240..5c0604017bbc5ad46874a56a372778bb631443e7 100644 (file)
@@ -39,23 +39,23 @@ namespace lyx {
 //
 /////////////////////////////////////////////////////////////////////
 
-MacroData::MacroData()
-       : queried_(true), numargs_(0), optionals_(0), lockCount_(0),
+MacroData::MacroData(Buffer * buf)
+       : buffer_(buf), queried_(true), numargs_(0), optionals_(0), lockCount_(0),
          redefinition_(false), type_(MacroTypeNewcommand)
 {}
 
        
        
-MacroData::MacroData(Buffer const & buf, DocIterator const & pos)
-       : buffer_(&buf), pos_(pos), queried_(false), numargs_(0),
+MacroData::MacroData(Buffer * buf, DocIterator const & pos)
+       : buffer_(buf), pos_(pos), queried_(false), numargs_(0),
          optionals_(0), lockCount_(0), redefinition_(false),
          type_(MacroTypeNewcommand)
 {
 }
        
        
-MacroData::MacroData(MathMacroTemplate const & macro)
-       : queried_(false), numargs_(0), optionals_(0), lockCount_(0),
+MacroData::MacroData(Buffer * buf, MathMacroTemplate const & macro)
+       : buffer_(buf), queried_(false), numargs_(0), optionals_(0), lockCount_(0),
          redefinition_(false), type_(MacroTypeNewcommand)
 {
        queryData(macro);
@@ -67,7 +67,8 @@ void MacroData::expand(vector<MathData> const & args, MathData & to) const
        updateData();
 
        // Hack. Any inset with a cell would do.
-       static InsetMathSqrt inset;
+       static InsetMathSqrt inset(0);
+       inset.setBuffer(const_cast<Buffer &>(*buffer_));
 
        // FIXME UNICODE
        asArray(display_.empty() ? definition_ : display_, inset.cell(0));
@@ -197,11 +198,11 @@ void MacroTable::insert(docstring const & name, MacroData const & data)
 }
 
 
-void MacroTable::insert(docstring const & def, string const & requires)
+void MacroTable::insert(Buffer * buf, docstring const & def, string const & requires)
 {
        //lyxerr << "MacroTable::insert, def: " << to_utf8(def) << endl;
-       MathMacroTemplate mac(def);
-       MacroData data(mac);
+       MathMacroTemplate mac(buf, def);
+       MacroData data(buf, mac);
        data.requires() = requires;
        insert(mac.name(), data);
 }
@@ -232,7 +233,7 @@ void MacroTable::dump()
 //
 /////////////////////////////////////////////////////////////////////
 
-MacroContext::MacroContext(Buffer const & buf, DocIterator const & pos)
+MacroContext::MacroContext(Buffer const * buf, DocIterator const & pos)
        : buf_(buf), pos_(pos)
 {
 }
@@ -240,7 +241,7 @@ MacroContext::MacroContext(Buffer const & buf, DocIterator const & pos)
 
 MacroData const * MacroContext::get(docstring const & name) const
 {
-       return buf_.getMacro(name, pos_);
+       return buf_->getMacro(name, pos_);
 }
 
 } // namespace lyx
index d1b455b03a390026cb0b741ba4a082e13a9ed6f3..24e896c6b2403c9d3e0dfff1018be381bc5e7111 100644 (file)
@@ -39,11 +39,11 @@ enum MacroType {
 class MacroData {
 public:
        /// Constructor to make STL containers happy
-       MacroData();
+       MacroData(Buffer * buf = 0);
        /// Create lazy MacroData which only queries the macro template when needed
-       MacroData(Buffer const & buf, DocIterator const & pos);
+       MacroData(Buffer * buf, DocIterator const & pos);
        /// Create non-lazy MacroData which directly queries the macro template
-       MacroData(MathMacroTemplate const & macro);
+       MacroData(Buffer * buf, MathMacroTemplate const & macro);
 
        ///
        docstring const & definition() const { updateData(); return definition_; }
@@ -153,7 +153,7 @@ class MacroTable : public std::map<docstring, MacroData>
 {
 public:
        /// Parse full "\\def..." or "\\newcommand..." or ...
-       void insert(docstring const & definition, std::string const &);
+       void insert(Buffer * buf, docstring const & definition, std::string const &);
        /// Insert pre-digested macro definition
        void insert(docstring const & name, MacroData const & data);
        ///
@@ -179,14 +179,14 @@ public:
 class MacroContext {
 public:
        /// construct context for the insets at pos
-       MacroContext(Buffer const & buf, DocIterator const & pos);
+       MacroContext(Buffer const * buf, DocIterator const & pos);
        
        /// Lookup macro
        MacroData const * get(docstring const & name) const;
        
 private:
        ///
-       Buffer const & buf_;
+       Buffer const * buf_;
        ///
        DocIterator const & pos_;
 };
index 7474632caeff1aa8f73c0b8d02aeaf07b7138e4c..b52c34f5d27089837bd9f18552b79d44deea8b71 100644 (file)
@@ -46,8 +46,8 @@ using namespace std;
 namespace lyx {
 
 
-MathData::MathData(const_iterator from, const_iterator to)
-       : base_type(from, to)
+MathData::MathData(Buffer * buf, const_iterator from, const_iterator to)
+       : base_type(from, to), buffer_(buf)
 {}
 
 
@@ -469,6 +469,7 @@ void MathData::updateMacros(Cursor * cur, MacroContext const & mc)
 void MathData::detachMacroParameters(Cursor * cur, const size_type macroPos)
 {
        MathMacro * macroInset = operator[](macroPos).nucleus()->asMacro();
+       Buffer * buf = cur->buffer();
        
        // detach all arguments
        vector<MathData> detachedArgs;
@@ -523,7 +524,7 @@ void MathData::detachMacroParameters(Cursor * cur, const size_type macroPos)
                for (size_t q = 0; q < arg.size(); ++q) {
                        if (arg[q]->getChar() == ']') {
                                // put brace
-                               brace = new InsetMathBrace();
+                               brace = new InsetMathBrace(buf);
                                break;
                        }
                }
@@ -672,6 +673,7 @@ void MathData::collectOptionalParameters(Cursor * cur,
        size_t & pos, MathAtom & scriptToPutAround,
        const pos_type macroPos, const int thisPos, const int thisSlice)
 {
+       Buffer * buf = cur ? cur->buffer() : 0;
        // insert optional arguments?
        while (params.size() < numOptionalParams 
               && pos < size()
@@ -709,7 +711,7 @@ void MathData::collectOptionalParameters(Cursor * cur,
                }
                
                // add everything between [ and ] as optional argument
-               MathData optarg(begin() + pos + 1, begin() + right);
+               MathData optarg(buf, begin() + pos + 1, begin() + right);
                
                // a brace?
                bool brace = false;
index d44455a0a313e3ea2f09adb1be59b0d3ffe7a3e9..fa2dc9dfa6dd294ae2524cce1ef68cf33d157b76 100644 (file)
@@ -25,6 +25,7 @@
 
 namespace lyx {
 
+class Buffer;
 class BufferView;
 class Cursor;
 class DocIterator;
@@ -61,9 +62,13 @@ public:
 
 public:
        ///
-       MathData() {}
+       MathData(Buffer * buf = 0) : buffer_(buf) {}
        ///
-       MathData(const_iterator from, const_iterator to);
+       MathData(Buffer * buf, const_iterator from, const_iterator to);
+       ///
+       Buffer * buffer() { return buffer_; }
+       ///
+       Buffer const * buffer() const { return buffer_; }
        ///
        void append(MathData const & ar);
 
@@ -167,7 +172,8 @@ protected:
        mutable int slevel_;
        mutable int sshift_;
        mutable int kerning_;
-       
+       Buffer * buffer_;
+
 private:
        /// is this an exact match at this position?
        bool find1(MathData const & ar, size_type pos) const;
index c42da422e4845582529c6a40e2b2db86ecd27459..f8f7cba3b1bf6a878e1f67d9a4d77a67bd4e7a4f 100644 (file)
@@ -301,9 +301,9 @@ void replaceNested(
        MathData & ar,
        TestItemFunc testOpen,
        TestItemFunc testClose,
-       ReplaceArgumentFunc replaceArg
-)
+       ReplaceArgumentFunc replaceArg)
 {
+       Buffer * buf = ar.buffer();
        // use indices rather than iterators for the loop  because we are going
        // to modify the array.
        for (size_t i = 0; i < ar.size(); ++i) {
@@ -318,7 +318,7 @@ void replaceNested(
                        continue;
 
                // replace the original stuff by the new inset
-               ar[i] = replaceArg(MathData(it + 1, jt));
+               ar[i] = replaceArg(MathData(buf, it + 1, jt));
                ar.erase(it + 1, jt + 1);
        }
 }
@@ -332,6 +332,7 @@ void replaceNested(
 
 void splitScripts(MathData & ar)
 {
+       Buffer * buf = ar.buffer();
        //lyxerr << "\nScripts from: " << ar << endl;
        for (size_t i = 0; i < ar.size(); ++i) {
                InsetMathScript const * script = ar[i]->asScriptInset();
@@ -354,7 +355,7 @@ void splitScripts(MathData & ar)
 
                // create extra script inset and move superscript over
                InsetMathScript * p = ar[i].nucleus()->asScriptInset();
-               auto_ptr<InsetMathScript> q(new InsetMathScript(true));
+               auto_ptr<InsetMathScript> q(new InsetMathScript(buf, true));
                swap(q->up(), p->up());
                p->removeScript(true);
 
@@ -382,6 +383,7 @@ void splitScripts(MathData & ar)
 
 void extractExps(MathData & ar)
 {
+       Buffer * buf = ar.buffer();
        //lyxerr << "\nExps from: " << ar << endl;
        for (size_t i = 0; i + 1 < ar.size(); ++i) {
                // is this 'e'?
@@ -394,7 +396,7 @@ void extractExps(MathData & ar)
                        continue;
 
                // create a proper exp-inset as replacement
-               ar[i] = MathAtom(new InsetMathExFunc(from_ascii("exp"), sup->cell(1)));
+               ar[i] = MathAtom(new InsetMathExFunc(buf, from_ascii("exp"), sup->cell(1)));
                ar.erase(i + 1);
        }
        //lyxerr << "\nExps to: " << ar << endl;
@@ -406,6 +408,7 @@ void extractExps(MathData & ar)
 //
 void extractDets(MathData & ar)
 {
+       Buffer * buf = ar.buffer();
        //lyxerr << "\ndet from: " << ar << endl;
        for (MathData::iterator it = ar.begin(); it != ar.end(); ++it) {
                InsetMathDelim const * del = (*it)->asDelimInset();
@@ -413,7 +416,7 @@ void extractDets(MathData & ar)
                        continue;
                if (!del->isAbs())
                        continue;
-               *it = MathAtom(new InsetMathExFunc(from_ascii("det"), del->cell(0)));
+               *it = MathAtom(new InsetMathExFunc(buf, from_ascii("det"), del->cell(0)));
        }
        //lyxerr << "\ndet to: " << ar << endl;
 }
@@ -480,7 +483,8 @@ bool testCloseParen(MathAtom const & at)
 
 MathAtom replaceParenDelims(const MathData & ar)
 {
-       return MathAtom(new InsetMathDelim(from_ascii("("), from_ascii(")"), ar));
+       return MathAtom(new InsetMathDelim(const_cast<Buffer *>(ar.buffer()),
+               from_ascii("("), from_ascii(")"), ar));
 }
 
 
@@ -498,7 +502,8 @@ bool testCloseBracket(MathAtom const & at)
 
 MathAtom replaceBracketDelims(const MathData & ar)
 {
-       return MathAtom(new InsetMathDelim(from_ascii("["), from_ascii("]"), ar));
+       return MathAtom(new InsetMathDelim(const_cast<Buffer *>(ar.buffer()),
+               from_ascii("["), from_ascii("]"), ar));
 }
 
 
@@ -526,6 +531,8 @@ void extractFunctions(MathData & ar)
        if (ar.size() < 2)
                return;
 
+       Buffer * buf = ar.buffer();
+
        //lyxerr << "\nFunctions from: " << ar << endl;
        for (size_t i = 0; i + 1 < ar.size(); ++i) {
                MathData::iterator it = ar.begin() + i;
@@ -556,7 +563,7 @@ void extractFunctions(MathData & ar)
                extractScript(exp, jt, ar.end(), true);
 
                // create a proper inset as replacement
-               auto_ptr<InsetMathExFunc> p(new InsetMathExFunc(name));
+               auto_ptr<InsetMathExFunc> p(new InsetMathExFunc(buf, name));
 
                // jt points to the "argument". Get hold of this.
                MathData::iterator st = extractArgument(p->cell(0), jt, ar.end(), true);
@@ -621,6 +628,8 @@ void extractIntegrals(MathData & ar)
        if (ar.size() < 3)
                return;
 
+       Buffer * buf = ar.buffer();
+
        //lyxerr << "\nIntegrals from: " << ar << endl;
        for (size_t i = 0; i + 1 < ar.size(); ++i) {
                MathData::iterator it = ar.begin() + i;
@@ -638,14 +647,14 @@ void extractIntegrals(MathData & ar)
                        continue;
 
                // core ist part from behind the scripts to the 'd'
-               auto_ptr<InsetMathExInt> p(new InsetMathExInt(from_ascii("int")));
+               auto_ptr<InsetMathExInt> p(new InsetMathExInt(buf, from_ascii("int")));
 
                // handle scripts if available
                if (!testIntSymbol(*it)) {
                        p->cell(2) = (*it)->asScriptInset()->down();
                        p->cell(3) = (*it)->asScriptInset()->up();
                }
-               p->cell(0) = MathData(it + 1, jt);
+               p->cell(0) = MathData(buf, it + 1, jt);
 
                // use the "thing" behind the 'd' as differential
                MathData::iterator tt = extractArgument(p->cell(1), jt + 1, ar.end());
@@ -712,6 +721,8 @@ void extractSums(MathData & ar)
        if (ar.size() < 2)
                return;
 
+       Buffer * buf = ar.buffer();
+
        //lyxerr << "\nSums from: " << ar << endl;
        for (size_t i = 0; i + 1 < ar.size(); ++i) {
                MathData::iterator it = ar.begin() + i;
@@ -721,7 +732,7 @@ void extractSums(MathData & ar)
                        continue;
 
                // create a proper inset as replacement
-               auto_ptr<InsetMathExInt> p(new InsetMathExInt(from_ascii("sum")));
+               auto_ptr<InsetMathExInt> p(new InsetMathExInt(buf, from_ascii("sum")));
 
                // collect lower bound and summation index
                InsetMathScript const * sub = ar[i]->asScriptInset();
@@ -733,8 +744,8 @@ void extractSums(MathData & ar)
                        if (xt != ar.end()) {
                                // we found a '=', use everything in front of that as index,
                                // and everything behind as lower index
-                               p->cell(1) = MathData(ar.begin(), xt);
-                               p->cell(2) = MathData(xt + 1, ar.end());
+                               p->cell(1) = MathData(buf, ar.begin(), xt);
+                               p->cell(2) = MathData(buf, xt + 1, ar.end());
                        } else {
                                // use everything as summation index, don't use scripts.
                                p->cell(1) = ar;
@@ -793,6 +804,7 @@ bool testDiffFrac(MathAtom const & at)
 
 void extractDiff(MathData & ar)
 {
+       Buffer * buf = ar.buffer();
        //lyxerr << "\nDiffs from: " << ar << endl;
        for (size_t i = 0; i < ar.size(); ++i) {
                MathData::iterator it = ar.begin() + i;
@@ -808,7 +820,7 @@ void extractDiff(MathData & ar)
                }
 
                // create a proper diff inset
-               auto_ptr<InsetMathDiff> diff(new InsetMathDiff);
+               auto_ptr<InsetMathDiff> diff(new InsetMathDiff(buf));
 
                // collect function, let jt point behind last used item
                MathData::iterator jt = it + 1;
@@ -820,13 +832,13 @@ void extractDiff(MathData & ar)
                        // FIXME
                        //n = 1;
                        if (numer.size() > 2)
-                               diff->cell(0) = MathData(numer.begin() + 2, numer.end());
+                               diff->cell(0) = MathData(buf, numer.begin() + 2, numer.end());
                        else
                                jt = extractTerm(diff->cell(0), jt, ar.end());
                } else {
                        // simply d f(x) / d... or  d/d...
                        if (numer.size() > 1)
-                               diff->cell(0) = MathData(numer.begin() + 1, numer.end());
+                               diff->cell(0) = MathData(buf, numer.begin() + 1, numer.end());
                        else
                                jt = extractTerm(diff->cell(0), jt, ar.end());
                }
@@ -848,11 +860,11 @@ void extractDiff(MathData & ar)
                                if (extractNumber(script->up(), mult)) {
                                        //lyxerr << "mult: " << mult << endl;
                                        for (int i = 0; i < mult; ++i)
-                                               diff->addDer(MathData(dt + 1, st));
+                                               diff->addDer(MathData(buf, dt + 1, st));
                                }
                        } else {
                                // just  d.../dx
-                               diff->addDer(MathData(dt + 1, et));
+                               diff->addDer(MathData(buf, dt + 1, et));
                        }
                        dt = et;
                }
@@ -881,6 +893,7 @@ bool testRightArrow(MathAtom const & at)
 // assume 'extractDelims' ran before
 void extractLims(MathData & ar)
 {
+       Buffer * buf = ar.buffer();
        //lyxerr << "\nLimits from: " << ar << endl;
        for (size_t i = 0; i < ar.size(); ++i) {
                MathData::iterator it = ar.begin() + i;
@@ -901,8 +914,8 @@ void extractLims(MathData & ar)
                        continue;
 
                // the -> splits the subscript int x and x0
-               MathData x  = MathData(s.begin(), st);
-               MathData x0 = MathData(st + 1, s.end());
+               MathData x  = MathData(buf, s.begin(), st);
+               MathData x0 = MathData(buf, st + 1, s.end());
 
                // use something behind the script as core
                MathData f;
@@ -912,7 +925,7 @@ void extractLims(MathData & ar)
                ar.erase(it + 1, tt);
 
                // create a proper inset as replacement
-               *it = MathAtom(new InsetMathLim(f, x, x0));
+               *it = MathAtom(new InsetMathLim(buf, f, x, x0));
        }
        //lyxerr << "\nLimits to: " << ar << endl;
 }
@@ -1254,7 +1267,8 @@ namespace {
                vs << ar;
                string expr = to_utf8(os.str());
                string out;
-
+               // FIXME const cast
+               Buffer * buf = const_cast<Buffer *>(ar.buffer());
                lyxerr << "pipe: ar: '" << ar << "'\n"
                       << "pipe: expr: '" << expr << "'" << endl;
 
@@ -1304,13 +1318,14 @@ namespace {
                out = out.substr(i + 6);
 
                // parse output as matrix or single number
-               MathAtom at(new InsetMathArray(from_ascii("array"), from_utf8(out)));
+               MathAtom at(new InsetMathArray(buf, from_ascii("array"), from_utf8(out)));
                InsetMathArray const * mat = at->asArrayInset();
-               MathData res;
+               MathData res(buf);
                if (mat->ncols() == 1 && mat->nrows() == 1)
                        res.append(mat->cell(0));
                else {
-                       res.push_back(MathAtom(new InsetMathDelim(from_ascii("("), from_ascii(")"))));
+                       res.push_back(MathAtom(
+                               new InsetMathDelim(buf, from_ascii("("), from_ascii(")"))));
                        res.back().nucleus()->cell(0).push_back(at);
                }
                return res;
index 267432affd878c7440656ca73001efaa1a511b84..1d6d83baf8eb308990eabb19d52e2f6309feb084 100644 (file)
@@ -145,7 +145,7 @@ void initSymbols()
                        string macro;
                        string requires;
                        is >> macro >> requires;
-                       MacroTable::globalMacros().insert(from_utf8(macro), requires);
+                       MacroTable::globalMacros().insert(0, from_utf8(macro), requires);
                        continue;
                }
 
@@ -300,13 +300,13 @@ latexkeys const * in_word_set(docstring const & str)
 }
 
 
-MathAtom createInsetMath(char const * const s)
+MathAtom createInsetMath(char const * const s, Buffer * buf)
 {
-       return createInsetMath(from_utf8(s));
+       return createInsetMath(from_utf8(s), buf);
 }
 
 
-MathAtom createInsetMath(docstring const & s)
+MathAtom createInsetMath(docstring const & s, Buffer * buf)
 {
        //lyxerr << "creating inset with name: '" << to_utf8(s) << '\'' << endl;
        latexkeys const * l = in_word_set(s);
@@ -314,13 +314,13 @@ MathAtom createInsetMath(docstring const & s)
                docstring const & inset = l->inset;
                //lyxerr << " found inset: '" << inset << '\'' << endl;
                if (inset == "ref")
-                       return MathAtom(new InsetMathRef(l->name));
+                       return MathAtom(new InsetMathRef(buf, l->name));
                if (inset == "overset")
-                       return MathAtom(new InsetMathOverset);
+                       return MathAtom(new InsetMathOverset(buf));
                if (inset == "underset")
-                       return MathAtom(new InsetMathUnderset);
+                       return MathAtom(new InsetMathUnderset(buf));
                if (inset == "decoration")
-                       return MathAtom(new InsetMathDecoration(l));
+                       return MathAtom(new InsetMathDecoration(buf, l));
                if (inset == "space")
                        return MathAtom(new InsetMathSpace(to_ascii(l->name), ""));
                if (inset == "dots")
@@ -330,19 +330,19 @@ MathAtom createInsetMath(docstring const & s)
                        // InsetMathMBox is proposed to replace InsetMathBox,
                        // but is not ready yet (it needs a BufferView for
                        // construction)
-                       return MathAtom(new InsetMathBox(l->name));
+                       return MathAtom(new InsetMathBox(buf, l->name));
 //             if (inset == "fbox")
 //                     return MathAtom(new InsetMathFBox(l));
                if (inset == "style")
-                       return MathAtom(new InsetMathSize(l));
+                       return MathAtom(new InsetMathSize(buf, l));
                if (inset == "font")
-                       return MathAtom(new InsetMathFont(l));
+                       return MathAtom(new InsetMathFont(buf, l));
                if (inset == "oldfont")
-                       return MathAtom(new InsetMathFontOld(l));
+                       return MathAtom(new InsetMathFontOld(buf, l));
                if (inset == "matrix")
-                       return MathAtom(new InsetMathAMSArray(s));
+                       return MathAtom(new InsetMathAMSArray(buf, s));
                if (inset == "split")
-                       return MathAtom(new InsetMathSplit(s));
+                       return MathAtom(new InsetMathSplit(buf, s));
                if (inset == "big")
                        // we can't create a InsetMathBig, since the argument
                        // is missing.
@@ -356,13 +356,13 @@ MathAtom createInsetMath(docstring const & s)
                        && s[2] >= '1' && s[2] <= '9')
                return MathAtom(new MathMacroArgument(s[2] - '0'));
        if (s == "boxed")
-               return MathAtom(new InsetMathBoxed());
+               return MathAtom(new InsetMathBoxed(buf));
        if (s == "fbox")
-               return MathAtom(new InsetMathFBox());
+               return MathAtom(new InsetMathFBox(buf));
        if (s == "framebox")
-               return MathAtom(new InsetMathMakebox(true));
+               return MathAtom(new InsetMathMakebox(buf, true));
        if (s == "makebox")
-               return MathAtom(new InsetMathMakebox(false));
+               return MathAtom(new InsetMathMakebox(buf, false));
        if (s == "kern")
                return MathAtom(new InsetMathKern);
        if (s.substr(0, 8) == "xymatrix") {
@@ -390,94 +390,94 @@ MathAtom createInsetMath(docstring const & s)
                                spacing = Length(to_ascii(s.substr(i)));
                        }
                }
-               return MathAtom(new InsetMathXYMatrix(spacing, spacing_code));
+               return MathAtom(new InsetMathXYMatrix(buf, spacing, spacing_code));
        }
        if (s == "xrightarrow" || s == "xleftarrow")
-               return MathAtom(new InsetMathXArrow(s));
+               return MathAtom(new InsetMathXArrow(buf, s));
        if (s == "split" || s == "gathered" || s == "aligned" || s == "alignedat")
-               return MathAtom(new InsetMathSplit(s));
+               return MathAtom(new InsetMathSplit(buf, s));
        if (s == "cases")
-               return MathAtom(new InsetMathCases);
+               return MathAtom(new InsetMathCases(buf));
        if (s == "substack")
-               return MathAtom(new InsetMathSubstack);
+               return MathAtom(new InsetMathSubstack(buf));
        if (s == "subarray" || s == "array")
-               return MathAtom(new InsetMathArray(s, 1, 1));
+               return MathAtom(new InsetMathArray(buf, s, 1, 1));
        if (s == "sqrt")
-               return MathAtom(new InsetMathSqrt);
+               return MathAtom(new InsetMathSqrt(buf));
        if (s == "root")
-               return MathAtom(new InsetMathRoot);
+               return MathAtom(new InsetMathRoot(buf));
        if (s == "tabular")
-               return MathAtom(new InsetMathTabular(s, 1, 1));
+               return MathAtom(new InsetMathTabular(buf, s, 1, 1));
        if (s == "stackrel")
-               return MathAtom(new InsetMathStackrel);
+               return MathAtom(new InsetMathStackrel(buf));
        if (s == "binom")
-               return MathAtom(new InsetMathBinom(InsetMathBinom::BINOM));
+               return MathAtom(new InsetMathBinom(buf, InsetMathBinom::BINOM));
        if (s == "dbinom")
-               return MathAtom(new InsetMathBinom(InsetMathBinom::DBINOM));
+               return MathAtom(new InsetMathBinom(buf, InsetMathBinom::DBINOM));
        if (s == "tbinom")
-               return MathAtom(new InsetMathBinom(InsetMathBinom::TBINOM));
+               return MathAtom(new InsetMathBinom(buf, InsetMathBinom::TBINOM));
        if (s == "choose")
-               return MathAtom(new InsetMathBinom(InsetMathBinom::CHOOSE));
+               return MathAtom(new InsetMathBinom(buf, InsetMathBinom::CHOOSE));
        if (s == "brace")
-               return MathAtom(new InsetMathBinom(InsetMathBinom::BRACE));
+               return MathAtom(new InsetMathBinom(buf, InsetMathBinom::BRACE));
        if (s == "brack")
-               return MathAtom(new InsetMathBinom(InsetMathBinom::BRACK));
+               return MathAtom(new InsetMathBinom(buf, InsetMathBinom::BRACK));
        if (s == "frac")
-               return MathAtom(new InsetMathFrac);
+               return MathAtom(new InsetMathFrac(buf));
        if (s == "cfrac")
-               return MathAtom(new InsetMathFrac(InsetMathFrac::CFRAC));
+               return MathAtom(new InsetMathFrac(buf, InsetMathFrac::CFRAC));
        if (s == "dfrac")
-               return MathAtom(new InsetMathFrac(InsetMathFrac::DFRAC));
+               return MathAtom(new InsetMathFrac(buf, InsetMathFrac::DFRAC));
        if (s == "tfrac")
-               return MathAtom(new InsetMathFrac(InsetMathFrac::TFRAC));
+               return MathAtom(new InsetMathFrac(buf, InsetMathFrac::TFRAC));
        if (s == "over")
-               return MathAtom(new InsetMathFrac(InsetMathFrac::OVER));
+               return MathAtom(new InsetMathFrac(buf, InsetMathFrac::OVER));
        if (s == "nicefrac")
-               return MathAtom(new InsetMathFrac(InsetMathFrac::NICEFRAC));
+               return MathAtom(new InsetMathFrac(buf, InsetMathFrac::NICEFRAC));
        if (s == "unitfrac")
-               return MathAtom(new InsetMathFrac(InsetMathFrac::UNITFRAC));
+               return MathAtom(new InsetMathFrac(buf, InsetMathFrac::UNITFRAC));
        // These string values are only for math toolbar use, no LaTeX names
        if (s == "unitfracthree")
-               return MathAtom(new InsetMathFrac(InsetMathFrac::UNITFRAC, 3));
+               return MathAtom(new InsetMathFrac(buf, InsetMathFrac::UNITFRAC, 3));
        if (s == "unitone")
-               return MathAtom(new InsetMathFrac(InsetMathFrac::UNIT, 1));
+               return MathAtom(new InsetMathFrac(buf, InsetMathFrac::UNIT, 1));
        if (s == "unittwo")
-               return MathAtom(new InsetMathFrac(InsetMathFrac::UNIT));
+               return MathAtom(new InsetMathFrac(buf, InsetMathFrac::UNIT));
        if (s == "cfracleft")
-               return MathAtom(new InsetMathFrac(InsetMathFrac::CFRACLEFT));
+               return MathAtom(new InsetMathFrac(buf, InsetMathFrac::CFRACLEFT));
        if (s == "cfracright")
-               return MathAtom(new InsetMathFrac(InsetMathFrac::CFRACRIGHT));
+               return MathAtom(new InsetMathFrac(buf, InsetMathFrac::CFRACRIGHT));
        //if (s == "infer")
        //      return MathAtom(new MathInferInset);
        if (s == "atop")
-               return MathAtom(new InsetMathFrac(InsetMathFrac::ATOP));
+               return MathAtom(new InsetMathFrac(buf, InsetMathFrac::ATOP));
        if (s == "lefteqn")
-               return MathAtom(new InsetMathLefteqn);
+               return MathAtom(new InsetMathLefteqn(buf));
        if (s == "boldsymbol")
-               return MathAtom(new InsetMathBoldSymbol(InsetMathBoldSymbol::AMS_BOLD));
+               return MathAtom(new InsetMathBoldSymbol(buf, InsetMathBoldSymbol::AMS_BOLD));
        if (s == "bm")
-               return MathAtom(new InsetMathBoldSymbol(InsetMathBoldSymbol::BM_BOLD));
+               return MathAtom(new InsetMathBoldSymbol(buf, InsetMathBoldSymbol::BM_BOLD));
        if (s == "heavysymbol" || s == "hm")
-               return MathAtom(new InsetMathBoldSymbol(InsetMathBoldSymbol::BM_HEAVY));
+               return MathAtom(new InsetMathBoldSymbol(buf, InsetMathBoldSymbol::BM_HEAVY));
        if (s == "color" || s == "normalcolor")
-               return MathAtom(new InsetMathColor(true));
+               return MathAtom(new InsetMathColor(buf, true));
        if (s == "textcolor")
-               return MathAtom(new InsetMathColor(false));
+               return MathAtom(new InsetMathColor(buf, false));
        if (s == "hphantom")
-               return MathAtom(new InsetMathPhantom(InsetMathPhantom::hphantom));
+               return MathAtom(new InsetMathPhantom(buf, InsetMathPhantom::hphantom));
        if (s == "phantom")
-               return MathAtom(new InsetMathPhantom(InsetMathPhantom::phantom));
+               return MathAtom(new InsetMathPhantom(buf, InsetMathPhantom::phantom));
        if (s == "vphantom")
-               return MathAtom(new InsetMathPhantom(InsetMathPhantom::vphantom));
+               return MathAtom(new InsetMathPhantom(buf, InsetMathPhantom::vphantom));
        if (s == "ensuremath")
-               return MathAtom(new InsetMathEnsureMath);
+               return MathAtom(new InsetMathEnsureMath(buf));
        if (isSpecialChar(s))
                return MathAtom(new InsetMathSpecialChar(s));
 
        if (s == "regexp")
-               return MathAtom(new InsetMathHull(hullRegexp));
+               return MathAtom(new InsetMathHull(buf, hullRegexp));
 
-       return MathAtom(new MathMacro(s));
+       return MathAtom(new MathMacro(buf, s));
 }
 
 
index 82515baeb82c0447f8fe2a76aed6332a4f8c300d..9837ca75e2e2284be9aab3e09911cd08cb82f3aa 100644 (file)
@@ -24,8 +24,8 @@ class MathAtom;
 class MathData;
 
 
-MathAtom createInsetMath(docstring const &);
-MathAtom createInsetMath(char const * const);
+MathAtom createInsetMath(docstring const &, Buffer * buf);
+MathAtom createInsetMath(char const * const, Buffer * buf);
 
 /** Fills ar with the contents of str.
  *  str is created by the frontend dialog's and returned to the LyX core.
index f29a5e4ac79876b92e01463a9de98fdd9164fff7..f1aeb132934211b8565ee19a0232d1c0891e47ca 100644 (file)
@@ -116,10 +116,10 @@ private:
 };
 
 
-MathMacro::MathMacro(docstring const & name)
-       : InsetMathNest(0), name_(name), displayMode_(DISPLAY_INIT),
-               attachedArgsNum_(0), optionals_(0), nextFoldMode_(true),
-               macro_(0), needsUpdate_(false), appetite_(9)
+MathMacro::MathMacro(Buffer * buf, docstring const & name)
+       : InsetMathNest(buf, 0), name_(name), displayMode_(DISPLAY_INIT),
+               expanded_(buf), attachedArgsNum_(0), optionals_(0), nextFoldMode_(true),
+               macroBackup_(buf), macro_(0), needsUpdate_(false), appetite_(9)
 {}
 
 
@@ -634,7 +634,7 @@ bool MathMacro::notifyCursorLeaves(Cursor const & old, Cursor & cur)
                        cur.recordUndoInset();
                        cur.popForward();
                        cur.backspace();
-                       cur.insert(createInsetMath(unfolded_name));
+                       cur.insert(createInsetMath(unfolded_name, cur.buffer()));
                        if (left)
                                cur.backwardPos();
                        cur.updateFlags(Update::Force);
index 801c19dfb8d9d5972028aa31b82406cbacc857f2..b431a9a9a516c9344117d618cab328cd3ee6ae72 100644 (file)
@@ -26,7 +26,7 @@ namespace lyx {
 class MathMacro : public InsetMathNest {
 public:
        /// A macro can be built from an existing template
-       MathMacro(docstring const & name);
+       MathMacro(Buffer * buf, docstring const & name);
        ///
        virtual MathMacro * asMacro() { return this; }
        ///
index fc5e57a5e4baf2617677c9a24906a1a98c6e7786..257c55f639e867657a73fefb49e56a1a2a14ea2d 100644 (file)
@@ -57,9 +57,9 @@ using support::bformat;
 class InsetLabelBox : public InsetMathNest {
 public:
        ///
-       InsetLabelBox(MathAtom const & atom, docstring label,
+       InsetLabelBox(Buffer * buf, MathAtom const & atom, docstring label,
                      MathMacroTemplate const & parent, bool frame = false);
-       InsetLabelBox(docstring label, MathMacroTemplate const & parent,
+       InsetLabelBox(Buffer * buf, docstring label, MathMacroTemplate const & parent,
                      bool frame = false);
        ///
        void metrics(MetricsInfo & mi, Dimension & dim) const;
@@ -78,17 +78,17 @@ protected:
 };
 
 
-InsetLabelBox::InsetLabelBox(MathAtom const & atom, docstring label,
+InsetLabelBox::InsetLabelBox(Buffer * buf, MathAtom const & atom, docstring label,
        MathMacroTemplate const & parent, bool frame)
-       : InsetMathNest(1), parent_(parent), label_(label), frame_(frame)
+       : InsetMathNest(buf, 1), parent_(parent), label_(label), frame_(frame)
 {
        cell(0).insert(0, atom);
 }
 
 
-InsetLabelBox::InsetLabelBox(docstring label,
+InsetLabelBox::InsetLabelBox(Buffer * buf, docstring label,
                             MathMacroTemplate const & parent, bool frame)
-       : InsetMathNest(1), parent_(parent), label_(label), frame_(frame)
+       : InsetMathNest(buf, 1), parent_(parent), label_(label), frame_(frame)
 {
 }
 
@@ -181,7 +181,7 @@ void InsetLabelBox::draw(PainterInfo & pi, int x, int y) const
 class DisplayLabelBox : public InsetLabelBox {
 public:
        ///
-       DisplayLabelBox(MathAtom const & atom, docstring label,
+       DisplayLabelBox(Buffer * buf, MathAtom const & atom, docstring label,
                        MathMacroTemplate const & parent);
 
        ///
@@ -195,10 +195,10 @@ protected:
 };
 
 
-DisplayLabelBox::DisplayLabelBox(MathAtom const & atom,
+DisplayLabelBox::DisplayLabelBox(Buffer * buf, MathAtom const & atom,
                                 docstring label,
                                 MathMacroTemplate const & parent)
-       : InsetLabelBox(atom, label, parent, true)
+       : InsetLabelBox(buf, atom, label, parent, true)
 {
 }
 
@@ -279,9 +279,9 @@ void InsetMathWrapper::draw(PainterInfo & pi, int x, int y) const
 class InsetColoredCell : public InsetMathNest {
 public:
        ///
-       InsetColoredCell(ColorCode min, ColorCode max);
+       InsetColoredCell(Buffer * buf, ColorCode min, ColorCode max);
        ///
-       InsetColoredCell(ColorCode min, ColorCode max, MathAtom const & atom);
+       InsetColoredCell(Buffer * buf, ColorCode min, ColorCode max, MathAtom const & atom);
        ///
        void draw(PainterInfo &, int x, int y) const;
        ///
@@ -297,14 +297,14 @@ protected:
 };
 
 
-InsetColoredCell::InsetColoredCell(ColorCode min, ColorCode max)
-       : InsetMathNest(1), min_(min), max_(max)
+InsetColoredCell::InsetColoredCell(Buffer * buf, ColorCode min, ColorCode max)
+       : InsetMathNest(buf, 1), min_(min), max_(max)
 {
 }
 
 
-InsetColoredCell::InsetColoredCell(ColorCode min, ColorCode max, MathAtom const & atom)
-       : InsetMathNest(1), min_(min), max_(max)
+InsetColoredCell::InsetColoredCell(Buffer * buf, ColorCode min, ColorCode max, MathAtom const & atom)
+       : InsetMathNest(buf, 1), min_(min), max_(max)
 {
        cell(0).insert(0, atom);
 }
@@ -391,23 +391,20 @@ void InsetNameWrapper::draw(PainterInfo & pi, int x, int y) const
 
 
 MathMacroTemplate::MathMacroTemplate(Buffer * buf)
-       : InsetMathNest(3), numargs_(0), argsInLook_(0), optionals_(0),
+       : InsetMathNest(buf, 3), numargs_(0), argsInLook_(0), optionals_(0),
          type_(MacroTypeNewcommand), lookOutdated_(true)
 {
-       buffer_ = buf;
        initMath();
 }
 
 
-MathMacroTemplate::MathMacroTemplate(docstring const & name, int numargs,
-       int optionals, MacroType type, Buffer * buf,
-       vector<MathData> const & optionalValues,
+MathMacroTemplate::MathMacroTemplate(Buffer * buf, docstring const & name, int numargs,
+       int optionals, MacroType type, vector<MathData> const & optionalValues,
        MathData const & def, MathData const & display)
-       : InsetMathNest(optionals + 3), numargs_(numargs), argsInLook_(numargs),
+       : InsetMathNest(buf, optionals + 3), numargs_(numargs), argsInLook_(numargs),
          optionals_(optionals), optionalValues_(optionalValues),
          type_(type), lookOutdated_(true)
 {
-       buffer_ = buf;
        initMath();
 
        if (numargs_ > 9)
@@ -425,15 +422,15 @@ MathMacroTemplate::MathMacroTemplate(docstring const & name, int numargs,
 }
 
 
-MathMacroTemplate::MathMacroTemplate(docstring const & str, Buffer * buf)
-       : InsetMathNest(3), numargs_(0), optionals_(0),
+MathMacroTemplate::MathMacroTemplate(Buffer * buf, docstring const & str)
+       : InsetMathNest(buf, 3), numargs_(0), optionals_(0),
        type_(MacroTypeNewcommand), lookOutdated_(true)
 {
        buffer_ = buf;
        initMath();
 
-       MathData ar;
-       mathed_parse_cell(ar, str, Parse::NORMAL, buf);
+       MathData ar(buf);
+       mathed_parse_cell(ar, str, Parse::NORMAL);
        if (ar.size() != 1 || !ar[0]->asMacroTemplate()) {
                lyxerr << "Cannot read macro from '" << ar << "'" << endl;
                asArray(from_ascii("invalidmacro"), cell(0));
@@ -482,21 +479,23 @@ void MathMacroTemplate::createLook(int args) const
        argsInLook_ = args;
 
        // \foo
-       look_.push_back(MathAtom(new InsetLabelBox(_("Name"), *this, false)));
+       look_.push_back(MathAtom(
+               new InsetLabelBox(buffer_, _("Name"), *this, false)));
        MathData & nameData = look_[look_.size() - 1].nucleus()->cell(0);
        nameData.push_back(MathAtom(new InsetNameWrapper(&cell(0), *this)));
 
        // [#1][#2]
        int i = 0;
        if (optionals_ > 0) {
-               look_.push_back(MathAtom(new InsetLabelBox(_("optional"), *this, false)));
+               look_.push_back(MathAtom(
+                       new InsetLabelBox(buffer_, _("optional"), *this, false)));
                
                MathData * optData = &look_[look_.size() - 1].nucleus()->cell(0);
                for (; i < optionals_; ++i) {
                        // color it light grey, if it is to be removed when the cursor leaves
                        if (i == argsInLook_) {
                                optData->push_back(MathAtom(
-                                       new InsetColoredCell(Color_mathbg, Color_mathmacrooldarg)));
+                                       new InsetColoredCell(buffer_, Color_mathbg, Color_mathmacrooldarg)));
                                optData = &(*optData)[optData->size() - 1].nucleus()->cell(0);
                        }
 
@@ -511,7 +510,7 @@ void MathMacroTemplate::createLook(int args) const
                MathData arg;
                arg.push_back(MathAtom(new MathMacroArgument(i + 1)));
                if (i >= argsInLook_) {
-                       look_.push_back(MathAtom(new InsetColoredCell(
+                       look_.push_back(MathAtom(new InsetColoredCell(buffer_,
                                Color_mathbg, Color_mathmacrooldarg,
                                MathAtom(new InsetMathBrace(arg)))));
                } else
@@ -520,7 +519,7 @@ void MathMacroTemplate::createLook(int args) const
        for (; i < argsInLook_; ++i) {
                MathData arg;
                arg.push_back(MathAtom(new MathMacroArgument(i + 1)));
-               look_.push_back(MathAtom(new InsetColoredCell(
+               look_.push_back(MathAtom(new InsetColoredCell(buffer_,
                        Color_mathbg, Color_mathmacronewarg,
                        MathAtom(new InsetMathBrace(arg)))));
        }
@@ -531,12 +530,12 @@ void MathMacroTemplate::createLook(int args) const
 
        // definition
        look_.push_back(MathAtom(
-               new InsetLabelBox(MathAtom(
+               new InsetLabelBox(buffer_, MathAtom(
                        new InsetMathWrapper(&cell(defIdx()))), _("TeX"), *this,        true)));
 
        // display
        look_.push_back(MathAtom(
-               new DisplayLabelBox(MathAtom(
+               new DisplayLabelBox(buffer_, MathAtom(
                        new InsetMathWrapper(&cell(displayIdx()))), _("LyX"), *this)));
 }
 
@@ -1108,8 +1107,8 @@ bool MathMacroTemplate::getStatus(Cursor & /*cur*/, FuncRequest const & cmd,
 
 void MathMacroTemplate::read(Lexer & lex)
 {
-       MathData ar;
-       mathed_parse_cell(ar, lex.getStream(), Parse::NORMAL, &buffer());
+       MathData ar(buffer_);
+       mathed_parse_cell(ar, lex.getStream(), Parse::NORMAL);
        if (ar.size() != 1 || !ar[0]->asMacroTemplate()) {
                lyxerr << "Cannot read macro from '" << ar << "'" << endl;
                lyxerr << "Read: " << to_utf8(asString(ar)) << endl;
index 4b6b98924bd89083685f1c688522ecaec0f69b74..f6ac948d87e51330baf372c4d7c7c0b18063ed53 100644 (file)
@@ -26,15 +26,15 @@ namespace lyx {
 class MathMacroTemplate : public InsetMathNest {
 public:
        ///
-       MathMacroTemplate(Buffer * buf = 0);
+       MathMacroTemplate(Buffer * buf);
        ///
-       MathMacroTemplate(docstring const & name, int nargs, int optional, 
-               MacroType type, Buffer * buf = 0,
+       MathMacroTemplate(Buffer * buf, docstring const & name, int nargs,
+               int optional, MacroType type, 
                std::vector<MathData> const & optionalValues = std::vector<MathData>(),
                MathData const & def = MathData(),
                MathData const & display = MathData());
        ///
-       explicit MathMacroTemplate(const docstring & str, Buffer * buf = 0);
+       MathMacroTemplate(Buffer * buf, const docstring & str);
        ///
        bool editable() const { return true; }
        ///
index 74db5acc92461b04fa0cb90275ccb65ceab136a7..7c67f0df87d167b61d32a9a18d3c857c092ee144 100644 (file)
@@ -681,12 +681,12 @@ void Parser::error(string const & msg)
 bool Parser::parse(MathAtom & at)
 {
        skipSpaces();
-       MathData ar;
+       MathData ar(buffer_);
        parse(ar, false, InsetMath::UNDECIDED_MODE);
        if (ar.size() != 1 || ar.front()->getType() == hullNone) {
                if (!(mode_ & Parse::QUIET))
                        lyxerr << "unusual contents found: " << ar << endl;
-               at = MathAtom(new InsetMathPar(ar));
+               at = MathAtom(new InsetMathPar(buffer_, ar));
                //if (at->nargs() > 0)
                //      at.nucleus()->cell(0) = ar;
                //else
@@ -737,7 +737,7 @@ docstring Parser::parse_verbatim_item()
 
 MathData Parser::parse(unsigned flags, mode_type mode)
 {
-       MathData ar;
+       MathData ar(buffer_);
        parse(ar, flags, mode);
        return ar;
 }
@@ -745,7 +745,7 @@ MathData Parser::parse(unsigned flags, mode_type mode)
 
 bool Parser::parse(MathData & array, unsigned flags, mode_type mode)
 {
-       InsetMathGrid grid(1, 1);
+       InsetMathGrid grid(buffer_, 1, 1);
        parse1(grid, flags, mode, false);
        array = grid.cell(0);
        return success_;
@@ -766,6 +766,7 @@ bool Parser::parse1(InsetMathGrid & grid, unsigned flags,
        InsetMathGrid::row_type cellrow = 0;
        InsetMathGrid::col_type cellcol = 0;
        MathData * cell = &grid.cell(grid.index(cellrow, cellcol));
+       Buffer * buf = buffer_;
 
        if (grid.asHullInset())
                grid.asHullInset()->numbered(cellrow, numbered);
@@ -835,18 +836,18 @@ bool Parser::parse1(InsetMathGrid & grid, unsigned flags,
                                Token const & n = getToken();
                                if (n.cat() == catMath) {
                                        // TeX's $$...$$ syntax for displayed math
-                                       cell->push_back(MathAtom(new InsetMathHull(hullEquation, buffer_)));
+                                       cell->push_back(MathAtom(new InsetMathHull(buffer_, hullEquation)));
                                        parse2(cell->back(), FLAG_SIMPLE, InsetMath::MATH_MODE, false);
                                        getToken(); // skip the second '$' token
                                } else {
                                        // simple $...$  stuff
                                        putback();
                                        if (mode == InsetMath::UNDECIDED_MODE) {
-                                               cell->push_back(MathAtom(new InsetMathHull(hullSimple, buffer_)));
+                                               cell->push_back(MathAtom(new InsetMathHull(buffer_, hullSimple)));
                                                parse2(cell->back(), FLAG_SIMPLE, InsetMath::MATH_MODE, false);
                                        } else {
                                                // Don't create nested math hulls (bug #5392)
-                                               cell->push_back(MathAtom(new InsetMathEnsureMath));
+                                               cell->push_back(MathAtom(new InsetMathEnsureMath(buffer_)));
                                                parse(cell->back().nucleus()->cell(0), FLAG_SIMPLE, InsetMath::MATH_MODE);
                                        }
                                }
@@ -917,14 +918,14 @@ bool Parser::parse1(InsetMathGrid & grid, unsigned flags,
                        // we need no new script inset if the last thing was a scriptinset,
                        // which has that script already not the same script already
                        if (!cell->size())
-                               cell->push_back(MathAtom(new InsetMathScript(up)));
+                               cell->push_back(MathAtom(new InsetMathScript(buffer_, up)));
                        else if (cell->back()->asScriptInset() &&
                                        !cell->back()->asScriptInset()->has(up))
                                cell->back().nucleus()->asScriptInset()->ensure(up);
                        else if (cell->back()->asScriptInset())
-                               cell->push_back(MathAtom(new InsetMathScript(up)));
+                               cell->push_back(MathAtom(new InsetMathScript(buffer_, up)));
                        else
-                               cell->back() = MathAtom(new InsetMathScript(cell->back(), up));
+                               cell->back() = MathAtom(new InsetMathScript(buffer_, cell->back(), up));
                        InsetMathScript * p = cell->back().nucleus()->asScriptInset();
                        // special handling of {}-bases
                        // Here we could remove the brace inset for things
@@ -958,7 +959,7 @@ bool Parser::parse1(InsetMathGrid & grid, unsigned flags,
                            || mode == InsetMath::TEXT_MODE) {
                                cell->push_back(MathAtom(new InsetMathChar(c)));
                        } else {
-                               MathAtom at = createInsetMath("text");
+                               MathAtom at = createInsetMath("text", buf);
                                at.nucleus()->cell(0).push_back(MathAtom(new InsetMathChar(c)));
                                while (nextToken().cat() == catOther
                                       && !isAsciiOrMathAlpha(nextToken().character())) {
@@ -977,7 +978,7 @@ bool Parser::parse1(InsetMathGrid & grid, unsigned flags,
                                        break;
                                s += t.asString();
                        }
-                       cell->push_back(MathAtom(new InsetMathComment(s)));
+                       cell->push_back(MathAtom(new InsetMathComment(buffer_, s)));
                        skipSpaces();
                }
 
@@ -1017,8 +1018,8 @@ bool Parser::parse1(InsetMathGrid & grid, unsigned flags,
                        if (nextToken().cat() == catBegin)
                                parse(display, FLAG_ITEM, InsetMath::MATH_MODE);
                        
-                       cell->push_back(MathAtom(new MathMacroTemplate(name,
-                               nargs, 0, MacroTypeDef, buffer_,
+                       cell->push_back(MathAtom(new MathMacroTemplate(buffer_, name,
+                               nargs, 0, MacroTypeDef,
                                vector<MathData>(), def, display)));
                }
                
@@ -1062,8 +1063,8 @@ bool Parser::parse1(InsetMathGrid & grid, unsigned flags,
                        if (nextToken().cat() == catBegin)
                                parse(display, FLAG_ITEM, InsetMath::MATH_MODE);
                        
-                       cell->push_back(MathAtom(new MathMacroTemplate(name,
-                               nargs, optionals, MacroTypeNewcommand, buffer_,
+                       cell->push_back(MathAtom(new MathMacroTemplate(buffer_, name,
+                               nargs, optionals, MacroTypeNewcommand,
                                optionalValues, def, display)));
                }
                
@@ -1180,8 +1181,8 @@ bool Parser::parse1(InsetMathGrid & grid, unsigned flags,
                        if (nextToken().cat() == catBegin)
                                parse(display, FLAG_ITEM, InsetMath::MATH_MODE);
 
-                       cell->push_back(MathAtom(new MathMacroTemplate(name,
-                               nargs, optionals, MacroTypeNewcommandx, buffer_,
+                       cell->push_back(MathAtom(new MathMacroTemplate(buffer_, name,
+                               nargs, optionals, MacroTypeNewcommandx,
                                optionalValues, def, display)));
                }
 
@@ -1190,7 +1191,7 @@ bool Parser::parse1(InsetMathGrid & grid, unsigned flags,
                                error("bad math environment");
                                break;
                        }
-                       cell->push_back(MathAtom(new InsetMathHull(hullSimple, buffer_)));
+                       cell->push_back(MathAtom(new InsetMathHull(buffer_, hullSimple)));
                        parse2(cell->back(), FLAG_SIMPLE2, InsetMath::MATH_MODE, false);
                }
 
@@ -1199,7 +1200,7 @@ bool Parser::parse1(InsetMathGrid & grid, unsigned flags,
                                error("bad math environment");
                                break;
                        }
-                       cell->push_back(MathAtom(new InsetMathHull(hullEquation, buffer_)));
+                       cell->push_back(MathAtom(new InsetMathHull(buffer_, hullEquation)));
                        parse2(cell->back(), FLAG_EQUATION, InsetMath::MATH_MODE, false);
                }
 
@@ -1326,11 +1327,11 @@ bool Parser::parse1(InsetMathGrid & grid, unsigned flags,
                        MathData ar;
                        parse(ar, FLAG_OPTION, mode);
                        if (ar.size()) {
-                               cell->push_back(MathAtom(new InsetMathRoot));
+                               cell->push_back(MathAtom(new InsetMathRoot(buffer_)));
                                cell->back().nucleus()->cell(0) = ar;
                                parse(cell->back().nucleus()->cell(1), FLAG_ITEM, mode);
                        } else {
-                               cell->push_back(MathAtom(new InsetMathSqrt));
+                               cell->push_back(MathAtom(new InsetMathSqrt(buffer_)));
                                parse(cell->back().nucleus()->cell(0), FLAG_ITEM, mode);
                        }
                }
@@ -1340,11 +1341,11 @@ bool Parser::parse1(InsetMathGrid & grid, unsigned flags,
                        MathData ar;
                        parse(ar, FLAG_OPTION, mode);
                        if (ar.size()) {
-                               cell->push_back(MathAtom(new InsetMathFrac(InsetMathFrac::UNIT)));
+                               cell->push_back(MathAtom(new InsetMathFrac(buffer_, InsetMathFrac::UNIT)));
                                cell->back().nucleus()->cell(0) = ar;
                                parse(cell->back().nucleus()->cell(1), FLAG_ITEM, mode);
                        } else {
-                               cell->push_back(MathAtom(new InsetMathFrac(InsetMathFrac::UNIT, 1)));
+                               cell->push_back(MathAtom(new InsetMathFrac(buffer_, InsetMathFrac::UNIT, 1)));
                                parse(cell->back().nucleus()->cell(0), FLAG_ITEM, mode);
                        }
                }
@@ -1354,10 +1355,10 @@ bool Parser::parse1(InsetMathGrid & grid, unsigned flags,
                        MathData ar;
                        parse(ar, FLAG_OPTION, mode);
                        if (ar.size()) {
-                               cell->push_back(MathAtom(new InsetMathFrac(InsetMathFrac::UNITFRAC, 3)));
+                               cell->push_back(MathAtom(new InsetMathFrac(buffer_, InsetMathFrac::UNITFRAC, 3)));
                                cell->back().nucleus()->cell(2) = ar;
                        } else {
-                               cell->push_back(MathAtom(new InsetMathFrac(InsetMathFrac::UNITFRAC)));
+                               cell->push_back(MathAtom(new InsetMathFrac(buffer_, InsetMathFrac::UNITFRAC)));
                        }
                        parse(cell->back().nucleus()->cell(0), FLAG_ITEM, mode);
                        parse(cell->back().nucleus()->cell(1), FLAG_ITEM, mode);
@@ -1368,11 +1369,11 @@ bool Parser::parse1(InsetMathGrid & grid, unsigned flags,
                        docstring const arg = getArg('[', ']');
                        //lyxerr << "got so far: '" << arg << "'" << endl;                              
                                if (arg == "l")
-                                       cell->push_back(MathAtom(new InsetMathFrac(InsetMathFrac::CFRACLEFT)));
+                                       cell->push_back(MathAtom(new InsetMathFrac(buffer_, InsetMathFrac::CFRACLEFT)));
                                else if (arg == "r")
-                                       cell->push_back(MathAtom(new InsetMathFrac(InsetMathFrac::CFRACRIGHT)));
+                                       cell->push_back(MathAtom(new InsetMathFrac(buffer_, InsetMathFrac::CFRACRIGHT)));
                                else if (arg.empty() || arg == "c")
-                                       cell->push_back(MathAtom(new InsetMathFrac(InsetMathFrac::CFRAC)));
+                                       cell->push_back(MathAtom(new InsetMathFrac(buffer_, InsetMathFrac::CFRAC)));
                                else {
                                        error("found invalid optional argument");
                                        break;
@@ -1382,14 +1383,14 @@ bool Parser::parse1(InsetMathGrid & grid, unsigned flags,
                }
 
                else if (t.cs() == "xrightarrow" || t.cs() == "xleftarrow") {
-                       cell->push_back(createInsetMath(t.cs()));
+                       cell->push_back(createInsetMath(t.cs(), buf));
                        parse(cell->back().nucleus()->cell(1), FLAG_OPTION, mode);
                        parse(cell->back().nucleus()->cell(0), FLAG_ITEM, mode);
                }
 
                else if (t.cs() == "ref" || t.cs() == "eqref" || t.cs() == "prettyref"
                          || t.cs() == "pageref" || t.cs() == "vpageref" || t.cs() == "vref") {
-                       cell->push_back(MathAtom(new InsetMathRef(t.cs())));
+                       cell->push_back(MathAtom(new InsetMathRef(buffer_, t.cs())));
                        parse(cell->back().nucleus()->cell(1), FLAG_OPTION, mode);
                        parse(cell->back().nucleus()->cell(0), FLAG_ITEM, mode);
                }
@@ -1408,7 +1409,7 @@ bool Parser::parse1(InsetMathGrid & grid, unsigned flags,
                        skipSpaces();
                        Token const & tr = getToken();
                        docstring const r = tr.cs() == "|" ? from_ascii("Vert") : tr.asString();
-                       cell->push_back(MathAtom(new InsetMathDelim(l, r, ar)));
+                       cell->push_back(MathAtom(new InsetMathDelim(buf, l, r, ar)));
                }
 
                else if (t.cs() == "right") {
@@ -1426,7 +1427,7 @@ bool Parser::parse1(InsetMathGrid & grid, unsigned flags,
                        if (name == "array" || name == "subarray") {
                                docstring const valign = parse_verbatim_option() + 'c';
                                docstring const halign = parse_verbatim_item();
-                               cell->push_back(MathAtom(new InsetMathArray(name,
+                               cell->push_back(MathAtom(new InsetMathArray(buffer_, name,
                                        InsetMathGrid::guessColumns(halign), 1, (char)valign[0], halign)));
                                parse2(cell->back(), FLAG_END, mode, false);
                        }
@@ -1434,13 +1435,13 @@ bool Parser::parse1(InsetMathGrid & grid, unsigned flags,
                        else if (name == "tabular") {
                                docstring const valign = parse_verbatim_option() + 'c';
                                docstring const halign = parse_verbatim_item();
-                               cell->push_back(MathAtom(new InsetMathTabular(name,
+                               cell->push_back(MathAtom(new InsetMathTabular(buffer_, name,
                                        InsetMathGrid::guessColumns(halign), 1, (char)valign[0], halign)));
                                parse2(cell->back(), FLAG_END, InsetMath::TEXT_MODE, false);
                        }
 
                        else if (name == "split" || name == "cases") {
-                               cell->push_back(createInsetMath(name));
+                               cell->push_back(createInsetMath(name, buf));
                                parse2(cell->back(), FLAG_END, mode, false);
                        }
 
@@ -1448,7 +1449,7 @@ bool Parser::parse1(InsetMathGrid & grid, unsigned flags,
                                docstring const valign = parse_verbatim_option() + 'c';
                                // ignore this for a while
                                getArg('{', '}');
-                               cell->push_back(MathAtom(new InsetMathSplit(name, (char)valign[0])));
+                               cell->push_back(MathAtom(new InsetMathSplit(buffer_, name, (char)valign[0])));
                                parse2(cell->back(), FLAG_END, mode, false);
                        }
 
@@ -1457,7 +1458,7 @@ bool Parser::parse1(InsetMathGrid & grid, unsigned flags,
                                        error("bad math environment");
                                        break;
                                }
-                               cell->push_back(MathAtom(new InsetMathHull(hullSimple, buffer_)));
+                               cell->push_back(MathAtom(new InsetMathHull(buffer_, hullSimple)));
                                parse2(cell->back(), FLAG_END, InsetMath::MATH_MODE, true);
                        }
 
@@ -1467,7 +1468,7 @@ bool Parser::parse1(InsetMathGrid & grid, unsigned flags,
                                        error("bad math environment");
                                        break;
                                }
-                               cell->push_back(MathAtom(new InsetMathHull(hullEquation, buffer_)));
+                               cell->push_back(MathAtom(new InsetMathHull(buffer_, hullEquation)));
                                parse2(cell->back(), FLAG_END, InsetMath::MATH_MODE, (name == "equation"));
                        }
 
@@ -1476,7 +1477,7 @@ bool Parser::parse1(InsetMathGrid & grid, unsigned flags,
                                        error("bad math environment");
                                        break;
                                }
-                               cell->push_back(MathAtom(new InsetMathHull(hullEqnArray, buffer_)));
+                               cell->push_back(MathAtom(new InsetMathHull(buffer_, hullEqnArray)));
                                parse2(cell->back(), FLAG_END, InsetMath::MATH_MODE, !stared(name));
                        }
 
@@ -1485,7 +1486,7 @@ bool Parser::parse1(InsetMathGrid & grid, unsigned flags,
                                        error("bad math environment");
                                        break;
                                }
-                               cell->push_back(MathAtom(new InsetMathHull(hullAlign, buffer_)));
+                               cell->push_back(MathAtom(new InsetMathHull(buffer_, hullAlign)));
                                parse2(cell->back(), FLAG_END, InsetMath::MATH_MODE, !stared(name));
                        }
 
@@ -1494,7 +1495,7 @@ bool Parser::parse1(InsetMathGrid & grid, unsigned flags,
                                        error("bad math environment");
                                        break;
                                }
-                               cell->push_back(MathAtom(new InsetMathHull(hullFlAlign, buffer_)));
+                               cell->push_back(MathAtom(new InsetMathHull(buffer_, hullFlAlign)));
                                parse2(cell->back(), FLAG_END, InsetMath::MATH_MODE, !stared(name));
                        }
 
@@ -1505,7 +1506,7 @@ bool Parser::parse1(InsetMathGrid & grid, unsigned flags,
                                }
                                // ignore this for a while
                                getArg('{', '}');
-                               cell->push_back(MathAtom(new InsetMathHull(hullAlignAt, buffer_)));
+                               cell->push_back(MathAtom(new InsetMathHull(buffer_, hullAlignAt)));
                                parse2(cell->back(), FLAG_END, InsetMath::MATH_MODE, !stared(name));
                        }
 
@@ -1516,7 +1517,7 @@ bool Parser::parse1(InsetMathGrid & grid, unsigned flags,
                                }
                                // ignore this for a while
                                getArg('{', '}');
-                               cell->push_back(MathAtom(new InsetMathHull(hullXAlignAt, buffer_)));
+                               cell->push_back(MathAtom(new InsetMathHull(buffer_, hullXAlignAt)));
                                parse2(cell->back(), FLAG_END, InsetMath::MATH_MODE, !stared(name));
                        }
 
@@ -1527,7 +1528,7 @@ bool Parser::parse1(InsetMathGrid & grid, unsigned flags,
                                }
                                // ignore this for a while
                                getArg('{', '}');
-                               cell->push_back(MathAtom(new InsetMathHull(hullXXAlignAt, buffer_)));
+                               cell->push_back(MathAtom(new InsetMathHull(buffer_, hullXXAlignAt)));
                                parse2(cell->back(), FLAG_END, InsetMath::MATH_MODE, !stared(name));
                        }
 
@@ -1536,7 +1537,7 @@ bool Parser::parse1(InsetMathGrid & grid, unsigned flags,
                                        error("bad math environment");
                                        break;
                                }
-                               cell->push_back(MathAtom(new InsetMathHull(hullMultline, buffer_)));
+                               cell->push_back(MathAtom(new InsetMathHull(buffer_, hullMultline)));
                                parse2(cell->back(), FLAG_END, InsetMath::MATH_MODE, !stared(name));
                        }
 
@@ -1545,17 +1546,18 @@ bool Parser::parse1(InsetMathGrid & grid, unsigned flags,
                                        error("bad math environment");
                                        break;
                                }
-                               cell->push_back(MathAtom(new InsetMathHull(hullGather, buffer_)));
+                               cell->push_back(MathAtom(new InsetMathHull(buffer_, hullGather)));
                                parse2(cell->back(), FLAG_END, InsetMath::MATH_MODE, !stared(name));
                        }
 
                        else if (latexkeys const * l = in_word_set(name)) {
                                if (l->inset == "matrix") {
-                                       cell->push_back(createInsetMath(name));
+                                       cell->push_back(createInsetMath(name, buf));
                                        parse2(cell->back(), FLAG_END, mode, false);
                                } else if (l->inset == "split") {
                                        docstring const valign = parse_verbatim_option() + 'c';
-                                       cell->push_back(MathAtom(new InsetMathSplit(name, (char)valign[0])));
+                                       cell->push_back(MathAtom(
+                                               new InsetMathSplit(buffer_, name, (char)valign[0])));
                                        parse2(cell->back(), FLAG_END, mode, false);
                                } else {
                                        success_ = false;
@@ -1568,7 +1570,7 @@ bool Parser::parse1(InsetMathGrid & grid, unsigned flags,
                                                       << "'." << endl;
                                        }
                                        // create generic environment inset
-                                       cell->push_back(MathAtom(new InsetMathEnv(name)));
+                                       cell->push_back(MathAtom(new InsetMathEnv(buffer_, name)));
                                        parse(cell->back().nucleus()->cell(0), FLAG_END, mode);
                                }
                        }
@@ -1581,7 +1583,7 @@ bool Parser::parse1(InsetMathGrid & grid, unsigned flags,
                                               << to_utf8(name) << "'" << endl;
                                }
                                // create generic environment inset
-                               cell->push_back(MathAtom(new InsetMathEnv(name)));
+                               cell->push_back(MathAtom(new InsetMathEnv(buffer_, name)));
                                parse(cell->back().nucleus()->cell(0), FLAG_END, mode);
                        }
                }
@@ -1617,7 +1619,7 @@ bool Parser::parse1(InsetMathGrid & grid, unsigned flags,
                        if (grid.asHullInset()) {
                                grid.asHullInset()->label(cellrow, label);
                        } else {
-                               cell->push_back(createInsetMath(t.cs()));
+                               cell->push_back(createInsetMath(t.cs(), buf));
                                cell->push_back(MathAtom(new InsetMathBrace(ar)));
                        }
                }
@@ -1625,7 +1627,7 @@ bool Parser::parse1(InsetMathGrid & grid, unsigned flags,
                else if (t.cs() == "choose" || t.cs() == "over"
                                || t.cs() == "atop" || t.cs() == "brace"
                                || t.cs() == "brack") {
-                       MathAtom at = createInsetMath(t.cs());
+                       MathAtom at = createInsetMath(t.cs(), buf);
                        at.nucleus()->cell(0) = *cell;
                        cell->clear();
                        parse(at.nucleus()->cell(1), flags, mode);
@@ -1635,25 +1637,25 @@ bool Parser::parse1(InsetMathGrid & grid, unsigned flags,
 
                else if (t.cs() == "color") {
                        docstring const color = parse_verbatim_item();
-                       cell->push_back(MathAtom(new InsetMathColor(true, color)));
+                       cell->push_back(MathAtom(new InsetMathColor(buffer_, true, color)));
                        parse(cell->back().nucleus()->cell(0), flags, mode);
                        return success_;
                }
 
                else if (t.cs() == "textcolor") {
                        docstring const color = parse_verbatim_item();
-                       cell->push_back(MathAtom(new InsetMathColor(false, color)));
+                       cell->push_back(MathAtom(new InsetMathColor(buffer_, false, color)));
                        parse(cell->back().nucleus()->cell(0), FLAG_ITEM, InsetMath::TEXT_MODE);
                }
 
                else if (t.cs() == "normalcolor") {
-                       cell->push_back(createInsetMath(t.cs()));
+                       cell->push_back(createInsetMath(t.cs(), buf));
                        parse(cell->back().nucleus()->cell(0), flags, mode);
                        return success_;
                }
 
                else if (t.cs() == "substack") {
-                       cell->push_back(createInsetMath(t.cs()));
+                       cell->push_back(createInsetMath(t.cs(), buf));
                        parse2(cell->back(), FLAG_ITEM, mode, false);
                }
 
@@ -1661,12 +1663,12 @@ bool Parser::parse1(InsetMathGrid & grid, unsigned flags,
                        odocstringstream os;
                        while (good() && nextToken().cat() != catBegin)
                                os << getToken().asInput();
-                       cell->push_back(createInsetMath(t.cs() + os.str()));
+                       cell->push_back(createInsetMath(t.cs() + os.str(), buf));
                        parse2(cell->back(), FLAG_ITEM, mode, false);
                }
 
                else if (t.cs() == "framebox" || t.cs() == "makebox") {
-                       cell->push_back(createInsetMath(t.cs()));
+                       cell->push_back(createInsetMath(t.cs(), buf));
                        parse(cell->back().nucleus()->cell(0), FLAG_OPTION, InsetMath::TEXT_MODE);
                        parse(cell->back().nucleus()->cell(1), FLAG_OPTION, InsetMath::TEXT_MODE);
                        parse(cell->back().nucleus()->cell(2), FLAG_ITEM, InsetMath::TEXT_MODE);
@@ -1675,9 +1677,9 @@ bool Parser::parse1(InsetMathGrid & grid, unsigned flags,
                else if (t.cs() == "tag") {
                        if (nextToken().character() == '*') {
                                getToken();
-                               cell->push_back(createInsetMath(t.cs() + '*'));
+                               cell->push_back(createInsetMath(t.cs() + '*', buf));
                        } else
-                               cell->push_back(createInsetMath(t.cs()));
+                               cell->push_back(createInsetMath(t.cs(), buf));
                        parse(cell->back().nucleus()->cell(0), FLAG_ITEM, InsetMath::TEXT_MODE);
                }
 
@@ -1690,10 +1692,10 @@ bool Parser::parse1(InsetMathGrid & grid, unsigned flags,
                        else {
                                // Since the Length class cannot use length variables
                                // we must not create an InsetMathSpace.
-                               cell->push_back(MathAtom(new MathMacro(name)));
+                               cell->push_back(MathAtom(new MathMacro(buffer_, name)));
                                MathData ar;
                                mathed_parse_cell(ar, '{' + arg + '}',
-                                               Parse::NORMAL, buffer_);
+                                               Parse::NORMAL);
                                cell->append(ar);
                        }
                }
@@ -1702,7 +1704,7 @@ bool Parser::parse1(InsetMathGrid & grid, unsigned flags,
                else if (t.cs() == "infer") {
                        MathData ar;
                        parse(ar, FLAG_OPTION, mode);
-                       cell->push_back(createInsetMath(t.cs()));
+                       cell->push_back(createInsetMath(t.cs(), buf));
                        parse2(cell->back(), FLAG_ITEM, mode, false);
                }
 
@@ -1772,19 +1774,19 @@ bool Parser::parse1(InsetMathGrid & grid, unsigned flags,
                                                cell->push_back(MathAtom(
                                                        new InsetMathBig(t.cs(), delim)));
                                        else {
-                                               cell->push_back(createInsetMath(t.cs()));
+                                               cell->push_back(createInsetMath(t.cs(), buf));
                                                putback();
                                        }
                                }
 
                                else if (l->inset == "font") {
-                                       cell->push_back(createInsetMath(t.cs()));
+                                       cell->push_back(createInsetMath(t.cs(), buf));
                                        parse(cell->back().nucleus()->cell(0),
                                                FLAG_ITEM, asMode(mode, l->extra));
                                }
 
                                else if (l->inset == "oldfont") {
-                                       cell->push_back(createInsetMath(t.cs()));
+                                       cell->push_back(createInsetMath(t.cs(), buf));
                                        parse(cell->back().nucleus()->cell(0),
                                                flags | FLAG_ALIGN, asMode(mode, l->extra));
                                        if (prevToken().cat() != catAlign &&
@@ -1794,7 +1796,7 @@ bool Parser::parse1(InsetMathGrid & grid, unsigned flags,
                                }
 
                                else if (l->inset == "style") {
-                                       cell->push_back(createInsetMath(t.cs()));
+                                       cell->push_back(createInsetMath(t.cs(), buf));
                                        parse(cell->back().nucleus()->cell(0),
                                                flags | FLAG_ALIGN, mode);
                                        if (prevToken().cat() != catAlign &&
@@ -1804,7 +1806,7 @@ bool Parser::parse1(InsetMathGrid & grid, unsigned flags,
                                }
 
                                else {
-                                       MathAtom at = createInsetMath(t.cs());
+                                       MathAtom at = createInsetMath(t.cs(), buf);
                                        for (InsetMath::idx_type i = 0; i < at->nargs(); ++i)
                                                parse(at.nucleus()->cell(i),
                                                        FLAG_ITEM, asMode(mode, l->extra));
@@ -1852,8 +1854,8 @@ bool Parser::parse1(InsetMathGrid & grid, unsigned flags,
                                }
                                if (!is_unicode_symbol) {
                                        MathAtom at = is_user_macro ?
-                                               MathAtom(new MathMacro(t.cs()))
-                                               : createInsetMath(t.cs());
+                                               MathAtom(new MathMacro(buffer_, t.cs()))
+                                               : createInsetMath(t.cs(), buf);
                                        InsetMath::mode_type m = mode;
                                        //if (m == InsetMath::UNDECIDED_MODE)
                                        //lyxerr << "default creation: m1: " << m << endl;
@@ -1891,40 +1893,38 @@ bool Parser::parse1(InsetMathGrid & grid, unsigned flags,
 } // anonymous namespace
 
 
-bool mathed_parse_cell(MathData & ar, docstring const & str,
-                      Parse::flags f, Buffer * buf)
+bool mathed_parse_cell(MathData & ar, docstring const & str, Parse::flags f)
 {
-       return Parser(str, f, buf).parse(ar, 0, f & Parse::TEXTMODE ?
+       return Parser(str, f, ar.buffer()).parse(ar, 0, f & Parse::TEXTMODE ?
                                InsetMath::TEXT_MODE : InsetMath::MATH_MODE);
 }
 
 
-bool mathed_parse_cell(MathData & ar, istream & is,
-                      Parse::flags f, Buffer * buf)
+bool mathed_parse_cell(MathData & ar, istream & is, Parse::flags f)
 {
-       return Parser(is, f, buf).parse(ar, 0, f & Parse::TEXTMODE ?
+       return Parser(is, f, ar.buffer()).parse(ar, 0, f & Parse::TEXTMODE ?
                                InsetMath::TEXT_MODE : InsetMath::MATH_MODE);
 }
 
 
-bool mathed_parse_normal(MathAtom & t, docstring const & str,
-                        Parse::flags f, Buffer * buf)
+bool mathed_parse_normal(Buffer * buf, MathAtom & t, docstring const & str,
+                        Parse::flags f)
 {
        return Parser(str, f, buf).parse(t);
 }
 
 
-bool mathed_parse_normal(MathAtom & t, Lexer & lex,
-                        Parse::flags f, Buffer * buf)
+bool mathed_parse_normal(Buffer * buf, MathAtom & t, Lexer & lex,
+                        Parse::flags f)
 {
        return Parser(lex, f, buf).parse(t);
 }
 
 
 bool mathed_parse_normal(InsetMathGrid & grid, docstring const & str,
-                        Parse::flags f, Buffer * buf)
+                        Parse::flags f)
 {
-       return Parser(str, f, buf).parse1(grid, 0, f & Parse::TEXTMODE ?
+       return Parser(str, f, &grid.buffer()).parse1(grid, 0, f & Parse::TEXTMODE ?
                        InsetMath::TEXT_MODE : InsetMath::MATH_MODE, false);
 }
 
index 31cbecc2723d07e89cd555e2435dd10c8d78896e..c4ae6f89949bf3bb93e1b6edd82531a79743b805 100644 (file)
@@ -62,25 +62,25 @@ public:
 latexkeys const * in_word_set(docstring const & str);
 
 /// parse formula from a string
-bool mathed_parse_normal(MathAtom &, docstring const &,
-               Parse::flags f = Parse::NORMAL, Buffer * buf = 0);
+bool mathed_parse_normal(Buffer * buf, MathAtom &, docstring const &,
+               Parse::flags f = Parse::NORMAL);
 
 /// parse formula from the LyX lexxer
-bool mathed_parse_normal(MathAtom &, Lexer &,
-               Parse::flags f = Parse::NORMAL, Buffer * buf = 0);
+bool mathed_parse_normal(Buffer * buf, MathAtom &, Lexer &,
+               Parse::flags f = Parse::NORMAL);
 
 /// parse formula from a string into a grid
 bool mathed_parse_normal(InsetMathGrid &, docstring const &,
-               Parse::flags f = Parse::NORMAL, Buffer * buf = 0);
+               Parse::flags f = Parse::NORMAL);
 
 /// parse a single cell from a string
 bool mathed_parse_cell(MathData & ar, docstring const &,
-               Parse::flags f = Parse::NORMAL, Buffer * buf = 0);
+               Parse::flags f = Parse::NORMAL);
 
 /// parse a single cell from a stream. Only use this for reading from .lyx
 /// file format, for the reason see Parser::tokenize(std::istream &).
 bool mathed_parse_cell(MathData & ar, std::istream &,
-               Parse::flags f = Parse::NORMAL, Buffer * buf = 0);
+               Parse::flags f = Parse::NORMAL);
 
 void initParser();