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 #include "ControlParagraph.h"
17 #include "ButtonControllerBase.h"
21 #include "BufferView.h"
24 #include "ParagraphParameters.h"
26 #include "frontends/LyXView.h"
27 #include "support/LAssert.h"
30 ControlParagraph::ControlParagraph(LyXView & lv, Dialogs & d)
31 : ControlDialogBD(lv, d), pp_(0), ininset_(false)
35 ControlParagraph::~ControlParagraph()
39 ParagraphParameters & ControlParagraph::params()
41 lyx::Assert(pp_.get());
46 bool ControlParagraph::inInset() const
52 LyXAlignment ControlParagraph::alignPossible() const
54 return alignpossible_;
58 LyXAlignment ControlParagraph::alignDefault() 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 lv_.message(_("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 alignpossible_ = layout->alignpossible;
118 /// set default alignment
119 aligndefault_ = layout->align;
121 /// is paragraph in inset
122 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));