move tabular creation to the factory

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@5125 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
André Pönitz 2002-08-27 15:56:32 +00:00
parent a0d71b53fe
commit a1e77e762d
2 changed files with 20 additions and 21 deletions

View File

@ -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 <cstdio>
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;

View File

@ -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 <ctime>
#include <clocale>
#include <cstdio>
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();