]> git.lyx.org Git - features.git/commitdiff
two bug fixes
authorAndré Pönitz <poenitz@gmx.net>
Wed, 4 Feb 2004 11:23:25 +0000 (11:23 +0000)
committerAndré Pönitz <poenitz@gmx.net>
Wed, 4 Feb 2004 11:23:25 +0000 (11:23 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8401 a592a061-630c-0410-9148-cb99ea01b6c8

src/BufferView.C
src/BufferView.h
src/BufferView_pimpl.C
src/insets/insetfootlike.C
src/insets/insetfootlike.h
src/mathed/math_hullinset.C
src/text2.C
src/text3.C

index 6c7b71e8597e75c0f50463794d31fdfc89a46959..85dee85ac9d3abb221c01846b6abc821ad4a1f3b 100644 (file)
@@ -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();
index b047df3904a4c7a559a6647208097d2d5821c749..2399db6d13ca93faee12feb703a9ebc355eabafd 100644 (file)
@@ -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);
 
index d67b7990cc2d17fbbbe06935e46a4c6be7e48e31..dee7f7df354ac7192799b9a929cc46956ef85c44 100644 (file)
@@ -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;
index 964e2d594bbb93f26d6ae28b3c53789d44672d74..4ceb2efe41f22fa6e711370d67c0c0f65bfb0d2f 100644 (file)
@@ -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";
index c6489f53d399b392d87e7c1b3578451f2cefde47..31387e47da797cf1e8911d84dc72b04229f97f65 100644 (file)
@@ -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;
index 165e6b0a3fdfab50ab3ab6870340da29487c285b..4bfd9ac8fc502b7c31e342160a73e5f41b59b119 100644 (file)
@@ -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;
 }
index a352a9b05e456d86c521e148e19fd2ee5510434f..ea4466542c005eb38203bbe776a03b42a6a32b76 100644 (file)
@@ -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;
index 778ba44459e8f632dd6b39cd6105c649167b856a..211edad94c0c2ae6736a97efa1a986771e84f8e8 100644 (file)
@@ -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: