3 * \file ControlParagraph.C
4 * See the file COPYING.
8 * Full author contact details are available in file CREDITS
14 #pragma implementation
17 #include "ControlParagraph.h"
19 #include "ButtonControllerBase.h"
23 #include "BufferView.h"
26 #include "ParagraphParameters.h"
28 #include "frontends/Liason.h"
30 #include "support/LAssert.h"
32 using Liason::setMinibuffer;
35 ControlParagraph::ControlParagraph(LyXView & lv, Dialogs & d)
36 : ControlDialogBD(lv, d), pp_(0), ininset_(false)
40 ControlParagraph::~ControlParagraph()
44 ParagraphParameters & ControlParagraph::params()
46 lyx::Assert(pp_.get());
51 bool ControlParagraph::inInset() const
57 LyXAlignment ControlParagraph::alignPossible() const
63 void ControlParagraph::apply()
65 if (!bufferIsAvailable())
70 LyXText * text(bufferview()->getLyXText());
71 text->setParagraph(bufferview(),
75 pp_->pagebreakBottom(),
80 pp_->labelWidthString(),
83 // Actually apply these settings
84 bufferview()->update(text,
89 buffer()->markDirty();
91 setMinibuffer(&lv_, _("Paragraph layout set"));
95 void ControlParagraph::setParams()
98 pp_.reset(new ParagraphParameters());
101 Paragraph const * par_ = bufferview()->getLyXText()->cursor.par();
103 /// Set the paragraph parameters
104 *pp_ = par_->params();
106 /// this needs to be done separately
107 pp_->labelWidthString(par_->getLabelWidthString());
110 LyXLayout_ptr const & layout = par_->layout();
111 if (pp_->align() == LYX_ALIGN_LAYOUT)
112 pp_->align(layout->align);
114 /// is alignment possible
115 alignpos_ = layout->alignpossible;
117 /// is paragraph in inset
118 ininset_ = par_->inInset();
121 void ControlParagraph::changedParagraph()
124 Paragraph const * p = bufferview()->getLyXText()->cursor.par();
126 if (p == 0) // this is wrong as we don't set par_ here! /* || p == par_) */
129 // For now, don't bother checking if the params are different.
130 // Will the underlying paragraph accept our changes?
131 Inset * const inset = p->inInset();
132 bool const accept = !(inset && inset->forceDefaultParagraphs(inset));