3 * \file ControlParagraph.C
4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
9 * Full author contact details are available in file CREDITS
15 #pragma implementation
18 #include "ControlParagraph.h"
20 #include "ButtonControllerBase.h"
24 #include "BufferView.h"
27 #include "ParagraphParameters.h"
29 #include "frontends/LyXView.h"
31 #include "support/LAssert.h"
34 ControlParagraph::ControlParagraph(LyXView & lv, Dialogs & d)
35 : ControlDialogBD(lv, d), pp_(0), ininset_(false)
39 ControlParagraph::~ControlParagraph()
43 ParagraphParameters & ControlParagraph::params()
45 lyx::Assert(pp_.get());
50 bool ControlParagraph::inInset() const
56 LyXAlignment ControlParagraph::alignPossible() const
62 void ControlParagraph::apply()
64 if (!bufferIsAvailable())
69 LyXText * text(bufferview()->getLyXText());
70 text->setParagraph(bufferview(),
74 pp_->pagebreakBottom(),
79 pp_->labelWidthString(),
82 // Actually apply these settings
83 bufferview()->update(text,
88 buffer()->markDirty();
90 lv_.message(_("Paragraph layout set"));
94 void ControlParagraph::setParams()
97 pp_.reset(new ParagraphParameters());
100 Paragraph const * par_ = bufferview()->getLyXText()->cursor.par();
102 /// Set the paragraph parameters
103 *pp_ = par_->params();
105 /// this needs to be done separately
106 pp_->labelWidthString(par_->getLabelWidthString());
109 LyXLayout_ptr const & layout = par_->layout();
110 if (pp_->align() == LYX_ALIGN_LAYOUT)
111 pp_->align(layout->align);
113 /// is alignment possible
114 alignpos_ = layout->alignpossible;
116 /// is paragraph in inset
117 ininset_ = par_->inInset();
120 void ControlParagraph::changedParagraph()
123 Paragraph const * p = bufferview()->getLyXText()->cursor.par();
125 if (p == 0) // this is wrong as we don't set par_ here! /* || p == par_) */
128 // For now, don't bother checking if the params are different.
129 // Will the underlying paragraph accept our changes?
130 Inset * const inset = p->inInset();
131 bool const accept = !(inset && inset->forceDefaultParagraphs(inset));