2002-06-11 16:40:18 +00:00
|
|
|
// -*- C++ -*-
|
|
|
|
/**
|
|
|
|
* \file ControlParagraph.C
|
2002-09-05 15:14:23 +00:00
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
2002-06-11 16:40:18 +00:00
|
|
|
*
|
2002-10-20 01:48:28 +00:00
|
|
|
* \author Edwin Leuven
|
2002-09-05 14:10:50 +00:00
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS
|
2002-06-11 16:40:18 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma implementation
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "ControlParagraph.h"
|
2002-08-14 19:19:47 +00:00
|
|
|
|
2002-08-02 12:28:59 +00:00
|
|
|
#include "ButtonControllerBase.h"
|
2002-06-18 15:44:30 +00:00
|
|
|
#include "ViewBase.h"
|
2002-08-14 19:19:47 +00:00
|
|
|
|
|
|
|
#include "buffer.h"
|
2002-06-11 16:40:18 +00:00
|
|
|
#include "BufferView.h"
|
|
|
|
#include "gettext.h"
|
|
|
|
#include "lyxtext.h"
|
2002-08-14 19:19:47 +00:00
|
|
|
#include "ParagraphParameters.h"
|
|
|
|
|
2002-10-20 01:48:28 +00:00
|
|
|
#include "frontends/LyXView.h"
|
2002-06-11 16:40:18 +00:00
|
|
|
#include "support/LAssert.h"
|
2002-08-14 19:19:47 +00:00
|
|
|
|
2002-06-11 16:40:18 +00:00
|
|
|
|
|
|
|
ControlParagraph::ControlParagraph(LyXView & lv, Dialogs & d)
|
|
|
|
: ControlDialogBD(lv, d), pp_(0), ininset_(false)
|
2002-08-15 17:48:53 +00:00
|
|
|
{}
|
2002-06-11 16:40:18 +00:00
|
|
|
|
2002-06-12 14:27:30 +00:00
|
|
|
|
|
|
|
ControlParagraph::~ControlParagraph()
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
2002-06-11 16:40:18 +00:00
|
|
|
ParagraphParameters & ControlParagraph::params()
|
|
|
|
{
|
|
|
|
lyx::Assert(pp_.get());
|
|
|
|
return *pp_;
|
|
|
|
}
|
|
|
|
|
2002-06-12 14:27:30 +00:00
|
|
|
|
2002-06-11 16:40:18 +00:00
|
|
|
bool ControlParagraph::inInset() const
|
|
|
|
{
|
|
|
|
return ininset_;
|
|
|
|
}
|
|
|
|
|
2002-06-12 14:27:30 +00:00
|
|
|
|
2002-06-11 16:40:18 +00:00
|
|
|
LyXAlignment ControlParagraph::alignPossible() const
|
|
|
|
{
|
2002-10-30 13:57:01 +00:00
|
|
|
return alignpossible_;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LyXAlignment ControlParagraph::alignDefault() const
|
|
|
|
{
|
|
|
|
return aligndefault_;
|
2002-06-11 16:40:18 +00:00
|
|
|
}
|
|
|
|
|
2002-06-12 14:27:30 +00:00
|
|
|
|
2002-06-11 16:40:18 +00:00
|
|
|
void ControlParagraph::apply()
|
|
|
|
{
|
2002-08-12 20:17:41 +00:00
|
|
|
if (!bufferIsAvailable())
|
2002-06-11 16:40:18 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
view().apply();
|
|
|
|
|
2002-08-12 20:17:41 +00:00
|
|
|
LyXText * text(bufferview()->getLyXText());
|
|
|
|
text->setParagraph(bufferview(),
|
2002-06-11 16:40:18 +00:00
|
|
|
pp_->lineTop(),
|
|
|
|
pp_->lineBottom(),
|
|
|
|
pp_->pagebreakTop(),
|
|
|
|
pp_->pagebreakBottom(),
|
|
|
|
pp_->spaceTop(),
|
|
|
|
pp_->spaceBottom(),
|
|
|
|
pp_->spacing(),
|
|
|
|
pp_->align(),
|
|
|
|
pp_->labelWidthString(),
|
|
|
|
pp_->noindent());
|
|
|
|
|
|
|
|
// Actually apply these settings
|
2002-08-12 20:17:41 +00:00
|
|
|
bufferview()->update(text,
|
|
|
|
BufferView::SELECT |
|
|
|
|
BufferView::FITCUR |
|
|
|
|
BufferView::CHANGE);
|
2002-06-18 15:44:30 +00:00
|
|
|
|
2002-08-12 20:17:41 +00:00
|
|
|
buffer()->markDirty();
|
2002-06-18 15:44:30 +00:00
|
|
|
|
2002-10-20 01:48:28 +00:00
|
|
|
lv_.message(_("Paragraph layout set"));
|
2002-06-11 16:40:18 +00:00
|
|
|
}
|
|
|
|
|
2002-06-12 14:27:30 +00:00
|
|
|
|
2002-06-11 16:40:18 +00:00
|
|
|
void ControlParagraph::setParams()
|
|
|
|
{
|
|
|
|
if (!pp_.get())
|
|
|
|
pp_.reset(new ParagraphParameters());
|
|
|
|
|
|
|
|
/// get paragraph
|
2002-08-12 20:17:41 +00:00
|
|
|
Paragraph const * par_ = bufferview()->getLyXText()->cursor.par();
|
2002-06-18 15:44:30 +00:00
|
|
|
|
2002-06-11 16:40:18 +00:00
|
|
|
/// Set the paragraph parameters
|
2002-06-18 15:44:30 +00:00
|
|
|
*pp_ = par_->params();
|
|
|
|
|
2002-06-11 16:40:18 +00:00
|
|
|
/// this needs to be done separately
|
|
|
|
pp_->labelWidthString(par_->getLabelWidthString());
|
2002-06-18 15:44:30 +00:00
|
|
|
|
2002-06-11 16:40:18 +00:00
|
|
|
/// alignment
|
2002-06-24 20:28:12 +00:00
|
|
|
LyXLayout_ptr const & layout = par_->layout();
|
2002-06-11 16:40:18 +00:00
|
|
|
if (pp_->align() == LYX_ALIGN_LAYOUT)
|
2002-06-24 20:28:12 +00:00
|
|
|
pp_->align(layout->align);
|
2002-06-11 16:40:18 +00:00
|
|
|
|
|
|
|
/// is alignment possible
|
2002-10-30 13:57:01 +00:00
|
|
|
alignpossible_ = layout->alignpossible;
|
|
|
|
|
|
|
|
/// set default alignment
|
|
|
|
aligndefault_ = layout->align;
|
2002-06-11 16:40:18 +00:00
|
|
|
|
|
|
|
/// is paragraph in inset
|
2002-06-18 15:44:30 +00:00
|
|
|
ininset_ = par_->inInset();
|
2002-06-11 16:40:18 +00:00
|
|
|
}
|
2002-08-02 12:28:59 +00:00
|
|
|
|
2002-10-21 17:38:09 +00:00
|
|
|
|
2002-08-02 12:28:59 +00:00
|
|
|
void ControlParagraph::changedParagraph()
|
|
|
|
{
|
|
|
|
/// get paragraph
|
2002-08-12 20:17:41 +00:00
|
|
|
Paragraph const * p = bufferview()->getLyXText()->cursor.par();
|
2002-08-02 12:28:59 +00:00
|
|
|
|
|
|
|
if (p == 0) // this is wrong as we don't set par_ here! /* || p == par_) */
|
|
|
|
return;
|
|
|
|
|
|
|
|
// For now, don't bother checking if the params are different.
|
|
|
|
// Will the underlying paragraph accept our changes?
|
|
|
|
Inset * const inset = p->inInset();
|
|
|
|
bool const accept = !(inset && inset->forceDefaultParagraphs(inset));
|
|
|
|
bc().valid(accept);
|
|
|
|
}
|