]> git.lyx.org Git - lyx.git/commitdiff
Force a Buffer * argument to math insets constructor
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Wed, 24 Apr 2024 13:07:15 +0000 (15:07 +0200)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Wed, 24 Apr 2024 14:27:04 +0000 (16:27 +0200)
Make sure that math insets have a proper buffer. To this end, make the
Buffer* parameter of InsetMath mandatory and fix the compilation
errors that ensue.

36 files changed:
src/Cursor.cpp
src/mathed/InsetMath.h
src/mathed/InsetMathBig.cpp
src/mathed/InsetMathBig.h
src/mathed/InsetMathBrace.cpp
src/mathed/InsetMathBrace.h
src/mathed/InsetMathChar.cpp
src/mathed/InsetMathChar.h
src/mathed/InsetMathDots.cpp
src/mathed/InsetMathDots.h
src/mathed/InsetMathExInt.cpp
src/mathed/InsetMathGrid.cpp
src/mathed/InsetMathHull.cpp
src/mathed/InsetMathKern.cpp
src/mathed/InsetMathKern.h
src/mathed/InsetMathMacro.cpp
src/mathed/InsetMathMacroArgument.cpp
src/mathed/InsetMathMacroArgument.h
src/mathed/InsetMathMacroTemplate.cpp
src/mathed/InsetMathNest.cpp
src/mathed/InsetMathNumber.cpp
src/mathed/InsetMathNumber.h
src/mathed/InsetMathSpace.cpp
src/mathed/InsetMathSpace.h
src/mathed/InsetMathSpecialChar.cpp
src/mathed/InsetMathSpecialChar.h
src/mathed/InsetMathString.cpp
src/mathed/InsetMathString.h
src/mathed/InsetMathSymbol.cpp
src/mathed/InsetMathSymbol.h
src/mathed/InsetMathUnknown.cpp
src/mathed/InsetMathUnknown.h
src/mathed/MathData.cpp
src/mathed/MathExtern.cpp
src/mathed/MathFactory.cpp
src/mathed/MathParser.cpp

index 0e1c3ded5558c9dd62283ad29d738fc1c15e552d..45ae34c4b265c3fc14d093ba0fca680e1e7ad5e8 100644 (file)
@@ -1492,7 +1492,7 @@ void Cursor::insert(char_type c)
        LASSERT(!empty(), return);
        if (inMathed()) {
                cap::selClearOrDel(*this);
-               insert(new InsetMathChar(c));
+               insert(new InsetMathChar(buffer(), c));
        } else {
                text()->insertChar(*this, c);
        }
@@ -1576,7 +1576,7 @@ void Cursor::niceInsert(MathAtom const & t)
                docstring const name = t->asMacro()->name();
                MacroData const * data = buffer()->getMacro(name);
                if (data && data->numargs() - data->optionals() > 0) {
-                       plainInsert(MathAtom(new InsetMathBrace(ar)));
+                       plainInsert(MathAtom(new InsetMathBrace(buffer(), ar)));
                        posBackward();
                }
        }
@@ -1836,7 +1836,7 @@ bool Cursor::macroModeClose(bool cancel)
        // finally put the macro argument behind, if needed
        if (macroArg) {
                if (selection.size() > 1 || selection[0]->asScriptInset())
-                       plainInsert(MathAtom(new InsetMathBrace(selection)));
+                       plainInsert(MathAtom(new InsetMathBrace(buffer(), selection)));
                else
                        insert(selection);
        }
index 7ea8a7cfc19d37a32fa0838e130d555ddc34bc25..34484028bb8c083eafaaaf79dfc06df25da28572 100644 (file)
@@ -120,7 +120,7 @@ class ReplaceData;
 class InsetMath : public Inset {
 public:
        ///
-       explicit InsetMath(Buffer * buf = 0) : Inset(buf) {}
+       explicit InsetMath(Buffer * buf) : Inset(buf) {}
        /// identification as math inset
        InsetMath * asInsetMath() override { return this; }
        /// identification as math inset
index 4972911b7589cd915beed900fe798389db68f018..93661e1f566add60a57a798a032283606db4f85e 100644 (file)
@@ -28,8 +28,8 @@
 namespace lyx {
 
 
-InsetMathBig::InsetMathBig(docstring const & name, docstring const & delim)
-       : name_(name), delim_(delim)
+InsetMathBig::InsetMathBig(Buffer * buf, docstring const & name, docstring const & delim)
+       : InsetMath(buf), name_(name), delim_(delim)
 {}
 
 
index 09f04a6f78ebe63ea7b7eb18ed2fd53fd49f06d8..5f00006793775655a18298f55a35ad0eac874f57 100644 (file)
@@ -21,7 +21,7 @@ namespace lyx {
 class InsetMathBig : public InsetMath {
 public:
        ///
-       InsetMathBig(docstring const & name, docstring const & delim);
+       InsetMathBig(Buffer * buf, docstring const & name, docstring const & delim);
        ///
        docstring name() const override;
        /// class is different for l(eft), r(ight) and m(iddle)
index b98d29a7e8627210d29df52654ef6e1574fa2789..db779563cdec5601185cb2165df7aef554873dc4 100644 (file)
@@ -32,8 +32,8 @@ InsetMathBrace::InsetMathBrace(Buffer * buf)
 {}
 
 
-InsetMathBrace::InsetMathBrace(MathData const & ar)
-       : InsetMathNest(const_cast<Buffer *>(ar.buffer()), 1),
+InsetMathBrace::InsetMathBrace(Buffer * buf, MathData const & ar)
+       : InsetMathNest(buf, 1),
          current_mode_(UNDECIDED_MODE)
 {
        cell(0) = ar;
index cde1967761eea418d441307bee654029ed42604d..b8f924dac08caee2cedefc7e1d869599e8032797 100644 (file)
@@ -24,7 +24,7 @@ public:
        ///
        explicit InsetMathBrace(Buffer * buf);
        ///
-       explicit InsetMathBrace(MathData const & ar);
+       explicit InsetMathBrace(Buffer * buf, MathData const & ar);
        /// identifies brace insets
        InsetMathBrace * asBraceInset() override { return this; }
        /// identifies brace insets
index a642a5e6da14e8b02f16f9fbf1efbd9c71be8d95..199982a5f7a13c829548adc92e9bdef6a71bce69 100644 (file)
@@ -92,8 +92,8 @@ static bool slanted(char_type c)
 }
 
 
-InsetMathChar::InsetMathChar(char_type c)
-       : char_(c), kerning_(0), subst_(makeSubstitute(c))
+InsetMathChar::InsetMathChar(Buffer * buf, char_type c)
+       : InsetMath(buf), char_(c), kerning_(0), subst_(makeSubstitute(c))
 {}
 
 
index be38a1398bb794f111201bfde6bfde577043970a..e98f33465d0ca80285a67b7e932f99ec07316b70 100644 (file)
@@ -22,7 +22,7 @@ class latexkeys;
 class InsetMathChar : public InsetMath {
 public:
        ///
-       explicit InsetMathChar(char_type c);
+       explicit InsetMathChar(Buffer * buf, char_type c);
        ///
        void metrics(MetricsInfo & mi, Dimension & dim) const override;
        ///
index ed0db97de6acc24402a51e0edfe4a6604ca77e06..2e9a99293cd586313a2459bdbe4796990508fe57 100644 (file)
@@ -25,8 +25,8 @@
 
 namespace lyx {
 
-InsetMathDots::InsetMathDots(latexkeys const * key)
-       : dh_(0), key_(key)
+InsetMathDots::InsetMathDots(Buffer * buf, latexkeys const * key)
+       : InsetMath(buf), dh_(0), key_(key)
 {}
 
 
index 5deffe5422aee15a0159e5de450234acec82fb69..6a733ecd68a38b87eb18b644fbfd31eb10ba6193 100644 (file)
@@ -23,7 +23,7 @@ class latexkeys;
 class InsetMathDots : public InsetMath {
 public:
        ///
-       explicit InsetMathDots(latexkeys const * key);
+       explicit InsetMathDots(Buffer * buf, latexkeys const * key);
        ///
        void metrics(MetricsInfo & mi, Dimension & dim) const override;
        ///
index 03f516dd8370e5ee4a69c14f34461afbce755e09..65ef5e78df2a235baf755343ba52c19d99ea8475 100644 (file)
@@ -129,7 +129,7 @@ void InsetMathExInt::mathmlize(MathMLStream & ms) const
        // If we should decide to do so later, then we'll need to re-merge
        // r32566 and r32568.
        // So right now this only handles integrals.
-       InsetMathSymbol sym(symbol_);
+       InsetMathSymbol sym(buffer_, symbol_);
        bool const lower = !cell(2).empty();
        bool const upper = !cell(3).empty();
        if (lower && upper)
@@ -164,7 +164,7 @@ void InsetMathExInt::htmlize(HtmlStream & os) const
 {
        // At the moment, we are not extracting sums and the like for HTML.
        // So right now this only handles integrals.
-       InsetMathSymbol sym(symbol_);
+       InsetMathSymbol sym(buffer_, symbol_);
        bool const lower = !cell(2).empty();
        bool const upper = !cell(3).empty();
 
index 05242aca00d5afb46b11f60ed018d1c1c6a58592..c775ff4943c2b24f4a85b5cb583d47f253c89a56 100644 (file)
@@ -1598,7 +1598,7 @@ void InsetMathGrid::doDispatch(Cursor & cur, FuncRequest & cmd)
                        else {
                                for (unsigned int l = 0; l < grid.rowinfo_[0].lines; ++l) {
                                         cur.cell().insert(0,
-                                               MathAtom(new InsetMathUnknown(from_ascii("\\hline"))));
+                                               MathAtom(new InsetMathUnknown(buffer_, from_ascii("\\hline"))));
                                         cur.pos()++;
                                }
                        }
@@ -1624,7 +1624,7 @@ void InsetMathGrid::doDispatch(Cursor & cur, FuncRequest & cmd)
                                        for (unsigned int l = 0; l < grid.rowinfo_[r].lines; ++l) {
                                                idx_type i = index(r + startrow, 0);
                                                cell(i).insert(0,
-                                                       MathAtom(new InsetMathUnknown(from_ascii("\\hline"))));
+                                                       MathAtom(new InsetMathUnknown(buffer_, from_ascii("\\hline"))));
                                        }
                                }
                                // append columns for the left over horizontal cells
@@ -1649,7 +1649,7 @@ void InsetMathGrid::doDispatch(Cursor & cur, FuncRequest & cmd)
                                else {
                                        for (unsigned int l = 0; l < grid.rowinfo_[r].lines; ++l) {
                                                cell(i).insert(0,
-                                                       MathAtom(new InsetMathUnknown(from_ascii("\\hline"))));
+                                                       MathAtom(new InsetMathUnknown(buffer_, from_ascii("\\hline"))));
                                        }
                                }
                        }
index 9c93f89f2104202178707e0f8d702ade2ebeaa53..6bbd11ebaab5a1a3792ca16b6c8b0ad671defc4c 100644 (file)
@@ -1793,7 +1793,7 @@ void InsetMathHull::doExtern(Cursor & cur, FuncRequest & func)
        }
 
        MathData eq(buffer_);
-       eq.push_back(MathAtom(new InsetMathChar('=')));
+       eq.push_back(MathAtom(new InsetMathChar(buffer_, '=')));
 
        // go to first item in line
        cur.idx() -= cur.idx() % ncols();
index f99a210a9d398a76d821424ec3796392959e8c54..20544e60e21a4dcc25fd6a8da4e15d198b711b4e 100644 (file)
 
 namespace lyx {
 
-InsetMathKern::InsetMathKern()
+InsetMathKern::InsetMathKern(Buffer * buf)
+       : InsetMath(buf)
 {
 }
 
 
-InsetMathKern::InsetMathKern(Length const & w)
-       : wid_(w)
+InsetMathKern::InsetMathKern(Buffer * buf, Length const & w)
+       : InsetMath(buf), wid_(w)
 {
 }
 
 
-InsetMathKern::InsetMathKern(docstring const & s)
-       : wid_(to_utf8(s))
+InsetMathKern::InsetMathKern(Buffer * buf, docstring const & s)
+       : InsetMath(buf), wid_(to_utf8(s))
 {
 }
 
index c562250a363b00ab9b10c2074c8bcd5067ab7093..742ecfa8220ec3ab0bd230417c33f54ae86902af 100644 (file)
@@ -26,11 +26,11 @@ namespace lyx {
 class InsetMathKern : public InsetMath {
 public:
        ///
-       InsetMathKern();
+       InsetMathKern(Buffer * buf);
        ///
-       explicit InsetMathKern(Length const & wid);
+       explicit InsetMathKern(Buffer * buf, Length const & wid);
        ///
-       explicit InsetMathKern(docstring const & wid);
+       explicit InsetMathKern(Buffer * buf, docstring const & wid);
        ///
        void metrics(MetricsInfo & mi, Dimension & dim) const override;
        ///
index 6a5f504661f34a6debae4a2f70fa013c991b7961..9d67c7807796236b6ee9555166920aa87bc069ba 100644 (file)
@@ -59,10 +59,12 @@ class InsetArgumentProxy : public InsetMath {
 public:
        ///
        InsetArgumentProxy(InsetMathMacro * mathMacro, size_t idx)
-               : mathMacro_(mathMacro), idx_(idx), def_(&mathMacro->buffer()) {}
+               : InsetMath(&mathMacro->buffer()), mathMacro_(mathMacro), idx_(idx),
+                 def_(&mathMacro->buffer()) {}
        ///
        InsetArgumentProxy(InsetMathMacro * mathMacro, size_t idx, docstring const & def)
-               : mathMacro_(mathMacro), idx_(idx), def_(&mathMacro->buffer())
+               : InsetMath(&mathMacro->buffer()), mathMacro_(mathMacro), idx_(idx),
+                 def_(&mathMacro->buffer())
        {
                        asArray(def, def_);
        }
index 7352b3ac8712afef28c71060675801112ff4d5a0..0c3e4dd97fad15eb0e30fe6e50f42f2c402bef7d 100644 (file)
@@ -52,8 +52,8 @@ void InsetMathHash::normalize(NormalStream & os) const
 }
 
 
-InsetMathMacroArgument::InsetMathMacroArgument(int n)
-       : number_(n)
+InsetMathMacroArgument::InsetMathMacroArgument(Buffer * buf, int n)
+       : InsetMathHash(buf), number_(n)
 {
        if (n < 1 || n > 9) {
                LYXERR0("InsetMathMacroArgument::InsetMathMacroArgument: wrong Argument id: "
index c11a9a6dbb2928b31c0aacb93e05db3f4a162f94..4ca277016a7400b090bde5b1e0e7c411b6a9b9ec 100644 (file)
@@ -24,7 +24,8 @@ namespace lyx {
 // A # that failed to parse
 class InsetMathHash : public InsetMath {
 public:
-       explicit InsetMathHash(docstring const & str = docstring()) : str_('#' + str) {}
+       explicit InsetMathHash(Buffer * buf, docstring const & str = docstring())
+               : InsetMath(buf), str_('#' + str) {}
        ///
        void metrics(MetricsInfo & mi, Dimension & dim) const override;
        ///
@@ -47,7 +48,7 @@ protected:
 class InsetMathMacroArgument : public InsetMathHash {
 public:
        /// Assumes 0 < number <= 9
-       explicit InsetMathMacroArgument(int number);
+       explicit InsetMathMacroArgument(Buffer * buf, int number);
        ///
        int number() const { return number_; }
        /// Assumes 0 < n <= 9
index 3dbc08c02c3c07e6720e39a29cde6199e6c7bf8c..2a2a87eb57e73cea1e59444f0c82e6d5ad8ddecc 100644 (file)
@@ -249,7 +249,8 @@ void InsetDisplayLabelBox::draw(PainterInfo & pi, int x, int y) const
 class InsetMathWrapper : public InsetMath {
 public:
        ///
-       explicit InsetMathWrapper(MathData const * value) : value_(value) {}
+       explicit InsetMathWrapper(Buffer * buf, MathData const * value)
+               : InsetMath(buf), value_(value) {}
        ///
        void metrics(MetricsInfo & mi, Dimension & dim) const override;
        ///
@@ -339,7 +340,7 @@ void InsetColoredCell::draw(PainterInfo & pi, int x, int y) const
 class InsetNameWrapper : public InsetMathWrapper {
 public:
        ///
-       InsetNameWrapper(MathData const * value, InsetMathMacroTemplate const & parent);
+       InsetNameWrapper(Buffer * buf, MathData const * value, InsetMathMacroTemplate const & parent);
        ///
        void metrics(MetricsInfo & mi, Dimension & dim) const override;
        ///
@@ -353,9 +354,9 @@ private:
 };
 
 
-InsetNameWrapper::InsetNameWrapper(MathData const * value,
+InsetNameWrapper::InsetNameWrapper(Buffer * buf, MathData const * value,
                                   InsetMathMacroTemplate const & parent)
-       : InsetMathWrapper(value), parent_(parent)
+       : InsetMathWrapper(buf, value), parent_(parent)
 {
 }
 
@@ -489,7 +490,7 @@ void InsetMathMacroTemplate::createLook(int args) const
        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)));
+       nameData.push_back(MathAtom(new InsetNameWrapper(buffer_, &cell(0), *this)));
 
        // [#1][#2]
        int i = 0;
@@ -506,44 +507,44 @@ void InsetMathMacroTemplate::createLook(int args) const
                                optData = &(*optData)[optData->size() - 1].nucleus()->cell(0);
                        }
 
-                       optData->push_back(MathAtom(new InsetMathChar('[')));
-                       optData->push_back(MathAtom(new InsetMathWrapper(&cell(1 + i))));
-                       optData->push_back(MathAtom(new InsetMathChar(']')));
+                       optData->push_back(MathAtom(new InsetMathChar(buffer_, '[')));
+                       optData->push_back(MathAtom(new InsetMathWrapper(buffer_, &cell(1 + i))));
+                       optData->push_back(MathAtom(new InsetMathChar(buffer_, ']')));
                }
        }
 
        // {#3}{#4}
        for (; i < numargs_; ++i) {
                MathData arg(buffer_);
-               arg.push_back(MathAtom(new InsetMathMacroArgument(i + 1)));
+               arg.push_back(MathAtom(new InsetMathMacroArgument(buffer_, i + 1)));
                if (i >= argsInLook_) {
                        look_.push_back(MathAtom(new InsetColoredCell(buffer_,
                                Color_mathmacrooldarg,
-                               MathAtom(new InsetMathBrace(arg)))));
+                               MathAtom(new InsetMathBrace(buffer_, arg)))));
                } else
-                       look_.push_back(MathAtom(new InsetMathBrace(arg)));
+                       look_.push_back(MathAtom(new InsetMathBrace(buffer_, arg)));
        }
        for (; i < argsInLook_; ++i) {
                MathData arg(buffer_);
-               arg.push_back(MathAtom(new InsetMathMacroArgument(i + 1)));
+               arg.push_back(MathAtom(new InsetMathMacroArgument(buffer_, i + 1)));
                look_.push_back(MathAtom(new InsetColoredCell(buffer_,
                        Color_mathmacronewarg,
-                       MathAtom(new InsetMathBrace(arg)))));
+                       MathAtom(new InsetMathBrace(buffer_, arg)))));
        }
 
        // :=
-       look_.push_back(MathAtom(new InsetMathChar(':')));
-       look_.push_back(MathAtom(new InsetMathChar('=')));
+       look_.push_back(MathAtom(new InsetMathChar(buffer_, ':')));
+       look_.push_back(MathAtom(new InsetMathChar(buffer_, '=')));
 
        // definition
        look_.push_back(MathAtom(
                new InsetLabelBox(buffer_, MathAtom(
-                       new InsetMathWrapper(&cell(defIdx()))), _("TeX"), *this,        true)));
+                       new InsetMathWrapper(buffer_, &cell(defIdx()))), _("TeX"), *this,       true)));
 
        // display
        look_.push_back(MathAtom(
                new InsetDisplayLabelBox(buffer_, MathAtom(
-                       new InsetMathWrapper(&cell(displayIdx()))), _("LyX"), *this)));
+                       new InsetMathWrapper(buffer_, &cell(displayIdx()))), _("LyX"), *this)));
 
        look_.setContentsBuffer();
 }
@@ -716,7 +717,7 @@ void InsetMathMacroTemplate::insertMissingArguments(int maxArg)
                if (found[i])
                        continue;
 
-               cell(idx).push_back(MathAtom(new InsetMathMacroArgument(i + 1)));
+               cell(idx).push_back(MathAtom(new InsetMathMacroArgument(buffer_, i + 1)));
        }
 }
 
@@ -886,9 +887,9 @@ void InsetMathMacroTemplate::insertParameter(Cursor & cur,
                if (addarg) {
                        shiftArguments(pos, 1);
 
-                       cell(defIdx()).push_back(MathAtom(new InsetMathMacroArgument(pos + 1)));
+                       cell(defIdx()).push_back(MathAtom(new InsetMathMacroArgument(buffer_, pos + 1)));
                        if (!cell(displayIdx()).empty())
-                               cell(displayIdx()).push_back(MathAtom(new InsetMathMacroArgument(pos + 1)));
+                               cell(displayIdx()).push_back(MathAtom(new InsetMathMacroArgument(buffer_, pos + 1)));
                }
 
                if (!greedy) {
index 844496d111545fd06fe0781af581fc3c202c7f7b..8d97ec101d47921203256548b31cf39f52a83bda 100644 (file)
@@ -1433,13 +1433,11 @@ void InsetMathNest::doDispatch(Cursor & cur, FuncRequest & cmd)
                        docstring const selection = grabAndEraseSelection(cur);
                        selClearOrDel(cur);
                        if (have_l)
-                               cur.insert(MathAtom(new InsetMathBig(lname,
-                                                               ldelim)));
+                               cur.insert(MathAtom(new InsetMathBig(buffer_, lname, ldelim)));
                        // first insert the right delimiter and then go back
                        // and re-insert the selection (bug 7088)
                        if (have_r) {
-                               cur.insert(MathAtom(new InsetMathBig(rname,
-                                                               rdelim)));
+                               cur.insert(MathAtom(new InsetMathBig(buffer_, rname, rdelim)));
                                cur.posBackward();
                        }
                        cur.niceInsert(selection);
@@ -1453,18 +1451,18 @@ void InsetMathNest::doDispatch(Cursor & cur, FuncRequest & cmd)
                cur.recordUndoSelection();
                string const name = cmd.getArg(0);
                if (name == "normal")
-                       cur.insert(MathAtom(new InsetMathSpace(" ", "")));
+                       cur.insert(MathAtom(new InsetMathSpace(buffer_, " ", "")));
                else if (name == "protected")
-                       cur.insert(MathAtom(new InsetMathSpace("~", "")));
+                       cur.insert(MathAtom(new InsetMathSpace(buffer_, "~", "")));
                else if (name == "thin" || name == "med" || name == "thick")
-                       cur.insert(MathAtom(new InsetMathSpace(name + "space", "")));
+                       cur.insert(MathAtom(new InsetMathSpace(buffer_, name + "space", "")));
                else if (name == "hfill*")
-                       cur.insert(MathAtom(new InsetMathSpace("hspace*{\\fill}", "")));
+                       cur.insert(MathAtom(new InsetMathSpace(buffer_, "hspace*{\\fill}", "")));
                else if (name == "quad" || name == "qquad" ||
                         name == "enspace" || name == "enskip" ||
                         name == "negthinspace" || name == "negmedspace" ||
                         name == "negthickspace" || name == "hfill")
-                       cur.insert(MathAtom(new InsetMathSpace(name, "")));
+                       cur.insert(MathAtom(new InsetMathSpace(buffer_, name, "")));
                else if (name == "hspace" || name == "hspace*") {
                        string const len = cmd.getArg(1);
                        if (len.empty() || !isValidLength(len)) {
@@ -1472,20 +1470,20 @@ void InsetMathNest::doDispatch(Cursor & cur, FuncRequest & cmd)
                                          "needs a valid length argument." << endl;
                                break;
                        }
-                       cur.insert(MathAtom(new InsetMathSpace(name, len)));
+                       cur.insert(MathAtom(new InsetMathSpace(buffer_, name, len)));
                } else
-                       cur.insert(MathAtom(new InsetMathSpace));
+                       cur.insert(MathAtom(new InsetMathSpace(buffer_)));
                break;
        }
 
        case LFUN_MATH_SPACE:
                cur.recordUndoSelection();
                if (cmd.argument().empty())
-                       cur.insert(MathAtom(new InsetMathSpace));
+                       cur.insert(MathAtom(new InsetMathSpace(buffer_)));
                else {
                        string const name = cmd.getArg(0);
                        string const len = cmd.getArg(1);
-                       cur.insert(MathAtom(new InsetMathSpace(name, len)));
+                       cur.insert(MathAtom(new InsetMathSpace(buffer_, name, len)));
                }
                break;
 
@@ -2024,7 +2022,7 @@ bool InsetMathNest::interpretChar(Cursor & cur, char_type const c)
                        cur.backspace();
                        int n = c - '0';
                        if (n >= 1 && n <= 9)
-                               cur.insert(new InsetMathMacroArgument(n));
+                               cur.insert(new InsetMathMacroArgument(buffer_, n));
                        return true;
                }
 
@@ -2057,7 +2055,7 @@ bool InsetMathNest::interpretChar(Cursor & cur, char_type const c)
                                asArray(p->selection(), sel);
                                cur.backspace();
                                if (c == '{')
-                                       cur.niceInsert(MathAtom(new InsetMathBrace(sel)));
+                                       cur.niceInsert(MathAtom(new InsetMathBrace(buffer_, sel)));
                                else
                                        cur.niceInsert(MathAtom(new InsetMathComment(sel)));
                        } else if (c == '#') {
@@ -2095,7 +2093,7 @@ bool InsetMathNest::interpretChar(Cursor & cur, char_type const c)
                                --cur.pos();
                                cur.cell().erase(cur.pos());
                                cur.plainInsert(MathAtom(
-                                       new InsetMathBig(name.substr(1), delim)));
+                                       new InsetMathBig(buffer_, name.substr(1), delim)));
                                return true;
                        }
                } else if (name == "\\smash" && c == '[') {
@@ -2142,7 +2140,7 @@ bool InsetMathNest::interpretChar(Cursor & cur, char_type const c)
                        cur.recordUndoInset();
                        docstring const safe = cap::grabAndEraseSelection(cur);
                        if (!cur.inRegexped() && !in_macro_name)
-                               cur.insert(MathAtom(new InsetMathUnknown(from_ascii("\\"), safe, false)));
+                               cur.insert(MathAtom(new InsetMathUnknown(buffer_, from_ascii("\\"), safe, false)));
                        else
                                cur.niceInsert(createInsetMath("backslash", buf));
                }
@@ -2238,7 +2236,7 @@ bool InsetMathNest::interpretChar(Cursor & cur, char_type const c)
                        return true;
                }
                if (currentMode() == InsetMath::MATH_MODE && Encodings::isUnicodeTextOnly(c)) {
-                       MathAtom const atom(new InsetMathChar(c));
+                       MathAtom const atom(new InsetMathChar(buffer_, c));
                        if (cur.prevInset() && cur.prevInset()->asInsetMath()->name() == "text") {
                                // reuse existing \text inset
                                cur.prevInset()->asInsetMath()->cell(0).push_back(atom);
@@ -2296,7 +2294,7 @@ bool InsetMathNest::interpretString(Cursor & cur, docstring const & str)
                                if (l && l->inset == "big") {
                                        cur.recordUndoSelection();
                                        cur.cell()[cur.pos() - 1] =
-                                               MathAtom(new InsetMathBig(prev, str));
+                                               MathAtom(new InsetMathBig(buffer_, prev, str));
                                        return true;
                                }
                        }
index 2ce14a7875b567cd716f9311db7af1b004edd5dc..e1b3f5082ee7c94701fe64079ae13aa2b3751b11 100644 (file)
@@ -21,8 +21,8 @@ using namespace std;
 
 namespace lyx {
 
-InsetMathNumber::InsetMathNumber(docstring const & s)
-       : str_(s)
+InsetMathNumber::InsetMathNumber(Buffer * buf, docstring const & s)
+       : InsetMath(buf), str_(s)
 {}
 
 
index 1b1f059bc09b213a95b22bb314a363642081914a..99e8c3c70b1f802aae8c65e9489c41939c642abd 100644 (file)
@@ -24,7 +24,7 @@ namespace lyx {
 class InsetMathNumber : public InsetMath {
 public:
        ///
-       explicit InsetMathNumber(docstring const & s);
+       explicit InsetMathNumber(Buffer * buf, docstring const & s);
        ///
        void metrics(MetricsInfo & mi, Dimension & dim) const override;
        ///
index b5f03881bfb1fc924d0fa6765ecc3e310055f856..b0b2dfec3bf62185a9938198af44b2f8641880ab 100644 (file)
@@ -77,14 +77,14 @@ int const defaultSpace = 4;
 
 } // namespace
 
-InsetMathSpace::InsetMathSpace()
-       : space_(defaultSpace)
+InsetMathSpace::InsetMathSpace(Buffer * buf)
+       : InsetMath(buf), space_(defaultSpace)
 {
 }
 
 
-InsetMathSpace::InsetMathSpace(string const & name, string const & length)
-       : space_(defaultSpace)
+InsetMathSpace::InsetMathSpace(Buffer * buf, string const & name, string const & length)
+       : InsetMath(buf), space_(defaultSpace)
 {
        for (int i = 0; i < nSpace; ++i)
                if (space_info[i].name == name) {
@@ -101,8 +101,8 @@ InsetMathSpace::InsetMathSpace(string const & name, string const & length)
 }
 
 
-InsetMathSpace::InsetMathSpace(Length const & length, bool const prot)
-       : space_(defaultSpace), length_(length)
+InsetMathSpace::InsetMathSpace(Buffer * buf, Length const & length, bool const prot)
+       : InsetMath(buf), space_(defaultSpace), length_(length)
 {
        for (int i = 0; i < nSpace; ++i)
                if ((prot && space_info[i].name == "hspace*")
index 96121726b6806f3d13a7caaf01b68b95a18491ff..bbccd366541f0bceca3fa3c3ae03e353c87b378a 100644 (file)
@@ -25,11 +25,11 @@ struct InsetSpaceParams;
 class InsetMathSpace : public InsetMath {
 public:
        ///
-       explicit InsetMathSpace();
+       explicit InsetMathSpace(Buffer * buf);
        ///
-       explicit InsetMathSpace(std::string const & name, std::string const & length);
+       explicit InsetMathSpace(Buffer * buf, std::string const & name, std::string const & length);
        ///
-       explicit InsetMathSpace(Length const & length, bool const prot = false);
+       explicit InsetMathSpace(Buffer * buf, Length const & length, bool const prot = false);
        ///
        InsetMathSpace const * asSpaceInset() const override { return this; }
        ///
index 3fc796f8347a7886aa6943481a1746772c7b7801..746cec5bdabd5370d0c4da9563eb254061512047 100644 (file)
@@ -29,8 +29,8 @@
 namespace lyx {
 
 
-InsetMathSpecialChar::InsetMathSpecialChar(docstring const & name)
-       : name_(name), kerning_(0)
+InsetMathSpecialChar::InsetMathSpecialChar(Buffer * buf, docstring const & name)
+       : InsetMath(buf), name_(name), kerning_(0)
 {
        if (name.size() != 1) {
                if (name == "textasciicircum" || name == "mathcircumflex")
index d46e3456d78ec4c3e28a20ca654509db9c0905c1..9abd6b30ada55a3d9309bb3f594e569a454dab0a 100644 (file)
@@ -23,7 +23,7 @@ class InsetMathSpecialChar : public InsetMath
 {
 public:
        ///
-       explicit InsetMathSpecialChar(docstring const & name);
+       explicit InsetMathSpecialChar(Buffer * buf, docstring const & name);
        ///
        void metrics(MetricsInfo & mi, Dimension & dim) const override;
        ///
index 2a80e546bef03b5ce4ebee44e3ada37d06187c5a..f7e86d11bf4328eaf3efb8dc1e6befd753865970 100644 (file)
@@ -31,8 +31,8 @@ using lyx::support::escape;
 
 namespace lyx {
 
-InsetMathString::InsetMathString(docstring const & s)
-       : str_(s)
+InsetMathString::InsetMathString(Buffer * buf, docstring const & s)
+       : InsetMath(buf), str_(s)
 {}
 
 
index 02ce7f039c55fd3273235b7ca8e804692f612274..6112b2546bbdf0a49b13a4034cb74032fd040366 100644 (file)
@@ -26,7 +26,7 @@ namespace lyx {
 class InsetMathString : public InsetMath {
 public:
        ///
-       explicit InsetMathString(docstring const & s);
+       explicit InsetMathString(Buffer * buf, docstring const & s);
        ///
        void metrics(MetricsInfo & mi, Dimension & dim) const override;
        ///
index a978deb02840a6cac578f4ae30d0dada77116e59..14e84fdfd23760d2a4643ddee3475d5b5d65ed5d 100644 (file)
@@ -30,18 +30,18 @@ using namespace std;
 
 namespace lyx {
 
-InsetMathSymbol::InsetMathSymbol(latexkeys const * l)
-       : sym_(l)
+InsetMathSymbol::InsetMathSymbol(Buffer * buf, latexkeys const * l)
+       : InsetMath(buf), sym_(l)
 {}
 
 
-InsetMathSymbol::InsetMathSymbol(char const * name)
-       : sym_(in_word_set(from_ascii(name)))
+InsetMathSymbol::InsetMathSymbol(Buffer * buf, char const * name)
+       : InsetMath(buf), sym_(in_word_set(from_ascii(name)))
 {}
 
 
-InsetMathSymbol::InsetMathSymbol(docstring const & name)
-       : sym_(in_word_set(name))
+InsetMathSymbol::InsetMathSymbol(Buffer * buf, docstring const & name)
+       : InsetMath(buf), sym_(in_word_set(name))
 {}
 
 
index f894782ab5c1366fe195f6ec3a0b5c81c20f49eb..735890ecbaa5552e54a713f1f7ca0be3fe3dcf1f 100644 (file)
@@ -23,11 +23,11 @@ class latexkeys;
 class InsetMathSymbol : public InsetMath {
 public:
        ///
-       explicit InsetMathSymbol(latexkeys const * l);
+       explicit InsetMathSymbol(Buffer * buf, latexkeys const * l);
        ///
-       explicit InsetMathSymbol(char const * name);
+       explicit InsetMathSymbol(Buffer * buf, char const * name);
        ///
-       explicit InsetMathSymbol(docstring const & name);
+       explicit InsetMathSymbol(Buffer * buf, docstring const & name);
        ///
        void metrics(MetricsInfo & mi, Dimension & dim) const override;
        ///
index 92d6b416e1fe31ef2c894c5f74447bee6d970527..4b215cfa450dbba2daed22a738871451d1794446 100644 (file)
@@ -23,9 +23,9 @@
 
 namespace lyx {
 
-InsetMathUnknown::InsetMathUnknown(docstring const & name,
+InsetMathUnknown::InsetMathUnknown(Buffer * buf, docstring const & name,
        docstring const & selection, bool final, bool black)
-       : name_(name), final_(final), black_(black), kerning_(0),
+       : InsetMath(buf), name_(name), final_(final), black_(black), kerning_(0),
          selection_(selection)
 {}
 
index f0377168fa60789f926be551bcb6c737f4d6dad8..a6efb161e007b09452b7962d1aeb571a265052f7 100644 (file)
@@ -21,7 +21,7 @@ namespace lyx {
 class InsetMathUnknown : public InsetMath {
 public:
        ///
-       explicit InsetMathUnknown(docstring const & name,
+       explicit InsetMathUnknown(Buffer * buf, docstring const & name,
                docstring const & selection = empty_docstring(),
                bool final = true, bool black = false);
        ///
index 9677fddb979705157b0e883e5dbeb66940e745ab..5f62d86846ab5247b70f3dac7b57dc8c331f9c0f 100644 (file)
@@ -645,7 +645,7 @@ void MathData::detachMacroParameters(DocIterator * cur, const size_type macroPos
                    && !(arg[0]->asMacro() && arg[0]->asMacro()->arity() > 0))
                        insert(p, arg[0]);
                else
-                       insert(p, MathAtom(new InsetMathBrace(arg)));
+                       insert(p, MathAtom(new InsetMathBrace(buffer_, arg)));
 
                // cursor in macro?
                if (curMacroSlice == -1)
@@ -711,7 +711,7 @@ void MathData::attachMacroParameters(Cursor * cur,
                if (scriptInset->nuc().empty()) {
                        MathData ar(buffer_);
                        scriptInset->nuc().push_back(
-                                       MathAtom(new InsetMathBrace(ar)));
+                                       MathAtom(new InsetMathBrace(buffer_, ar)));
                }
                // put macro into a script inset
                scriptInset->nuc()[0] = operator[](macroPos);
index 0f7ad7cb0ee63238830b8805f6c69fed7376cbf9..1f9356f8f241bdaf97de18bbf4f619b4e31f6749 100644 (file)
@@ -191,7 +191,7 @@ void extractStrings(MathData & ar)
                if (!ar[i]->asCharInset())
                        continue;
                docstring s = charSequence(ar.begin() + i, ar.end());
-               ar[i] = MathAtom(new InsetMathString(s));
+               ar[i] = MathAtom(new InsetMathString(ar.buffer(), s));
                ar.erase(i + 1, i + s.size());
        }
        //lyxerr << "\nStrings to: " << ar << endl;
@@ -486,7 +486,7 @@ void extractNumbers(MathData & ar)
 
                docstring s = digitSequence(ar.begin() + i, ar.end());
 
-               ar[i] = MathAtom(new InsetMathNumber(s));
+               ar[i] = MathAtom(new InsetMathNumber(ar.buffer(), s));
                ar.erase(i + 1, i + s.size());
        }
        //lyxerr << "\nNumbers to: " << ar << endl;
index 299cf00c05fdfb947305fb1b7a3206a32bf0b887..2a25d8464a10bfbb64e0f7b73b5a253bc768e516 100644 (file)
@@ -474,11 +474,11 @@ MathAtom createInsetMath(docstring const & s, Buffer * buf)
                if (inset == "decoration")
                        return MathAtom(new InsetMathDecoration(buf, l));
                if (inset == "space")
-                       return MathAtom(new InsetMathSpace(to_ascii(l->name), ""));
+                       return MathAtom(new InsetMathSpace(buf, to_ascii(l->name), ""));
                if (inset == "class")
                        return MathAtom(new InsetMathClass(buf, string_to_class(s)));
                if (inset == "dots")
-                       return MathAtom(new InsetMathDots(l));
+                       return MathAtom(new InsetMathDots(buf, l));
                if (inset == "mbox")
                        return MathAtom(new InsetMathBox(buf, l->name));
 //             if (inset == "fbox")
@@ -498,15 +498,15 @@ MathAtom createInsetMath(docstring const & s, Buffer * buf)
                if (inset == "big")
                        // we can't create a InsetMathBig, since the argument
                        // is missing.
-                       return MathAtom(new InsetMathUnknown(s));
-               return MathAtom(new InsetMathSymbol(l));
+                       return MathAtom(new InsetMathUnknown(buf, s));
+               return MathAtom(new InsetMathSymbol(buf, l));
        }
 
        if (s.size() == 2 && s[0] == '#' && s[1] >= '1' && s[1] <= '9')
-               return MathAtom(new InsetMathMacroArgument(s[1] - '0'));
+               return MathAtom(new InsetMathMacroArgument(buf, s[1] - '0'));
        if (s.size() == 3 && s[0] == '\\' && s[1] == '#'
                        && s[2] >= '1' && s[2] <= '9')
-               return MathAtom(new InsetMathMacroArgument(s[2] - '0'));
+               return MathAtom(new InsetMathMacroArgument(buf, s[2] - '0'));
        if (s == "boxed")
                return MathAtom(new InsetMathBoxed(buf));
        if (s == "fbox")
@@ -680,9 +680,9 @@ MathAtom createInsetMath(docstring const & s, Buffer * buf)
        if (s == "sidesetn")
                return MathAtom(new InsetMathSideset(buf, false, false));
        if (isSpecialChar(s))
-               return MathAtom(new InsetMathSpecialChar(s));
+               return MathAtom(new InsetMathSpecialChar(buf, s));
        if (s == " ")
-               return MathAtom(new InsetMathSpace(" ", ""));
+               return MathAtom(new InsetMathSpace(buf, " ", ""));
        if (s == "regexp")
                return MathAtom(new InsetMathHull(buf, hullRegexp));
 
index a7791d1482b0c7986890dd6131558bb2364500e6..79e0ec003d42a35e0ec47cab234ef207e79253e3 100644 (file)
@@ -916,30 +916,30 @@ bool Parser::parse1(InsetMathGrid & grid, unsigned flags,
                }
 
                else if (t.cat() == catLetter)
-                       cell->push_back(MathAtom(new InsetMathChar(t.character())));
+                       cell->push_back(MathAtom(new InsetMathChar(buf, t.character())));
 
                else if (t.cat() == catSpace && mode != InsetMath::MATH_MODE) {
                        if (cell->empty() || cell->back()->getChar() != ' ')
-                               cell->push_back(MathAtom(new InsetMathChar(t.character())));
+                               cell->push_back(MathAtom(new InsetMathChar(buf, t.character())));
                }
 
                else if (t.cat() == catNewline && mode != InsetMath::MATH_MODE) {
                        if (cell->empty() || cell->back()->getChar() != ' ')
-                               cell->push_back(MathAtom(new InsetMathChar(' ')));
+                               cell->push_back(MathAtom(new InsetMathChar(buf, ' ')));
                }
 
                else if (t.cat() == catParameter) {
                        Token const & n = nextToken();
                        char_type c = n.character();
                        if (c && '0' < c && c <= '9') {
-                               cell->push_back(MathAtom(new InsetMathMacroArgument(c - '0')));
+                               cell->push_back(MathAtom(new InsetMathMacroArgument(buf, c - '0')));
                                getToken();
                        } else
-                               cell->push_back(MathAtom(new InsetMathHash()));
+                               cell->push_back(MathAtom(new InsetMathHash(buf)));
                }
 
                else if (t.cat() == catActive)
-                       cell->push_back(MathAtom(new InsetMathSpace(string(1, t.character()), "")));
+                       cell->push_back(MathAtom(new InsetMathSpace(buf, string(1, t.character()), "")));
 
                else if (t.cat() == catBegin) {
                        MathData ar(buf);
@@ -949,7 +949,7 @@ bool Parser::parse1(InsetMathGrid & grid, unsigned flags,
                        if (ar.size() == 1 && ar[0]->extraBraces())
                                cell->append(ar);
                        else
-                               cell->push_back(MathAtom(new InsetMathBrace(ar)));
+                               cell->push_back(MathAtom(new InsetMathBrace(buf, ar)));
                }
 
                else if (t.cat() == catEnd) {
@@ -1017,14 +1017,14 @@ bool Parser::parse1(InsetMathGrid & grid, unsigned flags,
                            || mode_ & Parse::VERBATIM
                            || !(mode_ & Parse::USETEXT)
                            || mode == InsetMath::TEXT_MODE) {
-                               cell->push_back(MathAtom(new InsetMathChar(c)));
+                               cell->push_back(MathAtom(new InsetMathChar(buf, c)));
                        } else {
                                MathAtom at = createInsetMath("text", buf);
-                               at.nucleus()->cell(0).push_back(MathAtom(new InsetMathChar(c)));
+                               at.nucleus()->cell(0).push_back(MathAtom(new InsetMathChar(buf, c)));
                                while (nextToken().cat() == catOther
                                       && Encodings::isUnicodeTextOnly(nextToken().character())) {
                                        c = getToken().character();
-                                       at.nucleus()->cell(0).push_back(MathAtom(new InsetMathChar(c)));
+                                       at.nucleus()->cell(0).push_back(MathAtom(new InsetMathChar(buf, c)));
                                }
                                cell->push_back(at);
                        }
@@ -1397,7 +1397,7 @@ bool Parser::parse1(InsetMathGrid & grid, unsigned flags,
                        } else {
                                MathAtom at = MathAtom(new InsetMathMacro(buf, t.cs()));
                                cell->push_back(at);
-                               cell->push_back(MathAtom(new InsetMathBrace(count)));
+                               cell->push_back(MathAtom(new InsetMathBrace(buf, count)));
                        }
                }
 
@@ -1553,10 +1553,10 @@ bool Parser::parse1(InsetMathGrid & grid, unsigned flags,
                        docstring const ref = parse_verbatim_item();
                        if (!opt.empty()) {
                                cell->back().nucleus()->cell(1).push_back(
-                                       MathAtom(new InsetMathString(opt)));
+                                       MathAtom(new InsetMathString(buf, opt)));
                        }
                        cell->back().nucleus()->cell(0).push_back(
-                                       MathAtom(new InsetMathString(ref)));
+                                       MathAtom(new InsetMathString(buf, ref)));
                }
 
                else if (t.cs() == "left") {
@@ -1784,7 +1784,7 @@ bool Parser::parse1(InsetMathGrid & grid, unsigned flags,
                        if (s.empty())
                                cell->push_back(MathAtom(new InsetMathMacro(buf, t.cs())));
                        else
-                               cell->push_back(MathAtom(new InsetMathKern(s)));
+                               cell->push_back(MathAtom(new InsetMathKern(buf, s)));
                }
 
                else if (t.cs() == "label") {
@@ -1796,7 +1796,7 @@ bool Parser::parse1(InsetMathGrid & grid, unsigned flags,
                                grid.asHullInset()->label(cellrow, label);
                        } else {
                                cell->push_back(createInsetMath(t.cs(), buf));
-                               cell->push_back(MathAtom(new InsetMathBrace(ar)));
+                               cell->push_back(MathAtom(new InsetMathBrace(buf, ar)));
                        }
                }
 
@@ -1885,9 +1885,9 @@ bool Parser::parse1(InsetMathGrid & grid, unsigned flags,
                        docstring const arg = parse_verbatim_item();
                        Length length;
                        if (prot && arg == "\\fill")
-                               cell->push_back(MathAtom(new InsetMathSpace("hspace*{\\fill}", "")));
+                               cell->push_back(MathAtom(new InsetMathSpace(buf, "hspace*{\\fill}", "")));
                        else if (isValidLength(to_utf8(arg), &length))
-                               cell->push_back(MathAtom(new InsetMathSpace(length, prot)));
+                               cell->push_back(MathAtom(new InsetMathSpace(buf, length, prot)));
                        else {
                                // Since the Length class cannot use length variables
                                // we must not create an InsetMathSpace.
@@ -1962,10 +1962,10 @@ bool Parser::parse1(InsetMathGrid & grid, unsigned flags,
                                        Encodings::MATH_CMD | Encodings::TEXT_CMD,
                                        termination, rem);
                                for (char_type c : cmd)
-                                       cell->push_back(MathAtom(new InsetMathChar(c)));
+                                       cell->push_back(MathAtom(new InsetMathChar(buf, c)));
                                if (!rem.empty()) {
                                        char_type c = rem[0];
-                                       cell->push_back(MathAtom(new InsetMathChar(c)));
+                                       cell->push_back(MathAtom(new InsetMathChar(buf, c)));
                                        cmd = rem.substr(1);
                                        rem.clear();
                                } else
@@ -1991,7 +1991,7 @@ bool Parser::parse1(InsetMathGrid & grid, unsigned flags,
                                        docstring const delim = getToken().asInput();
                                        if (InsetMathBig::isBigInsetDelim(delim))
                                                cell->push_back(MathAtom(
-                                                       new InsetMathBig(t.cs(), delim)));
+                                                                                       new InsetMathBig(buf, t.cs(), delim)));
                                        else {
                                                cell->push_back(createInsetMath(t.cs(), buf));
                                                // For some reason delim.empty()
@@ -2091,7 +2091,7 @@ bool Parser::parse1(InsetMathGrid & grid, unsigned flags,
                                                        }
                                                }
                                                is_unicode_symbol = true;
-                                               cell->push_back(MathAtom(new InsetMathChar(c)));
+                                               cell->push_back(MathAtom(new InsetMathChar(buf, c)));
                                        } else {
                                                while (num_tokens--)
                                                        putback();