3 * \file ControlParagraph.C
4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
8 * \author Angus Leeming
10 * Full author contact details are available in file CREDITS
15 #include "ControlParagraph.h"
16 #include "ButtonController.h"
17 #include "funcrequest.h"
19 #include "ParagraphParameters.h"
20 #include "support/LAssert.h"
24 ControlParagraph::ControlParagraph(Dialog & parent)
25 : Dialog::Controller(parent), ininset_(false)
29 bool ControlParagraph::initialiseParams(string const & data)
31 istringstream is(STRCONV(data));
35 // Set tri-state flag:
36 // action == 0: show dialog
37 // action == 1: update dialog, accept changes
38 // action == 2: update dialog, do not accept changes
43 string const token = lex.getString();
45 if (token == "show") {
47 } else if (token == "update") {
49 bool const accept = lex.getBool();
50 action = accept ? 1 : 2;
51 } else if (!token.empty()) {
57 ParagraphParameters * tmp = new ParagraphParameters;
60 // For now, only reset the params on "show".
61 // Don't bother checking if the params are different on "update"
68 // Read the rest of the data irrespective of "show" or "update"
72 string const token = lex.getString();
78 if (token == "\\alignpossible" ||
79 token == "\\aligndefault" ||
80 token == "\\ininset") {
82 Int = lex.getInteger();
90 if (token == "\\alignpossible") {
91 alignpossible_ = static_cast<LyXAlignment>(Int);
92 } else if (token == "\\aligndefault") {
93 aligndefault_ = static_cast<LyXAlignment>(Int);
102 // If "update", then set the activation status of the button controller
104 bool const accept = action == 1;
105 dialog().bc().valid(accept);
111 void ControlParagraph::clearParams()
117 void ControlParagraph::dispatchParams()
120 params().write(data);
121 FuncRequest const fr(LFUN_PARAGRAPH_APPLY, STRCONV(data.str()));
122 kernel().dispatch(fr);
126 ParagraphParameters & ControlParagraph::params()
128 lyx::Assert(params_.get());
133 ParagraphParameters const & ControlParagraph::params() const
135 lyx::Assert(params_.get());
140 bool ControlParagraph::inInset() const
146 LyXAlignment ControlParagraph::alignPossible() const
148 return alignpossible_;
152 LyXAlignment ControlParagraph::alignDefault() const
154 return aligndefault_;