///
operator base_type() const { return data_; }
///
+ bool empty() const { return data_.empty(); }
private:
base_type data_;
};
if (*cit == '\n') {
if (autobreakrows && (!par.empty() || par.allowEmpty())) {
breakParagraph(params(), pars, pit, pos,
- par.layout()->isEnvironment());
+ par.layout().isEnvironment());
++pit;
pos = 0;
space_inserted = true;
// increased depth?
if ((par.params().depth() > depth
|| par.params().leftIndent() != leftIndent)
- && par.layout()->isEnvironment()) {
+ && par.layout().isEnvironment()) {
updateBlockMacros(it, scope);
continue;
}
// set scope for macros in this paragraph:
// * either the "old" outer scope
// * or the scope ending after the environment
- if (par.layout()->isEnvironment()) {
+ if (par.layout().isEnvironment()) {
// find end of environment block,
DocIterator envEnd = it;
pit_type n = it.lastpit() + 1;
void Cursor::checkBufferStructure()
{
- if (paragraph().layout()->toclevel == Layout::NOT_IN_TOC)
+ if (paragraph().layout().toclevel == Layout::NOT_IN_TOC)
return;
Buffer const * master = buffer().masterBuffer();
master->tocBackend().updateItem(ParConstIterator(*this));
// layouts
ParIterator end = par_iterator_end(in);
for (ParIterator it = par_iterator_begin(in); it != end; ++it) {
- docstring const name = it->layout()->name();
+ docstring const name = it->layout().name();
bool hasLayout = newtc.hasLayout(name);
if (in.useEmptyLayout())
docstring const s = bformat(
_("Layout had to be changed from\n%1$s to %2$s\n"
"because of class conversion from\n%3$s to %4$s"),
- name, it->layout()->name(),
+ name, it->layout().name(),
from_utf8(oldtc.name()), from_utf8(newtc.name()));
// To warn the user that something had to be done.
errorlist.push_back(ErrorItem(_("Changed Layout"), s,
}
+bool Layout::operator==(Layout const & rhs) const
+{
+ // This is enough for the applications we actually make,
+ // at least at the moment. But we could check more.
+ return name() == rhs.name()
+ && latexname() == rhs.latexname()
+ && latextype == rhs.latextype;
+}
+
+
Layout * Layout::forCaption()
{
Layout * lay = new Layout();
docstring const & labelstring_appendix() const {
return labelstring_appendix_;
}
+ ///
+ bool isParagraph() const { return latextype == LATEX_PARAGRAPH; }
+ ///
+ bool isCommand() const { return latextype == LATEX_COMMAND; }
+ ///
+ bool isEnvironment() const {
+ return latextype == LATEX_ENVIRONMENT
+ || latextype == LATEX_BIB_ENVIRONMENT
+ || latextype == LATEX_ITEM_ENVIRONMENT
+ || latextype == LATEX_LIST_ENVIRONMENT;
+ }
+
+ ///
+ bool operator==(Layout const &) const;
+ ///
+ bool operator!=(Layout const & rhs) const
+ { return !(*this == rhs); }
+
+ ////////////////////////////////////////////////////////////////
+ // members
+ ////////////////////////////////////////////////////////////////
/** Default font for this layout/environment.
The main font for this kind of environment. If an attribute has
INHERITED_*, it means that the value is specified by
bool needprotect;
/// true when empty paragraphs should be kept.
bool keepempty;
- ///
- bool isParagraph() const { return latextype == LATEX_PARAGRAPH; }
- ///
- bool isCommand() const { return latextype == LATEX_COMMAND; }
- ///
- bool isEnvironment() const {
- return latextype == LATEX_ENVIRONMENT
- || latextype == LATEX_BIB_ENVIRONMENT
- || latextype == LATEX_ITEM_ENVIRONMENT
- || latextype == LATEX_LIST_ENVIRONMENT;
- }
/// Type of LaTeX object
LatexType latextype;
/// Does this object belong in the title part of the document?
#include "Paragraph.h"
+#include "BaseClassList.h"
#include "Buffer.h"
#include "BufferParams.h"
#include "Changes.h"
{
public:
///
- Private(Paragraph * owner);
+ Private(Paragraph * owner, Layout const & layout);
/// "Copy constructor"
Private(Private const &, Paragraph * owner);
///
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_.
///
- LayoutPtr 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_;
};
} // namespace anon
-Paragraph::Private::Private(Paragraph * owner)
- : owner_(owner), inset_owner_(0), begin_of_body_(0)
+Paragraph::Private::Private(Paragraph * owner, Layout const & layout)
+ : owner_(owner), inset_owner_(0), begin_of_body_(0), layout_(&layout)
{
id_ = paragraph_id++;
text_.reserve(100);
Paragraph::Private::Private(Private const & p, Paragraph * owner)
: owner_(owner), inset_owner_(p.inset_owner_), fontlist_(p.fontlist_),
params_(p.params_), changes_(p.changes_), insetlist_(p.insetlist_),
- layout_(p.layout_), begin_of_body_(p.begin_of_body_), text_(p.text_),
- words_(p.words_)
+ begin_of_body_(p.begin_of_body_), text_(p.text_), words_(p.words_),
+ layout_(p.layout_)
{
id_ = paragraph_id++;
}
//
/////////////////////////////////////////////////////////////////////
-Paragraph::Paragraph()
- : d(new Paragraph::Private(this))
+namespace {
+ Layout const emptyParagraphLayout;
+}
+
+Paragraph::Paragraph()
+ : d(new Paragraph::Private(this, emptyParagraphLayout))
{
itemdepth = 0;
d->params_.clear();
}
// 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->layout_ = par.d->layout_;
+ d->setLayout(par.d->layout());
d->params_ = par.d->params_;
}
bool Paragraph::hasSameLayout(Paragraph const & par) const
{
- return par.d->layout_ == d->layout_ && d->params_.sameLayout(par.d->params_);
+ 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!");
}
-docstring Paragraph::expandLabel(LayoutPtr const & layout,
+docstring Paragraph::expandLabel(Layout const & layout,
BufferParams const & bparams, bool process_appendix) const
{
DocumentClass const & tclass = bparams.documentClass();
docstring fmt;
if (process_appendix && d->params_.appendix())
- fmt = translateIfPossible(layout->labelstring_appendix(),
+ fmt = translateIfPossible(layout.labelstring_appendix(),
bparams);
else
- fmt = translateIfPossible(layout->labelstring(), bparams);
+ fmt = translateIfPossible(layout.labelstring(), bparams);
- if (fmt.empty() && layout->labeltype == LABEL_COUNTER
- && !layout->counter.empty())
- fmt = "\\the" + layout->counter;
+ if (fmt.empty() && layout.labeltype == LABEL_COUNTER
+ && !layout.counter.empty())
+ fmt = "\\the" + layout.counter;
// handle 'inherited level parts' in 'fmt',
// i.e. the stuff between '@' in '@Section@.\arabic{subsection}'
docstring parent(fmt, i + 1, j - i - 1);
docstring label = from_ascii("??");
if (tclass.hasLayout(parent))
- docstring label = expandLabel(&(tclass[parent]), bparams,
+ docstring label = expandLabel(tclass[parent], bparams,
process_appendix);
fmt = docstring(fmt, 0, i) + label
+ docstring(fmt, j + 1, docstring::npos);
void Paragraph::applyLayout(Layout const & new_layout)
{
- d->layout_ = &new_layout;
+ d->setLayout(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 return_value = false;
- LayoutPtr style;
+ Layout style;
bool asdefault = forceEmptyLayout();
if (asdefault)
- style = &(bparams.documentClass().emptyLayout());
+ style = bparams.documentClass().emptyLayout();
else
- style = d->layout_;
+ style = d->layout();
// Current base font for all inherited font changes, without any
// change caused by an individual character, except for the language:
// if the paragraph is empty, the loop will not be entered at all
if (empty()) {
- if (style->isCommand()) {
+ if (style.isCommand()) {
os << '{';
++column;
}
os << "}] ";
column +=3;
}
- if (style->isCommand()) {
+ if (style.isCommand()) {
os << '{';
++column;
}
if (c == ' ') {
// FIXME: integrate this case in latexSpecialChar
// Do not print the separation of the optional argument
- // if style->pass_thru is false. This works because
+ // if style.pass_thru is false. This works because
// latexSpecialChar ignores spaces if
- // style->pass_thru is false.
+ // style.pass_thru is false.
if (i != body_pos - 1) {
if (d->simpleTeXBlanks(
runparams, os, texrow,
- i, column, font, *style)) {
+ i, column, font, style)) {
// A surrogate pair was output. We
// must not call latexSpecialChar
// in this iteration, since it would output
}
OutputParams rp = runparams;
- rp.free_spacing = style->free_spacing;
+ rp.free_spacing = style.free_spacing;
rp.local_font = &font;
- rp.intitle = style->intitle;
+ rp.intitle = style.intitle;
// Two major modes: LaTeX or plain
// Handle here those cases common to both modes
d->latexInset(bparams, os,
texrow, rp, running_font,
basefont, outerfont, open_font,
- runningChange, *style, i, column);
+ runningChange, style, i, column);
else {
try {
d->latexSpecialChar(os, rp, running_font, runningChange,
- *style, i, column);
+ style, i, column);
} catch (EncodingException & e) {
if (runparams.dryrun) {
os << "<" << _("LyX Warning: ")
{
bool emph_flag = false;
- LayoutPtr const & style = d->layout_;
+ Layout const & style = d->layout();
FontInfo font_old =
- style->labeltype == LABEL_MANUAL ? style->labelfont : style->font;
+ style.labeltype == LABEL_MANUAL ? style.labelfont : style.font;
- if (style->pass_thru && !d->onlyText(buf, outerfont, initial))
+ if (style.pass_thru && !d->onlyText(buf, outerfont, initial))
os << "]]>";
// parsing main loop
} else {
char_type c = d->text_[i];
- if (style->pass_thru)
+ if (style.pass_thru)
os.put(c);
else
os << sgml::escapeChar(c);
os << "</emphasis>";
}
- if (style->free_spacing)
+ if (style.free_spacing)
os << '\n';
- if (style->pass_thru && !d->onlyText(buf, outerfont, initial))
+ if (style.pass_thru && !d->onlyText(buf, outerfont, initial))
os << "<![CDATA[";
}
}
-LayoutPtr const & Paragraph::layout() const
+Layout const & Paragraph::layout() const
{
- return d->layout_;
+ return d->layout();
}
-void Paragraph::setLayout(LayoutPtr const & layout)
+void Paragraph::setLayout(Layout const & layout)
{
- d->layout_ = layout;
+ d->setLayout(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();
}
// 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()
#define PARAGRAPH_H
#include "FontEnums.h"
-#include "LayoutPtr.h"
+#include "Layout.h"
#include "insets/InsetCode.h"
bool empty() const;
///
- LayoutPtr const & layout() const;
+ Layout const & layout() const;
///
- void setLayout(LayoutPtr const & layout);
- ///
- void setLayout(Layout const & layout) { setLayout(&layout); }
+ void setLayout(Layout const & layout);
///
void setEmptyOrDefaultLayout(DocumentClass const & tc);
docstring const translateIfPossible(docstring const & label,
BufferParams const & bparams) const;
/// Expand the counters for the labelstring of \c layout
- docstring expandLabel(LayoutPtr const &, BufferParams const &,
+ docstring expandLabel(Layout const &, BufferParams const &,
bool process_appendix = true) const;
/// Actual paragraph alignment used
char getAlign() const;
int const r_margin =
bv.rightMargin()
+ fm.signedWidth(tclass.rightmargin())
- + fm.signedWidth(par_->layout()->rightmargin)
+ + fm.signedWidth(par_->layout().rightmargin)
* 4 / (par_->getDepth() + 4);
return r_margin;
}
// do not expand in some labels
- if (par_->layout()->margintype != MARGIN_MANUAL && pos < par_->beginOfBody())
+ if (par_->layout().margintype != MARGIN_MANUAL && pos < par_->beginOfBody())
return false;
// if there is anything between the first char of the row and
ostringstream os;
params.write(os);
- LayoutPtr const & layout = par.layout();
+ Layout const & layout = par.layout();
// Is alignment possible
- os << "\\alignpossible " << layout->alignpossible << '\n';
+ os << "\\alignpossible " << layout.alignpossible << '\n';
/// set default alignment
- os << "\\aligndefault " << layout->align << '\n';
+ os << "\\aligndefault " << layout.align << '\n';
/// paragraph is always in inset. This is redundant.
os << "\\ininset " << 1 << '\n';
par.setLayout(bp.documentClass()[layoutname]);
// Test whether the layout is obsolete.
- LayoutPtr const & layout = par.layout();
- if (!layout->obsoleted_by().empty())
- par.setLayout(bp.documentClass()[layout->obsoleted_by()]);
+ Layout const & layout = par.layout();
+ if (!layout.obsoleted_by().empty())
+ par.setLayout(bp.documentClass()[layout.obsoleted_by()]);
par.params().read(lex);
{
return pars_.empty() || (pars_.size() == 1 && pars_[0].empty()
// FIXME: Should we consider the labeled type as empty too?
- && pars_[0].layout()->labeltype == LABEL_NO_LABEL);
+ && pars_[0].layout().labeltype == LABEL_NO_LABEL);
}
pit_type cpit = cur.pit();
DocumentClass const & tclass = cur.buffer().params().documentClass();
- LayoutPtr const & layout = cpar.layout();
+ Layout const & layout = cpar.layout();
// this is only allowed, if the current paragraph is not empty
// or caption and if it has not the keepempty flag active
if (cur.lastpos() == 0 && !cpar.allowEmpty() &&
- layout->labeltype != LABEL_SENSITIVE)
+ layout.labeltype != LABEL_SENSITIVE)
return;
// a layout change may affect also the following paragraph
// What should the layout for the new paragraph be?
bool keep_layout = inverse_logic ?
- !layout->isEnvironment()
- : layout->isEnvironment();
+ !layout.isEnvironment()
+ : layout.isEnvironment();
// We need to remember this before we break the paragraph, because
// that invalidates the layout variable
- bool sensitive = layout->labeltype == LABEL_SENSITIVE;
+ bool sensitive = layout.labeltype == LABEL_SENSITIVE;
// we need to set this before we insert the paragraph.
bool const isempty = cpar.allowEmpty() && cpar.empty();
// try to remove this
pit_type const pit = cur.pit();
- bool const freeSpacing = par.layout()->free_spacing ||
+ bool const freeSpacing = par.layout().free_spacing ||
par.isFreeSpacing();
if (lyxrc.auto_number) {
bool Text::handleBibitems(Cursor & cur)
{
- if (cur.paragraph().layout()->labeltype != LABEL_BIBLIO)
+ if (cur.paragraph().layout().labeltype != LABEL_BIBLIO)
return false;
if (cur.pos() != 0)
// Correction: Pasting is always allowed with standard-layout
// or the empty layout.
else if (par.layout() == prevpar.layout()
- || tclass.isDefaultLayout(*par.layout())
- || tclass.isEmptyLayout(*par.layout())) {
+ || tclass.isDefaultLayout(par.layout())
+ || tclass.isEmptyLayout(par.layout())) {
cur.recordUndo(ATOMIC_UNDO, prevcur.pit());
mergeParagraph(bufparams, plist, prevcur.pit());
needsUpdate = true;
{
pit_type pit = cur.pit();
- LayoutPtr layout = pars_[pit].layout();
+ Layout const * layout = &(pars_[pit].layout());
docstring text;
docstring par_text = pars_[pit].asString(false);
// For section, subsection, etc...
if (layout->latextype == LATEX_PARAGRAPH && pit != 0) {
- LayoutPtr const & layout2 = pars_[pit - 1].layout();
+ Layout const * layout2 = &(pars_[pit - 1].layout());
if (layout2->latextype != LATEX_PARAGRAPH) {
--pit;
layout = layout2;
FontInfo Text::layoutFont(Buffer const & buffer, pit_type const pit) const
{
- LayoutPtr const & layout = pars_[pit].layout();
+ Layout const & layout = pars_[pit].layout();
if (!pars_[pit].getDepth()) {
- FontInfo lf = layout->resfont;
+ FontInfo lf = layout.resfont;
// In case the default family has been customized
- if (layout->font.family() == INHERIT_FAMILY)
+ if (layout.font.family() == INHERIT_FAMILY)
lf.setFamily(buffer.params().getFont().fontInfo().family());
return lf;
}
- FontInfo font = layout->font;
+ FontInfo font = layout.font;
// Realize with the fonts of lesser depth.
//font.realize(outerFont(pit, paragraphs()));
font.realize(buffer.params().getFont().fontInfo());
FontInfo Text::labelFont(Buffer const & buffer, Paragraph const & par) const
{
- LayoutPtr const & layout = par.layout();
+ Layout const & layout = par.layout();
if (!par.getDepth()) {
- FontInfo lf = layout->reslabelfont;
+ FontInfo lf = layout.reslabelfont;
// In case the default family has been customized
- if (layout->labelfont.family() == INHERIT_FAMILY)
+ if (layout.labelfont.family() == INHERIT_FAMILY)
lf.setFamily(buffer.params().getFont().fontInfo().family());
return lf;
}
- FontInfo font = layout->labelfont;
+ FontInfo font = layout.labelfont;
// Realize with the fonts of lesser depth.
font.realize(buffer.params().getFont().fontInfo());
pos_type pos, Font const & fnt, Font const & display_font)
{
Font font = fnt;
- LayoutPtr const & layout = pars_[pit].layout();
+ Layout const & layout = pars_[pit].layout();
// Get concrete layout font to reduce against
FontInfo layoutfont;
if (pos < pars_[pit].beginOfBody())
- layoutfont = layout->labelfont;
+ layoutfont = layout.labelfont;
else
- layoutfont = layout->font;
+ layoutfont = layout.font;
// Realize against environment font information
if (pars_[pit].getDepth()) {
pars_[tp].getDepth()) {
tp = outerHook(tp, paragraphs());
if (tp != pit_type(paragraphs().size()))
- layoutfont.realize(pars_[tp].layout()->font);
+ layoutfont.realize(pars_[tp].layout().font);
}
}
static bool changeDepthAllowed(Text::DEPTH_CHANGE type,
Paragraph const & par, int max_depth)
{
- if (par.layout()->labeltype == LABEL_BIBLIO)
+ if (par.layout().labeltype == LABEL_BIBLIO)
return false;
int const depth = par.params().depth();
if (type == Text::INC_DEPTH && depth < max_depth)
Paragraph & par = pars_[pit];
ParagraphParameters params = par.params();
params.read(argument, merge);
- par.params().apply(params, *par.layout());
+ par.params().apply(params, par.layout());
}
}
for (pit_type pit = cur.selBegin().pit(), end = cur.selEnd().pit();
pit <= end; ++pit) {
Paragraph & par = pars_[pit];
- Layout const & layout = *(par.layout());
- par.params().apply(p, layout);
+ par.params().apply(p, par.layout());
}
}
DocumentClass const & tc = buf.params().documentClass();
- int const thistoclevel = start->layout()->toclevel;
+ int const thistoclevel = start->layout().toclevel;
int toclevel;
// Move out (down) from this section header
++finish;
// Seek the one (on same level) below
for (; finish != end; ++finish) {
- toclevel = finish->layout()->toclevel;
+ toclevel = finish->layout().toclevel;
if (toclevel != Layout::NOT_IN_TOC && toclevel <= thistoclevel) {
break;
}
// Search previous same-level header above
do {
--dest;
- toclevel = dest->layout()->toclevel;
+ toclevel = dest->layout().toclevel;
} while(dest != bgn
&& (toclevel == Layout::NOT_IN_TOC
|| toclevel > thistoclevel));
pit_type const len = distance(start, finish);
buf.undo().recordUndo(cur, ATOMIC_UNDO, pit, pit + len - 1);
for (; start != finish; ++start) {
- toclevel = start->layout()->toclevel;
+ toclevel = start->layout().toclevel;
if (toclevel == Layout::NOT_IN_TOC)
continue;
DocumentClass::const_iterator lit = tc.begin();
DocumentClass::const_iterator len = tc.end();
for (; lit != len; ++lit) {
if (lit->toclevel == toclevel + 1 &&
- start->layout()->labeltype == lit->labeltype) {
+ start->layout().labeltype == lit->labeltype) {
start->setLayout(*lit);
break;
}
pit_type const len = distance(start, finish);
buf.undo().recordUndo(cur, ATOMIC_UNDO, pit, pit + len - 1);
for (; start != finish; ++start) {
- toclevel = start->layout()->toclevel;
+ toclevel = start->layout().toclevel;
if (toclevel == Layout::NOT_IN_TOC)
continue;
DocumentClass::const_iterator lit = tc.begin();
DocumentClass::const_iterator len = tc.end();
for (; lit != len; ++lit) {
if (lit->toclevel == toclevel - 1 &&
- start->layout()->labeltype == lit->labeltype) {
+ start->layout().labeltype == lit->labeltype) {
start->setLayout(*lit);
break;
}
/*
Paragraph & par = pars_[cur.pit()];
if (inset->lyxCode() == LABEL_CODE
- && par.layout()->labeltype == LABEL_COUNTER) {
+ && par.layout().labeltype == LABEL_COUNTER) {
// Go to the end of the paragraph
// Warning: Because of Change-Tracking, the last
// position is 'size()' and not 'size()-1':
break;
case LFUN_SPACE_INSERT:
- if (cur.paragraph().layout()->free_spacing)
+ if (cur.paragraph().layout().free_spacing)
insertChar(cur, ' ');
else {
doInsertInset(cur, this, cmd, false, false);
break;
case LFUN_SERVER_GET_LAYOUT:
- cur.message(cur.paragraph().layout()->name());
+ cur.message(cur.paragraph().layout().name());
break;
case LFUN_LAYOUT: {
LYXERR(Debug::INFO, "LFUN_LAYOUT: (arg) " << to_utf8(layout));
Paragraph const & para = cur.paragraph();
- docstring const old_layout = para.layout()->name();
+ docstring const old_layout = para.layout().name();
DocumentClass const & tclass = bv->buffer().params().documentClass();
if (layout.empty())
pit_type spit = cur.selBegin().pit();
pit_type epit = cur.selEnd().pit() + 1;
while (spit != epit) {
- if (pars_[spit].layout()->name() != old_layout) {
+ if (pars_[spit].layout().name() != old_layout) {
change_layout = true;
break;
}
Paragraph & par = cur.paragraph();
pos_type pos = cur.pos();
BufferParams const & bufparams = bv->buffer().params();
- LayoutPtr const & style = par.layout();
- if (!style->pass_thru
+ Layout const & style = par.layout();
+ if (!style.pass_thru
&& par.getFontSettings(bufparams, pos).language()->lang() != "hebrew") {
// this avoids a double undo
// FIXME: should not be needed, ideally
return true;
case LFUN_BIBITEM_INSERT:
- enable = (cur.paragraph().layout()->labeltype == LABEL_BIBLIO
+ enable = (cur.paragraph().layout().labeltype == LABEL_BIBLIO
&& cur.pos() == 0);
break;
case LFUN_OPTIONAL_INSERT:
code = OPTARG_CODE;
enable = cur.paragraph().insetList().count(OPTARG_CODE)
- < cur.paragraph().layout()->optionalargs;
+ < cur.paragraph().layout().optionalargs;
break;
case LFUN_ENVIRONMENT_INSERT:
code = BOX_CODE;
case LFUN_OUTLINE_DOWN:
case LFUN_OUTLINE_IN:
case LFUN_OUTLINE_OUT:
- enable = (cur.paragraph().layout()->toclevel != Layout::NOT_IN_TOC);
+ enable = (cur.paragraph().layout().toclevel != Layout::NOT_IN_TOC);
break;
case LFUN_WORD_DELETE_FORWARD:
#include "FontInfo.h"
#include "Layout.h"
#include "LayoutEnums.h"
-#include "LayoutPtr.h"
#include "insets/InsetLayout.h"
ParagraphList const & pars = text_->paragraphs();
Paragraph const & par = pars[pit];
- LayoutPtr const & layout = par.layout();
+ Layout const & layout = par.layout();
Buffer const & buffer = bv_->buffer();
// FIXME: broken?
BufferParams const & params = buffer.params();
Font f = par.getFontSettings(params, pos);
if (!text_->isMainText(buffer))
applyOuterFont(f);
- bool lab = layout->labeltype == LABEL_MANUAL && pos < body_pos;
+ bool lab = layout.labeltype == LABEL_MANUAL && pos < body_pos;
- FontInfo const & lf = lab ? layout->labelfont : layout->font;
- FontInfo rlf = lab ? layout->reslabelfont : layout->resfont;
+ FontInfo const & lf = lab ? layout.labelfont : layout.font;
+ FontInfo rlf = lab ? layout.reslabelfont : layout.resfont;
// In case the default family has been customized
if (lf.family() == INHERIT_FAMILY)
// The uncommon case need not be optimized as much
FontInfo const & layoutfont = pos < body_pos ?
- layout->labelfont : layout->font;
+ layout.labelfont : layout.font;
Font font = par.getFontSettings(params, pos);
font.fontInfo().realize(layoutfont);
row.x = leftMargin(max_width_, pit, row.pos());
// is there a manual margin with a manual label
- LayoutPtr const & layout = par.layout();
+ Layout const & layout = par.layout();
- if (layout->margintype == MARGIN_MANUAL
- && layout->labeltype == LABEL_MANUAL) {
+ if (layout.margintype == MARGIN_MANUAL
+ && layout.labeltype == LABEL_MANUAL) {
/// We might have real hfills in the label part
int nlh = numberOfLabelHfills(par, row);
// set x how you need it
int align;
if (par.params().align() == LYX_ALIGN_LAYOUT)
- align = layout->align;
+ align = layout.align;
else
align = par.params().align();
&& (body_pos > end || !par.isLineSeparator(body_pos - 1)))
{
row.x += theFontMetrics(text_->labelFont(buffer, par)).
- width(layout->labelsep);
+ width(layout.labelsep);
if (body_pos <= end)
row.x += row.label_hfill;
}
int TextMetrics::labelEnd(pit_type const pit) const
{
// labelEnd is only needed if the layout fills a flushleft label.
- if (text_->getPar(pit).layout()->margintype != MARGIN_MANUAL)
+ if (text_->getPar(pit).layout().margintype != MARGIN_MANUAL)
return 0;
// return the beginning of the body
return leftMargin(max_width_, pit);
if (pos == end || width < 0)
return end;
- LayoutPtr const & layout = par.layout();
+ Layout const & layout = par.layout();
- if (layout->margintype == MARGIN_RIGHT_ADDRESS_BOX)
+ if (layout.margintype == MARGIN_RIGHT_ADDRESS_BOX)
return addressBreakPoint(pos, par);
pos_type const body_pos = par.beginOfBody();
if (body_pos && i == body_pos) {
FontMetrics const & fm = theFontMetrics(
text_->labelFont(buffer, par));
- int add = fm.width(layout->labelsep);
+ int add = fm.width(layout.labelsep);
if (par.isLineSeparator(i - 1))
add -= singleWidth(pit, i - 1);
if (body_pos > 0 && i == body_pos) {
FontMetrics const & fm = theFontMetrics(
text_->labelFont(buffer, par));
- w += fm.width(par.layout()->labelsep);
+ w += fm.width(par.layout().labelsep);
if (par.isLineSeparator(i - 1))
w -= singleWidth(pit, i - 1);
w = max(w, label_end);
if (body_pos > 0 && body_pos >= end) {
FontMetrics const & fm = theFontMetrics(
text_->labelFont(buffer, par));
- w += fm.width(par.layout()->labelsep);
+ w += fm.width(par.layout().labelsep);
if (end > 0 && par.isLineSeparator(end - 1))
w -= singleWidth(pit, end - 1);
w = max(w, label_end);
// ok, let us initialize the maxasc and maxdesc value.
// Only the fontsize count. The other properties
// are taken from the layoutfont. Nicer on the screen :)
- LayoutPtr const & layout = par.layout();
+ Layout const & layout = par.layout();
// as max get the first character of this row then it can
// increase but not decrease the height. Just some point to
FontMetrics const & fontmetrics = theFontMetrics(font);
// these are minimum values
- double const spacing_val = layout->spacing.getValue()
+ double const spacing_val = layout.spacing.getValue()
* text_->spacing(buffer, par);
//lyxerr << "spacing_val = " << spacing_val << endl;
int maxasc = int(fontmetrics.maxAscent() * spacing_val);
&& par.ownerCode() != ERT_CODE
&& par.ownerCode() != LISTINGS_CODE
&& pit > 0
- && ((layout->isParagraph() && par.getDepth() == 0)
- || (pars[pit - 1].layout()->isParagraph()
+ && ((layout.isParagraph() && par.getDepth() == 0)
+ || (pars[pit - 1].layout().isParagraph()
&& pars[pit - 1].getDepth() == 0)))
{
maxasc += bufparams.getDefSkip().inPixels(*bv_);
// This is special code for the chapter, since the label of this
// layout is printed in an extra row
- if (layout->counter == "chapter"
+ if (layout.counter == "chapter"
&& !par.params().labelString().empty()) {
labeladdon = int(labelfont_metrics.maxHeight()
- * layout->spacing.getValue()
+ * layout.spacing.getValue()
* text_->spacing(buffer, par));
}
// special code for the top label
- if ((layout->labeltype == LABEL_TOP_ENVIRONMENT
- || layout->labeltype == LABEL_BIBLIO
- || layout->labeltype == LABEL_CENTERED_TOP_ENVIRONMENT)
+ if ((layout.labeltype == LABEL_TOP_ENVIRONMENT
+ || layout.labeltype == LABEL_BIBLIO
+ || layout.labeltype == LABEL_CENTERED_TOP_ENVIRONMENT)
&& isFirstInSequence(pit, pars)
&& !par.labelString().empty())
{
labeladdon = int(
labelfont_metrics.maxHeight()
- * layout->spacing.getValue()
+ * layout.spacing.getValue()
* text_->spacing(buffer, par)
- + (layout->topsep + layout->labelbottomsep) * dh);
+ + (layout.topsep + layout.labelbottomsep) * dh);
}
// Add the layout spaces, for example before and after
&& prevpar.getDepth() == par.getDepth()
&& prevpar.getLabelWidthString()
== par.getLabelWidthString()) {
- layoutasc = layout->itemsep * dh;
+ layoutasc = layout.itemsep * dh;
} else if (pit != 0 || first != 0) {
- if (layout->topsep > 0)
- layoutasc = layout->topsep * dh;
+ if (layout.topsep > 0)
+ layoutasc = layout.topsep * dh;
}
prev = outerHook(pit, pars);
if (prev != pit_type(pars.size())) {
- maxasc += int(pars[prev].layout()->parsep * dh);
+ maxasc += int(pars[prev].layout().parsep * dh);
} else if (pit != 0) {
Paragraph const & prevpar = pars[pit - 1];
if (prevpar.getDepth() != 0 ||
prevpar.layout() == layout) {
- maxasc += int(layout->parsep * dh);
+ maxasc += int(layout.parsep * dh);
}
}
}
double unusual = 0;
if (pars[cpit].getDepth() > pars[nextpit].getDepth()) {
- usual = pars[cpit].layout()->bottomsep * dh;
+ usual = pars[cpit].layout().bottomsep * dh;
cpit = depthHook(cpit, pars, pars[nextpit].getDepth());
if (pars[cpit].layout() != pars[nextpit].layout()
|| pars[nextpit].getLabelWidthString() != pars[cpit].getLabelWidthString())
{
- unusual = pars[cpit].layout()->bottomsep * dh;
+ unusual = pars[cpit].layout().bottomsep * dh;
}
layoutdesc = max(unusual, usual);
} else if (pars[cpit].getDepth() == pars[nextpit].getDepth()) {
if (pars[cpit].layout() != pars[nextpit].layout()
|| pars[nextpit].getLabelWidthString() != pars[cpit].getLabelWidthString())
- layoutdesc = int(pars[cpit].layout()->bottomsep * dh);
+ layoutdesc = int(pars[cpit].layout().bottomsep * dh);
}
}
}
pos_type vc = row.pos();
pos_type end = row.endpos();
pos_type c = 0;
- LayoutPtr const & layout = par.layout();
+ Layout const & layout = par.layout();
bool left_side = false;
if (body_pos > 0 && c == body_pos - 1) {
FontMetrics const & fm = theFontMetrics(
text_->labelFont(buffer, par));
- tmpx += row.label_hfill + fm.width(layout->labelsep);
+ tmpx += row.label_hfill + fm.width(layout.labelsep);
if (par.isLineSeparator(body_pos - 1))
tmpx -= singleWidth(pit, body_pos - 1);
}
if (body_pos > 0 && pos == body_pos - 1) {
FontMetrics const & labelfm = theFontMetrics(
text_->labelFont(buffer, par));
- x += row.label_hfill + labelfm.width(par.layout()->labelsep);
+ x += row.label_hfill + labelfm.width(par.layout().labelsep);
if (par.isLineSeparator(body_pos - 1))
x -= singleWidth(pit, body_pos - 1);
}
Buffer const & buffer = bv_->buffer();
//lyxerr << "TextMetrics::leftMargin: pit: " << pit << " pos: " << pos << endl;
DocumentClass const & tclass = buffer.params().documentClass();
- LayoutPtr const & layout = par.layout();
+ Layout const & layout = par.layout();
- docstring parindent = layout->parindent;
+ docstring parindent = layout.parindent;
int l_margin = 0;
// find the next level paragraph
pit_type newpar = outerHook(pit, pars);
if (newpar != pit_type(pars.size())) {
- if (pars[newpar].layout()->isEnvironment()) {
+ if (pars[newpar].layout().isEnvironment()) {
l_margin = leftMargin(max_width, newpar);
}
- if (tclass.isDefaultLayout(*par.layout())
- || tclass.isEmptyLayout(*par.layout())) {
+ if (tclass.isDefaultLayout(par.layout())
+ || tclass.isEmptyLayout(par.layout())) {
if (pars[newpar].params().noindent())
parindent.erase();
else
- parindent = pars[newpar].layout()->parindent;
+ parindent = pars[newpar].layout().parindent;
}
}
}
// This happens after sections in standard classes. The 1.3.x
// code compared depths too, but it does not seem necessary
// (JMarc)
- if (tclass.isDefaultLayout(*par.layout())
- && pit > 0 && pars[pit - 1].layout()->nextnoindent)
+ if (tclass.isDefaultLayout(par.layout())
+ && pit > 0 && pars[pit - 1].layout().nextnoindent)
parindent.erase();
FontInfo const labelfont = text_->labelFont(buffer, par);
FontMetrics const & labelfont_metrics = theFontMetrics(labelfont);
- switch (layout->margintype) {
+ switch (layout.margintype) {
case MARGIN_DYNAMIC:
- if (!layout->leftmargin.empty()) {
+ if (!layout.leftmargin.empty()) {
l_margin += theFontMetrics(buffer.params().getFont()).signedWidth(
- layout->leftmargin);
+ layout.leftmargin);
}
if (!par.labelString().empty()) {
- l_margin += labelfont_metrics.signedWidth(layout->labelindent);
+ l_margin += labelfont_metrics.signedWidth(layout.labelindent);
l_margin += labelfont_metrics.width(par.labelString());
- l_margin += labelfont_metrics.width(layout->labelsep);
+ l_margin += labelfont_metrics.width(layout.labelsep);
}
break;
case MARGIN_MANUAL: {
- l_margin += labelfont_metrics.signedWidth(layout->labelindent);
+ l_margin += labelfont_metrics.signedWidth(layout.labelindent);
// The width of an empty par, even with manual label, should be 0
if (!par.empty() && pos >= par.beginOfBody()) {
if (!par.getLabelWidthString().empty()) {
docstring labstr = par.getLabelWidthString();
l_margin += labelfont_metrics.width(labstr);
- l_margin += labelfont_metrics.width(layout->labelsep);
+ l_margin += labelfont_metrics.width(layout.labelsep);
}
}
break;
case MARGIN_STATIC: {
l_margin += theFontMetrics(buffer.params().getFont()).
- signedWidth(layout->leftmargin) * 4 / (par.getDepth() + 4);
+ signedWidth(layout.leftmargin) * 4 / (par.getDepth() + 4);
break;
}
case MARGIN_FIRST_DYNAMIC:
- if (layout->labeltype == LABEL_MANUAL) {
+ if (layout.labeltype == LABEL_MANUAL) {
if (pos >= par.beginOfBody()) {
- l_margin += labelfont_metrics.signedWidth(layout->leftmargin);
+ l_margin += labelfont_metrics.signedWidth(layout.leftmargin);
} else {
- l_margin += labelfont_metrics.signedWidth(layout->labelindent);
+ l_margin += labelfont_metrics.signedWidth(layout.labelindent);
}
} else if (pos != 0
// Special case to fix problems with
// theorems (JMarc)
- || (layout->labeltype == LABEL_STATIC
- && layout->latextype == LATEX_ENVIRONMENT
+ || (layout.labeltype == LABEL_STATIC
+ && layout.latextype == LATEX_ENVIRONMENT
&& !isFirstInSequence(pit, pars))) {
- l_margin += labelfont_metrics.signedWidth(layout->leftmargin);
- } else if (layout->labeltype != LABEL_TOP_ENVIRONMENT
- && layout->labeltype != LABEL_BIBLIO
- && layout->labeltype !=
+ l_margin += labelfont_metrics.signedWidth(layout.leftmargin);
+ } else if (layout.labeltype != LABEL_TOP_ENVIRONMENT
+ && layout.labeltype != LABEL_BIBLIO
+ && layout.labeltype !=
LABEL_CENTERED_TOP_ENVIRONMENT) {
- l_margin += labelfont_metrics.signedWidth(layout->labelindent);
- l_margin += labelfont_metrics.width(layout->labelsep);
+ l_margin += labelfont_metrics.signedWidth(layout.labelindent);
+ l_margin += labelfont_metrics.width(layout.labelsep);
l_margin += labelfont_metrics.width(par.labelString());
}
break;
for ( ; rit != end; ++rit)
if (rit->fill() < minfill)
minfill = rit->fill();
- l_margin += theFontMetrics(params.getFont()).signedWidth(layout->leftmargin);
+ l_margin += theFontMetrics(params.getFont()).signedWidth(layout.leftmargin);
l_margin += minfill;
#endif
// also wrong, but much shorter.
LyXAlignment align;
if (par.params().align() == LYX_ALIGN_LAYOUT)
- align = layout->align;
+ align = layout.align;
else
align = par.params().align();
// set the correct parindent
if (pos == 0
- && (layout->labeltype == LABEL_NO_LABEL
- || layout->labeltype == LABEL_TOP_ENVIRONMENT
- || layout->labeltype == LABEL_CENTERED_TOP_ENVIRONMENT
- || (layout->labeltype == LABEL_STATIC
- && layout->latextype == LATEX_ENVIRONMENT
+ && (layout.labeltype == LABEL_NO_LABEL
+ || layout.labeltype == LABEL_TOP_ENVIRONMENT
+ || layout.labeltype == LABEL_CENTERED_TOP_ENVIRONMENT
+ || (layout.labeltype == LABEL_STATIC
+ && layout.latextype == LATEX_ENVIRONMENT
&& !isFirstInSequence(pit, pars)))
&& align == LYX_ALIGN_BLOCK
&& !par.params().noindent()
&& !(!par.empty()
&& par.isInset(pos)
&& par.getInset(pos)->display())
- && ((tclass.isDefaultLayout(*par.layout())
- || tclass.isEmptyLayout(*par.layout()))
+ && ((tclass.isDefaultLayout(par.layout())
+ || tclass.isEmptyLayout(par.layout()))
|| buffer.params().paragraph_separation == BufferParams::PARSEP_INDENT)
)
{
}
}
- int const toclevel = toc_item->par_it_->layout()->toclevel;
+ int const toclevel = toc_item->par_it_->layout().toclevel;
if (toclevel != Layout::NOT_IN_TOC && toclevel >= min_toclevel
&& tocstring.empty())
tocstring = toc_item->par_it_->asString(true);
}
/// now the toc entry for the paragraph
- int const toclevel = pit->layout()->toclevel;
+ int const toclevel = pit->layout().toclevel;
if (toclevel != Layout::NOT_IN_TOC
&& toclevel >= min_toclevel) {
// insert this into the table of contents
#include "Language.h"
#include "LaTeX.h"
#include "Layout.h"
-#include "LayoutPtr.h"
#include "LyX.h"
#include "TextClass.h"
#include "Paragraph.h"
depth_type getItemDepth(ParIterator const & it)
{
Paragraph const & par = *it;
- LabelType const labeltype = par.layout()->labeltype;
+ LabelType const labeltype = par.layout().labeltype;
if (labeltype != LABEL_ENUMERATE && labeltype != LABEL_ITEMIZE)
return 0;
// that is not more deeply nested.
Paragraph & prev_par = *prev_it;
depth_type const prev_depth = getDepth(prev_it);
- if (labeltype == prev_par.layout()->labeltype) {
+ if (labeltype == prev_par.layout().labeltype) {
if (prev_depth < min_depth)
return prev_par.itemdepth + 1;
if (prev_depth == min_depth)
bool needEnumCounterReset(ParIterator const & it)
{
Paragraph const & par = *it;
- BOOST_ASSERT(par.layout()->labeltype == LABEL_ENUMERATE);
+ BOOST_ASSERT(par.layout().labeltype == LABEL_ENUMERATE);
depth_type const cur_depth = par.getDepth();
ParIterator prev_it = it;
while (prev_it.pit()) {
--prev_it.top().pit();
Paragraph const & prev_par = *prev_it;
if (prev_par.getDepth() <= cur_depth)
- return prev_par.layout()->labeltype != LABEL_ENUMERATE;
+ return prev_par.layout().labeltype != LABEL_ENUMERATE;
}
// start of nested inset: reset
return true;
{
DocumentClass const & textclass = buf.params().documentClass();
Paragraph & par = it.paragraph();
- LayoutPtr const & layout = par.layout();
+ Layout const & layout = par.layout();
Counters & counters = textclass.counters();
if (par.params().startOfAppendix()) {
// Compute the item depth of the paragraph
par.itemdepth = getItemDepth(it);
- if (layout->margintype == MARGIN_MANUAL) {
+ if (layout.margintype == MARGIN_MANUAL) {
if (par.params().labelWidthString().empty())
- par.params().labelWidthString(par.translateIfPossible(layout->labelstring(), buf.params()));
+ par.params().labelWidthString(par.translateIfPossible(layout.labelstring(), buf.params()));
} else {
par.params().labelWidthString(docstring());
}
- switch(layout->labeltype) {
+ switch(layout.labeltype) {
case LABEL_COUNTER:
- if (layout->toclevel <= buf.params().secnumdepth
- && (layout->latextype != LATEX_ENVIRONMENT
+ if (layout.toclevel <= buf.params().secnumdepth
+ && (layout.latextype != LATEX_ENVIRONMENT
|| isFirstInSequence(it.pit(), it.plist()))) {
- counters.step(layout->counter);
+ counters.step(layout.counter);
par.params().labelString(
par.expandLabel(layout, buf.params()));
} else
case LABEL_STATIC:
case LABEL_BIBLIO:
par.params().labelString(
- par.translateIfPossible(layout->labelstring(),
+ par.translateIfPossible(layout.labelstring(),
buf.params()));
break;
}
LyXAlignment GuiParagraph::alignPossible() const
{
- return bufferview()->cursor().innerParagraph().layout()->alignpossible;
+ return bufferview()->cursor().innerParagraph().layout().alignpossible;
}
LyXAlignment GuiParagraph::alignDefault() const
{
- return bufferview()->cursor().innerParagraph().layout()->align;
+ return bufferview()->cursor().innerParagraph().layout().align;
}
Inset const * inset =
owner_.view()->cursor().innerParagraph().inInset();
if (!reset && text_class_ == text_class && inset_ == inset) {
- set(owner_.view()->cursor().innerParagraph().layout()->name());
+ set(owner_.view()->cursor().innerParagraph().layout().name());
return;
}
addItemSort(name, lyxrc.sort_layouts);
}
- set(owner_.view()->cursor().innerParagraph().layout()->name());
+ set(owner_.view()->cursor().innerParagraph().layout().name());
// needed to recalculate size hint
hide();
Counters & cnts = tclass.counters();
docstring const foot = from_ascii("footnote");
Paragraph const & outer = it.paragraph();
- if (!outer.layout()->intitle && cnts.hasCounter(foot)) {
+ if (!outer.layout().intitle && cnts.hasCounter(foot)) {
cnts.step(foot);
// FIXME: the counter should format itself.
setLabel(support::bformat(from_ascii("%1$s %2$s"),
ParagraphList & pars = paragraphs();
// This is a gross hack...
- LayoutPtr old_layout = pars.begin()->layout();
+ Layout old_layout = pars.begin()->layout();
pars.clear();
pars.push_back(Paragraph());
}
-InsetMathMBox::InsetMathMBox(LayoutPtr const & layout)
+InsetMathMBox::InsetMathMBox(Layout const & layout)
{
text_.paragraphs().clear();
text_.paragraphs().push_back(Paragraph());
public:
///
explicit InsetMathMBox();
- explicit InsetMathMBox(LayoutPtr const & layout);
+ explicit InsetMathMBox(Layout const & layout);
/// this stores metrics information in cache_
void metrics(MetricsInfo & mi, Dimension & dim) const;
ParagraphList::const_iterator p,
ParagraphList::const_iterator const & pend)
{
- for (++p; p != pend && p->layout()->latextype == LATEX_PARAGRAPH; ++p)
+ for (++p; p != pend && p->layout().latextype == LATEX_PARAGRAPH; ++p)
;
return p;
ParagraphList::const_iterator p,
ParagraphList::const_iterator const & pend)
{
- LayoutPtr const & bstyle = p->layout();
+ Layout const & bstyle = p->layout();
for (++p; p != pend; ++p) {
- LayoutPtr const & style = p->layout();
- if (style->latextype == LATEX_COMMAND
- && style->commanddepth <= bstyle->commanddepth)
+ Layout const & style = p->layout();
+ if (style.latextype == LATEX_COMMAND
+ && style.commanddepth <= bstyle.commanddepth)
return p;
}
return pend;
ParagraphList::const_iterator p,
ParagraphList::const_iterator const & pend)
{
- LayoutPtr const & bstyle = p->layout();
+ Layout const & bstyle = p->layout();
size_t const depth = p->params().depth();
for (++p; p != pend; ++p) {
- LayoutPtr const & style = p->layout();
- if (style->latextype == LATEX_COMMAND)
+ Layout const & style = p->layout();
+ if (style.latextype == LATEX_COMMAND)
return p;
- if (style->latextype == LATEX_PARAGRAPH) {
+ if (style.latextype == LATEX_PARAGRAPH) {
if (p->params().depth() > depth)
continue;
return p;
if (p->params().depth() < depth)
return p;
- if (style->latexname() != bstyle->latexname()
+ if (style.latexname() != bstyle.latexname()
&& p->params().depth() == depth)
return p;
}
for (ParagraphList::const_iterator par = pbegin; par != pend; ++par) {
if (par != pbegin)
os << '\n';
- if (buf.params().documentClass().isDefaultLayout(*par->layout())
+ if (buf.params().documentClass().isDefaultLayout(par->layout())
&& par->emptyTag()) {
par->simpleDocBookOnePar(buf, os, runparams,
outerFont(distance(paragraphs.begin(), par), paragraphs));
ParagraphList::const_iterator par = pbegin;
Layout const & defaultstyle = buf.params().documentClass().defaultLayout();
- LayoutPtr const & bstyle = par->layout();
+ Layout const & bstyle = par->layout();
string item_tag;
// Opening outter tag
sgml::openTag(buf, os, runparams, *pbegin);
os << '\n';
- if (bstyle->latextype == LATEX_ENVIRONMENT && bstyle->pass_thru)
+ if (bstyle.latextype == LATEX_ENVIRONMENT && bstyle.pass_thru)
os << "<![CDATA[";
while (par != pend) {
- LayoutPtr const & style = par->layout();
+ Layout const & style = par->layout();
ParagraphList::const_iterator send;
string id = par->getID(buf, runparams);
string wrapper = "";
pos_type sep = 0;
// Opening inner tag
- switch (bstyle->latextype) {
+ switch (bstyle.latextype) {
case LATEX_ENVIRONMENT:
- if (!bstyle->innertag().empty()) {
- sgml::openTag(os, bstyle->innertag(), id);
+ if (!bstyle.innertag().empty()) {
+ sgml::openTag(os, bstyle.innertag(), id);
}
break;
case LATEX_ITEM_ENVIRONMENT:
- if (!bstyle->labeltag().empty()) {
- sgml::openTag(os, bstyle->innertag(), id);
- sgml::openTag(os, bstyle->labeltag());
+ if (!bstyle.labeltag().empty()) {
+ sgml::openTag(os, bstyle.innertag(), id);
+ sgml::openTag(os, bstyle.labeltag());
sep = par->firstWord(os, runparams) + 1;
- sgml::closeTag(os, bstyle->labeltag());
+ sgml::closeTag(os, bstyle.labeltag());
}
wrapper = defaultstyle.latexname();
// If a sub list (embedded list) appears next with a
// different depth, then there is no need to open
// another tag at the current depth.
if(par->params().depth() == pbegin->params().depth()) {
- sgml::openTag(os, bstyle->itemtag());
+ sgml::openTag(os, bstyle.itemtag());
}
break;
default:
break;
}
- switch (style->latextype) {
+ switch (style.latextype) {
case LATEX_ENVIRONMENT:
case LATEX_ITEM_ENVIRONMENT: {
if (par->params().depth() == pbegin->params().depth()) {
}
// Closing inner tag
- switch (bstyle->latextype) {
+ switch (bstyle.latextype) {
case LATEX_ENVIRONMENT:
- if (!bstyle->innertag().empty()) {
- sgml::closeTag(os, bstyle->innertag());
+ if (!bstyle.innertag().empty()) {
+ sgml::closeTag(os, bstyle.innertag());
os << '\n';
}
break;
// when par == pend but at the same time that the
// current tag is closed.
if((par != pend && par->params().depth() == pbegin->params().depth()) || par == pend) {
- sgml::closeTag(os, bstyle->itemtag());
+ sgml::closeTag(os, bstyle.itemtag());
}
- if (!bstyle->labeltag().empty())
- sgml::closeTag(os, bstyle->innertag());
+ if (!bstyle.labeltag().empty())
+ sgml::closeTag(os, bstyle.innertag());
break;
default:
break;
}
}
- if (bstyle->latextype == LATEX_ENVIRONMENT && bstyle->pass_thru)
+ if (bstyle.latextype == LATEX_ENVIRONMENT && bstyle.pass_thru)
os << "]]>";
// Closing outter tag
ParagraphList::const_iterator const & pend)
{
ParagraphList::const_iterator par = pbegin;
- LayoutPtr const & bstyle = par->layout();
+ Layout const & bstyle = par->layout();
//Open outter tag
sgml::openTag(buf, os, runparams, *pbegin);
os << '\n';
// Label around sectioning number:
- if (!bstyle->labeltag().empty()) {
- sgml::openTag(os, bstyle->labeltag());
+ if (!bstyle.labeltag().empty()) {
+ sgml::openTag(os, bstyle.labeltag());
// We don't care about appendix in DOCBOOK.
os << par->expandLabel(bstyle, buf.params(), false);
- sgml::closeTag(os, bstyle->labeltag());
+ sgml::closeTag(os, bstyle.labeltag());
}
// Opend inner tag and close inner tags
- sgml::openTag(os, bstyle->innertag());
+ sgml::openTag(os, bstyle.innertag());
par->simpleDocBookOnePar(buf, os, runparams, outerFont(distance(paragraphs.begin(), par), paragraphs));
- sgml::closeTag(os, bstyle->innertag());
+ sgml::closeTag(os, bstyle.innertag());
os << '\n';
++par;
while (par != pend) {
- LayoutPtr const & style = par->layout();
+ Layout const & style = par->layout();
ParagraphList::const_iterator send;
- switch (style->latextype) {
+ switch (style.latextype) {
case LATEX_COMMAND: {
send = searchCommand(par, pend);
par = makeCommand(buf, os, runparams, paragraphs, par,send);
}
while (par != pend) {
- LayoutPtr const & style = par->layout();
+ Layout const & style = par->layout();
ParagraphList::const_iterator lastpar = par;
ParagraphList::const_iterator send;
- switch (style->latextype) {
+ switch (style.latextype) {
case LATEX_COMMAND: {
send = searchCommand(par, pend);
par = makeCommand(buf, os, runparams, paragraphs, par,send);
while (par != paragraphs.end() &&
par->params().depth() == pit->params().depth()) {
- if (par->layout()->isEnvironment()) {
+ if (par->layout().isEnvironment()) {
par = TeXEnvironment(buf, text, par,
os, texrow, runparams);
} else {
BufferParams const & bparams = buf.params();
- LayoutPtr const & style = pit->forceEmptyLayout() ?
- &bparams.documentClass().emptyLayout() : pit->layout();
+ Layout const & style = pit->forceEmptyLayout() ?
+ bparams.documentClass().emptyLayout() : pit->layout();
ParagraphList const & paragraphs = text.paragraphs();
leftindent_open = true;
}
- if (style->isEnvironment()) {
- os << "\\begin{" << from_ascii(style->latexname()) << '}';
- if (style->optionalargs > 0) {
+ if (style.isEnvironment()) {
+ os << "\\begin{" << from_ascii(style.latexname()) << '}';
+ if (style.optionalargs > 0) {
int ret = latexOptArgInsets(*pit, os, runparams,
- style->optionalargs);
+ style.optionalargs);
while (ret > 0) {
texrow.newline();
--ret;
}
}
- if (style->latextype == LATEX_LIST_ENVIRONMENT) {
+ if (style.latextype == LATEX_LIST_ENVIRONMENT) {
os << '{'
<< pit->params().labelWidthString()
<< "}\n";
- } else if (style->labeltype == LABEL_BIBLIO) {
+ } else if (style.labeltype == LABEL_BIBLIO) {
// ale970405
os << '{' << bibitemWidest(buf) << "}\n";
} else
- os << from_ascii(style->latexparam()) << '\n';
+ os << from_ascii(style.latexparam()) << '\n';
texrow.newline();
}
os << '\n';
texrow.newline();
} else if (par->params().depth() > pit->params().depth()) {
- if (par->layout()->isParagraph()) {
+ if (par->layout().isParagraph()) {
// Thinko!
// How to handle this? (Lgb)
//&& !suffixIs(os, "\n\n")
open_encoding_ = none;
}
- if (style->isEnvironment()) {
- os << "\\end{" << from_ascii(style->latexname()) << "}\n";
+ if (style.isEnvironment()) {
+ os << "\\end{" << from_ascii(style.latexname()) << "}\n";
texrow.newline();
}
// was forceDefaultParagraphs()?
// In an inset with unlimited length (all in one row),
// force layout to default
- LayoutPtr const style = pit->forceEmptyLayout() ?
- &bparams.documentClass().emptyLayout() : pit->layout();
+ Layout const style = pit->forceEmptyLayout() ?
+ bparams.documentClass().emptyLayout() : pit->layout();
OutputParams runparams = runparams_in;
- runparams.moving_arg |= style->needprotect;
+ runparams.moving_arg |= style.needprotect;
bool const maintext = text.isMainText(buf);
// we are at the beginning of an inset and CJK is already open.
if (par_language->babel() != prev_language->babel()
// check if we already put language command in TeXEnvironment()
- && !(style->isEnvironment()
+ && !(style.isEnvironment()
&& (pit == paragraphs.begin() ||
(boost::prior(pit)->layout() != pit->layout() &&
boost::prior(pit)->getDepth() <= pit->getDepth())
texrow.newline();
}
- if (style->isCommand()) {
+ if (style.isCommand()) {
os << '\n';
texrow.newline();
}
}
- switch (style->latextype) {
+ switch (style.latextype) {
case LATEX_COMMAND:
- os << '\\' << from_ascii(style->latexname());
+ os << '\\' << from_ascii(style.latexname());
// Separate handling of optional argument inset.
- if (style->optionalargs > 0) {
+ if (style.optionalargs > 0) {
int ret = latexOptArgInsets(*pit, os, runparams,
- style->optionalargs);
+ style.optionalargs);
while (ret > 0) {
texrow.newline();
--ret;
}
}
else
- os << from_ascii(style->latexparam());
+ os << from_ascii(style.latexparam());
break;
case LATEX_ITEM_ENVIRONMENT:
case LATEX_LIST_ENVIRONMENT:
? pit->getLayoutFont(bparams, outerfont)
: pit->getFont(bparams, pit->size() - 1, outerfont);
- bool is_command = style->isCommand();
+ bool is_command = style.isCommand();
- if (style->resfont.size() != font.fontInfo().size()
+ if (style.resfont.size() != font.fontInfo().size()
&& boost::next(pit) != paragraphs.end()
&& !is_command) {
if (!need_par)
os << '}';
bool pending_newline = false;
- switch (style->latextype) {
+ switch (style.latextype) {
case LATEX_ITEM_ENVIRONMENT:
case LATEX_LIST_ENVIRONMENT:
if (boost::next(pit) != paragraphs.end()
// skip it otherwise fall through
ParagraphList::const_iterator next = boost::next(pit);
- if (next != paragraphs.end()
- && (next->layout() != pit->layout()
+ if (next != paragraphs.end() && (next->layout() != pit->layout()
|| next->params().depth() != pit->params().depth()))
break;
}
// also if the next paragraph is a multilingual environment (because of nesting)
if (boost::next(pit) != paragraphs.end() && open_encoding_ == CJK &&
(boost::next(pit)->getParLanguage(bparams)->encoding()->package() != Encoding::CJK ||
- boost::next(pit)->layout()->isEnvironment() && boost::next(pit)->isMultiLingual(bparams))
+ boost::next(pit)->layout().isEnvironment() && boost::next(pit)->isMultiLingual(bparams))
// in environments, CJK has to be closed later (nesting!)
- && !style->isEnvironment()) {
+ && !style.isEnvironment()) {
os << "\\end{CJK}\n";
open_encoding_ = none;
}
// If this is the last paragraph, close the CJK environment
// if necessary. If it's an environment, we'll have to \end that first.
- if (boost::next(pit) == paragraphs.end() && !style->isEnvironment()) {
+ if (boost::next(pit) == paragraphs.end() && !style.isEnvironment()) {
switch (open_encoding_) {
case CJK: {
// end of main text
// any environment other than the default layout of the
// text class to be valid!
if (par->allowParagraphCustomization()) {
- LayoutPtr const & layout = par->forceEmptyLayout() ?
- &tclass.emptyLayout() :
+ Layout const & layout = par->forceEmptyLayout() ?
+ tclass.emptyLayout() :
par->layout();
- if (layout->intitle) {
+ if (layout.intitle) {
if (already_title) {
lyxerr << "Error in latexParagraphs: You"
" should not mix title layouts"
was_title = false;
}
- if (layout->is_environment) {
+ if (layout.is_environment) {
par = TeXOnePar(buf, text, par, os, texrow,
runparams, everypar);
- } else if (layout->isEnvironment() ||
+ } else if (layout.isEnvironment() ||
!par->params().leftIndent().zero()) {
par = TeXEnvironment(buf, text, par, os,
texrow, runparams);
depth_type depth = par.params().depth();
// First write the layout
- string const tmp = to_utf8(par.layout()->name());
+ string const tmp = to_utf8(par.layout().name());
if (compare_ascii_no_case(tmp, "itemize") == 0) {
ltype = 1;
ltype_depth = depth + 1;
pit_type pit = p;
depth_type par_depth = pars[p].getDepth();
while (pit != pit_type(pars.size())) {
- LayoutPtr const & layout = pars[pit].layout();
- int const endlabeltype = layout->endlabeltype;
+ Layout const & layout = pars[pit].layout();
+ int const endlabeltype = layout.endlabeltype;
if (endlabeltype != END_LABEL_NO_LABEL) {
if (p + 1 == pit_type(pars.size()))
&& !tmpfont.resolved()) {
par_offset = outerHook(par_offset, pars);
if (par_offset != pit_type(pars.size())) {
- tmpfont.realize(pars[par_offset].layout()->font);
+ tmpfont.realize(pars[par_offset].layout().font);
par_depth = pars[par_offset].getDepth();
}
}
Buffer const & buffer = pi_.base.bv->buffer();
- LayoutPtr const & layout = par_.layout();
+ Layout const & layout = par_.layout();
if (buffer.params().paragraph_separation == BufferParams::PARSEP_SKIP) {
if (pit_ != 0) {
- if (layout->latextype == LATEX_PARAGRAPH
+ if (layout.latextype == LATEX_PARAGRAPH
&& !par_.getDepth()) {
y_top += buffer.params().getDefSkip().inPixels(*pi_.base.bv);
} else {
- LayoutPtr const & playout = pars_[pit_ - 1].layout();
- if (playout->latextype == LATEX_PARAGRAPH
+ Layout const & playout = pars_[pit_ - 1].layout();
+ if (playout.latextype == LATEX_PARAGRAPH
&& !pars_[pit_ - 1].getDepth()) {
// is it right to use defskip here, too? (AS)
y_top += buffer.params().getDefSkip().inPixels(*pi_.base.bv);
//lyxerr << "paintFirst: " << par_.id() << " is_seq: " << is_seq << endl;
// should we print a label?
- if (layout->labeltype >= LABEL_STATIC
- && (layout->labeltype != LABEL_STATIC
- || layout->latextype != LATEX_ENVIRONMENT
+ if (layout.labeltype >= LABEL_STATIC
+ && (layout.labeltype != LABEL_STATIC
+ || layout.latextype != LATEX_ENVIRONMENT
|| is_seq)) {
FontInfo const font = labelFont();
// this is special code for the chapter layout. This is
// printed in an extra row and has a pagebreak at
// the top.
- if (layout->counter == "chapter") {
+ if (layout.counter == "chapter") {
double spacing_val = 1.0;
if (!parparams.spacing().isDefault()) {
spacing_val = parparams.spacing().getValue();
spacing_val = buffer.params().spacing().getValue();
}
- int const labeladdon = int(fm.maxHeight() * layout->spacing.getValue() * spacing_val);
+ int const labeladdon = int(fm.maxHeight() * layout.spacing.getValue() * spacing_val);
- int const maxdesc = int(fm.maxDescent() * layout->spacing.getValue() * spacing_val)
- + int(layout->parsep) * defaultRowHeight();
+ int const maxdesc = int(fm.maxDescent() * layout.spacing.getValue() * spacing_val)
+ + int(layout.parsep) * defaultRowHeight();
if (is_rtl) {
x = width_ - leftMargin() -
} else {
if (is_rtl) {
x = width_ - leftMargin()
- + fm.width(layout->labelsep);
+ + fm.width(layout.labelsep);
} else {
- x = x_ - fm.width(layout->labelsep)
+ x = x_ - fm.width(layout.labelsep)
- fm.width(str);
}
// the labels at the top of an environment.
// More or less for bibliography
} else if (is_seq &&
- (layout->labeltype == LABEL_TOP_ENVIRONMENT ||
- layout->labeltype == LABEL_BIBLIO ||
- layout->labeltype == LABEL_CENTERED_TOP_ENVIRONMENT)) {
+ (layout.labeltype == LABEL_TOP_ENVIRONMENT ||
+ layout.labeltype == LABEL_BIBLIO ||
+ layout.labeltype == LABEL_CENTERED_TOP_ENVIRONMENT)) {
FontInfo const font = labelFont();
docstring const str = par_.labelString();
if (!str.empty()) {
FontMetrics const & fm = theFontMetrics(font);
int const labeladdon = int(fm.maxHeight()
- * layout->spacing.getValue() * spacing_val);
+ * layout.spacing.getValue() * spacing_val);
int maxdesc =
- int(fm.maxDescent() * layout->spacing.getValue() * spacing_val
- + (layout->labelbottomsep * defaultRowHeight()));
+ int(fm.maxDescent() * layout.spacing.getValue() * spacing_val
+ + (layout.labelbottomsep * defaultRowHeight()));
double x = x_;
- if (layout->labeltype == LABEL_CENTERED_TOP_ENVIRONMENT) {
+ if (layout.labeltype == LABEL_CENTERED_TOP_ENVIRONMENT) {
if (is_rtl)
x = leftMargin();
x += (width_ - text_metrics_.rightMargin(pm_) - leftMargin()) / 2;
case END_LABEL_STATIC: {
FontInfo const font = labelFont();
FontMetrics const & fm = theFontMetrics(font);
- docstring const & str = par_.layout()->endlabelstring();
+ docstring const & str = par_.layout().endlabelstring();
double const x = is_rtl ?
x_ - fm.width(str)
: - text_metrics_.rightMargin(pm_) - row_.width();
body_pos = 0;
}
- LayoutPtr const & layout = par_.layout();
+ Layout const & layout = par_.layout();
bool running_strikeout = false;
bool is_struckout = false;
if (body_pos > 0 && pos == body_pos - 1) {
int const lwidth = theFontMetrics(labelFont())
- .width(layout->labelsep);
+ .width(layout.labelsep);
x_ += row_.label_hfill + lwidth - width_pos;
}
void sgml::openTag(Buffer const & buf, odocstream & os,
OutputParams const & runparams, Paragraph const & par)
{
- LayoutPtr const & style = par.layout();
- string const & name = style->latexname();
- string param = style->latexparam();
+ Layout const & style = par.layout();
+ string const & name = style.latexname();
+ string param = style.latexparam();
Counters & counters = buf.params().documentClass().counters();
string id = par.getID(buf, runparams);
} else {
if (param.find('#') != string::npos) {
// FIXME UNICODE
- if (!style->counter.empty())
- counters.step(style->counter);
+ if (!style.counter.empty())
+ counters.step(style.counter);
else
counters.step(from_ascii(name));
int i = counters.value(from_ascii(name));
void sgml::closeTag(odocstream & os, Paragraph const & par)
{
- LayoutPtr const & style = par.layout();
- closeTag(os, style->latexname());
+ Layout const & style = par.layout();
+ closeTag(os, style.latexname());
}