lyx_mirror/src/frontends/controllers/ControlParagraph.C

115 lines
2.1 KiB
C++
Raw Normal View History

// -*- C++ -*-
/**
* \file ControlParagraph.C
* Copyright 2002 The LyX Team.
* See the file COPYING.
*
* \author Edwin Leuven <leuven@fee.uva.nl>
*/
#include <config.h>
#ifdef __GNUG__
#pragma implementation
#endif
#include "ControlParagraph.h"
#include "ViewBase.h"
#include "ParagraphParameters.h"
#include "Liason.h"
#include "LyXView.h"
#include "BufferView.h"
#include "gettext.h"
#include "buffer.h"
#include "lyxtext.h"
#include "support/LAssert.h"
using Liason::setMinibuffer;
ControlParagraph::ControlParagraph(LyXView & lv, Dialogs & d)
: ControlDialogBD(lv, d), pp_(0), ininset_(false)
{}
ControlParagraph::~ControlParagraph()
{}
ParagraphParameters & ControlParagraph::params()
{
lyx::Assert(pp_.get());
return *pp_;
}
bool ControlParagraph::inInset() const
{
return ininset_;
}
LyXAlignment ControlParagraph::alignPossible() const
{
return alignpos_;
}
void ControlParagraph::apply()
{
if (!lv_.view()->available())
return;
view().apply();
LyXText * text(lv_.view()->getLyXText());
text->setParagraph(lv_.view(),
pp_->lineTop(),
pp_->lineBottom(),
pp_->pagebreakTop(),
pp_->pagebreakBottom(),
pp_->spaceTop(),
pp_->spaceBottom(),
pp_->spacing(),
pp_->align(),
pp_->labelWidthString(),
pp_->noindent());
// Actually apply these settings
lv_.view()->update(text,
BufferView::SELECT |
BufferView::FITCUR |
BufferView::CHANGE);
lv_.buffer()->markDirty();
setMinibuffer(&lv_, _("Paragraph layout set"));
}
void ControlParagraph::setParams()
{
if (!pp_.get())
pp_.reset(new ParagraphParameters());
/// get paragraph
Paragraph const * par_ = lv_.view()->getLyXText()->cursor.par();
/// Set the paragraph parameters
*pp_ = par_->params();
/// this needs to be done separately
pp_->labelWidthString(par_->getLabelWidthString());
/// alignment
LyXLayout_ptr const & layout = par_->layout();
if (pp_->align() == LYX_ALIGN_LAYOUT)
pp_->align(layout->align);
/// is alignment possible
alignpos_ = layout->alignpossible;
/// is paragraph in inset
ininset_ = par_->inInset();
}