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"
19 #include "FuncRequest.h"
21 #include "Paragraph.h"
22 #include "ParagraphParameters.h"
26 using std::istringstream;
27 using std::ostringstream;
33 ControlParagraph::ControlParagraph(Dialog & parent)
34 : Dialog::Controller(parent), ininset_(false)
38 bool ControlParagraph::initialiseParams(string const & data)
40 istringstream is(data);
44 // Set tri-state flag:
45 // action == 0: show dialog
46 // action == 1: update dialog, accept changes
47 // action == 2: update dialog, do not accept changes
52 string const token = lex.getString();
54 if (token == "show") {
56 } else if (token == "update") {
58 bool const accept = lex.getBool();
60 action = accept ? 1 : 2;
62 // Unrecognised update option
65 } else if (!token.empty()) {
71 ParagraphParameters * tmp = new ParagraphParameters;
74 // For now, only reset the params on "show".
75 // Don't bother checking if the params are different on "update"
82 // Read the rest of the data irrespective of "show" or "update"
86 string const token = lex.getString();
92 if (token == "\\alignpossible" ||
93 token == "\\aligndefault" ||
94 token == "\\ininset") {
96 Int = lex.getInteger();
104 if (token == "\\alignpossible") {
105 alignpossible_ = static_cast<LyXAlignment>(Int);
106 } else if (token == "\\aligndefault") {
107 aligndefault_ = static_cast<LyXAlignment>(Int);
116 // If "update", then set the activation status of the button controller
118 bool const accept = action == 1;
119 dialog().setButtonsValid(accept);
125 void ControlParagraph::clearParams()
131 void ControlParagraph::dispatchParams()
134 params().write(data);
135 FuncRequest const fr(LFUN_PARAGRAPH_PARAMS_APPLY, data.str());
136 kernel().dispatch(fr);
140 ParagraphParameters & ControlParagraph::params()
142 BOOST_ASSERT(params_.get());
147 ParagraphParameters const & ControlParagraph::params() const
149 BOOST_ASSERT(params_.get());
154 bool const ControlParagraph::haveMulitParSelection() {
155 Cursor cur = kernel().bufferview()->cursor();
156 if (!cur.selection())
158 return (cur.selBegin().pit() != cur.selEnd().pit());
161 bool ControlParagraph::inInset() const
166 bool ControlParagraph::canIndent() const
168 return kernel().buffer().params().paragraph_separation ==
169 BufferParams::PARSEP_INDENT;
172 LyXAlignment ControlParagraph::alignPossible() const
174 return alignpossible_;
178 LyXAlignment ControlParagraph::alignDefault() const
180 return aligndefault_;
183 } // namespace frontend