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"
30 #include "support/LAssert.h"
33 ControlParagraph::ControlParagraph(LyXView & lv, Dialogs & d)
34 : ControlDialogBD(lv, d), pp_(0), ininset_(false)
38 ControlParagraph::~ControlParagraph()
42 ParagraphParameters & ControlParagraph::params()
44 lyx::Assert(pp_.get());
49 bool ControlParagraph::inInset() const
55 LyXAlignment ControlParagraph::alignPossible() const
57 return alignpossible_;
61 LyXAlignment ControlParagraph::alignDefault() const
67 void ControlParagraph::apply()
69 if (!bufferIsAvailable())
74 LyXText * text(bufferview()->getLyXText());
75 text->setParagraph(bufferview(),
79 pp_->pagebreakBottom(),
84 pp_->labelWidthString(),
87 // Actually apply these settings
88 bufferview()->update(text,
93 buffer()->markDirty();
95 lv_.message(_("Paragraph layout set"));
99 void ControlParagraph::setParams()
102 pp_.reset(new ParagraphParameters());
105 Paragraph const * par_ = bufferview()->getLyXText()->cursor.par();
107 /// Set the paragraph parameters
108 *pp_ = par_->params();
110 /// this needs to be done separately
111 pp_->labelWidthString(par_->getLabelWidthString());
114 LyXLayout_ptr const & layout = par_->layout();
115 if (pp_->align() == LYX_ALIGN_LAYOUT)
116 pp_->align(layout->align);
118 /// is alignment possible
119 alignpossible_ = layout->alignpossible;
121 /// set default alignment
122 aligndefault_ = layout->align;
124 /// is paragraph in inset
125 ininset_ = par_->inInset();
129 void ControlParagraph::changedParagraph()
132 Paragraph const * p = bufferview()->getLyXText()->cursor.par();
134 if (p == 0) // this is wrong as we don't set par_ here! /* || p == par_) */
137 // For now, don't bother checking if the params are different.
138 // Will the underlying paragraph accept our changes?
139 Inset * const inset = p->inInset();
140 bool const accept = !(inset && inset->forceDefaultParagraphs(inset));