From fa09ff85c48f7f1fa1081bae98431163fd9333dd Mon Sep 17 00:00:00 2001 From: Angus Leeming Date: Wed, 26 Feb 2003 15:01:10 +0000 Subject: [PATCH] Define InsetCommand::localDispatch and use it for LFUN_REF_APPLY. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6281 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/BufferView_pimpl.C | 22 ++++++++++------------ src/ChangeLog | 5 +++++ src/insets/ChangeLog | 4 ++++ src/insets/insetcommand.C | 21 +++++++++++++++++++-- src/insets/insetcommand.h | 2 ++ 5 files changed, 40 insertions(+), 14 deletions(-) diff --git a/src/BufferView_pimpl.C b/src/BufferView_pimpl.C index dd0074921b..f608d2a5d2 100644 --- a/src/BufferView_pimpl.C +++ b/src/BufferView_pimpl.C @@ -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(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; diff --git a/src/ChangeLog b/src/ChangeLog index 0b13ea291b..5738419f1d 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2003-02-26 Angus Leeming + + * BufferView_pimpl.C (dispatch): use InsetCommand::localDispatch for + LFUN_REF_APPLY. + 2003-02-25 John Levon * ispell.C: give the forked command a more accurate name diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index f4ef416f30..d5a9beaeb4 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,3 +1,7 @@ +2003-02-26 Angus Leeming + + * insetcommand.[Ch] (localDispatch): new method. + 2003-02-26 Angus Leeming * insetinclude.C (draw): cache the BufferView* using cache not diff --git a/src/insets/insetcommand.C b/src/insets/insetcommand.C index 3b2874b036..7c291d23af 100644 --- a/src/insets/insetcommand.C +++ b/src/insets/insetcommand.C @@ -11,12 +11,15 @@ #include - #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) diff --git a/src/insets/insetcommand.h b/src/insets/insetcommand.h index 387363a7d2..f5da108153 100644 --- a/src/insets/insetcommand.h +++ b/src/insets/insetcommand.h @@ -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: /// -- 2.39.5