2 * \file ControlParagraph.cpp
3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
7 * \author Angus Leeming
9 * Full author contact details are available in file CREDITS.
14 #include "ControlParagraph.h"
15 #include "ButtonController.h"
16 #include "funcrequest.h"
18 #include "paragraph.h"
19 #include "ParagraphParameters.h"
23 using std::istringstream;
24 using std::ostringstream;
30 ControlParagraph::ControlParagraph(Dialog & parent)
31 : Dialog::Controller(parent), ininset_(false)
35 bool ControlParagraph::initialiseParams(string const & data)
37 istringstream is(data);
41 // Set tri-state flag:
42 // action == 0: show dialog
43 // action == 1: update dialog, accept changes
44 // action == 2: update dialog, do not accept changes
49 string const token = lex.getString();
51 if (token == "show") {
53 } else if (token == "update") {
55 bool const accept = lex.getBool();
57 action = accept ? 1 : 2;
59 // Unrecognised update option
62 } else if (!token.empty()) {
68 ParagraphParameters * tmp = new ParagraphParameters;
71 // For now, only reset the params on "show".
72 // Don't bother checking if the params are different on "update"
79 // Read the rest of the data irrespective of "show" or "update"
83 string const token = lex.getString();
89 if (token == "\\alignpossible" ||
90 token == "\\aligndefault" ||
91 token == "\\ininset") {
93 Int = lex.getInteger();
101 if (token == "\\alignpossible") {
102 alignpossible_ = static_cast<LyXAlignment>(Int);
103 } else if (token == "\\aligndefault") {
104 aligndefault_ = static_cast<LyXAlignment>(Int);
113 // If "update", then set the activation status of the button controller
115 bool const accept = action == 1;
116 dialog().bc().valid(accept);
122 void ControlParagraph::clearParams()
128 void ControlParagraph::dispatchParams()
131 params().write(data);
132 FuncRequest const fr(LFUN_PARAGRAPH_PARAMS_APPLY, data.str());
133 kernel().dispatch(fr);
137 ParagraphParameters & ControlParagraph::params()
139 BOOST_ASSERT(params_.get());
144 ParagraphParameters const & ControlParagraph::params() const
146 BOOST_ASSERT(params_.get());
151 bool ControlParagraph::inInset() const
157 LyXAlignment ControlParagraph::alignPossible() const
159 return alignpossible_;
163 LyXAlignment ControlParagraph::alignDefault() const
165 return aligndefault_;
168 } // namespace frontend