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/Liason.h"
31 #include "support/LAssert.h"
33 using Liason::setMinibuffer;
36 ControlParagraph::ControlParagraph(LyXView & lv, Dialogs & d)
37 : ControlDialogBD(lv, d), pp_(0), ininset_(false)
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));