]> git.lyx.org Git - lyx.git/blob - src/frontends/controllers/ControlTabular.C
Port the tabular dialog to the new scheme based on class Dialog.
[lyx.git] / src / frontends / controllers / ControlTabular.C
1 // -*- C++ -*-
2 /**
3  * \file ControlTabular.C
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author John Levon
8  *
9  * Full author contact details are available in file CREDITS
10  */
11
12 #include <config.h>
13
14 #include "ControlTabular.h"
15 #include "funcrequest.h"
16 #include "lyxrc.h"
17 #include "insets/insettabular.h"
18 #include "support/LAssert.h"
19
20
21 ControlTabular::ControlTabular(Dialog & parent)
22         : Dialog::Controller(parent), active_cell_(-1)
23 {}
24
25
26 void ControlTabular::initialiseParams(string const & data)
27 {
28         Buffer * buffer = kernel().buffer();
29         if (!buffer)
30                 return;
31
32         InsetTabular tmp(*buffer);
33         int cell = InsetTabularMailer::string2params(data, tmp);
34         if (cell != -1) {
35                 params_.reset(new LyXTabular(*tmp.tabular.get()));
36                 active_cell_ = cell;
37         }
38 }
39
40
41 void ControlTabular::clearParams()
42 {
43         params_.reset();
44         active_cell_ = -1;
45 }
46
47
48 int ControlTabular::getActiveCell() const
49 {
50         return active_cell_;
51 }
52
53
54 LyXTabular const & ControlTabular::tabular() const
55 {
56         lyx::Assert(params_.get());
57         return *params_.get();
58 }
59
60
61 void ControlTabular::set(LyXTabular::Feature f, string const & arg)
62 {
63         string const data = featureAsString(f) + ' ' + arg;
64         kernel().dispatch(FuncRequest(LFUN_TABULAR_FEATURE, data));
65 }
66
67
68 bool ControlTabular::useMetricUnits() const
69 {
70         return lyxrc.default_papersize > BufferParams::PAPER_EXECUTIVEPAPER;
71 }