mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 05:16:21 +00:00
Add locaDispatch methods to various inset classes. refactor the LFUN_XYZ_APPLY
code but do not yet attempt to collapse them into LFUN_DIALOG_APPLY. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6289 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
c6c5eb530c
commit
86e2d69f18
@ -9,51 +9,43 @@
|
||||
#include <config.h>
|
||||
|
||||
#include "BufferView_pimpl.h"
|
||||
#include "frontends/WorkArea.h"
|
||||
#include "frontends/screen.h"
|
||||
#include "frontends/LyXScreenFactory.h"
|
||||
#include "frontends/WorkAreaFactory.h"
|
||||
#include "frontends/Dialogs.h"
|
||||
#include "frontends/Alert.h"
|
||||
#include "frontends/FileDialog.h"
|
||||
#include "frontends/mouse_state.h"
|
||||
#include "bufferlist.h"
|
||||
#include "bufferview_funcs.h"
|
||||
#include "commandtags.h"
|
||||
#include "debug.h"
|
||||
#include "factory.h"
|
||||
#include "FloatList.h"
|
||||
#include "funcrequest.h"
|
||||
#include "gettext.h"
|
||||
#include "intl.h"
|
||||
#include "iterators.h"
|
||||
#include "lyx_cb.h" // added for Dispatch functions
|
||||
#include "lyx_main.h"
|
||||
#include "lyxfind.h"
|
||||
#include "lyxfunc.h"
|
||||
#include "lyxtext.h"
|
||||
#include "lyxrc.h"
|
||||
#include "lyxrow.h"
|
||||
#include "paragraph.h"
|
||||
#include "frontends/LyXView.h"
|
||||
#include "commandtags.h"
|
||||
#include "lyxfunc.h"
|
||||
#include "debug.h"
|
||||
#include "bufferview_funcs.h"
|
||||
#include "TextCache.h"
|
||||
#include "bufferlist.h"
|
||||
#include "lyxrc.h"
|
||||
#include "intl.h"
|
||||
// added for Dispatch functions
|
||||
#include "lyx_cb.h"
|
||||
#include "lyx_main.h"
|
||||
#include "FloatList.h"
|
||||
#include "gettext.h"
|
||||
#include "ParagraphParameters.h"
|
||||
#include "TextCache.h"
|
||||
#include "undo_funcs.h"
|
||||
#include "funcrequest.h"
|
||||
#include "iterators.h"
|
||||
#include "lyxfind.h"
|
||||
|
||||
#include "insets/insetbibitem.h"
|
||||
#include "insets/insetbibtex.h"
|
||||
#include "insets/insetcite.h"
|
||||
#include "insets/insetert.h"
|
||||
#include "insets/insetfloatlist.h"
|
||||
#include "insets/insetgraphics.h"
|
||||
#include "insets/insetinclude.h"
|
||||
#include "insets/insetindex.h"
|
||||
#include "insets/insetlatexaccent.h"
|
||||
#include "insets/insetmarginal.h"
|
||||
#include "insets/insetref.h"
|
||||
#include "insets/insettext.h"
|
||||
#include "insets/insettoc.h"
|
||||
#include "insets/inseturl.h"
|
||||
|
||||
#include "frontends/Alert.h"
|
||||
#include "frontends/Dialogs.h"
|
||||
#include "frontends/FileDialog.h"
|
||||
#include "frontends/LyXView.h"
|
||||
#include "frontends/LyXScreenFactory.h"
|
||||
#include "frontends/mouse_state.h"
|
||||
#include "frontends/screen.h"
|
||||
#include "frontends/WorkArea.h"
|
||||
#include "frontends/WorkAreaFactory.h"
|
||||
|
||||
#include "mathed/formulabase.h"
|
||||
|
||||
@ -969,8 +961,12 @@ void BufferView::Pimpl::trackChanges()
|
||||
}
|
||||
|
||||
|
||||
bool BufferView::Pimpl::dispatch(FuncRequest const & ev)
|
||||
bool BufferView::Pimpl::dispatch(FuncRequest const & ev_in)
|
||||
{
|
||||
// Make sure that the cached BufferView is correct.
|
||||
FuncRequest ev = ev_in;
|
||||
ev.setView(bv_);
|
||||
|
||||
lyxerr[Debug::ACTION] << "BufferView::Pimpl::Dispatch:"
|
||||
<< " action[" << ev.action << ']'
|
||||
<< " arg[" << ev.argument << ']'
|
||||
@ -1169,212 +1165,71 @@ bool BufferView::Pimpl::dispatch(FuncRequest const & ev)
|
||||
case LFUN_MATH_DISPLAY: // Open or create a displayed math inset
|
||||
case LFUN_MATH_MODE: // Open or create an inlined math inset
|
||||
case LFUN_GREEK: // Insert a single greek letter
|
||||
mathDispatch(FuncRequest(bv_, ev.action, ev.argument));
|
||||
mathDispatch(ev);
|
||||
break;
|
||||
|
||||
case LFUN_BIBITEM_APPLY: {
|
||||
InsetCommandParams params;
|
||||
InsetCommandMailer::string2params(ev.argument, params);
|
||||
|
||||
InsetBase * base =
|
||||
owner_->getDialogs().getOpenInset("bibitem");
|
||||
InsetBibitem * inset = 0;
|
||||
if (base) {
|
||||
inset = dynamic_cast<InsetBibitem *>(base);
|
||||
if (!inset)
|
||||
break;
|
||||
|
||||
if (params.getContents() !=
|
||||
inset->params().getContents()) {
|
||||
bv_->ChangeCitationsIfUnique(
|
||||
inset->params().getContents(),
|
||||
params.getContents());
|
||||
}
|
||||
inset->setParams(params);
|
||||
} else {
|
||||
inset = new InsetBibitem(params);
|
||||
if (!insertInset(inset)) {
|
||||
delete inset;
|
||||
break;
|
||||
}
|
||||
}
|
||||
updateInset(inset, true);
|
||||
|
||||
// We need to do a redraw because the maximum
|
||||
// InsetBibitem width could have changed
|
||||
#warning please check you mean repaint() not update(),
|
||||
#warning and whether the repaint() is needed at all
|
||||
bv_->repaint();
|
||||
bv_->fitCursor();
|
||||
}
|
||||
break;
|
||||
|
||||
case LFUN_BIBTEX_APPLY: {
|
||||
InsetCommandParams params;
|
||||
InsetCommandMailer::string2params(ev.argument, params);
|
||||
|
||||
InsetBase * base =
|
||||
owner_->getDialogs().getOpenInset("bibtex");
|
||||
InsetBibtex * inset = 0;
|
||||
if (base) {
|
||||
inset = dynamic_cast<InsetBibtex *>(base);
|
||||
if (!inset)
|
||||
break;
|
||||
|
||||
if (params.getContents() !=
|
||||
inset->params().getContents()) {
|
||||
bv_->ChangeCitationsIfUnique(
|
||||
inset->params().getContents(),
|
||||
params.getContents());
|
||||
}
|
||||
inset->setParams(params);
|
||||
} else {
|
||||
inset = new InsetBibtex(params);
|
||||
if (!insertInset(inset)) {
|
||||
delete inset;
|
||||
break;
|
||||
}
|
||||
}
|
||||
updateInset(inset, true);
|
||||
}
|
||||
break;
|
||||
|
||||
case LFUN_CITATION_APPLY: {
|
||||
InsetCommandParams params;
|
||||
InsetCommandMailer::string2params(ev.argument, params);
|
||||
|
||||
InsetBase * base =
|
||||
owner_->getDialogs().getOpenInset("citation");
|
||||
InsetCitation * inset = 0;
|
||||
if (base) {
|
||||
inset = dynamic_cast<InsetCitation *>(base);
|
||||
if (!inset)
|
||||
break;
|
||||
|
||||
inset->setParams(params);
|
||||
} else {
|
||||
inset = new InsetCitation(params);
|
||||
if (!insertInset(inset)) {
|
||||
delete inset;
|
||||
break;
|
||||
} else {
|
||||
inset->setLoadingBuffer(bv_->buffer(), false);
|
||||
}
|
||||
}
|
||||
updateInset(inset, true);
|
||||
}
|
||||
break;
|
||||
|
||||
case LFUN_ERT_APPLY: {
|
||||
InsetBase * base = owner_->getDialogs().getOpenInset("ert");
|
||||
InsetERT * inset = 0;
|
||||
if (base) {
|
||||
inset = dynamic_cast<InsetERT *>(base);
|
||||
if (!inset)
|
||||
break;
|
||||
} else {
|
||||
inset = new InsetERT(bv_->buffer()->params);
|
||||
if (!insertInset(inset)) {
|
||||
delete inset;
|
||||
break;
|
||||
}
|
||||
case LFUN_BIBITEM_APPLY:
|
||||
case LFUN_BIBTEX_APPLY:
|
||||
case LFUN_CITATION_APPLY:
|
||||
case LFUN_ERT_APPLY:
|
||||
case LFUN_INDEX_APPLY:
|
||||
case LFUN_REF_APPLY:
|
||||
case LFUN_TOC_APPLY:
|
||||
case LFUN_URL_APPLY: {
|
||||
string name;
|
||||
switch (ev.action) {
|
||||
case LFUN_BIBITEM_APPLY:
|
||||
name = "bibitem";
|
||||
break;
|
||||
case LFUN_BIBTEX_APPLY:
|
||||
name = "bibtex";
|
||||
break;
|
||||
case LFUN_CITATION_APPLY:
|
||||
name = "citation";
|
||||
break;
|
||||
case LFUN_ERT_APPLY:
|
||||
name = "ert";
|
||||
break;
|
||||
case LFUN_INDEX_APPLY:
|
||||
name = "index";
|
||||
break;
|
||||
case LFUN_REF_APPLY:
|
||||
name = "ref";
|
||||
break;
|
||||
case LFUN_TOC_APPLY:
|
||||
name = "toc";
|
||||
break;
|
||||
case LFUN_URL_APPLY:
|
||||
name = "url";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
InsetERT::ERTStatus status;
|
||||
InsetERTMailer::string2params(ev.argument, status);
|
||||
|
||||
inset->status(bv_, status);
|
||||
updateInset(inset, true);
|
||||
}
|
||||
break;
|
||||
|
||||
case LFUN_INDEX_APPLY: {
|
||||
InsetCommandParams params;
|
||||
InsetCommandMailer::string2params(ev.argument, params);
|
||||
|
||||
InsetBase * base = owner_->getDialogs().getOpenInset("index");
|
||||
InsetIndex * inset = 0;
|
||||
if (base) {
|
||||
inset = dynamic_cast<InsetIndex *>(base);
|
||||
if (!inset)
|
||||
break;
|
||||
|
||||
inset->setParams(params);
|
||||
} else {
|
||||
InsetIndex * inset = new InsetIndex(params);
|
||||
if (!insertInset(inset)) {
|
||||
delete inset;
|
||||
break;
|
||||
}
|
||||
}
|
||||
updateInset(inset, true);
|
||||
}
|
||||
break;
|
||||
|
||||
case LFUN_REF_APPLY: {
|
||||
dispatch_result result = UNDISPATCHED;
|
||||
InsetBase * base = owner_->getDialogs().getOpenInset("ref");
|
||||
InsetBase * base = owner_->getDialogs().getOpenInset(name);
|
||||
Inset * inset = 0;
|
||||
if (base) {
|
||||
// This works both for 'original' and 'mathed' insets.
|
||||
result = base->localDispatch(ev);
|
||||
// Note that the localDispatch performs updateInset
|
||||
// also.
|
||||
base->localDispatch(ev);
|
||||
} else {
|
||||
InsetCommandParams params;
|
||||
InsetCommandMailer::string2params(ev.argument, params);
|
||||
|
||||
inset = new InsetRef(params, *buffer_);
|
||||
if (!insertInset(inset)) {
|
||||
inset = createInset(ev);
|
||||
if (inset && insertInset(inset)) {
|
||||
updateInset(inset, true);
|
||||
} else {
|
||||
delete inset;
|
||||
result = UNDISPATCHED;
|
||||
}
|
||||
updateInset(inset, true);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case LFUN_TOC_APPLY: {
|
||||
InsetCommandParams params;
|
||||
InsetCommandMailer::string2params(ev.argument, params);
|
||||
|
||||
InsetBase * base = owner_->getDialogs().getOpenInset("toc");
|
||||
InsetTOC * inset = 0;
|
||||
if (base) {
|
||||
InsetTOC * inset = dynamic_cast<InsetTOC *>(base);
|
||||
if (!inset)
|
||||
break;
|
||||
|
||||
inset->setParams(params);
|
||||
} else {
|
||||
InsetTOC * inset = new InsetTOC(params);
|
||||
if (!insertInset(inset)) {
|
||||
delete inset;
|
||||
break;
|
||||
}
|
||||
}
|
||||
updateInset(inset, true);
|
||||
}
|
||||
break;
|
||||
|
||||
case LFUN_URL_APPLY: {
|
||||
InsetCommandParams params;
|
||||
InsetCommandMailer::string2params(ev.argument, params);
|
||||
|
||||
InsetBase * base = owner_->getDialogs().getOpenInset("url");
|
||||
InsetUrl * inset = 0;
|
||||
if (base) {
|
||||
inset = dynamic_cast<InsetUrl *>(base);
|
||||
if (!inset)
|
||||
break;
|
||||
|
||||
inset->setParams(params);
|
||||
} else {
|
||||
InsetUrl * inset = new InsetUrl(params);
|
||||
if (!insertInset(inset)) {
|
||||
delete inset;
|
||||
break;
|
||||
}
|
||||
if (ev.action == LFUN_BIBITEM_APPLY) {
|
||||
// We need to do a redraw because the maximum
|
||||
// InsetBibitem width could have changed
|
||||
#warning please check you mean repaint() not update(),
|
||||
#warning and whether the repaint() is needed at all
|
||||
bv_->repaint();
|
||||
bv_->fitCursor();
|
||||
}
|
||||
updateInset(inset, true);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -1,3 +1,12 @@
|
||||
2003-02-26 Angus Leeming <leeming@lyx.org>
|
||||
|
||||
* BufferView_pimpl.C (dispatch): callapse the various LFUN_XYZ_APPLY
|
||||
blocks together.
|
||||
Rearrange the ~includes. Strip out the unnecessary ones.
|
||||
|
||||
* factory.C (createInset): reformat.
|
||||
create new insets for the various LFUN_XYZ_APPLY lfuns.
|
||||
|
||||
2003-02-26 John Levon <levon@movementarian.org>
|
||||
|
||||
* lyxrow.h:
|
||||
|
258
src/factory.C
258
src/factory.C
@ -19,7 +19,9 @@
|
||||
#include "lyxtext.h"
|
||||
|
||||
#include "insets/insetbibitem.h"
|
||||
#include "insets/insetbibtex.h"
|
||||
#include "insets/insetcaption.h"
|
||||
#include "insets/insetcite.h"
|
||||
#include "insets/insetert.h"
|
||||
#include "insets/insetexternal.h"
|
||||
#include "insets/insetfloat.h"
|
||||
@ -49,123 +51,175 @@ Inset * createInset(FuncRequest const & cmd)
|
||||
BufferParams const & params = bv->buffer()->params;
|
||||
|
||||
switch (cmd.action) {
|
||||
case LFUN_INSET_MINIPAGE:
|
||||
return new InsetMinipage(params);
|
||||
|
||||
case LFUN_INSET_MINIPAGE:
|
||||
return new InsetMinipage(params);
|
||||
case LFUN_INSERT_NOTE:
|
||||
return new InsetNote(params);
|
||||
|
||||
case LFUN_INSERT_NOTE:
|
||||
return new InsetNote(params);
|
||||
case LFUN_INSET_ERT:
|
||||
return new InsetERT(params);
|
||||
|
||||
case LFUN_INSET_ERT:
|
||||
return new InsetERT(params);
|
||||
case LFUN_INSET_EXTERNAL:
|
||||
return new InsetExternal;
|
||||
|
||||
case LFUN_INSET_EXTERNAL:
|
||||
return new InsetExternal;
|
||||
case LFUN_INSET_FOOTNOTE:
|
||||
return new InsetFoot(params);
|
||||
|
||||
case LFUN_INSET_FOOTNOTE:
|
||||
return new InsetFoot(params);
|
||||
case LFUN_INSET_MARGINAL:
|
||||
return new InsetMarginal(params);
|
||||
|
||||
case LFUN_INSET_MARGINAL:
|
||||
return new InsetMarginal(params);
|
||||
case LFUN_INSET_OPTARG:
|
||||
return new InsetOptArg(params);
|
||||
|
||||
case LFUN_INSET_OPTARG:
|
||||
return new InsetOptArg(params);
|
||||
case LFUN_INSERT_BIBITEM:
|
||||
return new InsetBibitem(InsetCommandParams("bibitem"));
|
||||
|
||||
case LFUN_INSERT_BIBITEM:
|
||||
return new InsetBibitem(InsetCommandParams("bibitem"));
|
||||
case LFUN_INSET_FLOAT:
|
||||
// check if the float type exists
|
||||
if (params.getLyXTextClass().floats().typeExist(cmd.argument))
|
||||
return new InsetFloat(params, cmd.argument);
|
||||
lyxerr << "Non-existent float type: " << cmd.argument << endl;
|
||||
return 0;
|
||||
|
||||
case LFUN_INSET_FLOAT:
|
||||
// check if the float type exists
|
||||
if (params.getLyXTextClass().floats().typeExist(cmd.argument))
|
||||
return new InsetFloat(params, cmd.argument);
|
||||
lyxerr << "Non-existent float type: " << cmd.argument << endl;
|
||||
return 0;
|
||||
|
||||
case LFUN_INSET_WIDE_FLOAT:
|
||||
// check if the float type exists
|
||||
if (params.getLyXTextClass().floats().typeExist(cmd.argument)) {
|
||||
InsetFloat * p = new InsetFloat(params, cmd.argument);
|
||||
p->wide(true, params);
|
||||
}
|
||||
lyxerr << "Non-existent float type: " << cmd.argument << endl;
|
||||
return 0;
|
||||
|
||||
case LFUN_INSET_WRAP:
|
||||
if (cmd.argument == "figure")
|
||||
return new InsetWrap(params, cmd.argument);
|
||||
lyxerr << "Non-existent floatflt type: " << cmd.argument << endl;
|
||||
return 0;
|
||||
|
||||
case LFUN_INDEX_INSERT: {
|
||||
// Try and generate a valid index entry.
|
||||
InsetCommandParams icp("index");
|
||||
string const contents = cmd.argument.empty() ?
|
||||
bv->getLyXText()->getStringToIndex(bv) :
|
||||
cmd.argument;
|
||||
icp.setContents(contents);
|
||||
|
||||
string data = InsetCommandMailer::params2string(icp);
|
||||
LyXView * lv = bv->owner();
|
||||
|
||||
if (icp.getContents().empty()) {
|
||||
lv->getDialogs().show("index", data, 0);
|
||||
} else {
|
||||
FuncRequest fr(bv, LFUN_INDEX_APPLY, data);
|
||||
lv->dispatch(fr);
|
||||
}
|
||||
return 0;
|
||||
case LFUN_INSET_WIDE_FLOAT:
|
||||
// check if the float type exists
|
||||
if (params.getLyXTextClass().floats().typeExist(cmd.argument)) {
|
||||
InsetFloat * p = new InsetFloat(params, cmd.argument);
|
||||
p->wide(true, params);
|
||||
}
|
||||
lyxerr << "Non-existent float type: " << cmd.argument << endl;
|
||||
return 0;
|
||||
|
||||
case LFUN_TABULAR_INSERT:
|
||||
if (!cmd.argument.empty()) {
|
||||
int r = 2;
|
||||
int c = 2;
|
||||
::sscanf(cmd.argument.c_str(),"%d%d", &r, &c);
|
||||
return new InsetTabular(*bv->buffer(), r, c);
|
||||
}
|
||||
bv->owner()->getDialogs().showTabularCreate();
|
||||
return 0;
|
||||
case LFUN_INSET_WRAP:
|
||||
if (cmd.argument == "figure")
|
||||
return new InsetWrap(params, cmd.argument);
|
||||
lyxerr << "Non-existent floatflt type: " << cmd.argument << endl;
|
||||
return 0;
|
||||
|
||||
case LFUN_INSET_CAPTION:
|
||||
if (bv->theLockingInset()) {
|
||||
lyxerr << "Locking inset code: "
|
||||
<< static_cast<int>(bv->theLockingInset()->lyxCode());
|
||||
InsetCaption * inset = new InsetCaption(params);
|
||||
inset->setOwner(bv->theLockingInset());
|
||||
inset->setAutoBreakRows(true);
|
||||
inset->setDrawFrame(0, InsetText::LOCKED);
|
||||
inset->setFrameColor(0, LColor::captionframe);
|
||||
return inset;
|
||||
}
|
||||
return 0;
|
||||
case LFUN_INDEX_INSERT: {
|
||||
// Try and generate a valid index entry.
|
||||
InsetCommandParams icp("index");
|
||||
string const contents = cmd.argument.empty() ?
|
||||
bv->getLyXText()->getStringToIndex(bv) :
|
||||
cmd.argument;
|
||||
icp.setContents(contents);
|
||||
|
||||
case LFUN_INDEX_PRINT:
|
||||
return new InsetPrintIndex(InsetCommandParams("printindex"));
|
||||
string data = InsetCommandMailer::params2string(icp);
|
||||
LyXView * lv = bv->owner();
|
||||
|
||||
case LFUN_TOC_INSERT:
|
||||
return new InsetTOC(InsetCommandParams("tableofcontents"));
|
||||
|
||||
case LFUN_PARENTINSERT:
|
||||
return new InsetParent(
|
||||
InsetCommandParams("lyxparent", cmd.argument), *bv->buffer());
|
||||
|
||||
case LFUN_INSERT_URL:
|
||||
{
|
||||
InsetCommandParams p;
|
||||
p.setFromString(cmd.argument);
|
||||
return new InsetUrl(p);
|
||||
if (icp.getContents().empty()) {
|
||||
lv->getDialogs().show("index", data, 0);
|
||||
} else {
|
||||
FuncRequest fr(bv, LFUN_INDEX_APPLY, data);
|
||||
lv->dispatch(fr);
|
||||
}
|
||||
|
||||
#if 0
|
||||
case LFUN_INSET_LIST:
|
||||
return new InsetList;
|
||||
|
||||
case LFUN_INSET_THEOREM:
|
||||
return new InsetTheorem;
|
||||
#endif
|
||||
|
||||
default:
|
||||
break;
|
||||
return 0;
|
||||
}
|
||||
|
||||
case LFUN_TABULAR_INSERT:
|
||||
if (!cmd.argument.empty()) {
|
||||
int r = 2;
|
||||
int c = 2;
|
||||
::sscanf(cmd.argument.c_str(),"%d%d", &r, &c);
|
||||
return new InsetTabular(*bv->buffer(), r, c);
|
||||
}
|
||||
bv->owner()->getDialogs().showTabularCreate();
|
||||
return 0;
|
||||
|
||||
case LFUN_INSET_CAPTION:
|
||||
if (bv->theLockingInset()) {
|
||||
lyxerr << "Locking inset code: "
|
||||
<< static_cast<int>(bv->theLockingInset()->lyxCode());
|
||||
InsetCaption * inset = new InsetCaption(params);
|
||||
inset->setOwner(bv->theLockingInset());
|
||||
inset->setAutoBreakRows(true);
|
||||
inset->setDrawFrame(0, InsetText::LOCKED);
|
||||
inset->setFrameColor(0, LColor::captionframe);
|
||||
return inset;
|
||||
}
|
||||
return 0;
|
||||
|
||||
case LFUN_INDEX_PRINT:
|
||||
return new InsetPrintIndex(InsetCommandParams("printindex"));
|
||||
|
||||
case LFUN_TOC_INSERT:
|
||||
return new InsetTOC(InsetCommandParams("tableofcontents"));
|
||||
|
||||
case LFUN_PARENTINSERT:
|
||||
return new InsetParent(
|
||||
InsetCommandParams("lyxparent", cmd.argument), *bv->buffer());
|
||||
|
||||
case LFUN_INSERT_URL:
|
||||
{
|
||||
InsetCommandParams p;
|
||||
p.setFromString(cmd.argument);
|
||||
return new InsetUrl(p);
|
||||
}
|
||||
|
||||
#if 0
|
||||
case LFUN_INSET_LIST:
|
||||
return new InsetList;
|
||||
|
||||
case LFUN_INSET_THEOREM:
|
||||
return new InsetTheorem;
|
||||
#endif
|
||||
|
||||
case LFUN_BIBITEM_APPLY: {
|
||||
InsetCommandParams icp;
|
||||
InsetCommandMailer::string2params(cmd.argument, icp);
|
||||
return new InsetBibitem(icp);
|
||||
}
|
||||
|
||||
case LFUN_BIBTEX_APPLY: {
|
||||
InsetCommandParams icp;
|
||||
InsetCommandMailer::string2params(cmd.argument, icp);
|
||||
return new InsetBibtex(icp);
|
||||
}
|
||||
|
||||
case LFUN_CITATION_APPLY: {
|
||||
InsetCommandParams icp;
|
||||
InsetCommandMailer::string2params(cmd.argument, icp);
|
||||
InsetCitation * inset = new InsetCitation(icp);
|
||||
inset->setLoadingBuffer(bv->buffer(), false);
|
||||
return inset;
|
||||
}
|
||||
|
||||
case LFUN_ERT_APPLY: {
|
||||
InsetERT * inset = new InsetERT(params);
|
||||
InsetERT::ERTStatus s;
|
||||
InsetERTMailer::string2params(cmd.argument, s);
|
||||
inset->status(bv, s);
|
||||
return inset;
|
||||
}
|
||||
|
||||
case LFUN_INDEX_APPLY: {
|
||||
InsetCommandParams icp;
|
||||
InsetCommandMailer::string2params(cmd.argument, icp);
|
||||
return new InsetIndex(icp);
|
||||
}
|
||||
|
||||
case LFUN_REF_APPLY: {
|
||||
InsetCommandParams icp;
|
||||
InsetCommandMailer::string2params(cmd.argument, icp);
|
||||
return new InsetRef(icp, *bv->buffer());
|
||||
}
|
||||
|
||||
case LFUN_TOC_APPLY: {
|
||||
InsetCommandParams icp;
|
||||
InsetCommandMailer::string2params(cmd.argument, icp);
|
||||
return new InsetTOC(icp);
|
||||
}
|
||||
|
||||
case LFUN_URL_APPLY: {
|
||||
InsetCommandParams icp;
|
||||
InsetCommandMailer::string2params(cmd.argument, icp);
|
||||
return new InsetUrl(icp);
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,3 +1,15 @@
|
||||
2003-02-26 Angus Leeming <leeming@lyx.org>
|
||||
|
||||
* insetbibitem.[Ch] (localDispatch):
|
||||
* insetbibtex.[Ch] (localDispatch):
|
||||
new method. Modify inset on receipt of LFUN_XYZ_APPLY.
|
||||
|
||||
* insetcommand.C (localDispatch):
|
||||
act only on receipt of LFUN_XYZ_APPLY.
|
||||
|
||||
* insetert.C (localDispatch): reformat.
|
||||
add LFUN_XYZ_APPLY to the switch.
|
||||
|
||||
2003-02-26 John Levon <levon@movementarian.org>
|
||||
|
||||
* insettext.C: use RowPainter
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include "insetbibitem.h"
|
||||
#include "buffer.h"
|
||||
#include "BufferView.h"
|
||||
#include "funcrequest.h"
|
||||
#include "lyxlex.h"
|
||||
|
||||
#include "frontends/font_metrics.h"
|
||||
@ -48,6 +49,29 @@ Inset * InsetBibitem::clone(Buffer const &, bool) const
|
||||
}
|
||||
|
||||
|
||||
dispatch_result InsetBibitem::localDispatch(FuncRequest const & cmd)
|
||||
{
|
||||
if (cmd.action != LFUN_BIBITEM_APPLY)
|
||||
return UNDISPATCHED;
|
||||
|
||||
InsetCommandParams p;
|
||||
InsetCommandMailer::string2params(cmd.argument, p);
|
||||
if (p.getCmdName().empty())
|
||||
return UNDISPATCHED;
|
||||
|
||||
if (view() && p.getContents() != params().getContents()) {
|
||||
view()->ChangeCitationsIfUnique(params().getContents(),
|
||||
p.getContents());
|
||||
}
|
||||
|
||||
setParams(p);
|
||||
if (view())
|
||||
view()->updateInset(this, true);
|
||||
|
||||
return DISPATCHED;
|
||||
}
|
||||
|
||||
|
||||
void InsetBibitem::setCounter(int c)
|
||||
{
|
||||
counter = c;
|
||||
|
@ -30,6 +30,8 @@ public:
|
||||
~InsetBibitem();
|
||||
///
|
||||
Inset * clone(Buffer const &, bool same_id = false) const;
|
||||
/// small wrapper for the time being
|
||||
virtual dispatch_result localDispatch(FuncRequest const & cmd);
|
||||
/** Currently \bibitem is used as a LyX2.x command,
|
||||
so we need this method.
|
||||
*/
|
||||
|
@ -12,7 +12,9 @@
|
||||
|
||||
#include "insetbibtex.h"
|
||||
#include "buffer.h"
|
||||
#include "BufferView.h"
|
||||
#include "debug.h"
|
||||
#include "funcrequest.h"
|
||||
#include "gettext.h"
|
||||
|
||||
#include "support/filetools.h"
|
||||
@ -44,6 +46,28 @@ InsetBibtex::~InsetBibtex()
|
||||
}
|
||||
|
||||
|
||||
dispatch_result InsetBibtex::localDispatch(FuncRequest const & cmd)
|
||||
{
|
||||
if (cmd.action != LFUN_BIBTEX_APPLY)
|
||||
return UNDISPATCHED;
|
||||
|
||||
InsetCommandParams p;
|
||||
InsetCommandMailer::string2params(cmd.argument, p);
|
||||
if (p.getCmdName().empty())
|
||||
return UNDISPATCHED;
|
||||
|
||||
if (view() && p.getContents() != params().getContents()) {
|
||||
view()->ChangeCitationsIfUnique(params().getContents(),
|
||||
p.getContents());
|
||||
}
|
||||
|
||||
setParams(p);
|
||||
if (view())
|
||||
view()->updateInset(this, true);
|
||||
|
||||
return DISPATCHED;
|
||||
}
|
||||
|
||||
string const InsetBibtex::getScreenLabel(Buffer const *) const
|
||||
{
|
||||
return _("BibTeX Generated References");
|
||||
|
@ -30,6 +30,8 @@ public:
|
||||
Inset * clone(Buffer const &, bool same_id = false) const {
|
||||
return new InsetBibtex(params(), same_id);
|
||||
}
|
||||
/// small wrapper for the time being
|
||||
virtual dispatch_result localDispatch(FuncRequest const & cmd);
|
||||
///
|
||||
string const getScreenLabel(Buffer const *) const;
|
||||
///
|
||||
|
@ -65,6 +65,17 @@ int InsetCommand::docbook(Buffer const *, ostream &, bool) const
|
||||
|
||||
dispatch_result InsetCommand::localDispatch(FuncRequest const & cmd)
|
||||
{
|
||||
switch (cmd.action) {
|
||||
case LFUN_CITATION_APPLY:
|
||||
case LFUN_INDEX_APPLY:
|
||||
case LFUN_REF_APPLY:
|
||||
case LFUN_TOC_APPLY:
|
||||
case LFUN_URL_APPLY:
|
||||
break;
|
||||
default:
|
||||
return UNDISPATCHED;
|
||||
}
|
||||
|
||||
InsetCommandParams p;
|
||||
InsetCommandMailer::string2params(cmd.argument, p);
|
||||
if (p.getCmdName().empty())
|
||||
|
@ -450,24 +450,37 @@ Inset::RESULT InsetERT::localDispatch(FuncRequest const & cmd)
|
||||
}
|
||||
|
||||
switch (cmd.action) {
|
||||
case LFUN_MOUSE_PRESS:
|
||||
lfunMousePress(cmd);
|
||||
return DISPATCHED;
|
||||
case LFUN_ERT_APPLY: {
|
||||
if (!bv)
|
||||
return UNDISPATCHED;
|
||||
|
||||
case LFUN_MOUSE_MOTION:
|
||||
lfunMouseMotion(cmd);
|
||||
return DISPATCHED;
|
||||
InsetERT::ERTStatus status_;
|
||||
InsetERTMailer::string2params(cmd.argument, status_);
|
||||
|
||||
case LFUN_MOUSE_RELEASE:
|
||||
lfunMouseRelease(cmd);
|
||||
return DISPATCHED;
|
||||
status(bv, status_);
|
||||
bv->updateInset(this, true);
|
||||
return DISPATCHED;
|
||||
}
|
||||
break;
|
||||
|
||||
case LFUN_MOUSE_PRESS:
|
||||
lfunMousePress(cmd);
|
||||
return DISPATCHED;
|
||||
|
||||
case LFUN_LAYOUT:
|
||||
bv->owner()->setLayout(inset.paragraph()->layout()->name());
|
||||
break;
|
||||
case LFUN_MOUSE_MOTION:
|
||||
lfunMouseMotion(cmd);
|
||||
return DISPATCHED;
|
||||
|
||||
default:
|
||||
result = InsetCollapsable::localDispatch(cmd);
|
||||
case LFUN_MOUSE_RELEASE:
|
||||
lfunMouseRelease(cmd);
|
||||
return DISPATCHED;
|
||||
|
||||
case LFUN_LAYOUT:
|
||||
bv->owner()->setLayout(inset.paragraph()->layout()->name());
|
||||
break;
|
||||
|
||||
default:
|
||||
result = InsetCollapsable::localDispatch(cmd);
|
||||
}
|
||||
|
||||
switch (cmd.action) {
|
||||
|
@ -1,3 +1,7 @@
|
||||
2003-02-26 Angus Leeming <leeming@lyx.org>
|
||||
|
||||
* ref_inset.C (localDispatch): act only on receipt of LFUN_REF_APPLY.
|
||||
|
||||
2003-02-26 Angus Leeming <leeming@lyx.org>
|
||||
|
||||
* formula.C (draw): cache the BufferView* using cache not
|
||||
|
@ -132,11 +132,18 @@ int RefInset::docbook(std::ostream & os, bool) const
|
||||
|
||||
dispatch_result RefInset::localDispatch(FuncRequest const & cmd)
|
||||
{
|
||||
if (cmd.action != LFUN_REF_APPLY)
|
||||
return UNDISPATCHED;
|
||||
|
||||
MathArray ar;
|
||||
if (!string2RefInset(cmd.argument, ar))
|
||||
return UNDISPATCHED;
|
||||
|
||||
*this = *ar[0].nucleus()->asRefInset();
|
||||
// if (cmd.view())
|
||||
// // This does not compile because updateInset expects
|
||||
// // an Inset* and 'this' isn't.
|
||||
// cmd.view()->updateInset(this, true);
|
||||
return DISPATCHED;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user