2002-06-11 16:40:18 +00:00
|
|
|
// -*- 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"
|
2002-06-18 15:44:30 +00:00
|
|
|
#include "ViewBase.h"
|
2002-06-12 14:27:30 +00:00
|
|
|
#include "ParagraphParameters.h"
|
2002-06-11 16:40:18 +00:00
|
|
|
#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)
|
2002-06-18 15:44:30 +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
|
|
|
|
{
|
|
|
|
return alignpos_;
|
|
|
|
}
|
|
|
|
|
2002-06-12 14:27:30 +00:00
|
|
|
|
2002-06-11 16:40:18 +00:00
|
|
|
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
|
2002-06-18 15:44:30 +00:00
|
|
|
lv_.view()->update(text,
|
2002-06-11 16:40:18 +00:00
|
|
|
BufferView::SELECT |
|
|
|
|
BufferView::FITCUR |
|
|
|
|
BufferView::CHANGE);
|
2002-06-18 15:44:30 +00:00
|
|
|
|
2002-06-11 16:40:18 +00:00
|
|
|
lv_.buffer()->markDirty();
|
2002-06-18 15:44:30 +00:00
|
|
|
|
2002-06-11 16:40:18 +00:00
|
|
|
setMinibuffer(&lv_, _("Paragraph layout set"));
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
Paragraph const * par_ = lv_.view()->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-06-24 20:28:12 +00:00
|
|
|
alignpos_ = layout->alignpossible;
|
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
|
|
|
}
|