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"
23 using std::istringstream;
24 using std::ostringstream;
28 ControlParagraph::ControlParagraph(Dialog & parent)
29 : Dialog::Controller(parent), ininset_(false)
33 bool ControlParagraph::initialiseParams(string const & data)
35 istringstream is(data);
39 // Set tri-state flag:
40 // action == 0: show dialog
41 // action == 1: update dialog, accept changes
42 // action == 2: update dialog, do not accept changes
47 string const token = lex.getString();
49 if (token == "show") {
51 } else if (token == "update") {
53 bool const accept = lex.getBool();
54 action = accept ? 1 : 2;
55 } else if (!token.empty()) {
61 ParagraphParameters * tmp = new ParagraphParameters;
64 // For now, only reset the params on "show".
65 // Don't bother checking if the params are different on "update"
72 // Read the rest of the data irrespective of "show" or "update"
76 string const token = lex.getString();
82 if (token == "\\alignpossible" ||
83 token == "\\aligndefault" ||
84 token == "\\ininset") {
86 Int = lex.getInteger();
94 if (token == "\\alignpossible") {
95 alignpossible_ = static_cast<LyXAlignment>(Int);
96 } else if (token == "\\aligndefault") {
97 aligndefault_ = static_cast<LyXAlignment>(Int);
106 // If "update", then set the activation status of the button controller
108 bool const accept = action == 1;
109 dialog().bc().valid(accept);
115 void ControlParagraph::clearParams()
121 void ControlParagraph::dispatchParams()
124 params().write(data);
125 FuncRequest const fr(LFUN_PARAGRAPH_APPLY, data.str());
126 kernel().dispatch(fr);
130 ParagraphParameters & ControlParagraph::params()
132 BOOST_ASSERT(params_.get());
137 ParagraphParameters const & ControlParagraph::params() const
139 BOOST_ASSERT(params_.get());
144 bool ControlParagraph::inInset() const
150 LyXAlignment ControlParagraph::alignPossible() const
152 return alignpossible_;
156 LyXAlignment ControlParagraph::alignDefault() const
158 return aligndefault_;