]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/InsetMathHull.cpp
Change the interface to a paragraph's layout. We still store a LayoutPtr, but now...
[lyx.git] / src / mathed / InsetMathHull.cpp
index cd2d5c42cc16391418a3749bc43abd50335566b1..b7de48c89f537078e2de2d797c9c5b347a800c94 100644 (file)
@@ -140,9 +140,10 @@ docstring hullName(HullType type)
        }
 }
 
+static InsetLabel * dummy_pointer = 0;
 
 InsetMathHull::InsetMathHull()
-       : InsetMathGrid(1, 1), type_(hullNone), nonum_(1, false), label_(1, 0),
+       : InsetMathGrid(1, 1), type_(hullNone), nonum_(1, false), label_(1, dummy_pointer),
          preview_(new RenderPreview(this))
 {
        //lyxerr << "sizeof InsetMath: " << sizeof(InsetMath) << endl;
@@ -155,7 +156,7 @@ InsetMathHull::InsetMathHull()
 
 
 InsetMathHull::InsetMathHull(HullType type)
-       : InsetMathGrid(getCols(type), 1), type_(type), nonum_(1, false), label_(1, 0),
+       : InsetMathGrid(getCols(type), 1), type_(type), nonum_(1, false), label_(1, dummy_pointer),
          preview_(new RenderPreview(this))
 {
        initMath();
@@ -171,10 +172,8 @@ InsetMathHull::InsetMathHull(InsetMathHull const & other)
 
 InsetMathHull::~InsetMathHull()
 {
-       for (size_t i = 0; i < label_.size(); ++i) {
-               if (label_[i])
-                       delete label_[i];
-       }
+       for (size_t i = 0; i < label_.size(); ++i)
+               delete label_[i];
 }
 
 
@@ -191,10 +190,8 @@ InsetMathHull & InsetMathHull::operator=(InsetMathHull const & other)
        InsetMathGrid::operator=(other);
        type_  = other.type_;
        nonum_ = other.nonum_;
-       for (size_t i = 0; i < label_.size(); ++i) {
-               if (label_[i])
-                       delete label_[i];
-       }
+       for (size_t i = 0; i < label_.size(); ++i)
+               delete label_[i];
        label_ = other.label_;
        for (size_t i = 0; i != label_.size(); ++i) {
                if (label_[i])
@@ -209,6 +206,12 @@ InsetMathHull & InsetMathHull::operator=(InsetMathHull const & other)
 void InsetMathHull::setBuffer(Buffer & buffer)
 {
        buffer_ = &buffer;
+       for (idx_type i = 0, n = nargs(); i != n; ++i) {
+               MathData & data = cell(i);
+               for (size_t j = 0; j != data.size(); ++j)
+                       data[j].nucleus()->setBuffer(buffer);
+       }
+
        for (size_t i = 0; i != label_.size(); ++i) {
                if (label_[i])
                        label_[i]->setBuffer(buffer);
@@ -687,7 +690,7 @@ void InsetMathHull::addRow(row_type row)
        if (!rowChangeOK())
                return;
        nonum_.insert(nonum_.begin() + row + 1, !numberedType());
-       label_.insert(label_.begin() + row + 1, 0);
+       label_.insert(label_.begin() + row + 1, dummy_pointer);
        InsetMathGrid::addRow(row);
 }
 
@@ -698,7 +701,12 @@ void InsetMathHull::swapRow(row_type row)
                return;
        if (row + 1 == nrows())
                --row;
-       swap(nonum_[row], nonum_[row + 1]);
+       // gcc doesn't like this:
+       //      swap(nonum_[row], nonum_[row + 1]);
+       // so we do it manually:
+       bool const b = nonum_[row];
+       nonum_[row] = nonum_[row + 1];
+       nonum_[row + 1] = b;
        swap(label_[row], label_[row + 1]);
        InsetMathGrid::swapRow(row);
 }
@@ -714,8 +722,7 @@ void InsetMathHull::delRow(row_type row)
        if (row == nrows() + 1)
                row--;
        nonum_.erase(nonum_.begin() + row);
-       if (label_[row])
-               delete label_[row];
+       delete label_[row];
        label_.erase(label_.begin() + row);
 }
 
@@ -979,7 +986,7 @@ docstring InsetMathHull::eolString(row_type row, bool emptyline, bool fragile) c
        docstring res;
        if (numberedType()) {
                if (label_[row] && !nonum_[row])
-                       res += "\\label{" + label_[row]->screenLabel() + '}';
+                       res += "\\label{" + label_[row]->getParam("name") + '}';
                if (nonum_[row] && (type_ != hullMultline))
                        res += "\\nonumber ";
        }