3 * \file ControlParagraph.C
4 * Copyright 2002 The LyX Team.
5 * See the file COPYING.
7 * \author Edwin Leuven <leuven@fee.uva.nl>
13 #pragma implementation
16 #include "ControlParagraph.h"
17 #include "ButtonControllerBase.h"
19 #include "ParagraphParameters.h"
22 #include "BufferView.h"
26 #include "support/LAssert.h"
28 #include <boost/bind.hpp>
30 using Liason::setMinibuffer;
33 ControlParagraph::ControlParagraph(LyXView & lv, Dialogs & d)
34 : ControlDialogBD(lv, d), pp_(0), ininset_(false)
36 d_.updateParagraph.connect(
37 boost::bind(&ControlParagraph::changedParagraph, this));
42 ControlParagraph::~ControlParagraph()
46 ParagraphParameters & ControlParagraph::params()
48 lyx::Assert(pp_.get());
53 bool ControlParagraph::inInset() const
59 LyXAlignment ControlParagraph::alignPossible() const
65 void ControlParagraph::apply()
67 if (!lv_.view()->available())
72 LyXText * text(lv_.view()->getLyXText());
73 text->setParagraph(lv_.view().get(),
77 pp_->pagebreakBottom(),
82 pp_->labelWidthString(),
85 // Actually apply these settings
86 lv_.view()->update(text,
91 lv_.buffer()->markDirty();
93 setMinibuffer(&lv_, _("Paragraph layout set"));
97 void ControlParagraph::setParams()
100 pp_.reset(new ParagraphParameters());
103 Paragraph const * par_ = lv_.view()->getLyXText()->cursor.par();
105 /// Set the paragraph parameters
106 *pp_ = par_->params();
108 /// this needs to be done separately
109 pp_->labelWidthString(par_->getLabelWidthString());
112 LyXLayout_ptr const & layout = par_->layout();
113 if (pp_->align() == LYX_ALIGN_LAYOUT)
114 pp_->align(layout->align);
116 /// is alignment possible
117 alignpos_ = layout->alignpossible;
119 /// is paragraph in inset
120 ininset_ = par_->inInset();
123 void ControlParagraph::changedParagraph()
126 Paragraph const * p = lv_.view()->getLyXText()->cursor.par();
128 if (p == 0) // this is wrong as we don't set par_ here! /* || p == par_) */
131 // For now, don't bother checking if the params are different.
132 // Will the underlying paragraph accept our changes?
133 Inset * const inset = p->inInset();
134 bool const accept = !(inset && inset->forceDefaultParagraphs(inset));