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/LAssert.h"
21 #include "support/std_sstream.h"
23 using namespace lyx::support;
25 using std::istringstream;
26 using std::ostringstream;
29 ControlParagraph::ControlParagraph(Dialog & parent)
30 : Dialog::Controller(parent), ininset_(false)
34 bool ControlParagraph::initialiseParams(string const & data)
36 istringstream is(STRCONV(data));
40 // Set tri-state flag:
41 // action == 0: show dialog
42 // action == 1: update dialog, accept changes
43 // action == 2: update dialog, do not accept changes
48 string const token = lex.getString();
50 if (token == "show") {
52 } else if (token == "update") {
54 bool const accept = lex.getBool();
55 action = accept ? 1 : 2;
56 } else if (!token.empty()) {
62 ParagraphParameters * tmp = new ParagraphParameters;
65 // For now, only reset the params on "show".
66 // Don't bother checking if the params are different on "update"
73 // Read the rest of the data irrespective of "show" or "update"
77 string const token = lex.getString();
83 if (token == "\\alignpossible" ||
84 token == "\\aligndefault" ||
85 token == "\\ininset") {
87 Int = lex.getInteger();
95 if (token == "\\alignpossible") {
96 alignpossible_ = static_cast<LyXAlignment>(Int);
97 } else if (token == "\\aligndefault") {
98 aligndefault_ = static_cast<LyXAlignment>(Int);
107 // If "update", then set the activation status of the button controller
109 bool const accept = action == 1;
110 dialog().bc().valid(accept);
116 void ControlParagraph::clearParams()
122 void ControlParagraph::dispatchParams()
125 params().write(data);
126 FuncRequest const fr(LFUN_PARAGRAPH_APPLY, STRCONV(data.str()));
127 kernel().dispatch(fr);
131 ParagraphParameters & ControlParagraph::params()
133 Assert(params_.get());
138 ParagraphParameters const & ControlParagraph::params() const
140 Assert(params_.get());
145 bool ControlParagraph::inInset() const
151 LyXAlignment ControlParagraph::alignPossible() const
153 return alignpossible_;
157 LyXAlignment ControlParagraph::alignDefault() const
159 return aligndefault_;