namespace frontend {
ControlParagraph::ControlParagraph(Dialog & parent)
- : Controller(parent), ininset_(false)
+ : Controller(parent)
{}
-bool ControlParagraph::initialiseParams(string const & data)
+ParagraphParameters & ControlParagraph::params()
{
- istringstream is(data);
- Lexer lex(0,0);
- lex.setStream(is);
-
- // Set tri-state flag:
- // action == 0: show dialog
- // action == 1: update dialog, accept changes
- // action == 2: update dialog, do not accept changes
- int action = 0;
-
- if (lex.isOK()) {
- lex.next();
- string const token = lex.getString();
-
- if (token == "show") {
- action = 0;
- } else if (token == "update") {
- lex.next();
- bool const accept = lex.getBool();
- if (lex) {
- action = accept ? 1 : 2;
- } else {
- // Unrecognised update option
- return false;
- }
- } else if (!token.empty()) {
- // Unrecognised token
- return false;
- }
- }
-
- ParagraphParameters tmp;
- tmp.read(lex);
-
- // For now, only reset the params on "show".
- // Don't bother checking if the params are different on "update"
- if (action == 0)
- params_ = tmp;
-
- // Read the rest of the data irrespective of "show" or "update"
- int nset = 0;
- while (lex.isOK()) {
- lex.next();
- string const token = lex.getString();
-
- if (token.empty())
- continue;
-
- int Int = 0;
- if (token == "\\alignpossible" ||
- token == "\\aligndefault" ||
- token == "\\ininset") {
- lex.next();
- Int = lex.getInteger();
- } else {
- // Unrecognised token
- return false;
- }
-
- ++nset;
-
- if (token == "\\alignpossible") {
- alignpossible_ = static_cast<LyXAlignment>(Int);
- } else if (token == "\\aligndefault") {
- aligndefault_ = static_cast<LyXAlignment>(Int);
- } else {
- ininset_ = Int;
- }
- }
- if (nset != 3) {
- return false;
- }
-
- // If "update", then set the activation status of the button controller
- if (action > 0) {
- bool const accept = action == 1;
- dialog().setButtonsValid(accept);
- }
- return true;
+ return bufferview()->cursor().paragraph().params();
}
-void ControlParagraph::clearParams()
+ParagraphParameters const & ControlParagraph::params() const
{
- params_ = ParagraphParameters();
+ return bufferview()->cursor().paragraph().params();
}
void ControlParagraph::dispatchParams()
{
- ostringstream data;
- params().write(data);
- FuncRequest const fr(LFUN_PARAGRAPH_PARAMS_APPLY, data.str());
- dispatch(fr);
+ bufferview()->updateMetrics(false);
+ bufferview()->buffer().changed();
}
LyXAlignment ControlParagraph::alignPossible() const
{
- return alignpossible_;
+ return bufferview()->cursor().paragraph().layout()->alignpossible;
}
LyXAlignment ControlParagraph::alignDefault() const
{
- return aligndefault_;
+ return bufferview()->cursor().paragraph().layout()->align;
}
} // namespace frontend
///
ControlParagraph(Dialog &);
///
- virtual bool initialiseParams(std::string const & data);
+ virtual bool initialiseParams(std::string const & data) { return true; }
/// clean-up on hide.
- virtual void clearParams();
+ virtual void clearParams() {}
///
virtual void dispatchParams();
///
virtual bool isBufferDependent() const { return true; }
///
- ParagraphParameters & params() { return params_; }
+ ParagraphParameters & params();
///
- ParagraphParameters const & params() const { return params_; }
+ ParagraphParameters const & params() const;
///
bool haveMulitParSelection();
///
- bool inInset() const { return ininset_; }
- ///
bool canIndent() const;
///
LyXAlignment alignPossible() const;
///
LyXAlignment alignDefault() const;
-
-private:
- ///
- ParagraphParameters params_;
- ///
- bool ininset_;
- ///
- LyXAlignment alignpossible_;
- ///
- LyXAlignment aligndefault_;
};
} // namespace frontend