diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index c026d21c6d..9307dbe4dd 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,3 +1,10 @@ +2003-03-07 Angus Leeming + + * insetbibitem.C (localDispatch): + * insetbibtex.C (localDispatch): + * insetlabel.C (localDispatch): + rewrite as a switch. + 2003-03-07 Angus Leeming * insetgraphics.[Ch]: define a new class InsetGraphicsMailer and use diff --git a/src/insets/insetbibitem.C b/src/insets/insetbibitem.C index 13a491b147..50abe3fe5b 100644 --- a/src/insets/insetbibitem.C +++ b/src/insets/insetbibitem.C @@ -51,24 +51,30 @@ Inset * InsetBibitem::clone(Buffer const &, bool) const dispatch_result InsetBibitem::localDispatch(FuncRequest const & cmd) { - if (cmd.action != LFUN_INSET_MODIFY) - return UNDISPATCHED; + Inset::RESULT result = UNDISPATCHED; - InsetCommandParams p; - InsetCommandMailer::string2params(cmd.argument, p); - if (p.getCmdName().empty()) - return UNDISPATCHED; + switch (cmd.action) { + case LFUN_INSET_MODIFY: { + InsetCommandParams p; + InsetCommandMailer::string2params(cmd.argument, p); + if (p.getCmdName().empty()) + break; - if (view() && p.getContents() != params().getContents()) { - view()->ChangeCitationsIfUnique(params().getContents(), - p.getContents()); + if (view() && p.getContents() != params().getContents()) { + view()->ChangeCitationsIfUnique(params().getContents(), + p.getContents()); + } + + setParams(p); + cmd.view()->updateInset(this, true); + result = DISPATCHED; + } + break; + default: + result = InsetCommand::localDispatch(cmd); } - setParams(p); - if (view()) - view()->updateInset(this, true); - - return DISPATCHED; + return result; } diff --git a/src/insets/insetbibtex.C b/src/insets/insetbibtex.C index 895b7a032b..370faeaf2b 100644 --- a/src/insets/insetbibtex.C +++ b/src/insets/insetbibtex.C @@ -48,24 +48,30 @@ InsetBibtex::~InsetBibtex() dispatch_result InsetBibtex::localDispatch(FuncRequest const & cmd) { - if (cmd.action != LFUN_INSET_MODIFY) - return UNDISPATCHED; + Inset::RESULT result = UNDISPATCHED; - InsetCommandParams p; - InsetCommandMailer::string2params(cmd.argument, p); - if (p.getCmdName().empty()) - return UNDISPATCHED; + switch (cmd.action) { + case LFUN_INSET_MODIFY: { + InsetCommandParams p; + InsetCommandMailer::string2params(cmd.argument, p); + if (p.getCmdName().empty()) + break; - if (view() && p.getContents() != params().getContents()) { - view()->ChangeCitationsIfUnique(params().getContents(), - p.getContents()); + if (view() && p.getContents() != params().getContents()) { + view()->ChangeCitationsIfUnique(params().getContents(), + p.getContents()); + } + + setParams(p); + cmd.view()->updateInset(this, true); + result = DISPATCHED; + } + break; + default: + result = InsetCommand::localDispatch(cmd); } - setParams(p); - if (view()) - view()->updateInset(this, true); - - return DISPATCHED; + return result; } string const InsetBibtex::getScreenLabel(Buffer const *) const diff --git a/src/insets/insetlabel.C b/src/insets/insetlabel.C index 015504e96b..0642361d3c 100644 --- a/src/insets/insetlabel.C +++ b/src/insets/insetlabel.C @@ -54,36 +54,31 @@ void InsetLabel::edit(BufferView *, int, int, mouse_button::state) dispatch_result InsetLabel::localDispatch(FuncRequest const & cmd) { - if (cmd.action != LFUN_INSET_MODIFY) - return UNDISPATCHED; + Inset::RESULT result = UNDISPATCHED; - InsetCommandParams p; - InsetCommandMailer::string2params(cmd.argument, p); - if (p.getCmdName().empty()) - return UNDISPATCHED; + switch (cmd.action) { + case LFUN_INSET_MODIFY: { + InsetCommandParams p; + InsetCommandMailer::string2params(cmd.argument, p); + if (p.getCmdName().empty()) + return UNDISPATCHED; - bool clean = true; - if (view() && p.getContents() != params().getContents()) { - clean = view()->ChangeRefsIfUnique(params().getContents(), - p.getContents()); + bool clean = true; + if (view() && p.getContents() != params().getContents()) { + clean = view()->ChangeRefsIfUnique(params().getContents(), + p.getContents()); + } + + setParams(p); + cmd.view()->updateInset(this, !clean); + result = DISPATCHED; + } + break; + default: + result = InsetCommand::localDispatch(cmd); } - setParams(p); - if (view()) - view()->updateInset(this, !clean); - - return DISPATCHED; -// if (result.first) { -// string new_contents = trim(result.second); -// if (!new_contents.empty() && -// getContents() != new_contents) { -// bv->buffer()->markDirty(); -// bool flag = bv->ChangeRefsIfUnique(getContents(), -// new_contents); -// setContents(new_contents); -// bv->updateInset(this, !flag); -// } -// } + return result; }