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"
21 #include "BufferView.h"
25 #include "support/LAssert.h"
27 #include <boost/bind.hpp>
29 using Liason::setMinibuffer;
32 ControlParagraph::ControlParagraph(LyXView & lv, Dialogs & d)
33 : ControlDialogBD(lv, d), pp_(0), ininset_(false)
35 d_.updateParagraph.connect(
36 boost::bind(&ControlParagraph::changedParagraph, this));
41 ControlParagraph::~ControlParagraph()
45 ParagraphParameters & ControlParagraph::params()
47 lyx::Assert(pp_.get());
52 bool ControlParagraph::inInset() const
58 LyXAlignment ControlParagraph::alignPossible() const
64 void ControlParagraph::apply()
66 if (!bufferIsAvailable())
71 LyXText * text(bufferview()->getLyXText());
72 text->setParagraph(bufferview(),
76 pp_->pagebreakBottom(),
81 pp_->labelWidthString(),
84 // Actually apply these settings
85 bufferview()->update(text,
90 buffer()->markDirty();
92 setMinibuffer(&lv_, _("Paragraph layout set"));
96 void ControlParagraph::setParams()
99 pp_.reset(new ParagraphParameters());
102 Paragraph const * par_ = bufferview()->getLyXText()->cursor.par();
104 /// Set the paragraph parameters
105 *pp_ = par_->params();
107 /// this needs to be done separately
108 pp_->labelWidthString(par_->getLabelWidthString());
111 LyXLayout_ptr const & layout = par_->layout();
112 if (pp_->align() == LYX_ALIGN_LAYOUT)
113 pp_->align(layout->align);
115 /// is alignment possible
116 alignpos_ = layout->alignpossible;
118 /// is paragraph in inset
119 ininset_ = par_->inInset();
122 void ControlParagraph::changedParagraph()
125 Paragraph const * p = bufferview()->getLyXText()->cursor.par();
127 if (p == 0) // this is wrong as we don't set par_ here! /* || p == par_) */
130 // For now, don't bother checking if the params are different.
131 // Will the underlying paragraph accept our changes?
132 Inset * const inset = p->inInset();
133 bool const accept = !(inset && inset->forceDefaultParagraphs(inset));