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"
16 #include "BufferParams.h"
17 #include "ButtonController.h"
18 #include "FuncRequest.h"
20 #include "Paragraph.h"
21 #include "ParagraphParameters.h"
25 using std::istringstream;
26 using std::ostringstream;
32 ControlParagraph::ControlParagraph(Dialog & parent)
33 : Dialog::Controller(parent), ininset_(false)
37 bool ControlParagraph::initialiseParams(string const & data)
39 istringstream is(data);
43 // Set tri-state flag:
44 // action == 0: show dialog
45 // action == 1: update dialog, accept changes
46 // action == 2: update dialog, do not accept changes
51 string const token = lex.getString();
53 if (token == "show") {
55 } else if (token == "update") {
57 bool const accept = lex.getBool();
59 action = accept ? 1 : 2;
61 // Unrecognised update option
64 } else if (!token.empty()) {
70 ParagraphParameters * tmp = new ParagraphParameters;
73 // For now, only reset the params on "show".
74 // Don't bother checking if the params are different on "update"
81 // Read the rest of the data irrespective of "show" or "update"
85 string const token = lex.getString();
91 if (token == "\\alignpossible" ||
92 token == "\\aligndefault" ||
93 token == "\\ininset") {
95 Int = lex.getInteger();
103 if (token == "\\alignpossible") {
104 alignpossible_ = static_cast<LyXAlignment>(Int);
105 } else if (token == "\\aligndefault") {
106 aligndefault_ = static_cast<LyXAlignment>(Int);
115 // If "update", then set the activation status of the button controller
117 bool const accept = action == 1;
118 dialog().bc().valid(accept);
124 void ControlParagraph::clearParams()
130 void ControlParagraph::dispatchParams()
133 params().write(data);
134 FuncRequest const fr(LFUN_PARAGRAPH_PARAMS_APPLY, data.str());
135 kernel().dispatch(fr);
139 ParagraphParameters & ControlParagraph::params()
141 BOOST_ASSERT(params_.get());
146 ParagraphParameters const & ControlParagraph::params() const
148 BOOST_ASSERT(params_.get());
153 bool ControlParagraph::inInset() const
158 bool ControlParagraph::canIndent() const
160 return kernel().buffer().params().paragraph_separation ==
161 BufferParams::PARSEP_INDENT;
164 LyXAlignment ControlParagraph::alignPossible() const
166 return alignpossible_;
170 LyXAlignment ControlParagraph::alignDefault() const
172 return aligndefault_;
175 } // namespace frontend