#include "VSpace.h"
#include "frontends/alert.h"
-#include "frontends/FontMetrics.h"
#include "insets/InsetBibitem.h"
#include "insets/InsetLabel.h"
if (change.type != Change::DELETED) {
for (pos_type pos = 0; pos < size(); ++pos) {
- if (isInset(pos))
- getInset(pos)->setChange(change);
+ if (Inset * inset = getInset(pos))
+ inset->setChange(change);
}
}
}
d->changes_.set(change, pos);
// see comment in setChange(Change const &) above
- if (change.type != Change::DELETED && pos < size() && isInset(pos))
- getInset(pos)->setChange(change);
+ if (change.type != Change::DELETED && pos < size())
+ if (Inset * inset = getInset(pos))
+ inset->setChange(change);
}
switch (lookupChange(pos).type) {
case Change::UNCHANGED:
// accept changes in nested inset
- if (pos < size() && isInset(pos))
- getInset(pos)->acceptChanges(bparams);
-
+ if (Inset * inset = getInset(pos))
+ inset->acceptChanges(bparams);
break;
case Change::INSERTED:
d->changes_.set(Change(Change::UNCHANGED), pos);
// also accept changes in nested inset
- if (pos < size() && isInset(pos)) {
- getInset(pos)->acceptChanges(bparams);
- }
+ if (Inset * inset = getInset(pos))
+ inset->acceptChanges(bparams);
break;
case Change::DELETED:
switch (lookupChange(pos).type) {
case Change::UNCHANGED:
// reject changes in nested inset
- if (pos < size() && isInset(pos)) {
- getInset(pos)->rejectChanges(bparams);
- }
+ if (Inset * inset = getInset(pos))
+ inset->rejectChanges(bparams);
break;
case Change::INSERTED:
depth_type & dth) const
{
// The beginning or end of a deeper (i.e. nested) area?
- if (dth != params().depth()) {
- if (params().depth() > dth) {
- while (params().depth() > dth) {
+ if (dth != d->params_.depth()) {
+ if (d->params_.depth() > dth) {
+ while (d->params_.depth() > dth) {
os << "\n\\begin_deeper";
++dth;
}
} else {
- while (params().depth() < dth) {
+ while (d->params_.depth() < dth) {
os << "\n\\end_deeper";
--dth;
}
}
// First write the layout
- os << "\n\\begin_layout " << to_utf8(layout()->name()) << '\n';
+ os << "\n\\begin_layout " << to_utf8(d->layout_->name()) << '\n';
- params().write(os);
+ d->params_.write(os);
Font font1(inherit_font, bparams.language);
char_type const c = d->text_[i];
switch (c) {
case META_INSET:
- {
- Inset const * inset = getInset(i);
- if (inset)
+ if (Inset const * inset = getInset(i)) {
if (inset->directWrite()) {
// international char, let it write
// code directly so it's shorter in
os << "\n\\end_inset\n\n";
column = 0;
}
- }
- break;
+ }
+ break;
case '\\':
os << "\n\\backslash\n";
column = 0;
void Paragraph::validate(LaTeXFeatures & features) const
{
- d->validate(features, *layout());
+ d->validate(features, *d->layout_);
}
Font const Paragraph::getLabelFont
(BufferParams const & bparams, Font const & outerfont) const
{
- FontInfo tmpfont = 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 = 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)
{
- layout(par.layout());
- // move to pimpl?
- d->params_ = par.params();
+ d->layout_ = par.d->layout_;
+ d->params_ = par.d->params_;
}
bool Paragraph::hasSameLayout(Paragraph const & par) const
{
- return par.layout() == layout() && d->params_.sameLayout(par.params());
+ return par.d->layout_ == d->layout_ && d->params_.sameLayout(par.d->params_);
}
depth_type Paragraph::getDepth() const
{
- return params().depth();
+ return d->params_.depth();
}
depth_type Paragraph::getMaxDepthAfter() const
{
- if (layout()->isEnvironment())
- return params().depth() + 1;
+ if (d->layout_->isEnvironment())
+ return d->params_.depth() + 1;
else
- return params().depth();
+ return d->params_.depth();
}
char Paragraph::getAlign() const
{
- if (params().align() == LYX_ALIGN_LAYOUT)
- return layout()->align;
+ if (d->params_.align() == LYX_ALIGN_LAYOUT)
+ return d->layout_->align;
else
- return params().align();
+ return d->params_.align();
}
-docstring const & Paragraph::getLabelstring() const
+docstring const & Paragraph::labelString() const
{
- return params().labelString();
+ return d->params_.labelString();
}
// the next two functions are for the manual labels
docstring const Paragraph::getLabelWidthString() const
{
- if (layout()->margintype == MARGIN_MANUAL)
- return params().labelWidthString();
+ if (d->layout_->margintype == MARGIN_MANUAL)
+ return d->params_.labelWidthString();
else
return _("Senseless with this layout!");
}
void Paragraph::setLabelWidthString(docstring const & s)
{
- params().labelWidthString(s);
+ d->params_.labelWidthString(s);
}
docstring Paragraph::expandLabel(LayoutPtr const & layout,
BufferParams const & bparams, bool process_appendix) const
{
- TextClass const & tclass = bparams.getTextClass();
+ TextClass const & tclass = bparams.textClass();
docstring fmt;
- if (process_appendix && params().appendix())
+ if (process_appendix && d->params_.appendix())
fmt = translateIfPossible(layout->labelstring_appendix(),
bparams);
else
void Paragraph::applyLayout(LayoutPtr const & new_layout)
{
- layout(new_layout);
- LyXAlignment const oldAlign = params().align();
+ d->layout_ = new_layout;
+ LyXAlignment const oldAlign = d->params_.align();
- if (!(oldAlign & 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."));
- params().align(LYX_ALIGN_LAYOUT);
+ d->params_.align(LYX_ALIGN_LAYOUT);
}
}
void Paragraph::setBeginOfBody()
{
- if (layout()->labeltype != LABEL_MANUAL) {
+ if (d->layout_->labeltype != LABEL_MANUAL) {
d->begin_of_body_ = 0;
return;
}
}
-bool Paragraph::forceDefaultParagraphs() const
+bool Paragraph::forceEmptyLayout() const
+{
+ return inInset() && inInset()->forceEmptyLayout();
+}
+
+
+bool Paragraph::allowParagraphCustomization() const
+{
+ return inInset() && inInset()->allowParagraphCustomization(0);
+}
+
+
+bool Paragraph::useEmptyLayout() const
{
- return inInset() && inInset()->forceDefaultParagraphs(0);
+ return inInset() && inInset()->useEmptyLayout();
}
// any special options in the paragraph and also we don't allow
// any environment other than the default layout of the text class
// to be valid!
- bool asdefault = forceDefaultParagraphs();
+ bool asdefault = forceEmptyLayout();
- if (asdefault) {
- style = bparams.getTextClass().defaultLayout();
- } else {
- style = layout();
- }
+ if (asdefault)
+ style = bparams.textClass().defaultLayout();
+ else
+ style = d->layout_;
// Current base font for all inherited font changes, without any
// change caused by an individual character, except for the language:
bool Paragraph::emptyTag() const
{
for (pos_type i = 0; i < size(); ++i) {
- if (isInset(i)) {
- Inset const * inset = getInset(i);
+ if (Inset const * inset = getInset(i)) {
InsetCode lyx_code = inset->lyxCode();
if (lyx_code != TOC_CODE &&
lyx_code != INCLUDE_CODE &&
string Paragraph::getID(Buffer const & buf, OutputParams const & runparams) const
{
for (pos_type i = 0; i < size(); ++i) {
- if (isInset(i)) {
- Inset const * inset = getInset(i);
+ if (Inset const * inset = getInset(i)) {
InsetCode lyx_code = inset->lyxCode();
if (lyx_code == LABEL_CODE) {
InsetLabel const * const il = static_cast<InsetLabel const *>(inset);
return "id='" + to_utf8(sgml::cleanID(buf, runparams, id)) + "'";
}
}
-
}
return string();
}
{
pos_type i;
for (i = 0; i < size(); ++i) {
- if (isInset(i)) {
- Inset const * inset = getInset(i);
+ if (Inset const * inset = getInset(i)) {
inset->docbook(buf, os, runparams);
} else {
char_type c = d->text_[i];
{
bool emph_flag = false;
- LayoutPtr const & style = layout();
+ LayoutPtr const & style = d->layout_;
FontInfo font_old =
style->labeltype == LABEL_MANUAL ? style->labelfont : style->font;
}
}
- if (isInset(i)) {
- Inset const * inset = getInset(i);
+ if (Inset const * inset = getInset(i)) {
inset->docbook(buf, os, runparams);
} else {
char_type c = d->text_[i];
bool Paragraph::isHfill(pos_type pos) const
{
- return isInset(pos) && getInset(pos)->lyxCode() == HFILL_CODE;
+ Inset const * inset = getInset(pos);
+ return inset && inset->lyxCode() == HFILL_CODE;
}
bool Paragraph::isNewline(pos_type pos) const
{
- return isInset(pos) && getInset(pos)->lyxCode() == NEWLINE_CODE;
+ Inset const * inset = getInset(pos);
+ return inset && inset->lyxCode() == NEWLINE_CODE;
}
bool Paragraph::isLineSeparator(pos_type pos) const
{
char_type const c = d->text_[pos];
- return isLineSeparatorChar(c)
- || (c == META_INSET && getInset(pos) &&
- getInset(pos)->isLineSeparator());
+ if (isLineSeparatorChar(c))
+ return true;
+ Inset const * inset = getInset(pos);
+ return inset && inset->isLineSeparator();
}
/// Used by the spellchecker
bool Paragraph::isLetter(pos_type pos) const
{
- if (isInset(pos))
- return getInset(pos)->isLetter();
+ if (Inset const * inset = getInset(pos))
+ return inset->isLetter();
char_type const c = d->text_[pos];
return isLetterChar(c) || isDigit(c);
}
odocstringstream os;
- if (beg == 0 && label && !params().labelString().empty())
- os << params().labelString() << ' ';
+ if (beg == 0 && label && !d->params_.labelString().empty())
+ os << d->params_.labelString() << ' ';
for (pos_type i = beg; i < end; ++i) {
char_type const c = d->text_[i];
}
-void Paragraph::layout(LayoutPtr const & new_layout)
+void Paragraph::setLayout(LayoutPtr const & layout)
{
- d->layout_ = new_layout;
+ d->layout_ = layout;
+}
+
+
+void Paragraph::setEmptyOrDefaultLayout(TextClass const & tclass)
+{
+ if (useEmptyLayout())
+ setLayout(tclass.emptyLayout());
+ else
+ setLayout(tclass.defaultLayout());
}
bool Paragraph::isFreeSpacing() const
{
- if (layout()->free_spacing)
+ if (d->layout_->free_spacing)
return true;
return d->inset_owner_ && d->inset_owner_->isFreeSpacing();
}
bool Paragraph::allowEmpty() const
{
- if (layout()->keepempty)
+ if (d->layout_->keepempty)
return true;
return d->inset_owner_ && d->inset_owner_->allowEmpty();
}
//up this bibitem issue for 1.6. See also bug 2743.
// Add bibitem insets if necessary
- if (layout()->labeltype != LABEL_BIBLIO)
+ if (d->layout_->labeltype != LABEL_BIBLIO)
return 0;
bool hasbibitem = !d->insetlist_.empty()
Inset * Paragraph::getInset(pos_type pos)
{
- return d->insetlist_.get(pos);
+ return (pos < pos_type(d->text_.size()) && d->text_[pos] == META_INSET)
+ ? d->insetlist_.get(pos) : 0;
}
Inset const * Paragraph::getInset(pos_type pos) const
{
- return d->insetlist_.get(pos);
+ return (pos < pos_type(d->text_.size()) && d->text_[pos] == META_INSET)
+ ? d->insetlist_.get(pos) : 0;
}