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"
18 #include "ButtonControllerBase.h"
22 #include "BufferView.h"
25 #include "ParagraphParameters.h"
27 #include "frontends/Dialogs.h"
28 #include "frontends/Liason.h"
30 #include "support/LAssert.h"
32 #include <boost/bind.hpp>
34 using Liason::setMinibuffer;
37 ControlParagraph::ControlParagraph(LyXView & lv, Dialogs & d)
38 : ControlDialogBD(lv, d), pp_(0), ininset_(false)
40 d_.updateParagraph.connect(
41 boost::bind(&ControlParagraph::changedParagraph, this));
45 ControlParagraph::~ControlParagraph()
49 ParagraphParameters & ControlParagraph::params()
51 lyx::Assert(pp_.get());
56 bool ControlParagraph::inInset() const
62 LyXAlignment ControlParagraph::alignPossible() const
68 void ControlParagraph::apply()
70 if (!bufferIsAvailable())
75 LyXText * text(bufferview()->getLyXText());
76 text->setParagraph(bufferview(),
80 pp_->pagebreakBottom(),
85 pp_->labelWidthString(),
88 // Actually apply these settings
89 bufferview()->update(text,
94 buffer()->markDirty();
96 setMinibuffer(&lv_, _("Paragraph layout set"));
100 void ControlParagraph::setParams()
103 pp_.reset(new ParagraphParameters());
106 Paragraph const * par_ = bufferview()->getLyXText()->cursor.par();
108 /// Set the paragraph parameters
109 *pp_ = par_->params();
111 /// this needs to be done separately
112 pp_->labelWidthString(par_->getLabelWidthString());
115 LyXLayout_ptr const & layout = par_->layout();
116 if (pp_->align() == LYX_ALIGN_LAYOUT)
117 pp_->align(layout->align);
119 /// is alignment possible
120 alignpos_ = layout->alignpossible;
122 /// is paragraph in inset
123 ininset_ = par_->inInset();
126 void ControlParagraph::changedParagraph()
129 Paragraph const * p = bufferview()->getLyXText()->cursor.par();
131 if (p == 0) // this is wrong as we don't set par_ here! /* || p == par_) */
134 // For now, don't bother checking if the params are different.
135 // Will the underlying paragraph accept our changes?
136 Inset * const inset = p->inInset();
137 bool const accept = !(inset && inset->forceDefaultParagraphs(inset));