2 * \file ControlParagraph.C
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();
56 action = accept ? 1 : 2;
57 } else if (!token.empty()) {
63 ParagraphParameters * tmp = new ParagraphParameters;
66 // For now, only reset the params on "show".
67 // Don't bother checking if the params are different on "update"
74 // Read the rest of the data irrespective of "show" or "update"
78 string const token = lex.getString();
84 if (token == "\\alignpossible" ||
85 token == "\\aligndefault" ||
86 token == "\\ininset") {
88 Int = lex.getInteger();
96 if (token == "\\alignpossible") {
97 alignpossible_ = static_cast<LyXAlignment>(Int);
98 } else if (token == "\\aligndefault") {
99 aligndefault_ = static_cast<LyXAlignment>(Int);
108 // If "update", then set the activation status of the button controller
110 bool const accept = action == 1;
111 dialog().bc().valid(accept);
117 void ControlParagraph::clearParams()
123 void ControlParagraph::dispatchParams()
126 params().write(data);
127 FuncRequest const fr(LFUN_PARAGRAPH_APPLY, data.str());
128 kernel().dispatch(fr);
132 ParagraphParameters & ControlParagraph::params()
134 BOOST_ASSERT(params_.get());
139 ParagraphParameters const & ControlParagraph::params() const
141 BOOST_ASSERT(params_.get());
146 bool ControlParagraph::inInset() const
152 LyXAlignment ControlParagraph::alignPossible() const
154 return alignpossible_;
158 LyXAlignment ControlParagraph::alignDefault() const
160 return aligndefault_;
163 } // namespace frontend