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(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;
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();
75 if (token == "\\alignpossible" ||
76 token == "\\aligndefault" ||
77 token == "\\ininset") {
79 Int = lex.getInteger();
87 if (token == "\\alignpossible") {
88 alignpossible_ = static_cast<LyXAlignment>(Int);
89 } else if (token == "\\aligndefault") {
90 aligndefault_ = static_cast<LyXAlignment>(Int);
98 // If "update", then set the activation status of the button controller
100 bool const accept = action == 1;
101 dialog().bc().valid(accept);
107 void ControlParagraph::clearParams()
113 void ControlParagraph::dispatchParams()
116 params().write(data);
117 FuncRequest const fr(LFUN_PARAGRAPH_APPLY, data.str());
118 kernel().dispatch(fr);
122 ParagraphParameters & ControlParagraph::params()
124 lyx::Assert(params_.get());
129 ParagraphParameters const & ControlParagraph::params() const
131 lyx::Assert(params_.get());
136 bool ControlParagraph::inInset() const
142 LyXAlignment ControlParagraph::alignPossible() const
144 return alignpossible_;
148 LyXAlignment ControlParagraph::alignDefault() const
150 return aligndefault_;