- if (available()) {
- hideCursor();
- update(bv_->getLyXText(), BufferView::SELECT|BufferView::FITCUR);
- InsetSpecialChar * new_inset =
- new InsetSpecialChar(InsetSpecialChar::HYPHENATION);
- bv_->insertInset(new_inset);
+ // if we are in a locking inset we should try to insert the
+ // inset there otherwise this is a illegal function now
+ if (bv_->theLockingInset()) {
+ if (bv_->theLockingInset()->insetAllowed(inset))
+ return bv_->theLockingInset()->insertInset(bv_, inset);
+ return false;
+ }
+
+ // not quite sure if we want this...
+ setCursorParUndo(bv_);
+ freezeUndo();
+
+ beforeChange(bv_->text);
+ if (!lout.empty()) {
+ update(bv_->text, BufferView::SELECT|BufferView::FITCUR);
+ bv_->text->breakParagraph(bv_);
+ update(bv_->text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
+
+ if (bv_->text->cursor.par()->size()) {
+ bv_->text->cursorLeft(bv_);
+
+ bv_->text->breakParagraph(bv_);
+ update(bv_->text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
+ }
+
+ string lres = lout;
+ LyXTextClass const & tclass =
+ textclasslist[buffer_->params.textclass];
+ bool hasLayout = tclass.hasLayout(lres);
+ string lay = tclass.defaultLayoutName();
+
+ if (hasLayout != false) {
+ // layout found
+ lay = lres;
+ } else {
+ // layout not fount using default
+ lay = tclass.defaultLayoutName();
+ }
+
+ bv_->text->setLayout(bv_, lay);
+
+ bv_->text->setParagraph(bv_, 0, 0,
+ 0, 0,
+ VSpace(VSpace::NONE), VSpace(VSpace::NONE),
+ Spacing(),
+ LYX_ALIGN_LAYOUT,
+ string(),
+ 0);
+ update(bv_->text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);