MathArray::~MathArray()
{
MathArray::~MathArray()
{
- for (int pos = 0; pos < size(); next(pos))
- if (isInset(pos))
- delete nextInset(pos);
}
MathArray::MathArray(MathArray const & array)
: bf_(array.bf_)
{
}
MathArray::MathArray(MathArray const & array)
: bf_(array.bf_)
{
- for (int pos = 0; pos < size(); next(pos))
- if (isInset(pos))
- replace(pos, nextInset(pos)->clone());
MathArray::MathArray(MathArray const & array, int from, int to)
: bf_(array.bf_.begin() + from, array.bf_.begin() + to)
{
MathArray::MathArray(MathArray const & array, int from, int to)
: bf_(array.bf_.begin() + from, array.bf_.begin() + to)
{
- for (int pos = 0; pos < size(); next(pos))
- if (isInset(pos))
- replace(pos, nextInset(pos)->clone());
+ deep_copy(0, size());
+}
+
+
+void MathArray::deep_copy(int pos1, int pos2)
+{
+ for (int pos = pos1; pos < pos2; next(pos))
+ if (isInset(pos)) {
+ MathInset * p = nextInset(pos)->clone();
+ memcpy(&bf_[pos + 1], &p, sizeof(p));
+ }
MathInset * MathArray::prevInset(int pos) const
{
MathInset * MathArray::prevInset(int pos) const
{
-void MathArray::replace(int pos, MathInset * p)
-{
- memcpy(&bf_[pos + 1], &p, sizeof(p));
-}
-
void MathArray::insert(int pos, MathInset * p)
{
void MathArray::insert(int pos, MathInset * p)
{
void MathArray::insert(int pos, MathArray const & array)
{
bf_.insert(bf_.begin() + pos, array.bf_.begin(), array.bf_.end());
void MathArray::insert(int pos, MathArray const & array)
{
bf_.insert(bf_.begin() + pos, array.bf_.begin(), array.bf_.end());
- for (int p = pos; p < pos + array.size(); next(p))
- if (isInset(p))
- replace(p, nextInset(p)->clone());
+ deep_copy(pos, pos + array.size());
void MathArray::clear()
{
void MathArray::clear()
{
- for (int pos = 0; pos < size(); next(pos))
- if (isInset(pos))
- delete nextInset(pos);
- bf_.clear();
void MathArray::erase(int pos1, int pos2)
{
void MathArray::erase(int pos1, int pos2)
{
+ for (int pos = pos1; pos < pos2; next(pos))
+ if (isInset(pos))
+ delete nextInset(pos);
bf_.erase(bf_.begin() + pos1, bf_.begin() + pos2);
}
bf_.erase(bf_.begin() + pos1, bf_.begin() + pos2);
}
MathInset * MathArray::back_inset() const
{
MathInset * MathArray::back_inset() const
{
- if (!empty()) {
- int pos = size();
- prev(pos);
- if (isInset(pos))
- return nextInset(pos);
- }
- return 0;
+ return prevInset(size());
{
int pos = size();
prev(pos);
{
int pos = size();
prev(pos);
- void replace(int pos, MathInset * inset);
- ///
bool prev(int & pos) const;
///
bool next(int & pos) const;
bool prev(int & pos) const;
///
bool next(int & pos) const;
///
int item_size(int pos) const;
///
int item_size(int pos) const;
+ ///
+ void deep_copy(int pos1, int pos2);
/// Buffer
buffer_type bf_;
};
/// Buffer
buffer_type bf_;
};
InsetFormulaBase::InsetFormulaBase(InsetFormulaBase const & f)
InsetFormulaBase::InsetFormulaBase(InsetFormulaBase const & f)
- : UpdatableInset(f), par_(static_cast<MathInset *>(f.par_->clone()))
+ : UpdatableInset(f), par_(f.par_->clone())
protected:
///
virtual void updateLocal(BufferView * bv, bool mark_dirty);
protected:
///
virtual void updateLocal(BufferView * bv, bool mark_dirty);
+private:
+ /// unimplemented
+ void operator=(const InsetFormulaBase &);
};
// We don't really mess want around with mathed stuff outside mathed.
};
// We don't really mess want around with mathed stuff outside mathed.
ascent_ = 0;
descent_ = 0;
width_ = 0;
ascent_ = 0;
descent_ = 0;
width_ = 0;
for (int pos = 0; pos < data_.size(); data_.next(pos)) {
int asc;
for (int pos = 0; pos < data_.size(); data_.next(pos)) {
int asc;