Force a Buffer * argument to math insets constructor

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.
This commit is contained in:
Jean-Marc Lasgouttes 2024-04-24 15:07:15 +02:00
parent 57d7130655
commit c013799887
36 changed files with 141 additions and 138 deletions

View 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);
}

View 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

View 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)
{}

View 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)

View 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;

View 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

View 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))
{}

View 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;
///

View 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)
{}

View 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;
///

View 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();

View 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"))));
}
}
}

View 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();

View File

@ -22,19 +22,20 @@
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))
{
}

View 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;
///

View 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_);
}

View 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: "

View 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

View 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) {

View 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;
}
}

View 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)
{}

View 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;
///

View 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*")

View 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; }
///

View 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")

View 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;
///

View 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)
{}

View 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;
///

View 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))
{}

View 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;
///

View 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)
{}

View 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);
///

View 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);

View 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;

View 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));

View 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();