}
-void Paragraph::insertInset(pos_type pos, Inset * inset,
+bool Paragraph::insertInset(pos_type pos, Inset * inset,
Change const & change)
{
LASSERT(inset, /**/);
LASSERT(pos >= 0 && pos <= size(), /**/);
+ // Paragraph::insertInset() can be used in cut/copy/paste operation where
+ // d->inset_owner_ is not set yet.
+ if (d->inset_owner_ && d->inset_owner_->insetAllowed(inset->lyxCode()))
+ return false;
+
d->insertChar(pos, META_INSET, change);
LASSERT(d->text_[pos] == META_INSET, /**/);
// Add a new entry in the insetlist_.
d->insetlist_.insert(inset, pos);
+ return true;
}
}
-void Paragraph::insertInset(pos_type pos, Inset * inset,
+bool Paragraph::insertInset(pos_type pos, Inset * inset,
Font const & font, Change const & change)
{
- insertInset(pos, inset, change);
+ bool const success = insertInset(pos, inset, change);
// Set the font/language of the inset...
setFont(pos, font);
+ return success;
}
///
void insertChar(pos_type pos, char_type c,
Font const &, Change const & change);
- ///
- void insertInset(pos_type pos, Inset * inset,
+ /// Insert \p inset at position \p pos with \p change traking status.
+ /// \return true if successful.
+ bool insertInset(pos_type pos, Inset * inset,
Change const & change);
- ///
- void insertInset(pos_type pos, Inset * inset,
- Font const &, Change const & change);
+ /// Insert \p inset at position \p pos with \p change traking status and
+ /// \p font.
+ /// \return true if successful.
+ bool insertInset(pos_type pos, Inset * inset,
+ Font const & font, Change const & change);
///
Inset * getInset(pos_type pos);
///
// the inset is not in the paragraph any more
tmpInset = fromPar.releaseInset(fromPos);
}
-
- if (!toPar.inInset().insetAllowed(tmpInset->lyxCode())) {
- delete tmpInset;
- return false;
- }
-
- toPar.insertInset(toPos, tmpInset, tmpFont, tmpChange);
+ return toPar.insertInset(toPos, tmpInset, tmpFont, tmpChange);
} else {
fromPar.eraseChar(fromPos, false);
toPar.insertChar(toPos, tmpChar, tmpFont, tmpChange);