]> git.lyx.org Git - lyx.git/blob - src/frontends/controllers/ControlTabular.C
* Give Dialog::Controller::initialiseParams a bool return type.
[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 bool ControlTabular::initialiseParams(string const & data)
27 {
28         Buffer * buffer = kernel().buffer();
29         if (!buffer)
30                 return false;
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         return true;
39 }
40
41
42 void ControlTabular::clearParams()
43 {
44         params_.reset();
45         active_cell_ = -1;
46 }
47
48
49 int ControlTabular::getActiveCell() const
50 {
51         return active_cell_;
52 }
53
54
55 LyXTabular const & ControlTabular::tabular() const
56 {
57         lyx::Assert(params_.get());
58         return *params_.get();
59 }
60
61
62 void ControlTabular::set(LyXTabular::Feature f, string const & arg)
63 {
64         string const data = featureAsString(f) + ' ' + arg;
65         kernel().dispatch(FuncRequest(LFUN_TABULAR_FEATURE, data));
66 }
67
68
69 bool ControlTabular::useMetricUnits() const
70 {
71         return lyxrc.default_papersize > BufferParams::PAPER_EXECUTIVEPAPER;
72 }