mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-26 03:11:59 +00:00
Changes LayoutList from a vector<LayoutPtr> to a vector<Layout>.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23519 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
e7d3e98546
commit
f401ce5d29
@ -147,7 +147,7 @@ pasteSelectionHelper(Cursor & cur, ParagraphList const & parlist,
|
||||
// note that we are doing this if the empty layout is
|
||||
// supposed to be the default, not just if it is forced
|
||||
if (cur.inset().useEmptyLayout()) {
|
||||
LayoutPtr const layout =
|
||||
Layout const & layout =
|
||||
buffer.params().documentClass().emptyLayout();
|
||||
ParagraphList::iterator const end = insertion.end();
|
||||
for (ParagraphList::iterator par = insertion.begin();
|
||||
|
@ -382,7 +382,7 @@ void LaTeXFeatures::useLayout(docstring const & layoutname)
|
||||
!= usedLayouts_.end())
|
||||
return;
|
||||
|
||||
Layout const & layout = *tclass[layoutname];
|
||||
Layout const & layout = tclass[layoutname];
|
||||
require(layout.requires());
|
||||
|
||||
if (!layout.depends_on().empty()) {
|
||||
@ -839,7 +839,7 @@ docstring const LaTeXFeatures::getTClassPreamble() const
|
||||
list<docstring>::const_iterator cit = usedLayouts_.begin();
|
||||
list<docstring>::const_iterator end = usedLayouts_.end();
|
||||
for (; cit != end; ++cit) {
|
||||
tcpreamble << tclass[*cit]->preamble();
|
||||
tcpreamble << tclass[*cit].preamble();
|
||||
}
|
||||
|
||||
return tcpreamble.str();
|
||||
|
@ -223,7 +223,7 @@ bool Layout::read(Lexer & lexrc, TextClass const & tclass)
|
||||
|
||||
if (tclass.hasLayout(style)) {
|
||||
docstring const tmpname = name_;
|
||||
this->operator=(*tclass[style]);
|
||||
this->operator=(tclass[style]);
|
||||
name_ = tmpname;
|
||||
} else {
|
||||
lyxerr << "Cannot copy unknown style `"
|
||||
@ -233,7 +233,7 @@ bool Layout::read(Lexer & lexrc, TextClass const & tclass)
|
||||
DocumentClass::const_iterator lit = tclass.begin();
|
||||
DocumentClass::const_iterator len = tclass.end();
|
||||
for (; lit != len; ++lit)
|
||||
lyxerr << to_utf8((*lit)->name()) << endl;
|
||||
lyxerr << to_utf8(lit->name()) << endl;
|
||||
|
||||
//lexrc.printError("Cannot copy known "
|
||||
// "style `$$Token'");
|
||||
@ -248,7 +248,7 @@ bool Layout::read(Lexer & lexrc, TextClass const & tclass)
|
||||
|
||||
if (tclass.hasLayout(style)) {
|
||||
docstring const tmpname = name_;
|
||||
this->operator=(*tclass[style]);
|
||||
this->operator=(tclass[style]);
|
||||
name_ = tmpname;
|
||||
if (obsoleted_by().empty())
|
||||
obsoleted_by_ = style;
|
||||
|
@ -12,15 +12,12 @@
|
||||
#ifndef LAYOUTPTR_H
|
||||
#define LAYOUTPTR_H
|
||||
|
||||
#include <boost/shared_ptr.hpp>
|
||||
|
||||
|
||||
namespace lyx {
|
||||
|
||||
class Layout;
|
||||
|
||||
/// Global typedef
|
||||
typedef boost::shared_ptr<Layout> LayoutPtr;
|
||||
typedef Layout const * LayoutPtr;
|
||||
|
||||
|
||||
} // namespace lyx
|
||||
|
@ -1544,7 +1544,7 @@ docstring Paragraph::expandLabel(LayoutPtr const & layout,
|
||||
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);
|
||||
@ -1555,9 +1555,9 @@ docstring Paragraph::expandLabel(LayoutPtr const & layout,
|
||||
}
|
||||
|
||||
|
||||
void Paragraph::applyLayout(LayoutPtr const & new_layout)
|
||||
void Paragraph::applyLayout(Layout const & new_layout)
|
||||
{
|
||||
d->layout_ = new_layout;
|
||||
d->layout_ = &new_layout;
|
||||
LyXAlignment const oldAlign = d->params_.align();
|
||||
|
||||
if (!(oldAlign & d->layout_->alignpossible)) {
|
||||
@ -1819,15 +1819,10 @@ bool Paragraph::latex(BufferParams const & bparams,
|
||||
|
||||
LayoutPtr style;
|
||||
|
||||
// well we have to check if we are in an inset with unlimited
|
||||
// length (all in one row) if that is true then we don't allow
|
||||
// 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 = forceEmptyLayout();
|
||||
|
||||
if (asdefault)
|
||||
style = bparams.documentClass().emptyLayout();
|
||||
style = &(bparams.documentClass().emptyLayout());
|
||||
else
|
||||
style = d->layout_;
|
||||
|
||||
|
@ -157,6 +157,8 @@ public:
|
||||
///
|
||||
void setLayout(LayoutPtr const & layout);
|
||||
///
|
||||
void setLayout(Layout const & layout) { setLayout(&layout); }
|
||||
///
|
||||
void setEmptyOrDefaultLayout(DocumentClass const & tc);
|
||||
|
||||
/// This is the item depth, only used by enumerate and itemize
|
||||
@ -219,7 +221,7 @@ public:
|
||||
/// The maximal possible depth of a paragraph after this one
|
||||
depth_type getMaxDepthAfter() const;
|
||||
///
|
||||
void applyLayout(LayoutPtr const & new_layout);
|
||||
void applyLayout(Layout const & new_layout);
|
||||
|
||||
/// (logically) erase the char at pos; return true if it was actually erased
|
||||
bool eraseChar(pos_type pos, bool trackChanges);
|
||||
|
@ -1004,8 +1004,8 @@ bool Text::backspacePos0(Cursor & cur)
|
||||
// Correction: Pasting is always allowed with standard-layout
|
||||
// or the empty layout.
|
||||
else if (par.layout() == prevpar.layout()
|
||||
|| par.layout() == tclass.defaultLayout()
|
||||
|| par.layout() == tclass.emptyLayout()) {
|
||||
|| tclass.isDefaultLayout(*par.layout())
|
||||
|| tclass.isEmptyLayout(*par.layout())) {
|
||||
cur.recordUndo(ATOMIC_UNDO, prevcur.pit());
|
||||
mergeParagraph(bufparams, plist, prevcur.pit());
|
||||
needsUpdate = true;
|
||||
|
@ -199,14 +199,14 @@ void Text::setLayout(Buffer const & buffer, pit_type start, pit_type end,
|
||||
BOOST_ASSERT(start != end);
|
||||
|
||||
BufferParams const & bufparams = buffer.params();
|
||||
LayoutPtr const & lyxlayout = bufparams.documentClass()[layout];
|
||||
Layout const & lyxlayout = bufparams.documentClass()[layout];
|
||||
|
||||
for (pit_type pit = start; pit != end; ++pit) {
|
||||
Paragraph & par = pars_[pit];
|
||||
par.applyLayout(lyxlayout);
|
||||
if (lyxlayout->margintype == MARGIN_MANUAL)
|
||||
if (lyxlayout.margintype == MARGIN_MANUAL)
|
||||
par.setLabelWidthString(par.translateIfPossible(
|
||||
lyxlayout->labelstring(), buffer.params()));
|
||||
lyxlayout.labelstring(), buffer.params()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -218,8 +218,8 @@ void Text::setLayout(Cursor & cur, docstring const & layout)
|
||||
// special handling of new environment insets
|
||||
BufferView & bv = cur.bv();
|
||||
BufferParams const & params = bv.buffer().params();
|
||||
LayoutPtr const & lyxlayout = params.documentClass()[layout];
|
||||
if (lyxlayout->is_environment) {
|
||||
Layout const & lyxlayout = params.documentClass()[layout];
|
||||
if (lyxlayout.is_environment) {
|
||||
// move everything in a new environment inset
|
||||
LYXERR(Debug::DEBUG, "setting layout " << to_utf8(layout));
|
||||
lyx::dispatch(FuncRequest(LFUN_LINE_BEGIN));
|
||||
|
@ -330,10 +330,9 @@ static void outline(OutlineOp mode, Cursor & cur)
|
||||
DocumentClass::const_iterator lit = tc.begin();
|
||||
DocumentClass::const_iterator len = tc.end();
|
||||
for (; lit != len; ++lit) {
|
||||
LayoutPtr const & lt = *lit;
|
||||
if (lt->toclevel == toclevel + 1 &&
|
||||
start->layout()->labeltype == lt->labeltype) {
|
||||
start->setLayout(lt);
|
||||
if (lit->toclevel == toclevel + 1 &&
|
||||
start->layout()->labeltype == lit->labeltype) {
|
||||
start->setLayout(*lit);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -350,10 +349,9 @@ static void outline(OutlineOp mode, Cursor & cur)
|
||||
DocumentClass::const_iterator lit = tc.begin();
|
||||
DocumentClass::const_iterator len = tc.end();
|
||||
for (; lit != len; ++lit) {
|
||||
LayoutPtr const & lt = *lit;
|
||||
if (lt->toclevel == toclevel - 1 &&
|
||||
start->layout()->labeltype == lt->labeltype) {
|
||||
start->setLayout(lt);
|
||||
if (lit->toclevel == toclevel - 1 &&
|
||||
start->layout()->labeltype == lit->labeltype) {
|
||||
start->setLayout(*lit);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -1011,7 +1009,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
|
||||
|
||||
// If the entry is obsolete, use the new one instead.
|
||||
if (hasLayout) {
|
||||
docstring const & obs = tclass[layout]->obsoleted_by();
|
||||
docstring const & obs = tclass[layout].obsoleted_by();
|
||||
if (!obs.empty())
|
||||
layout = obs;
|
||||
}
|
||||
|
@ -44,14 +44,14 @@ namespace lyx {
|
||||
|
||||
namespace {
|
||||
|
||||
class LayoutNamesEqual : public unary_function<LayoutPtr, bool> {
|
||||
class LayoutNamesEqual : public unary_function<Layout, bool> {
|
||||
public:
|
||||
LayoutNamesEqual(docstring const & name)
|
||||
: name_(name)
|
||||
{}
|
||||
bool operator()(LayoutPtr const & c) const
|
||||
bool operator()(Layout const & c) const
|
||||
{
|
||||
return c->name() == name_;
|
||||
return c.name() == name_;
|
||||
}
|
||||
private:
|
||||
docstring name_;
|
||||
@ -239,8 +239,8 @@ bool TextClass::read(FileName const & filename, ReadType rt)
|
||||
// The only way this happens is because the hardcoded layout above
|
||||
// is wrong.
|
||||
BOOST_ASSERT(false);
|
||||
}
|
||||
layoutlist_.push_back(boost::shared_ptr<Layout>(new Layout(lay)));
|
||||
};
|
||||
layoutlist_.push_back(lay);
|
||||
}
|
||||
|
||||
Lexer lexrc(textClassTags,
|
||||
@ -320,8 +320,8 @@ bool TextClass::read(FileName const & filename, ReadType rt)
|
||||
//error to true, since we couldn't even read the name?
|
||||
error = !readStyle(lexrc, lay);
|
||||
} else if (hasLayout(name)) {
|
||||
Layout * lay = operator[](name).get();
|
||||
error = !readStyle(lexrc, *lay);
|
||||
Layout & lay = operator[](name);
|
||||
error = !readStyle(lexrc, lay);
|
||||
} else {
|
||||
Layout lay;
|
||||
lay.setName(name);
|
||||
@ -329,7 +329,7 @@ bool TextClass::read(FileName const & filename, ReadType rt)
|
||||
lay.is_environment = true;
|
||||
error = !readStyle(lexrc, lay);
|
||||
if (!error)
|
||||
layoutlist_.push_back(boost::shared_ptr<Layout>(new Layout(lay)));
|
||||
layoutlist_.push_back(lay);
|
||||
|
||||
if (defaultlayout_.empty()) {
|
||||
// We do not have a default layout yet, so we choose
|
||||
@ -531,11 +531,10 @@ bool TextClass::read(FileName const & filename, ReadType rt)
|
||||
|
||||
min_toclevel_ = Layout::NOT_IN_TOC;
|
||||
max_toclevel_ = Layout::NOT_IN_TOC;
|
||||
DocumentClass::const_iterator lit = begin();
|
||||
DocumentClass::const_iterator len = end();
|
||||
const_iterator lit = begin();
|
||||
const_iterator len = end();
|
||||
for (; lit != len; ++lit) {
|
||||
Layout const & lt = **lit;
|
||||
int const toclevel = lt.toclevel;
|
||||
int const toclevel = lit->toclevel;
|
||||
if (toclevel != Layout::NOT_IN_TOC) {
|
||||
if (min_toclevel_ == Layout::NOT_IN_TOC)
|
||||
min_toclevel_ = toclevel;
|
||||
@ -863,28 +862,46 @@ bool TextClass::hasLayout(docstring const & n) const
|
||||
|
||||
|
||||
|
||||
LayoutPtr const & TextClass::operator[](docstring const & name) const
|
||||
Layout const & TextClass::operator[](docstring const & name) const
|
||||
{
|
||||
BOOST_ASSERT(!name.empty());
|
||||
|
||||
LayoutList::const_iterator cit =
|
||||
find_if(layoutlist_.begin(),
|
||||
layoutlist_.end(),
|
||||
LayoutNamesEqual(name));
|
||||
const_iterator it =
|
||||
find_if(begin(), end(), LayoutNamesEqual(name));
|
||||
|
||||
if (cit == layoutlist_.end()) {
|
||||
if (it == end()) {
|
||||
lyxerr << "We failed to find the layout '" << to_utf8(name)
|
||||
<< "' in the layout list. You MUST investigate!"
|
||||
<< endl;
|
||||
for (LayoutList::const_iterator it = layoutlist_.begin();
|
||||
it != layoutlist_.end(); ++it)
|
||||
lyxerr << " " << to_utf8(it->get()->name()) << endl;
|
||||
for (const_iterator cit = begin(); cit != end(); ++cit)
|
||||
lyxerr << " " << to_utf8(cit->name()) << endl;
|
||||
|
||||
// we require the name to exist
|
||||
BOOST_ASSERT(false);
|
||||
}
|
||||
|
||||
return *cit;
|
||||
return *it;
|
||||
}
|
||||
|
||||
|
||||
Layout & TextClass::operator[](docstring const & name)
|
||||
{
|
||||
BOOST_ASSERT(!name.empty());
|
||||
|
||||
iterator it = find_if(begin(), end(), LayoutNamesEqual(name));
|
||||
|
||||
if (it == end()) {
|
||||
lyxerr << "We failed to find the layout '" << to_utf8(name)
|
||||
<< "' in the layout list. You MUST investigate!"
|
||||
<< endl;
|
||||
for (const_iterator cit = begin(); cit != end(); ++cit)
|
||||
lyxerr << " " << to_utf8(cit->name()) << endl;
|
||||
|
||||
// we require the name to exist
|
||||
BOOST_ASSERT(false);
|
||||
}
|
||||
|
||||
return *it;
|
||||
}
|
||||
|
||||
|
||||
@ -952,12 +969,24 @@ docstring const & TextClass::defaultLayoutName() const
|
||||
}
|
||||
|
||||
|
||||
LayoutPtr const & TextClass::defaultLayout() const
|
||||
Layout const & TextClass::defaultLayout() const
|
||||
{
|
||||
return operator[](defaultLayoutName());
|
||||
}
|
||||
|
||||
|
||||
bool TextClass::isDefaultLayout(Layout const & lay) const
|
||||
{
|
||||
return lay.name() == defaultLayoutName();
|
||||
}
|
||||
|
||||
|
||||
bool TextClass::isEmptyLayout(Layout const & lay) const
|
||||
{
|
||||
return lay.name() == emptyLayoutName();
|
||||
}
|
||||
|
||||
|
||||
DocumentClass & DocumentClassBundle::newClass(LayoutFile const & baseClass)
|
||||
{
|
||||
DocumentClass dc(baseClass);
|
||||
@ -983,7 +1012,7 @@ bool DocumentClass::hasLaTeXLayout(std::string const & lay) const
|
||||
LayoutList::const_iterator it = layoutlist_.begin();
|
||||
LayoutList::const_iterator end = layoutlist_.end();
|
||||
for (; it != end; ++it)
|
||||
if (it->get()->latexname() == lay)
|
||||
if (it->latexname() == lay)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
@ -12,6 +12,7 @@
|
||||
|
||||
#include "ColorCode.h"
|
||||
#include "FontInfo.h"
|
||||
#include "Layout.h"
|
||||
#include "LayoutEnums.h"
|
||||
#include "LayoutPtr.h"
|
||||
|
||||
@ -54,7 +55,7 @@ public:
|
||||
// typedefs
|
||||
///////////////////////////////////////////////////////////////////
|
||||
/// The individual paragraph layouts comprising the document class
|
||||
typedef std::vector<LayoutPtr> LayoutList;
|
||||
typedef std::vector<Layout> LayoutList;
|
||||
/// The inset layouts available to this class
|
||||
typedef std::map<docstring, InsetLayout> InsetLayouts;
|
||||
///
|
||||
@ -63,8 +64,7 @@ public:
|
||||
///////////////////////////////////////////////////////////////////
|
||||
// Iterators
|
||||
///////////////////////////////////////////////////////////////////
|
||||
/// Note that this returns a (LayoutPtr *). We really need a custom
|
||||
/// iterator here.
|
||||
///
|
||||
const_iterator begin() const { return layoutlist_.begin(); }
|
||||
///
|
||||
const_iterator end() const { return layoutlist_.end(); }
|
||||
@ -74,12 +74,16 @@ public:
|
||||
// Layout Info
|
||||
///////////////////////////////////////////////////////////////////
|
||||
///
|
||||
LayoutPtr const & defaultLayout() const;
|
||||
Layout const & defaultLayout() const;
|
||||
///
|
||||
docstring const & defaultLayoutName() const;
|
||||
///
|
||||
bool isDefaultLayout(Layout const &) const;
|
||||
///
|
||||
bool isEmptyLayout(Layout const &) const;
|
||||
/// returns a special layout for use when we don't really want one,
|
||||
/// e.g., in table cells
|
||||
LayoutPtr const & emptyLayout() const
|
||||
Layout const & emptyLayout() const
|
||||
{ return operator[](emptylayout_); };
|
||||
/// the name of the empty layout
|
||||
docstring const & emptyLayoutName() const
|
||||
@ -89,7 +93,7 @@ public:
|
||||
///
|
||||
bool hasLayout(docstring const & name) const;
|
||||
///
|
||||
LayoutPtr const & operator[](docstring const & vname) const;
|
||||
Layout const & operator[](docstring const & vname) const;
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
// reading routines
|
||||
@ -125,6 +129,19 @@ public:
|
||||
protected:
|
||||
/// Protect construction
|
||||
TextClass();
|
||||
///
|
||||
Layout & operator[](docstring const & vname);
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
// non-const iterators
|
||||
///////////////////////////////////////////////////////////////////
|
||||
///
|
||||
typedef LayoutList::iterator iterator;
|
||||
///
|
||||
iterator begin() { return layoutlist_.begin(); }
|
||||
///
|
||||
iterator end() { return layoutlist_.end(); }
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
// members
|
||||
///////////////////////////////////////////////////////////////////
|
||||
|
@ -1719,8 +1719,8 @@ int TextMetrics::leftMargin(int max_width,
|
||||
if (pars[newpar].layout()->isEnvironment()) {
|
||||
l_margin = leftMargin(max_width, newpar);
|
||||
}
|
||||
//FIXME Should this check for emptyLayout() as well?
|
||||
if (par.layout() == tclass.defaultLayout()) {
|
||||
if (tclass.isDefaultLayout(*par.layout())
|
||||
|| tclass.isEmptyLayout(*par.layout())) {
|
||||
if (pars[newpar].params().noindent())
|
||||
parindent.erase();
|
||||
else
|
||||
@ -1732,7 +1732,7 @@ int TextMetrics::leftMargin(int max_width,
|
||||
// This happens after sections in standard classes. The 1.3.x
|
||||
// code compared depths too, but it does not seem necessary
|
||||
// (JMarc)
|
||||
if (par.layout() == tclass.defaultLayout()
|
||||
if (tclass.isDefaultLayout(*par.layout())
|
||||
&& pit > 0 && pars[pit - 1].layout()->nextnoindent)
|
||||
parindent.erase();
|
||||
|
||||
@ -1831,8 +1831,8 @@ int TextMetrics::leftMargin(int max_width,
|
||||
|| layout->labeltype == LABEL_TOP_ENVIRONMENT
|
||||
|| layout->labeltype == LABEL_CENTERED_TOP_ENVIRONMENT
|
||||
|| (layout->labeltype == LABEL_STATIC
|
||||
&& layout->latextype == LATEX_ENVIRONMENT
|
||||
&& !isFirstInSequence(pit, pars)))
|
||||
&& layout->latextype == LATEX_ENVIRONMENT
|
||||
&& !isFirstInSequence(pit, pars)))
|
||||
&& align == LYX_ALIGN_BLOCK
|
||||
&& !par.params().noindent()
|
||||
// in some insets, paragraphs are never indented
|
||||
@ -1841,9 +1841,10 @@ int TextMetrics::leftMargin(int max_width,
|
||||
&& !(!par.empty()
|
||||
&& par.isInset(pos)
|
||||
&& par.getInset(pos)->display())
|
||||
&& (par.layout() != tclass.defaultLayout() //should this check emptyLayout()?
|
||||
|| buffer.params().paragraph_separation ==
|
||||
BufferParams::PARSEP_INDENT))
|
||||
&& ((tclass.isDefaultLayout(*par.layout())
|
||||
|| tclass.isEmptyLayout(*par.layout()))
|
||||
|| buffer.params().paragraph_separation == BufferParams::PARSEP_INDENT)
|
||||
)
|
||||
{
|
||||
l_margin += theFontMetrics(buffer.params().getFont()).signedWidth(
|
||||
parindent);
|
||||
|
@ -1414,11 +1414,10 @@ void GuiDocument::updateNumbering()
|
||||
DocumentClass::const_iterator lit = tclass.begin();
|
||||
DocumentClass::const_iterator len = tclass.end();
|
||||
for (; lit != len; ++lit) {
|
||||
Layout const & lt = **lit;
|
||||
int const toclevel = lt.toclevel;
|
||||
if (toclevel != Layout::NOT_IN_TOC && lt.labeltype == LABEL_COUNTER) {
|
||||
int const toclevel = lit->toclevel;
|
||||
if (toclevel != Layout::NOT_IN_TOC && lit->labeltype == LABEL_COUNTER) {
|
||||
item = new QTreeWidgetItem(numberingModule->tocTW);
|
||||
item->setText(0, toqstr(translateIfPossible(lt.name())));
|
||||
item->setText(0, toqstr(translateIfPossible(lit->name())));
|
||||
item->setText(1, (toclevel <= depth) ? yes : no);
|
||||
item->setText(2, (toclevel <= toc) ? yes : no);
|
||||
}
|
||||
|
@ -546,7 +546,7 @@ void GuiLayoutBox::set(docstring const & layout)
|
||||
if (!text_class_)
|
||||
return;
|
||||
|
||||
QString const & name = toqstr((*text_class_)[layout]->name());
|
||||
QString const & name = toqstr((*text_class_)[layout].name());
|
||||
if (name == currentText())
|
||||
return;
|
||||
|
||||
@ -631,8 +631,7 @@ void GuiLayoutBox::updateContents(bool reset)
|
||||
DocumentClass::const_iterator lit = text_class_->begin();
|
||||
DocumentClass::const_iterator len = text_class_->end();
|
||||
for (; lit != len; ++lit) {
|
||||
Layout const & lt = **lit;
|
||||
docstring const & name = lt.name();
|
||||
docstring const & name = lit->name();
|
||||
// if this inset requires the empty layout, we skip the default
|
||||
// layout
|
||||
if (name == text_class_->defaultLayoutName() && inset &&
|
||||
|
@ -104,7 +104,7 @@ int InsetERT::docbook(odocstream & os, OutputParams const &) const
|
||||
void InsetERT::doDispatch(Cursor & cur, FuncRequest & cmd)
|
||||
{
|
||||
BufferParams const & bp = cur.buffer().params();
|
||||
LayoutPtr const layout = bp.documentClass().emptyLayout();
|
||||
Layout const layout = bp.documentClass().emptyLayout();
|
||||
//lyxerr << "\nInsetERT::doDispatch (begin): cmd: " << cmd << endl;
|
||||
switch (cmd.action) {
|
||||
|
||||
@ -136,8 +136,8 @@ void InsetERT::doDispatch(Cursor & cur, FuncRequest & cmd)
|
||||
// start of an existing paragraph get the buffer language
|
||||
// and not latex_language, so we take this brute force
|
||||
// approach.
|
||||
cur.current_font.fontInfo() = layout->font;
|
||||
cur.real_current_font.fontInfo() = layout->font;
|
||||
cur.current_font.fontInfo() = layout.font;
|
||||
cur.real_current_font.fontInfo() = layout.font;
|
||||
InsetCollapsable::doDispatch(cur, cmd);
|
||||
break;
|
||||
}
|
||||
|
@ -58,12 +58,12 @@ int InsetEnvironment::latex(odocstream & os,
|
||||
OutputParams const & runparams) const
|
||||
{
|
||||
// FIXME UNICODE
|
||||
os << from_utf8(layout_->latexheader);
|
||||
os << from_utf8(layout_.latexheader);
|
||||
TexRow texrow;
|
||||
latexParagraphs(buffer(), text_, os, texrow, runparams,
|
||||
layout_->latexparagraph);
|
||||
layout_.latexparagraph);
|
||||
// FIXME UNICODE
|
||||
os << from_utf8(layout_->latexfooter);
|
||||
os << from_utf8(layout_.latexfooter);
|
||||
return texrow.rows();
|
||||
}
|
||||
|
||||
@ -79,7 +79,7 @@ int InsetEnvironment::plaintext(odocstream & os,
|
||||
}
|
||||
|
||||
|
||||
LayoutPtr const & InsetEnvironment::layout() const
|
||||
Layout const & InsetEnvironment::layout() const
|
||||
{
|
||||
return layout_;
|
||||
}
|
||||
|
@ -13,11 +13,11 @@
|
||||
#define INSETENVIRONMENT_H
|
||||
|
||||
#include "InsetText.h"
|
||||
#include "LayoutPtr.h"
|
||||
|
||||
|
||||
namespace lyx {
|
||||
|
||||
class Layout;
|
||||
|
||||
class InsetEnvironment : public InsetText {
|
||||
public:
|
||||
///
|
||||
@ -39,7 +39,7 @@ public:
|
||||
///
|
||||
Inset::EDITABLE editable() const { return HIGHLY_EDITABLE; }
|
||||
///
|
||||
LayoutPtr const & layout() const;
|
||||
Layout const & layout() const;
|
||||
/** returns true if, when outputing LaTeX, font changes should
|
||||
be closed before generating this inset. This is needed for
|
||||
insets that may contain several paragraphs */
|
||||
@ -48,7 +48,7 @@ private:
|
||||
///
|
||||
Inset * clone() const { return new InsetEnvironment(*this); }
|
||||
/// the layout
|
||||
LayoutPtr layout_;
|
||||
Layout const & layout_;
|
||||
///
|
||||
docstring name_;
|
||||
};
|
||||
|
@ -101,11 +101,11 @@ ParagraphList::const_iterator makeParagraph(Buffer const & buf,
|
||||
ParagraphList::const_iterator const & pbegin,
|
||||
ParagraphList::const_iterator const & pend)
|
||||
{
|
||||
LayoutPtr const & defaultstyle = buf.params().documentClass().defaultLayout();
|
||||
for (ParagraphList::const_iterator par = pbegin; par != pend; ++par) {
|
||||
if (par != pbegin)
|
||||
os << '\n';
|
||||
if (par->layout() == defaultstyle && par->emptyTag()) {
|
||||
if (buf.params().documentClass().isDefaultLayout(*par->layout())
|
||||
&& par->emptyTag()) {
|
||||
par->simpleDocBookOnePar(buf, os, runparams,
|
||||
outerFont(distance(paragraphs.begin(), par), paragraphs));
|
||||
} else {
|
||||
@ -127,7 +127,7 @@ ParagraphList::const_iterator makeEnvironment(Buffer const & buf,
|
||||
ParagraphList::const_iterator const & pend) {
|
||||
ParagraphList::const_iterator par = pbegin;
|
||||
|
||||
LayoutPtr const & defaultstyle = buf.params().documentClass().defaultLayout();
|
||||
Layout const & defaultstyle = buf.params().documentClass().defaultLayout();
|
||||
LayoutPtr const & bstyle = par->layout();
|
||||
string item_tag;
|
||||
|
||||
@ -159,7 +159,7 @@ ParagraphList::const_iterator makeEnvironment(Buffer const & buf,
|
||||
sep = par->firstWord(os, runparams) + 1;
|
||||
sgml::closeTag(os, bstyle->labeltag());
|
||||
}
|
||||
wrapper = defaultstyle->latexname();
|
||||
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.
|
||||
|
@ -109,7 +109,7 @@ TeXEnvironment(Buffer const & buf,
|
||||
BufferParams const & bparams = buf.params();
|
||||
|
||||
LayoutPtr const & style = pit->forceEmptyLayout() ?
|
||||
bparams.documentClass().emptyLayout() : pit->layout();
|
||||
&bparams.documentClass().emptyLayout() : pit->layout();
|
||||
|
||||
ParagraphList const & paragraphs = text.paragraphs();
|
||||
|
||||
@ -309,7 +309,7 @@ TeXOnePar(Buffer const & buf,
|
||||
// In an inset with unlimited length (all in one row),
|
||||
// force layout to default
|
||||
LayoutPtr const style = pit->forceEmptyLayout() ?
|
||||
bparams.documentClass().emptyLayout() : pit->layout();
|
||||
&bparams.documentClass().emptyLayout() : pit->layout();
|
||||
|
||||
OutputParams runparams = runparams_in;
|
||||
runparams.moving_arg |= style->needprotect;
|
||||
@ -790,7 +790,7 @@ void latexParagraphs(Buffer const & buf,
|
||||
// text class to be valid!
|
||||
if (par->allowParagraphCustomization()) {
|
||||
LayoutPtr const & layout = par->forceEmptyLayout() ?
|
||||
tclass.emptyLayout() :
|
||||
&tclass.emptyLayout() :
|
||||
par->layout();
|
||||
|
||||
if (layout->intitle) {
|
||||
|
@ -93,10 +93,10 @@ Context::Context(bool need_layout_,
|
||||
layout(layout_), parent_layout(parent_layout_),
|
||||
font(font_)
|
||||
{
|
||||
if (!layout.get())
|
||||
layout = textclass.defaultLayout();
|
||||
if (!parent_layout.get())
|
||||
parent_layout = textclass.defaultLayout();
|
||||
if (!layout)
|
||||
layout = &textclass.defaultLayout();
|
||||
if (!parent_layout)
|
||||
parent_layout = &textclass.defaultLayout();
|
||||
}
|
||||
|
||||
|
||||
@ -132,7 +132,7 @@ void Context::check_layout(ostream & os)
|
||||
// that this may require a begin_deeper.
|
||||
if (!deeper_paragraph)
|
||||
begin_deeper(os);
|
||||
begin_layout(os, textclass.defaultLayout(),
|
||||
begin_layout(os, &textclass.defaultLayout(),
|
||||
font, normalfont);
|
||||
deeper_paragraph = true;
|
||||
}
|
||||
|
@ -426,8 +426,8 @@ LayoutPtr findLayout(TextClass const & textclass, string const & name)
|
||||
DocumentClass::const_iterator lit = textclass.begin();
|
||||
DocumentClass::const_iterator len = textclass.end();
|
||||
for (; lit != len; ++lit)
|
||||
if ((*lit)->latexname() == name)
|
||||
return *lit;
|
||||
if (lit->latexname() == name)
|
||||
return &*lit;
|
||||
return LayoutPtr();
|
||||
}
|
||||
|
||||
@ -809,7 +809,7 @@ void parse_environment(Parser & p, ostream & os, bool outer,
|
||||
}
|
||||
|
||||
// The single '=' is meant here.
|
||||
else if ((newlayout = findLayout(parent_context.textclass, name)).get() &&
|
||||
else if ((newlayout = findLayout(parent_context.textclass, name)) &&
|
||||
newlayout->isEnvironment()) {
|
||||
eat_whitespace(p, os, parent_context, false);
|
||||
Context context(true, parent_context.textclass, newlayout,
|
||||
@ -1062,7 +1062,7 @@ void parse_noweb(Parser & p, ostream & os, Context & context)
|
||||
// always must be in an own paragraph.
|
||||
context.new_paragraph(os);
|
||||
Context newcontext(true, context.textclass,
|
||||
context.textclass[from_ascii("Scrap")]);
|
||||
&context.textclass[from_ascii("Scrap")]);
|
||||
newcontext.check_layout(os);
|
||||
os << name;
|
||||
while (p.good()) {
|
||||
@ -1514,9 +1514,8 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
|
||||
else if ((p.next_token().asInput() == "*") &&
|
||||
context.new_layout_allowed &&
|
||||
// The single '=' is meant here.
|
||||
(newlayout = findLayout(context.textclass,
|
||||
t.cs() + '*')).get() &&
|
||||
newlayout->isCommand()) {
|
||||
(newlayout = findLayout(context.textclass, t.cs() + '*')) &&
|
||||
newlayout->isCommand()) {
|
||||
p.get_token();
|
||||
output_command_layout(os, p, outer, context, newlayout);
|
||||
p.skip_spaces();
|
||||
@ -1524,7 +1523,7 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
|
||||
|
||||
// The single '=' is meant here.
|
||||
else if (context.new_layout_allowed &&
|
||||
(newlayout = findLayout(context.textclass, t.cs())).get() &&
|
||||
(newlayout = findLayout(context.textclass, t.cs())) &&
|
||||
newlayout->isCommand()) {
|
||||
output_command_layout(os, p, outer, context, newlayout);
|
||||
p.skip_spaces();
|
||||
|
Loading…
Reference in New Issue
Block a user