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"
24 ControlParagraph::ControlParagraph(Dialog & parent)
25 : Dialog::Controller(parent), ininset_(false)
29 void ControlParagraph::initialiseParams(string const & data)
31 istringstream is(data);
35 // Set tri-state flag:
36 // action == 0: show dialog
37 // action == 1: update dialog, accept changes
38 // action == 2: update dialog, do not accept changes
43 string const token = lex.getString();
45 if (token == "show") {
47 } else if (token == "update") {
49 bool const accept = lex.getBool();
50 action = accept ? 1 : 2;
57 ParagraphParameters * tmp = new ParagraphParameters;
60 // For now, only reset the params on "show".
61 // Don't bother checking if the params are different on "update"
68 // Read the rest of the data irrespective of "show" or "update"
72 string const token = lex.getString();
75 if (token == "\\alignpossible" ||
76 token == "\\aligndefault" ||
77 token == "\\ininset") {
79 Int = lex.getInteger();
87 if (token == "\\alignpossible") {
88 alignpossible_ = static_cast<LyXAlignment>(Int);
89 } else if (token == "\\aligndefault") {
90 aligndefault_ = static_cast<LyXAlignment>(Int);
95 lyx::Assert(nset == 3);
97 // If "update", then set the activation status of the button controller
99 bool const accept = action == 1;
100 dialog().bc().valid(accept);
105 void ControlParagraph::clearParams()
111 void ControlParagraph::dispatchParams()
114 params().write(data);
115 FuncRequest const fr(LFUN_PARAGRAPH_APPLY, data.str());
116 kernel().dispatch(fr);
120 ParagraphParameters & ControlParagraph::params()
122 lyx::Assert(params_.get());
127 ParagraphParameters const & ControlParagraph::params() const
129 lyx::Assert(params_.get());
134 bool ControlParagraph::inInset() const
140 LyXAlignment ControlParagraph::alignPossible() const
142 return alignpossible_;
146 LyXAlignment ControlParagraph::alignDefault() const
148 return aligndefault_;