+}
+
+
+bool InsetText::unlockInsetInInset(BufferView * bv, UpdatableInset * inset,
+ bool lr)
+{
+ if (!the_locking_inset)
+ return false;
+ if (the_locking_inset == inset) {
+ the_locking_inset->insetUnlock(bv);
+ getLyXText(bv)->updateInset(bv, inset);
+ the_locking_inset = 0;
+ if (lr)
+ moveRight(bv, false);
+ old_par = 0; // force layout setting
+ if (scroll())
+ scroll(bv, 0.0F);
+ else
+ updateLocal(bv, CURSOR, false);
+ return true;
+ }
+ return the_locking_inset->unlockInsetInInset(bv, inset, lr);
+}
+
+
+bool InsetText::updateInsetInInset(BufferView * bv, Inset * inset)
+{
+ if (!the_locking_inset)
+ return false;
+ if (the_locking_inset != inset) {
+ getLyXText(bv)->updateInset(bv, the_locking_inset);
+ setUpdateStatus(bv, CURSOR_PAR);
+ return the_locking_inset->updateInsetInInset(bv, inset);
+ }
+ if (getLyXText(bv)->updateInset(bv, inset))
+ updateLocal(bv, CURSOR_PAR, false);
+ if (cpar(bv) == inset_par && cpos(bv) == inset_pos) {
+ inset_x = cx(bv) - top_x + drawTextXOffset;
+ inset_y = cy(bv) + drawTextYOffset;
+ }
+ return true;
+}
+
+
+void InsetText::insetButtonPress(BufferView * bv, int x, int y, int button)
+{
+ no_selection = true;
+
+ int tmp_x = x - drawTextXOffset;
+ int tmp_y = y + insetAscent - getLyXText(bv)->first;
+ Inset * inset = bv->checkInsetHit(getLyXText(bv), tmp_x, tmp_y, button);
+
+ hideInsetCursor(bv);
+ if (the_locking_inset) {
+ if (the_locking_inset == inset) {
+ the_locking_inset->insetButtonPress(bv,x-inset_x,y-inset_y,button);
+ no_selection = false;
+ return;
+ } else if (inset) {
+ // otherwise unlock the_locking_inset and lock the new inset
+ the_locking_inset->insetUnlock(bv);
+ inset_x = cx(bv) - top_x + drawTextXOffset;
+ inset_y = cy(bv) + drawTextYOffset;
+ the_locking_inset = static_cast<UpdatableInset*>(inset);
+ inset->insetButtonPress(bv, x - inset_x, y - inset_y, button);
+ inset->edit(bv, x - inset_x, y - inset_y, button);
+ if (the_locking_inset)
+ updateLocal(bv, CURSOR, false);
+ no_selection = false;
+ return;
+ }
+ // otherwise only unlock the_locking_inset
+ the_locking_inset->insetUnlock(bv);
+ the_locking_inset = 0;
+ }
+ if (bv->theLockingInset()) {
+ if (inset && inset->editable() == Inset::HIGHLY_EDITABLE) {
+ UpdatableInset * uinset = static_cast<UpdatableInset*>(inset);
+ inset_x = cx(bv) - top_x + drawTextXOffset;
+ inset_y = cy(bv) + drawTextYOffset;
+ inset_pos = cpos(bv);
+ inset_par = cpar(bv);
+ inset_boundary = cboundary(bv);
+ the_locking_inset = uinset;
+ uinset->insetButtonPress(bv, x - inset_x, y - inset_y,
+ button);
+ uinset->edit(bv, x - inset_x, y - inset_y, 0);
+ if (the_locking_inset)
+ updateLocal(bv, CURSOR, false);
+ no_selection = false;
+ return;
+ }
+ }
+ if (!inset) { // && (button == 2)) {
+ bool paste_internally = false;
+ if ((button == 2) && getLyXText(bv)->selection.set()) {
+ localDispatch(bv, LFUN_COPY, "");
+ paste_internally = true;
+ }
+ bool clear = false;
+ if (!lt) {
+ lt = getLyXText(bv);
+ clear = true;
+ }
+ lt->setCursorFromCoordinates(bv, x-drawTextXOffset, y + insetAscent);
+ if (lt->selection.set()) {
+ lt->clearSelection();
+ updateLocal(bv, FULL, false);
+ } else {
+ lt->clearSelection();
+ }
+ bv->owner()->setLayout(cpar(bv)->getLayout());
+ old_par = cpar(bv);
+ // Insert primary selection with middle mouse
+ // if there is a local selection in the current buffer,
+ // insert this
+ if (button == 2) {
+ if (paste_internally)
+ localDispatch(bv, LFUN_PASTE, "");
+ else
+ localDispatch(bv, LFUN_PASTESELECTION,
+ "paragraph");
+ }
+ if (clear)
+ lt = 0;
+ }
+ showInsetCursor(bv);
+ no_selection = false;
+}
+
+
+void InsetText::insetButtonRelease(BufferView * bv, int x, int y, int button)
+{
+ UpdatableInset * inset = 0;
+
+ if (the_locking_inset) {
+ the_locking_inset->insetButtonRelease(bv,
+ x - inset_x, y - inset_y,
+ button);
+ } else {
+ if (cpar(bv)->getChar(cpos(bv)) == Paragraph::META_INSET) {
+ inset = static_cast<UpdatableInset*>(cpar(bv)->getInset(cpos(bv)));
+ if (inset->editable() == Inset::HIGHLY_EDITABLE) {
+ inset->insetButtonRelease(bv,
+ x - inset_x,
+ y - inset_y, button);
+ } else {
+ inset_x = cx(bv) - top_x + drawTextXOffset;
+ inset_y = cy(bv) + drawTextYOffset;
+ inset->insetButtonRelease(bv,
+ x - inset_x,
+ y - inset_y, button);
+ inset->edit(bv,
+ x - inset_x, y - inset_y, button);
+ }
+ updateLocal(bv, CURSOR_PAR, false);
+ }
+ }
+ no_selection = false;
+}
+
+
+void InsetText::insetMotionNotify(BufferView * bv, int x, int y, int state)
+{
+ if (no_selection)
+ return;
+ if (the_locking_inset) {
+ the_locking_inset->insetMotionNotify(bv, x - inset_x,
+ y - inset_y,state);
+ return;
+ }
+ LyXText * t = getLyXText(bv);
+ hideInsetCursor(bv);
+ t->setCursorFromCoordinates(bv, x - drawTextXOffset, y + insetAscent);
+ t->setSelection(bv);
+ if (t->toggle_cursor.par() != t->toggle_end_cursor.par() ||
+ t->toggle_cursor.pos() != t->toggle_end_cursor.pos())
+ updateLocal(bv, SELECTION, false);
+ showInsetCursor(bv);
+}
+
+
+void InsetText::insetKeyPress(XKeyEvent * xke)
+{
+ if (the_locking_inset) {
+ the_locking_inset->insetKeyPress(xke);
+ return;
+ }
+}
+
+
+UpdatableInset::RESULT
+InsetText::localDispatch(BufferView * bv,
+ kb_action action, string const & arg)
+{
+ no_selection = false;
+ UpdatableInset::RESULT
+ result= UpdatableInset::localDispatch(bv, action, arg);
+ if (result != UNDISPATCHED) {
+ return DISPATCHED;
+ }
+
+ result = DISPATCHED;
+ if ((action < 0) && arg.empty())
+ return FINISHED;
+
+ if (the_locking_inset) {
+ result = the_locking_inset->localDispatch(bv, action, arg);
+ if (result == DISPATCHED_NOUPDATE)
+ return result;
+ else if (result == DISPATCHED) {
+ updateLocal(bv, CURSOR_PAR, false);
+ return result;
+ } else if (result == FINISHED) {
+ bool dispatched = false;
+ switch (action) {
+ case LFUN_UNKNOWN_ACTION:
+ case LFUN_BREAKPARAGRAPH:
+ case LFUN_BREAKLINE:
+ moveRightIntern(bv, false, false);
+ break;
+ case LFUN_RIGHT:
+ if (!getLyXText(bv)->cursor.par()->isRightToLeftPar(bv->buffer()->params))
+ moveRightIntern(bv, false, false);
+ dispatched = true;
+ break;
+ case LFUN_LEFT:
+ if (getLyXText(bv)->cursor.par()->isRightToLeftPar(bv->buffer()->params))
+ moveRightIntern(bv, false, false);
+ dispatched = true;
+ break;
+ default:
+ break;
+ }
+ the_locking_inset = 0;
+ if (dispatched)
+ return DISPATCHED;
+ }
+ }
+ hideInsetCursor(bv);
+ bool clear = false;
+ if (!lt) {
+ lt = getLyXText(bv);
+ clear = true;
+ }
+ switch (action) {
+ // Normal chars
+ case LFUN_SELFINSERT:
+ if (bv->buffer()->isReadonly()) {
+// setErrorMessage(N_("Document is read only"));
+ break;
+ }
+ if (!arg.empty()) {
+ /* Automatically delete the currently selected
+ * text and replace it with what is being
+ * typed in now. Depends on lyxrc settings
+ * "auto_region_delete", which defaults to
+ * true (on). */
+
+ setUndo(bv, Undo::INSERT,
+ lt->cursor.par(), lt->cursor.par()->next());
+ bv->setState();
+ if (lyxrc.auto_region_delete) {
+ if (lt->selection.set()) {
+ lt->cutSelection(bv, false);
+ }
+ }
+ lt->clearSelection();
+ for (string::size_type i = 0; i < arg.length(); ++i) {
+ bv->owner()->getIntl()->getTrans().TranslateAndInsert(arg[i], lt);
+ }
+ }
+ lt->selection.cursor = lt->cursor;
+ updateLocal(bv, CURSOR_PAR, true);
+ result = DISPATCHED_NOUPDATE;
+ break;
+ // --- Cursor Movements -----------------------------------
+ case LFUN_RIGHTSEL:
+ finishUndo();
+ moveRight(bv, false, true);
+ lt->setSelection(bv);
+ updateLocal(bv, SELECTION, false);
+ break;
+ case LFUN_RIGHT:
+ result = moveRight(bv);
+ finishUndo();
+ updateLocal(bv, CURSOR, false);
+ break;
+ case LFUN_LEFTSEL:
+ finishUndo();
+ moveLeft(bv, false, true);
+ lt->setSelection(bv);
+ updateLocal(bv, SELECTION, false);
+ break;
+ case LFUN_LEFT:
+ finishUndo();
+ result = moveLeft(bv);
+ updateLocal(bv, CURSOR, false);
+ break;
+ case LFUN_DOWNSEL:
+ finishUndo();
+ moveDown(bv);
+ lt->setSelection(bv);
+ updateLocal(bv, SELECTION, false);
+ break;
+ case LFUN_DOWN:
+ finishUndo();
+ result = moveDown(bv);
+ updateLocal(bv, CURSOR, false);
+ break;
+ case LFUN_UPSEL:
+ finishUndo();
+ moveUp(bv);
+ lt->setSelection(bv);
+ updateLocal(bv, SELECTION, false);
+ break;
+ case LFUN_UP:
+ finishUndo();
+ result = moveUp(bv);
+ updateLocal(bv, CURSOR, false);
+ break;
+ case LFUN_HOME:
+ finishUndo();
+ lt->cursorHome(bv);
+ updateLocal(bv, CURSOR, false);
+ break;
+ case LFUN_END:
+ lt->cursorEnd(bv);
+ updateLocal(bv, CURSOR, false);
+ break;
+ case LFUN_BACKSPACE: {
+ setUndo(bv, Undo::DELETE,
+ lt->cursor.par(), lt->cursor.par()->next());
+ if (lt->selection.set())
+ lt->cutSelection(bv);
+ else
+ lt->backspace(bv);
+ updateLocal(bv, CURSOR_PAR, true);
+ }
+ break;
+
+ case LFUN_DELETE: {
+ setUndo(bv, Undo::DELETE,
+ lt->cursor.par(), lt->cursor.par()->next());
+ if (lt->selection.set()) {
+ lt->cutSelection(bv);
+ } else {
+ lt->Delete(bv);
+ }
+ updateLocal(bv, CURSOR_PAR, true);
+ }
+ break;
+
+ case LFUN_CUT: {
+ setUndo(bv, Undo::DELETE,
+ lt->cursor.par(), lt->cursor.par()->next());
+ lt->cutSelection(bv);
+ updateLocal(bv, CURSOR_PAR, true);
+ }
+ break;
+
+ case LFUN_COPY:
+ finishUndo();
+ lt->copySelection(bv);
+ updateLocal(bv, CURSOR_PAR, false);
+ break;
+ case LFUN_PASTESELECTION:
+ {
+ string const clip(bv->getClipboard());
+
+ if (clip.empty())
+ break;
+ if (arg == "paragraph") {
+ lt->insertStringAsParagraphs(bv, clip);
+ } else {
+ lt->insertStringAsLines(bv, clip);
+ }
+ updateLocal(bv, CURSOR_PAR, true);
+ break;
+ }
+ case LFUN_PASTE: {
+ if (!autoBreakRows) {
+
+ if (CutAndPaste::nrOfParagraphs() > 1) {
+ WriteAlert(_("Impossible operation"),
+ _("Cannot include more than one paragraph!"),
+ _("Sorry."));
+ break;
+ }
+ }
+ setUndo(bv, Undo::INSERT,
+ lt->cursor.par(), lt->cursor.par()->next());
+ lt->pasteSelection(bv);
+ updateLocal(bv, CURSOR_PAR, true);
+ }
+ break;
+
+ case LFUN_BREAKPARAGRAPH:
+ if (!autoBreakRows) {
+ result = DISPATCHED;
+ break;
+ }
+ lt->breakParagraph(bv, 0);
+ updateLocal(bv, FULL, true);
+ break;
+ case LFUN_BREAKPARAGRAPHKEEPLAYOUT:
+ if (!autoBreakRows) {
+ result = DISPATCHED;
+ break;
+ }
+ lt->breakParagraph(bv, 1);
+ updateLocal(bv, FULL, true);
+ break;
+
+ case LFUN_BREAKLINE: {
+ if (!autoBreakRows) {
+ result = DISPATCHED;
+ break;
+ }
+ setUndo(bv, Undo::INSERT,
+ lt->cursor.par(), lt->cursor.par()->next());
+ lt->insertChar(bv, Paragraph::META_NEWLINE);
+ updateLocal(bv, CURSOR_PAR, true);
+ }
+ break;
+
+ case LFUN_LAYOUT:
+ // do not set layouts on non breakable textinsets
+ if (autoBreakRows) {
+ LyXTextClass::size_type cur_layout = cpar(bv)->layout;
+
+ // Derive layout number from given argument (string)
+ // and current buffer's textclass (number). */
+ LyXTextClassList::ClassList::size_type tclass =
+ bv->buffer()->params.textclass;
+ std::pair <bool, LyXTextClass::size_type> layout =
+ textclasslist.NumberOfLayout(tclass, arg);
+
+ // If the entry is obsolete, use the new one instead.
+ if (layout.first) {
+ string obs = textclasslist.Style(tclass,layout.second).
+ obsoleted_by();
+ if (!obs.empty())
+ layout = textclasslist.NumberOfLayout(tclass, obs);
+ }
+
+ // see if we found the layout number:
+ if (!layout.first) {
+ string const msg = string(N_("Layout ")) + arg + N_(" not known");
+ bv->owner()->getLyXFunc()->dispatch(LFUN_MESSAGE, msg);
+ break;
+ }
+
+ if (cur_layout != layout.second) {
+ cur_layout = layout.second;
+ lt->setLayout(bv, layout.second);
+ bv->owner()->setLayout(cpar(bv)->getLayout());
+ updateLocal(bv, CURSOR_PAR, true);
+ }
+ } else {
+ // reset the layout box
+ bv->owner()->setLayout(cpar(bv)->getLayout());
+ }
+ break;
+ case LFUN_PARAGRAPH_SPACING:
+ // This one is absolutely not working. When fiddling with this
+ // it also seems to me that the paragraphs inside the insettext
+ // inherit bufferparams/paragraphparams in a strange way. (Lgb)
+ {
+ Paragraph * par = lt->cursor.par();
+ Spacing::Space cur_spacing = par->params().spacing().getSpace();
+ float cur_value = 1.0;
+ if (cur_spacing == Spacing::Other) {
+ cur_value = par->params().spacing().getValue();
+ }
+
+ istringstream istr(arg.c_str());
+ string tmp;
+ istr >> tmp;
+ Spacing::Space new_spacing = cur_spacing;
+ float new_value = cur_value;
+ if (tmp.empty()) {
+ lyxerr << "Missing argument to `paragraph-spacing'"
+ << endl;
+ } else if (tmp == "single") {
+ new_spacing = Spacing::Single;
+ } else if (tmp == "onehalf") {
+ new_spacing = Spacing::Onehalf;
+ } else if (tmp == "double") {
+ new_spacing = Spacing::Double;
+ } else if (tmp == "other") {
+ new_spacing = Spacing::Other;
+ float tmpval = 0.0;
+ istr >> tmpval;
+ lyxerr << "new_value = " << tmpval << endl;
+ if (tmpval != 0.0)
+ new_value = tmpval;
+ } else if (tmp == "default") {
+ new_spacing = Spacing::Default;
+ } else {
+ lyxerr << _("Unknown spacing argument: ")
+ << arg << endl;
+ }
+ if (cur_spacing != new_spacing || cur_value != new_value) {
+ par->params().spacing(Spacing(new_spacing, new_value));
+ updateLocal(bv, CURSOR_PAR, true);
+ }
+ }
+ break;
+
+ default:
+ if (!bv->Dispatch(action, arg))
+ result = UNDISPATCHED;
+ break;
+ }
+
+ /// If the action has deleted all text in the inset, we need to change the
+ // language to the language of the surronding text.
+ if (par->size() == 0 && !par->next()) {
+ LyXFont font(LyXFont::ALL_IGNORE);
+ font.setLanguage(bv->getParentLanguage(this));
+ setFont(bv, font, false);
+ }
+
+ if (result != FINISHED) {
+ showInsetCursor(bv);
+ } else
+ bv->unlockInset(this);
+ if (clear)
+ lt = 0;
+ return result;
+}
+
+
+int InsetText::latex(Buffer const * buf, ostream & os, bool, bool) const
+{
+ TexRow texrow;
+ buf->latexParagraphs(os, par, 0, texrow);
+ return texrow.rows();
+}
+
+
+int InsetText::ascii(Buffer const * buf, ostream & os, int linelen) const
+{
+ Paragraph * p = par;
+ unsigned int lines = 0;
+
+ while (p) {
+ string const tmp = buf->asciiParagraph(p, linelen);
+ lines += countChar(tmp, '\n');
+ os << tmp;
+ p = p->next();
+ }
+ return lines;
+}
+
+
+int InsetText::docBook(Buffer const * buf, ostream & os) const
+{
+ Paragraph * p = par;
+ unsigned int lines = 0;
+ int desc = 0;
+
+ string tmp;
+ while (p) {
+ buf->simpleDocBookOnePar(os, tmp, p, desc, 0);
+ p = p->next();
+ }
+
+ return lines;
+}
+
+
+void InsetText::validate(LaTeXFeatures & features) const
+{
+ Paragraph * p = par;
+ while (p) {
+ p->validate(features);
+ p = p->next();
+ }
+}
+
+
+int InsetText::beginningOfMainBody(Buffer const * buf, Paragraph * p) const
+{
+ if (textclasslist.Style(buf->params.textclass,
+ p->getLayout()).labeltype != LABEL_MANUAL)
+ return 0;
+ else
+ return p->beginningOfMainBody();
+}
+
+
+void InsetText::getCursorPos(BufferView * bv,
+ int & x, int & y) const
+{
+ if (the_locking_inset) {
+ the_locking_inset->getCursorPos(bv, x, y);
+ return;
+ }
+ x = cx(bv);
+ y = cy(bv);
+}
+
+
+unsigned int InsetText::insetInInsetY()
+{
+ if (!the_locking_inset)
+ return 0;
+
+ return (inset_y + the_locking_inset->insetInInsetY());
+}
+
+
+void InsetText::toggleInsetCursor(BufferView * bv)
+{
+ if (the_locking_inset) {
+ the_locking_inset->toggleInsetCursor(bv);
+ return;
+ }
+
+ LyXFont const font(getLyXText(bv)->getFont(bv->buffer(), cpar(bv), cpos(bv)));
+
+ int const asc = lyxfont::maxAscent(font);
+ int const desc = lyxfont::maxDescent(font);
+
+ if (isCursorVisible())
+ bv->hideLockedInsetCursor();
+ else
+ bv->showLockedInsetCursor(cx(bv), cy(bv), asc, desc);
+ toggleCursorVisible();
+}
+
+
+void InsetText::showInsetCursor(BufferView * bv, bool show)
+{
+ if (the_locking_inset) {
+ the_locking_inset->showInsetCursor(bv, show);
+ return;
+ }
+ if (!isCursorVisible()) {
+ LyXFont const font =
+ getLyXText(bv)->getFont(bv->buffer(), cpar(bv), cpos(bv));
+
+ int const asc = lyxfont::maxAscent(font);
+ int const desc = lyxfont::maxDescent(font);
+
+ bv->fitLockedInsetCursor(cx(bv), cy(bv), asc, desc);
+ if (show)
+ bv->showLockedInsetCursor(cx(bv), cy(bv), asc, desc);
+ setCursorVisible(true);
+ }
+}
+
+
+void InsetText::hideInsetCursor(BufferView * bv)
+{
+ if (isCursorVisible()) {
+ bv->hideLockedInsetCursor();
+ setCursorVisible(false);
+ }
+ if (the_locking_inset)
+ the_locking_inset->hideInsetCursor(bv);
+}
+
+
+void InsetText::fitInsetCursor(BufferView * bv) const
+{
+ if (the_locking_inset) {
+ the_locking_inset->fitInsetCursor(bv);
+ return;
+ }
+ LyXFont const font =
+ getLyXText(bv)->getFont(bv->buffer(), cpar(bv), cpos(bv));
+
+ int const asc = lyxfont::maxAscent(font);
+ int const desc = lyxfont::maxDescent(font);
+
+ bv->fitLockedInsetCursor(cx(bv), cy(bv), asc, desc);
+}
+
+
+UpdatableInset::RESULT
+InsetText::moveRight(BufferView * bv, bool activate_inset, bool selecting)
+{
+ if (getLyXText(bv)->cursor.par()->isRightToLeftPar(bv->buffer()->params))
+ return moveLeftIntern(bv, false, activate_inset, selecting);
+ else
+ return moveRightIntern(bv, false, activate_inset, selecting);
+}
+
+
+UpdatableInset::RESULT
+InsetText::moveLeft(BufferView * bv, bool activate_inset, bool selecting)
+{
+ if (getLyXText(bv)->cursor.par()->isRightToLeftPar(bv->buffer()->params))
+ return moveRightIntern(bv, true, activate_inset, selecting);
+ else
+ return moveLeftIntern(bv, true, activate_inset, selecting);
+}
+
+
+UpdatableInset::RESULT
+InsetText::moveRightIntern(BufferView * bv, bool behind,
+ bool activate_inset, bool selecting)
+{
+ if (!cpar(bv)->next() && (cpos(bv) >= cpar(bv)->size()))
+ return FINISHED;
+ if (activate_inset && checkAndActivateInset(bv, behind))
+ return DISPATCHED;
+ getLyXText(bv)->cursorRight(bv);
+ if (!selecting)
+ getLyXText(bv)->selection.cursor = getLyXText(bv)->cursor;
+ return DISPATCHED_NOUPDATE;
+}
+
+
+UpdatableInset::RESULT
+InsetText::moveLeftIntern(BufferView * bv, bool behind,
+ bool activate_inset, bool selecting)
+{
+ if (!cpar(bv)->previous() && (cpos(bv) <= 0))
+ return FINISHED;
+ getLyXText(bv)->cursorLeft(bv);
+ if (!selecting)
+ getLyXText(bv)->selection.cursor = getLyXText(bv)->cursor;
+ if (activate_inset && checkAndActivateInset(bv, behind))
+ return DISPATCHED;
+ return DISPATCHED_NOUPDATE;
+}
+
+
+UpdatableInset::RESULT
+InsetText::moveUp(BufferView * bv)
+{
+ if (!crow(bv)->previous())
+ return FINISHED;
+ getLyXText(bv)->cursorUp(bv);
+ return DISPATCHED_NOUPDATE;
+}
+
+
+UpdatableInset::RESULT
+InsetText::moveDown(BufferView * bv)
+{
+ if (!crow(bv)->next())
+ return FINISHED;
+ getLyXText(bv)->cursorDown(bv);
+ return DISPATCHED_NOUPDATE;
+}
+
+
+bool InsetText::insertInset(BufferView * bv, Inset * inset)
+{
+ if (the_locking_inset) {
+ if (the_locking_inset->insetAllowed(inset))
+ return the_locking_inset->insertInset(bv, inset);
+ return false;
+ }
+ inset->setOwner(this);
+ hideInsetCursor(bv);
+
+ bool clear = false;
+ if (!lt) {
+ lt = getLyXText(bv);
+ clear = true;
+ }
+ lt->insertInset(bv, inset);