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"
20 #include "support/std_sstream.h"
22 using std::istringstream;
23 using std::ostringstream;
26 ControlParagraph::ControlParagraph(Dialog & parent)
27 : Dialog::Controller(parent), ininset_(false)
31 bool ControlParagraph::initialiseParams(string const & data)
33 istringstream is(data);
37 // Set tri-state flag:
38 // action == 0: show dialog
39 // action == 1: update dialog, accept changes
40 // action == 2: update dialog, do not accept changes
45 string const token = lex.getString();
47 if (token == "show") {
49 } else if (token == "update") {
51 bool const accept = lex.getBool();
52 action = accept ? 1 : 2;
53 } else if (!token.empty()) {
59 ParagraphParameters * tmp = new ParagraphParameters;
62 // For now, only reset the params on "show".
63 // Don't bother checking if the params are different on "update"
70 // Read the rest of the data irrespective of "show" or "update"
74 string const token = lex.getString();
80 if (token == "\\alignpossible" ||
81 token == "\\aligndefault" ||
82 token == "\\ininset") {
84 Int = lex.getInteger();
92 if (token == "\\alignpossible") {
93 alignpossible_ = static_cast<LyXAlignment>(Int);
94 } else if (token == "\\aligndefault") {
95 aligndefault_ = static_cast<LyXAlignment>(Int);
104 // If "update", then set the activation status of the button controller
106 bool const accept = action == 1;
107 dialog().bc().valid(accept);
113 void ControlParagraph::clearParams()
119 void ControlParagraph::dispatchParams()
122 params().write(data);
123 FuncRequest const fr(LFUN_PARAGRAPH_APPLY, data.str());
124 kernel().dispatch(fr);
128 ParagraphParameters & ControlParagraph::params()
130 BOOST_ASSERT(params_.get());
135 ParagraphParameters const & ControlParagraph::params() const
137 BOOST_ASSERT(params_.get());
142 bool ControlParagraph::inInset() const
148 LyXAlignment ControlParagraph::alignPossible() const
150 return alignpossible_;
154 LyXAlignment ControlParagraph::alignDefault() const
156 return aligndefault_;