#include "Paragraph.h"
-#include "BaseClassList.h"
+#include "LayoutFile.h"
#include "Buffer.h"
#include "BufferParams.h"
#include "Changes.h"
///
InsetList insetlist_;
- // This little bit of indirection is needed so that we can protect
- // the layout as const but still be able to change layout_.
- ///
- Layout const & layout() const { return *layout_; }
- ///
- void setLayout(Layout const & layout) { layout_ = &layout; }
-
/// end of label
pos_type begin_of_body_;
typedef std::set<docstring> Words;
///
Words words_;
-private:
///
Layout const * layout_;
};
}
// First write the layout
- os << "\n\\begin_layout " << to_utf8(d->layout().name()) << '\n';
+ os << "\n\\begin_layout " << to_utf8(d->layout_->name()) << '\n';
d->params_.write(os);
void Paragraph::validate(LaTeXFeatures & features) const
{
- d->validate(features, d->layout());
+ d->validate(features, *d->layout_);
}
pos_type const body_pos = beginOfBody();
if (pos < body_pos)
- font.fontInfo().realize(d->layout().labelfont);
+ font.fontInfo().realize(d->layout_->labelfont);
else
- font.fontInfo().realize(d->layout().font);
+ font.fontInfo().realize(d->layout_->font);
font.fontInfo().realize(outerfont.fontInfo());
font.fontInfo().realize(bparams.getFont().fontInfo());
Font const Paragraph::getLabelFont
(BufferParams const & bparams, Font const & outerfont) const
{
- FontInfo tmpfont = d->layout().labelfont;
+ FontInfo tmpfont = d->layout_->labelfont;
tmpfont.realize(outerfont.fontInfo());
tmpfont.realize(bparams.getFont().fontInfo());
return Font(tmpfont, getParLanguage(bparams));
Font const Paragraph::getLayoutFont
(BufferParams const & bparams, Font const & outerfont) const
{
- FontInfo tmpfont = d->layout().font;
+ FontInfo tmpfont = d->layout_->font;
tmpfont.realize(outerfont.fontInfo());
tmpfont.realize(bparams.getFont().fontInfo());
return Font(tmpfont, getParLanguage(bparams));
void Paragraph::makeSameLayout(Paragraph const & par)
{
- d->setLayout(par.d->layout());
+ d->layout_ = par.d->layout_;
d->params_ = par.d->params_;
}
bool Paragraph::hasSameLayout(Paragraph const & par) const
{
- return par.d->layout() == d->layout()
+ return par.d->layout_ == d->layout_
&& d->params_.sameLayout(par.d->params_);
}
depth_type Paragraph::getMaxDepthAfter() const
{
- if (d->layout().isEnvironment())
+ if (d->layout_->isEnvironment())
return d->params_.depth() + 1;
else
return d->params_.depth();
char Paragraph::getAlign() const
{
if (d->params_.align() == LYX_ALIGN_LAYOUT)
- return d->layout().align;
+ return d->layout_->align;
else
return d->params_.align();
}
// the next two functions are for the manual labels
docstring const Paragraph::getLabelWidthString() const
{
- if (d->layout().margintype == MARGIN_MANUAL)
+ if (d->layout_->margintype == MARGIN_MANUAL)
return d->params_.labelWidthString();
else
return _("Senseless with this layout!");
void Paragraph::applyLayout(Layout const & new_layout)
{
- d->setLayout(new_layout);
+ d->layout_ = &new_layout;
LyXAlignment const oldAlign = d->params_.align();
- if (!(oldAlign & d->layout().alignpossible)) {
+ if (!(oldAlign & d->layout_->alignpossible)) {
frontend::Alert::warning(_("Alignment not permitted"),
_("The new layout does not permit the alignment previously used.\nSetting to default."));
d->params_.align(LYX_ALIGN_LAYOUT);
void Paragraph::setBeginOfBody()
{
- if (d->layout().labeltype != LABEL_MANUAL) {
+ if (d->layout_->labeltype != LABEL_MANUAL) {
d->begin_of_body_ = 0;
return;
}
bool Paragraph::forceEmptyLayout() const
{
- return inInset() && inInset()->forceEmptyLayout();
+ Inset const * const inset = inInset();
+ if (!inset)
+ return true;
+ return inset->forceEmptyLayout();
}
bool Paragraph::allowParagraphCustomization() const
{
- return inInset() && inInset()->allowParagraphCustomization(0);
+ Inset const * const inset = inInset();
+ if (!inset)
+ return true;
+ return inset->allowParagraphCustomization();
}
bool Paragraph::useEmptyLayout() const
{
- return inInset() && inInset()->useEmptyLayout();
+ Inset const * const inset = inInset();
+ if (!inset)
+ return false;
+ return inset->useEmptyLayout();
}
bool return_value = false;
- Layout style;
-
bool asdefault = forceEmptyLayout();
- if (asdefault)
- style = bparams.documentClass().emptyLayout();
- else
- style = d->layout();
+ Layout const & style = asdefault ?
+ bparams.documentClass().emptyLayout() :
+ *d->layout_;
// Current base font for all inherited font changes, without any
// change caused by an individual character, except for the language:
{
bool emph_flag = false;
- Layout const & style = d->layout();
+ Layout const & style = *d->layout_;
FontInfo font_old =
style.labeltype == LABEL_MANUAL ? style.labelfont : style.font;
bool Paragraph::isHfill(pos_type pos) const
{
Inset const * inset = getInset(pos);
- return inset && inset->lyxCode() == HFILL_CODE;
+ return inset && (inset->lyxCode() == SPACE_CODE &&
+ inset->isStretchableSpace());
}
Layout const & Paragraph::layout() const
{
- return d->layout();
+ return *d->layout_;
}
void Paragraph::setLayout(Layout const & layout)
{
- d->setLayout(layout);
+ d->layout_ = &layout;
}
bool Paragraph::isFreeSpacing() const
{
- if (d->layout().free_spacing)
+ if (d->layout_->free_spacing)
return true;
return d->inset_owner_ && d->inset_owner_->isFreeSpacing();
}
bool Paragraph::allowEmpty() const
{
- if (d->layout().keepempty)
+ if (d->layout_->keepempty)
return true;
return d->inset_owner_ && d->inset_owner_->allowEmpty();
}
char_type Paragraph::transformChar(char_type c, pos_type pos) const
{
- if (!Encodings::is_arabic(c))
+ if (!Encodings::isArabicChar(c))
return c;
char_type prev_char = ' ';
for (pos_type i = pos - 1; i >= 0; --i) {
char_type const par_char = d->text_[i];
- if (!Encodings::isComposeChar_arabic(par_char)) {
+ if (!Encodings::isArabicComposeChar(par_char)) {
prev_char = par_char;
break;
}
for (pos_type i = pos + 1, end = size(); i < end; ++i) {
char_type const par_char = d->text_[i];
- if (!Encodings::isComposeChar_arabic(par_char)) {
+ if (!Encodings::isArabicComposeChar(par_char)) {
next_char = par_char;
break;
}
}
- if (Encodings::is_arabic(next_char)) {
- if (Encodings::is_arabic(prev_char) &&
- !Encodings::is_arabic_special(prev_char))
+ if (Encodings::isArabicChar(next_char)) {
+ if (Encodings::isArabicChar(prev_char) &&
+ !Encodings::isArabicSpecialChar(prev_char))
return Encodings::transformChar(c, Encodings::FORM_MEDIAL);
else
return Encodings::transformChar(c, Encodings::FORM_INITIAL);
} else {
- if (Encodings::is_arabic(prev_char) &&
- !Encodings::is_arabic_special(prev_char))
+ if (Encodings::isArabicChar(prev_char) &&
+ !Encodings::isArabicSpecialChar(prev_char))
return Encodings::transformChar(c, Encodings::FORM_FINAL);
else
return Encodings::transformChar(c, Encodings::FORM_ISOLATED);
// up this bibitem issue for 1.6. See also bug 2743.
// Add bibitem insets if necessary
- if (d->layout().labeltype != LABEL_BIBLIO)
+ if (d->layout_->labeltype != LABEL_BIBLIO)
return 0;
bool hasbibitem = !d->insetlist_.empty()