]> git.lyx.org Git - features.git/commitdiff
Define InsetCommand::localDispatch and use it for LFUN_REF_APPLY.
authorAngus Leeming <leeming@lyx.org>
Wed, 26 Feb 2003 15:01:10 +0000 (15:01 +0000)
committerAngus Leeming <leeming@lyx.org>
Wed, 26 Feb 2003 15:01:10 +0000 (15:01 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6281 a592a061-630c-0410-9148-cb99ea01b6c8

src/BufferView_pimpl.C
src/ChangeLog
src/insets/ChangeLog
src/insets/insetcommand.C
src/insets/insetcommand.h

index dd0074921b1e150800e18256e0807b1e76c80f02..f608d2a5d21e41c10605b31d01b4a619992e2264 100644 (file)
@@ -1312,25 +1312,23 @@ bool BufferView::Pimpl::dispatch(FuncRequest const & ev)
        break;
 
        case LFUN_REF_APPLY: {
-               InsetCommandParams params;
-               InsetCommandMailer::string2params(ev.argument, params);
-
+               dispatch_result result = UNDISPATCHED;
                InsetBase * base = owner_->getDialogs().getOpenInset("ref");
-               InsetRef * inset = 0;
+               Inset * inset = 0;
                if (base) {
-                       inset = dynamic_cast<InsetRef *>(base);
-                       if (!inset)
-                               break;
-
-                       inset->setParams(params);
+                       // This works both for 'original' and 'mathed' insets.
+                       result = base->localDispatch(ev);
                } else {
-                       InsetRef * inset = new InsetRef(params, *buffer_);
+                       InsetCommandParams params;
+                       InsetCommandMailer::string2params(ev.argument, params);
+
+                       inset = new InsetRef(params, *buffer_);
                        if (!insertInset(inset)) {
                                delete inset;
-                               break;
+                               result = UNDISPATCHED;
                        }
+                       updateInset(inset, true);
                }
-               updateInset(inset, true);
        }
        break;
 
index 0b13ea291ba714df1965d043cdcf825f55350111..5738419f1dc0bcbb15551a2431b38cccd2420e7b 100644 (file)
@@ -1,3 +1,8 @@
+2003-02-26  Angus Leeming  <leeming@lyx.org>
+
+       * BufferView_pimpl.C (dispatch): use InsetCommand::localDispatch for
+       LFUN_REF_APPLY.
+
 2003-02-25  John Levon  <levon@movementarian.org>
 
        * ispell.C: give the forked command a more accurate name
index f4ef416f3011453b82c57fdd56e01595cd083cd3..d5a9beaeb4a7bc46d05b4eedd612e99d875a444e 100644 (file)
@@ -1,3 +1,7 @@
+2003-02-26  Angus Leeming  <leeming@lyx.org>
+
+       * insetcommand.[Ch] (localDispatch): new method.
+
 2003-02-26  Angus Leeming  <leeming@lyx.org>
 
        * insetinclude.C (draw): cache the BufferView* using cache not
index 3b2874b036471cd57b8983feb1d9ea4dbb0ca057..7c291d23afba654edf978df9b79e0dd660ef1369 100644 (file)
 
 #include <config.h>
 
-
 #include "insetcommand.h"
+#include "BufferView.h"
 #include "debug.h"
+#include "funcrequest.h"
+#include "lyxlex.h"
+
 #include "frontends/Painter.h"
+
 #include "Lsstream.h"
-#include "lyxlex.h"
 
 using std::ostream;
 using std::endl;
@@ -61,6 +64,20 @@ int InsetCommand::docbook(Buffer const *, ostream &, bool) const
 }
 
 
+dispatch_result InsetCommand::localDispatch(FuncRequest const & cmd)
+{
+       InsetCommandParams p;
+       InsetCommandMailer::string2params(cmd.argument, p);
+       if (p.getCmdName().empty())
+               return UNDISPATCHED;
+
+       setParams(p);
+       if (view())
+               view()->updateInset(this, true);
+
+       return DISPATCHED;
+}
+
 InsetCommandMailer::InsetCommandMailer(string const & name,
                                       InsetCommand & inset)
        : name_(name), inset_(inset)
index 387363a7d211d5cf39f9358782f1d44c10eb4d89..f5da108153399f6cffaa9b5b3a395895db0c8e7f 100644 (file)
@@ -70,6 +70,8 @@ public:
        InsetCommandParams const & params() const { return p_; }
        ///
        void setParams(InsetCommandParams const &);
+       /// small wrapper for the time being
+       virtual dispatch_result localDispatch(FuncRequest const & cmd);
 
 private:
        ///