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"
23 using namespace lyx::support;
25 ControlParagraph::ControlParagraph(Dialog & parent)
26 : Dialog::Controller(parent), ininset_(false)
30 bool ControlParagraph::initialiseParams(string const & data)
32 istringstream is(STRCONV(data));
36 // Set tri-state flag:
37 // action == 0: show dialog
38 // action == 1: update dialog, accept changes
39 // action == 2: update dialog, do not accept changes
44 string const token = lex.getString();
46 if (token == "show") {
48 } else if (token == "update") {
50 bool const accept = lex.getBool();
51 action = accept ? 1 : 2;
52 } else if (!token.empty()) {
58 ParagraphParameters * tmp = new ParagraphParameters;
61 // For now, only reset the params on "show".
62 // Don't bother checking if the params are different on "update"
69 // Read the rest of the data irrespective of "show" or "update"
73 string const token = lex.getString();
79 if (token == "\\alignpossible" ||
80 token == "\\aligndefault" ||
81 token == "\\ininset") {
83 Int = lex.getInteger();
91 if (token == "\\alignpossible") {
92 alignpossible_ = static_cast<LyXAlignment>(Int);
93 } else if (token == "\\aligndefault") {
94 aligndefault_ = static_cast<LyXAlignment>(Int);
103 // If "update", then set the activation status of the button controller
105 bool const accept = action == 1;
106 dialog().bc().valid(accept);
112 void ControlParagraph::clearParams()
118 void ControlParagraph::dispatchParams()
121 params().write(data);
122 FuncRequest const fr(LFUN_PARAGRAPH_APPLY, STRCONV(data.str()));
123 kernel().dispatch(fr);
127 ParagraphParameters & ControlParagraph::params()
129 Assert(params_.get());
134 ParagraphParameters const & ControlParagraph::params() const
136 Assert(params_.get());
141 bool ControlParagraph::inInset() const
147 LyXAlignment ControlParagraph::alignPossible() const
149 return alignpossible_;
153 LyXAlignment ControlParagraph::alignDefault() const
155 return aligndefault_;