From: André Pönitz Date: Tue, 27 Aug 2002 15:56:32 +0000 (+0000) Subject: move tabular creation to the factory X-Git-Tag: 1.6.10~18444 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=a1e77e762d696bbd08d01ef4198cbbd7e4fe1a72;p=features.git move tabular creation to the factory git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@5125 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/factory.C b/src/factory.C index 54d08fa2ea..ac1368b630 100644 --- a/src/factory.C +++ b/src/factory.C @@ -15,12 +15,18 @@ #include "insets/insetoptarg.h" #include "insets/insetparent.h" #include "insets/insetref.h" +#include "insets/insettabular.h" #include "insets/insettext.h" +#include "frontends/Dialogs.h" +#include "frontends/LyXView.h" + +#include 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 +67,16 @@ Inset * createInset(FuncRequest const & cmd) 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; + #if 0 case LFUN_INSET_LIST: return new InsetList; diff --git a/src/text3.C b/src/text3.C index e7ecc2867c..fa90c2e43e 100644 --- a/src/text3.C +++ b/src/text3.C @@ -28,17 +28,14 @@ #include "frontends/LyXView.h" #include "frontends/screen.h" #include "frontends/WorkArea.h" -#include "frontends/Dialogs.h" #include "insets/insetspecialchar.h" #include "insets/insettext.h" #include "insets/insetquotes.h" #include "insets/insetcommand.h" -#include "insets/insettabular.h" #include "undo_funcs.h" #include #include -#include using std::endl; @@ -1072,7 +1069,9 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd) case LFUN_INSET_MARGINAL: case LFUN_INSET_MINIPAGE: case LFUN_INSET_OPTARG: - case LFUN_INSET_WIDE_FLOAT: { + case LFUN_INSET_WIDE_FLOAT: + case LFUN_TABULAR_INSERT: + { Inset * inset = createInset(cmd); if (inset) { bool gotsel = false; @@ -1091,22 +1090,6 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd) break; } - case LFUN_TABULAR_INSERT: - if (cmd.argument.empty()) - bv->owner()->getDialogs().showTabularCreate(); - else { - int r = 2; - int c = 2; - ::sscanf(cmd.argument.c_str(),"%d%d", &r, &c); - InsetTabular * inset = new InsetTabular(*bv->buffer(), r, c); - bv->beforeChange(this); - finishUndo(); - if (!bv->insertInset(inset)) - delete inset; - else - inset->edit(bv, !real_current_font.isRightToLeft()); - } - break; case LFUN_QUOTE: { Paragraph const * par = cursor.par();