- // if we are in a locking inset we should try to insert the
- // inset there otherwise this is a illegal function now
- if (theLockingInset()) {
- if (theLockingInset()->InsertInsetAllowed(inset))
- return theLockingInset()->InsertInset(this, inset);
- return false;
- }
-
- // not quite sure if we want this...
- text->SetCursorParUndo(buffer());
- text->FreezeUndo();
-
- beforeChange(text);
- if (!lout.empty()) {
- update(text, BufferView::SELECT|BufferView::FITCUR);
- text->BreakParagraph(this);
- update(text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
-
- if (text->cursor.par()->size()) {
- text->CursorLeft(this);
-
- text->BreakParagraph(this);
- update(text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
- }
-
- pair<bool, LyXTextClass::size_type> lres =
- textclasslist.NumberOfLayout(buffer()->params
- .textclass, lout);
- LyXTextClass::size_type lay;
- if (lres.first != false) {
- // layout found
- lay = lres.second;
- } else {
- // layout not fount using default "Standard" (0)
- lay = 0;
- }
-
- text->SetLayout(this, lay);
-
- text->SetParagraph(this, 0, 0,
- 0, 0,
- VSpace(VSpace::NONE), VSpace(VSpace::NONE),
- LYX_ALIGN_LAYOUT,
- string(),
- 0);
- update(text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
-
- text->current_font.setLatex(LyXFont::OFF);
- }
-
- text->InsertInset(this, inset);
- update(text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
-
- text->UnFreezeUndo();
- return true;