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 "BufferView.h"
18 #include "ButtonController.h"
20 #include "FuncRequest.h"
22 #include "Paragraph.h"
23 #include "ParagraphParameters.h"
27 using std::istringstream;
28 using std::ostringstream;
34 ControlParagraph::ControlParagraph(Dialog & parent)
35 : Dialog::Controller(parent), ininset_(false)
39 bool ControlParagraph::initialiseParams(string const & data)
41 istringstream is(data);
45 // Set tri-state flag:
46 // action == 0: show dialog
47 // action == 1: update dialog, accept changes
48 // action == 2: update dialog, do not accept changes
53 string const token = lex.getString();
55 if (token == "show") {
57 } else if (token == "update") {
59 bool const accept = lex.getBool();
61 action = accept ? 1 : 2;
63 // Unrecognised update option
66 } else if (!token.empty()) {
72 ParagraphParameters * tmp = new ParagraphParameters;
75 // For now, only reset the params on "show".
76 // Don't bother checking if the params are different on "update"
83 // Read the rest of the data irrespective of "show" or "update"
87 string const token = lex.getString();
93 if (token == "\\alignpossible" ||
94 token == "\\aligndefault" ||
95 token == "\\ininset") {
97 Int = lex.getInteger();
105 if (token == "\\alignpossible") {
106 alignpossible_ = static_cast<LyXAlignment>(Int);
107 } else if (token == "\\aligndefault") {
108 aligndefault_ = static_cast<LyXAlignment>(Int);
117 // If "update", then set the activation status of the button controller
119 bool const accept = action == 1;
120 dialog().bc().valid(accept);
126 void ControlParagraph::clearParams()
132 void ControlParagraph::dispatchParams()
135 params().write(data);
136 FuncRequest const fr(LFUN_PARAGRAPH_PARAMS_APPLY, data.str());
137 kernel().dispatch(fr);
141 ParagraphParameters & ControlParagraph::params()
143 BOOST_ASSERT(params_.get());
148 ParagraphParameters const & ControlParagraph::params() const
150 BOOST_ASSERT(params_.get());
155 bool const ControlParagraph::haveMulitParSelection() {
156 Cursor cur = kernel().bufferview()->cursor();
157 if (!cur.selection())
159 return (cur.selBegin().pit() != cur.selEnd().pit());
162 bool ControlParagraph::inInset() const
167 bool ControlParagraph::canIndent() const
169 return kernel().buffer().params().paragraph_separation ==
170 BufferParams::PARSEP_INDENT;
173 LyXAlignment ControlParagraph::alignPossible() const
175 return alignpossible_;
179 LyXAlignment ControlParagraph::alignDefault() const
181 return aligndefault_;
184 } // namespace frontend