X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Ffactory.C;h=3509bc8150b612b3d2ce56836ecfd2f538778f7f;hb=498f06d43a0f2000c3f704db1ea39fda3c819fe6;hp=54d08fa2ea7b80edb2c304fa63b030407df5b118;hpb=a0d71b53fea6dfb12489f937de0eb7218b0d20ea;p=lyx.git diff --git a/src/factory.C b/src/factory.C index 54d08fa2ea..3509bc8150 100644 --- a/src/factory.C +++ b/src/factory.C @@ -1,3 +1,14 @@ +/** + * \file factory.C + * This file is part of LyX, the document processor. + * Licence details can be found in the file COPYING. + * + * \author André Pönitz + * + * Full author contact details are available in file CREDITS + */ + +#include #include "funcrequest.h" #include "bufferparams.h" @@ -5,22 +16,36 @@ #include "FloatList.h" #include "debug.h" #include "BufferView.h" +#include "lyxtext.h" + +#include "insets/insetcaption.h" #include "insets/insetert.h" #include "insets/insetexternal.h" #include "insets/insetfloat.h" #include "insets/insetfoot.h" +#include "insets/insetindex.h" #include "insets/insetmarginal.h" #include "insets/insetminipage.h" #include "insets/insetnote.h" #include "insets/insetoptarg.h" #include "insets/insetparent.h" #include "insets/insetref.h" +#include "insets/insettabular.h" #include "insets/insettext.h" +#include "insets/insettoc.h" +#include "insets/inseturl.h" +#include "insets/insetwrap.h" +#include "frontends/Dialogs.h" +#include "frontends/LyXView.h" + +#include +using std::endl; Inset * createInset(FuncRequest const & cmd) { - BufferParams const & params = cmd.view()->buffer()->params; + BufferView * bv = cmd.view(); + BufferParams const & params = bv->buffer()->params; switch (cmd.action) { @@ -61,6 +86,67 @@ Inset * createInset(FuncRequest const & cmd) 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: { + string const entry = cmd.argument.empty() ? + "index" : cmd.argument; + InsetCommandParams icp; + icp.setFromString(entry); + + if (icp.getContents().empty()) + icp.setContents(bv->getLyXText()->getStringToIndex(bv)); + if (!icp.getContents().empty()) + return new InsetIndex(icp); + + bv->owner()->getDialogs().createIndex(); + 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(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; @@ -74,5 +160,3 @@ Inset * createInset(FuncRequest const & cmd) } return 0; } - -