From: André Pönitz Date: Wed, 4 Feb 2004 11:23:25 +0000 (+0000) Subject: two bug fixes X-Git-Tag: 1.6.10~15531 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=281047c2bfb5c50b16f9ebab4a2f1b0aed4f7e12;p=features.git two bug fixes git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8401 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/BufferView.C b/src/BufferView.C index 6c7b71e859..85dee85ac9 100644 --- a/src/BufferView.C +++ b/src/BufferView.C @@ -303,33 +303,6 @@ void BufferView::setCursorFromRow(int row) } -void BufferView::insertInset(InsetBase * inset, string const & lout) -{ - // not quite sure if we want this... - text()->recUndo(text()->cursor().par()); - freezeUndo(); - - cursor().clearSelection(); - if (!lout.empty()) { - text()->breakParagraph(buffer()->paragraphs()); - - if (!text()->cursorPar()->empty()) { - text()->cursorLeft(true); - text()->breakParagraph(buffer()->paragraphs()); - } - - string lres = lout; - LyXTextClass const & tclass = buffer()->params().getLyXTextClass(); - bool hasLayout = tclass.hasLayout(lres); - - text()->setLayout(hasLayout ? lres : tclass.defaultLayoutName()); - text()->setParagraph(Spacing(), LYX_ALIGN_LAYOUT, string(), 0); - } - cursor().innerText()->insertInset(inset); - unFreezeUndo(); -} - - void BufferView::gotoLabel(string const & label) { for (Buffer::inset_iterator it = buffer()->inset_iterator_begin(); diff --git a/src/BufferView.h b/src/BufferView.h index b047df3904..2399db6d13 100644 --- a/src/BufferView.h +++ b/src/BufferView.h @@ -140,10 +140,6 @@ public: /// set the cursor based on the given TeX source row void setCursorFromRow(int row); - /// Insert an inset into the buffer, in a layout of lout. - void insertInset(InsetBase * inset, - std::string const & lout = std::string()); - /// Inserts a lyx file at cursor position. return false if it fails bool insertLyXFile(std::string const & file); diff --git a/src/BufferView_pimpl.C b/src/BufferView_pimpl.C index d67b7990cc..dee7f7df35 100644 --- a/src/BufferView_pimpl.C +++ b/src/BufferView_pimpl.C @@ -1080,7 +1080,23 @@ bool BufferView::Pimpl::dispatch(FuncRequest const & cmd) case LFUN_FLOAT_LIST: if (tclass.floats().typeExist(cmd.argument)) { InsetBase * inset = new InsetFloatList(cmd.argument); - bv_->insertInset(inset, tclass.defaultLayoutName()); + + // not quite sure if we want this... + bv_->text()->recUndo(bv_->text()->cursor().par()); + freezeUndo(); + + cur.clearSelection(); + bv_->text()->breakParagraph(bv_->buffer()->paragraphs()); + + if (!bv_->text()->cursorPar()->empty()) { + bv_->text()->cursorLeft(true); + bv_->text()->breakParagraph(bv_->buffer()->paragraphs()); + } + + bv_->text()->setLayout(tclass.defaultLayoutName()); + bv_->text()->setParagraph(Spacing(), LYX_ALIGN_LAYOUT, string(), 0); + bv_->getLyXText()->insertInset(inset); + unFreezeUndo(); } else { lyxerr << "Non-existent float type: " << cmd.argument << endl; diff --git a/src/insets/insetfootlike.C b/src/insets/insetfootlike.C index 964e2d594b..4ceb2efe41 100644 --- a/src/insets/insetfootlike.C +++ b/src/insets/insetfootlike.C @@ -42,15 +42,6 @@ InsetFootlike::InsetFootlike(InsetFootlike const & in) } -void InsetFootlike::metrics(MetricsInfo & mi, Dimension & dim) const -{ - InsetCollapsable::metrics(mi, dim); - if (isOpen()) - dim.wid = mi.base.textwidth; - dim_ = dim; -} - - void InsetFootlike::write(Buffer const & buf, ostream & os) const { os << getInsetName() << "\n"; diff --git a/src/insets/insetfootlike.h b/src/insets/insetfootlike.h index c6489f53d3..31387e47da 100644 --- a/src/insets/insetfootlike.h +++ b/src/insets/insetfootlike.h @@ -24,8 +24,6 @@ public: /// InsetFootlike(InsetFootlike const &); /// - void metrics(MetricsInfo &, Dimension &) const; - /// void write(Buffer const & buf, std::ostream & os) const; /// bool insetAllowed(InsetOld::Code) const; diff --git a/src/mathed/math_hullinset.C b/src/mathed/math_hullinset.C index 165e6b0a3f..4bfd9ac8fc 100644 --- a/src/mathed/math_hullinset.C +++ b/src/mathed/math_hullinset.C @@ -1328,7 +1328,7 @@ namespace { bool openNewInset(LCursor & cur, InsetBase * inset) { - cur.bv().insertInset(inset); + cur.bv().getLyXText()->insertInset(inset); inset->edit(cur, true); return true; } diff --git a/src/text2.C b/src/text2.C index a352a9b05e..ea4466542c 100644 --- a/src/text2.C +++ b/src/text2.C @@ -291,7 +291,7 @@ void LyXText::setLayout(string const & layout) bv()->owner()->dispatch(FuncRequest(LFUN_ENDSEL)); bv()->owner()->dispatch(FuncRequest(LFUN_CUT)); InsetBase * inset = new InsetEnvironment(params, layout); - bv()->insertInset(inset); + insertInset(inset); //inset->edit(bv()); //bv()->owner()->dispatch(FuncRequest(LFUN_PASTE)); return; diff --git a/src/text3.C b/src/text3.C index 778ba44459..211edad94c 100644 --- a/src/text3.C +++ b/src/text3.C @@ -398,14 +398,13 @@ namespace { void specialChar(LyXText * text, BufferView * bv, InsetSpecialChar::Kind kind) { bv->update(); - InsetSpecialChar * new_inset = new InsetSpecialChar(kind); replaceSelection(text); - bv->insertInset(new_inset); + text->insertInset(new InsetSpecialChar(kind)); bv->update(); } -void doInsertInset(BufferView * bv, FuncRequest const & cmd, +void doInsertInset(LyXText * text, BufferView * bv, FuncRequest const & cmd, bool edit, bool pastesel) { InsetBase * inset = createInset(bv, cmd); @@ -417,7 +416,7 @@ void doInsertInset(BufferView * bv, FuncRequest const & cmd, bv->owner()->dispatch(FuncRequest(LFUN_CUT)); gotsel = true; } - bv->insertInset(inset); + text->insertInset(inset); if (edit) inset->edit(bv->cursor(), true); if (gotsel && pastesel) @@ -863,7 +862,7 @@ DispatchResult LyXText::dispatch(LCursor & cur, FuncRequest const & cmd) case LFUN_INSET_INSERT: { InsetBase * inset = createInset(bv, cmd); if (inset) - bv->insertInset(inset); + insertInset(inset); break; } @@ -884,7 +883,7 @@ DispatchResult LyXText::dispatch(LCursor & cur, FuncRequest const & cmd) if (cursorPar()->layout()->free_spacing) insertChar(' '); else - doInsertInset(bv, cmd, false, false); + doInsertInset(this, bv, cmd, false, false); moveCursor(cur, false); break; @@ -1108,7 +1107,7 @@ DispatchResult LyXText::dispatch(LCursor & cur, FuncRequest const & cmd) BufferParams const & bufparams = bv->buffer()->params(); if (style->pass_thru || pit->getFontSettings(bufparams,pos).language()->lang() == "hebrew") - bv->insertInset(new InsetQuotes(c, bufparams)); + insertInset(new InsetQuotes(c, bufparams)); else bv->owner()->dispatch(FuncRequest(LFUN_SELFINSERT, "\"")); break; @@ -1357,12 +1356,12 @@ DispatchResult LyXText::dispatch(LCursor & cur, FuncRequest const & cmd) case LFUN_ENVIRONMENT_INSERT: // Open the inset, and move the current selection // inside it. - doInsertInset(bv, cmd, true, true); + doInsertInset(this, bv, cmd, true, true); break; case LFUN_INDEX_INSERT: // Just open the inset - doInsertInset(bv, cmd, true, false); + doInsertInset(this, bv, cmd, true, false); break; case LFUN_INDEX_PRINT: @@ -1371,7 +1370,7 @@ DispatchResult LyXText::dispatch(LCursor & cur, FuncRequest const & cmd) case LFUN_INSERT_LINE: case LFUN_INSERT_PAGEBREAK: // do nothing fancy - doInsertInset(bv, cmd, false, false); + doInsertInset(this, bv, cmd, false, false); break; case LFUN_DEPTH_MIN: