// Convert newline to paragraph break in ERT inset.
// This should not be here!
- if (pars[pit].inInset() &&
- (pars[pit].inInset()->lyxCode() == ERT_CODE ||
- pars[pit].inInset()->lyxCode() == LISTINGS_CODE)) {
- for (ParagraphList::size_type i = 0; i < insertion.size(); ++i) {
- for (pos_type j = 0; j < insertion[i].size(); ++j) {
+ Inset * inset = pars[pit].inInset();
+ if (inset && (inset->lyxCode() == ERT_CODE ||
+ inset->lyxCode() == LISTINGS_CODE)) {
+ for (size_t i = 0; i != insertion.size(); ++i) {
+ for (pos_type j = 0; j != insertion[i].size(); ++j) {
if (insertion[i].isNewline(j)) {
// do not track deletion of newline
insertion[i].eraseChar(j, false);
ParagraphList::iterator const end = insertion.end();
for (ParagraphList::iterator par = insertion.begin();
par != end; ++par)
- par->layout(layout);
+ par->setLayout(layout);
}
// Make sure there is no class difference.
bool hasLayout = newtc.hasLayout(name);
if (hasLayout)
- it->layout(newtc[name]);
+ it->setLayout(newtc[name]);
else
- it->layout(newtc.defaultLayout());
+ it->setLayout(newtc.defaultLayout());
if (!hasLayout && name != oldtc.defaultLayoutName()) {
docstring const s = bformat(
ParagraphList pars;
Paragraph par;
BufferParams const & bp = cur.buffer().params();
- par.layout(bp.textClass().defaultLayout());
+ par.setLayout(bp.textClass().defaultLayout());
par.insert(0, grabSelection(cur), Font(), Change(Change::UNCHANGED));
pars.push_back(par);
cutstack.push(make_pair(pars, bp.textClassIndex()));
ParagraphList pars;
Paragraph par;
BufferParams const & bp = cur.buffer().params();
- par.layout(bp.textClass().defaultLayout());
+ par.setLayout(bp.textClass().defaultLayout());
par.insert(0, plaintext, Font(), Change(Change::UNCHANGED));
pars.push_back(par);
theCuts.push(make_pair(pars, bp.textClassIndex()));
<< to_utf8(style) << "'\n"
<< "All layouts so far:"
<< endl;
- TextClass::const_iterator it =
- tclass.begin();
- TextClass::const_iterator end =
- tclass.end();
- for (; it != end; ++it) {
- lyxerr << to_utf8((*it)->name())
+ for (size_t i = 0; i != tclass.layoutCount(); ++i)
+ lyxerr << to_utf8(tclass.layout(i)->name())
<< endl;
- }
//lexrc.printError("Cannot copy known "
// "style `$$Token'");
FuncRequest(LFUN_NOACTION)));
return;
}
- InsetLayouts const & insetlayouts =
- buf->params().textClass().insetlayouts();
- InsetLayouts::const_iterator cit = insetlayouts.begin();
- InsetLayouts::const_iterator end = insetlayouts.end();
+ InsetLayouts const & insetLayouts =
+ buf->params().textClass().insetLayouts();
+ InsetLayouts::const_iterator cit = insetLayouts.begin();
+ InsetLayouts::const_iterator end = insetLayouts.end();
for (; cit != end; ++cit) {
docstring const label = cit->first;
if (cit->second.lyxtype() == s)
}
-docstring const & Paragraph::getLabelstring() const
+docstring const & Paragraph::labelString() const
{
return d->params_.labelString();
}
}
-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());
}
class OutputParams;
class PainterInfo;
class ParagraphParameters;
+class TextClass;
class TexRow;
///
LayoutPtr const & layout() const;
///
- void layout(LayoutPtr const & new_layout);
+ void setLayout(LayoutPtr const & layout);
+ ///
+ void setEmptyOrDefaultLayout(TextClass const & tc);
/// This is the item depth, only used by enumerate and itemize
signed char itemdepth;
void setBeginOfBody();
///
- docstring const & getLabelstring() const;
+ docstring const & labelString() const;
/// the next two functions are for the manual labels
docstring const getLabelWidthString() const;
tclass.defaultLayoutName();
}
- par.layout(bp.textClass()[layoutname]);
+ par.setLayout(bp.textClass()[layoutname]);
// Test whether the layout is obsolete.
LayoutPtr const & layout = par.layout();
if (!layout->obsoleted_by().empty())
- par.layout(bp.textClass()[layout->obsoleted_by()]);
+ par.setLayout(bp.textClass()[layout->obsoleted_by()]);
par.params().read(lex);
}
-double Text::spacing(Buffer const & buffer,
- Paragraph const & par) const
+double Text::spacing(Buffer const & buffer, Paragraph const & par) const
{
if (par.params().spacing().isDefault())
return buffer.params().spacing().getValue();
// otherwise reset to default
if (par.useEmptyLayout())
- cur.paragraph().layout(bufparams.textClass().emptyLayout());
+ cur.paragraph().setLayout(bufparams.textClass().emptyLayout());
else
- cur.paragraph().layout(bufparams.textClass().defaultLayout());
+ cur.paragraph().setLayout(bufparams.textClass().defaultLayout());
return true;
}
InsetText * insetText = dynamic_cast<InsetText *>(inset);
if (insetText && !insetText->allowMultiPar() || cur.lastpit() == 0) {
// reset first par to default
- LayoutPtr const layout = insetText->useEmptyLayout()
- ? bparams.textClass().emptyLayout()
- : bparams.textClass().defaultLayout();
- cur.text()->paragraphs().begin()->layout(layout);
+ cur.text()->paragraphs().begin()
+ ->setEmptyOrDefaultLayout(bparams.textClass());
cur.pos() = 0;
cur.pit() = 0;
// Merge multiple paragraphs -- hack
ParagraphList::iterator finish = start;
ParagraphList::iterator end = pars.end();
- TextClass::const_iterator lit = buf.params().textClass().begin();
- TextClass::const_iterator const lend = buf.params().textClass().end();
+ TextClass const & tc = buf.params().textClass();
int const thistoclevel = start->layout()->toclevel;
int toclevel;
}
case OutlineIn:
buf.undo().recordUndo(cur);
- for (; lit != lend; ++lit) {
- if ((*lit)->toclevel == thistoclevel + 1 &&
- start->layout()->labeltype == (*lit)->labeltype) {
- start->layout((*lit));
+ for (size_t i = 0; i != tc.layoutCount(); ++i) {
+ LayoutPtr const & lt = tc.layout(i);
+ if (lt->toclevel == thistoclevel + 1 &&
+ start->layout()->labeltype == lt->labeltype) {
+ start->setLayout(lt);
break;
}
}
break;
case OutlineOut:
buf.undo().recordUndo(cur);
- for (; lit != lend; ++lit) {
- if ((*lit)->toclevel == thistoclevel - 1 &&
- start->layout()->labeltype == (*lit)->labeltype) {
- start->layout((*lit));
+ for (size_t i = 0; i != tc.layoutCount(); ++i) {
+ LayoutPtr const & lt = tc.layout(i);
+ if (lt->toclevel == thistoclevel - 1 &&
+ start->layout()->labeltype == lt->labeltype) {
+ start->setLayout(lt);
break;
}
}
// add a separate paragraph for the caption inset
pars.push_back(Paragraph());
pars.back().setInsetOwner(pars[0].inInset());
- if (pars.back().useEmptyLayout())
- pars.back().layout(tclass.emptyLayout());
- else
- pars.back().layout(tclass.defaultLayout());
-
+ pars.back().setEmptyOrDefaultLayout(tclass);
int cap_pit = pars.size() - 1;
// if an empty inset was created, we create an additional empty
if (!content) {
pars.push_back(Paragraph());
pars.back().setInsetOwner(pars[0].inInset());
- if (pars.back().useEmptyLayout())
- pars.back().layout(tclass.emptyLayout());
- else
- pars.back().layout(tclass.defaultLayout());
+ pars.back().setEmptyOrDefaultLayout(tclass);
}
// reposition the cursor to the caption
case LFUN_FLEX_INSERT: {
code = FLEX_CODE;
string s = cmd.getArg(0);
- InsetLayout il = cur.buffer().params().textClass().insetlayout(from_utf8(s));
+ InsetLayout il = cur.buffer().params().textClass().insetLayout(from_utf8(s));
if (il.lyxtype() != "charstyle" &&
il.lyxtype() != "custom" &&
il.lyxtype() != "element" &&
min_toclevel_ = Layout::NOT_IN_TOC;
max_toclevel_ = Layout::NOT_IN_TOC;
- const_iterator cit = begin();
- const_iterator the_end = end();
- for ( ; cit != the_end ; ++cit) {
- int const toclevel = (*cit)->toclevel;
+ for (size_t i = 0; i != layoutCount(); ++i) {
+ int const toclevel = layout(i)->toclevel;
if (toclevel != Layout::NOT_IN_TOC) {
if (min_toclevel_ == Layout::NOT_IN_TOC)
min_toclevel_ = toclevel;
else
- min_toclevel_ = min(min_toclevel_,
- toclevel);
- max_toclevel_ = max(max_toclevel_,
- toclevel);
+ min_toclevel_ = min(min_toclevel_, toclevel);
+ max_toclevel_ = max(max_toclevel_, toclevel);
}
}
LYXERR(Debug::TCLASS, "Minimum TocLevel is " << min_toclevel_
// will invoke the layout object defined by name = 'CharStyle'.
// If that doesn't work either, an empty object returns (shouldn't
// happen). -- Idea JMarc, comment MV
-InsetLayout const & TextClass::insetlayout(docstring const & name) const
+InsetLayout const & TextClass::insetLayout(docstring const & name) const
{
docstring n = name;
while (!n.empty()) {
if (insetlayoutlist_.count(n) > 0)
return insetlayoutlist_[n];
- docstring::size_type i = n.find(':');
+ size_t i = n.find(':');
if (i == string::npos)
break;
n = n.substr(0,i);
public:
/// The individual styles comprising the document class
typedef std::vector<LayoutPtr> LayoutList;
- /// Enumerate the paragraph styles.
- typedef LayoutList::const_iterator const_iterator;
/// Construct a layout with default values. Actual values loaded later.
explicit
TextClass(std::string const & = std::string(),
/// check whether the TeX class is available
bool isTeXClassAvailable() const;
- /// paragraph styles begin iterator.
- const_iterator begin() const { return layoutlist_.begin(); }
- /// paragraph styles end iterator
- const_iterator end() const { return layoutlist_.end(); }
+ /// Enumerate the paragraph styles.
+ size_t layoutCount() const { return layoutlist_.size(); }
+ /// Access the paragraph styles.
+ LayoutPtr const & layout(size_t index) const { return layoutlist_[index]; }
- ///Enum used with TextClass::read
+ /// Enum used with TextClass::read
enum ReadType {
BASECLASS, //>This is a base class, i.e., top-level layout file
MERGE, //>This is a file included in a layout file
/// The Counters present in this document class.
Counters & counters() const;
/// Inset layouts of this doc class
- InsetLayouts & insetlayouts() const { return insetlayoutlist_; };
+ InsetLayouts & insetLayouts() const { return insetlayoutlist_; };
///
- InsetLayout const & insetlayout(docstring const & name) const;
+ InsetLayout const & insetLayout(docstring const & name) const;
///
docstring const & defaultLayoutName() const;
///
|| layout->labeltype == LABEL_BIBLIO
|| layout->labeltype == LABEL_CENTERED_TOP_ENVIRONMENT)
&& isFirstInSequence(pit, pars)
- && !par.getLabelstring().empty())
+ && !par.labelString().empty())
{
labeladdon = int(
labelfont_metrics.maxHeight()
l_margin += theFontMetrics(buffer.params().getFont()).signedWidth(
layout->leftmargin);
}
- if (!par.getLabelstring().empty()) {
+ if (!par.labelString().empty()) {
l_margin += labelfont_metrics.signedWidth(layout->labelindent);
- l_margin += labelfont_metrics.width(par.getLabelstring());
+ l_margin += labelfont_metrics.width(par.labelString());
l_margin += labelfont_metrics.width(layout->labelsep);
}
break;
LABEL_CENTERED_TOP_ENVIRONMENT) {
l_margin += labelfont_metrics.signedWidth(layout->labelindent);
l_margin += labelfont_metrics.width(layout->labelsep);
- l_margin += labelfont_metrics.width(par.getLabelstring());
+ l_margin += labelfont_metrics.width(par.labelString());
}
break;
break;
Paragraph const & par =
*static_cast<InsetOptArg&>(inset).paragraphs().begin();
- if (!toc_item->par_it_->getLabelstring().empty())
- tocstring = toc_item->par_it_->getLabelstring() + ' ';
+ if (!toc_item->par_it_->labelString().empty())
+ tocstring = toc_item->par_it_->labelString() + ' ';
tocstring += par.asString(*buffer_, false);
break;
}
break;
Paragraph const & par =
*static_cast<InsetOptArg&>(inset).paragraphs().begin();
- if (!pit->getLabelstring().empty())
- tocstring = pit->getLabelstring() + ' ';
+ if (!pit->labelString().empty())
+ tocstring = pit->labelString() + ' ';
tocstring += par.asString(*buffer_, false);
break;
}
this, SLOT(change_adaptor()));
connect(textLayoutModule->lspacingCO, SIGNAL(activated(int)),
this, SLOT(setLSpacing(int)));
- connect(textLayoutModule->lspacingLE, SIGNAL(textChanged(const QString&)),
+ connect(textLayoutModule->lspacingLE, SIGNAL(textChanged(const QString &)),
this, SLOT(change_adaptor()));
connect(textLayoutModule->skipRB, SIGNAL(clicked()),
this, SLOT(change_adaptor()));
int const toc = numberingModule->tocSL->value();
QString const no = qt_("No");
QString const yes = qt_("Yes");
- TextClass::const_iterator end = tclass.end();
- TextClass::const_iterator cit = tclass.begin();
QTreeWidgetItem * item = 0;
- for ( ; cit != end ; ++cit) {
- int const toclevel = (*cit)->toclevel;
- if (toclevel != Layout::NOT_IN_TOC
- && (*cit)->labeltype == LABEL_COUNTER) {
+ for (size_t i = 0; i != tclass.layoutCount(); ++i) {
+ Layout const & lt = *tclass.layout(i);
+ int const toclevel = lt.toclevel;
+ if (toclevel != Layout::NOT_IN_TOC && lt.labeltype == LABEL_COUNTER) {
item = new QTreeWidgetItem(numberingModule->tocTW);
- item->setText(0, toqstr(translateIfPossible((*cit)->name())));
+ item->setText(0, toqstr(translateIfPossible(lt.name())));
item->setText(1, (toclevel <= depth) ? yes : no);
item->setText(2, (toclevel <= toc) ? yes : no);
}
text_class_ = text_class;
clear();
- TextClass::const_iterator it = text_class_->begin();
- TextClass::const_iterator const end = text_class_->end();
- for (; it != end; ++it) {
- docstring const & name = (*it)->name();
+ for (size_t i = 0; i != text_class_->layoutCount(); ++i) {
+ Layout const & lt = *text_class_->layout(i);
+ docstring const & name = lt.name();
// if this inset requires the empty layout, we skip the default
// layout
if (name == text_class_->defaultLayoutName() && inset &&
return;
docstring const name = qstring_to_ucs4(str);
- TextClass::const_iterator it = text_class_->begin();
- TextClass::const_iterator const end = text_class_->end();
- for (; it != end; ++it) {
- docstring const & itname = (*it)->name();
- //FIXME Comparing translated strings is not ideal.
- //This should be done the way module names are handled
- //in GuiDocument: viz, the untranslated name should be
- //associated with the item via QComboBox::setItemData().
+ for (size_t i = 0; i != text_class_->layoutCount(); ++i) {
+ docstring const & itname = text_class_->layout(i)->name();
+ // FIXME: Comparing translated strings is not ideal.
+ // This should be done the way module names are handled
+ // in GuiDocument: viz, the untranslated name should be
+ // associated with the item via QComboBox::setItemData().
if (translateIfPossible(itname) == name) {
FuncRequest const func(LFUN_LAYOUT, itname,
FuncRequest::TOOLBAR);
InsetLayout const & Inset::getLayout(BufferParams const & bp) const
{
- return bp.textClass().insetlayout(name());
+ return bp.textClass().insetLayout(name());
}
: InsetCollapsable(bp), params_(label)
{
if (forceEmptyLayout())
- paragraphs().back().layout(bp.textClass().emptyLayout());
+ paragraphs().back().setLayout(bp.textClass().emptyLayout());
}
setFrameColor(Color_captionframe);
//FIXME Do we need to set all paragraphs here? or will there
//always only be one?
- paragraphs().back().layout(bp.textClass().emptyLayout());
+ paragraphs().back().setLayout(bp.textClass().emptyLayout());
}
setAutoBreakRows(true);
setDrawFrame(true);
setFrameColor(Color_collapsableframe);
- paragraphs().back().layout(bp.textClass().emptyLayout());
+ paragraphs().back().setLayout(bp.textClass().emptyLayout());
}
{
textClass_ = tcindex;
if (tcindex != TextClassIndex(-1)) {
- layout_ = &textclasslist[tcindex].insetlayout(name());
+ layout_ = &textclasslist[tcindex].insetLayout(name());
labelstring_ = layout_->labelstring();
} else {
layout_ = &TextClass::emptyInsetLayout();
rotate(false),
inset(new InsetText(bp))
{
- inset->paragraphs().back().layout(bp.textClass().emptyLayout());
+ inset->paragraphs().back().setLayout(bp.textClass().emptyLayout());
}
{
paragraphs().push_back(Paragraph());
Paragraph & ourpar = paragraphs().back();
- if (useEmptyLayout())
- ourpar.layout(bp.textClass().emptyLayout());
- else
- ourpar.layout(bp.textClass().defaultLayout());
+ ourpar.setEmptyOrDefaultLayout(bp.textClass());
ourpar.setInsetOwner(this);
}
pars.clear();
pars.push_back(Paragraph());
pars.begin()->setInsetOwner(this);
- pars.begin()->layout(old_layout);
+ pars.begin()->setLayout(old_layout);
}
// without doing that we get a crash when typing <Return> at the
// end of a paragraph
if (par.useEmptyLayout())
- tmp->layout(bparams.textClass().emptyLayout());
+ tmp->setLayout(bparams.textClass().emptyLayout());
else
- tmp->layout(bparams.textClass().defaultLayout());
+ tmp->setLayout(bparams.textClass().defaultLayout());
// layout stays the same with latex-environments
if (keep_layout) {
- tmp->layout(par.layout());
+ tmp->setLayout(par.layout());
tmp->setLabelWidthString(par.params().labelWidthString());
tmp->params().depth(par.params().depth());
} else if (par.params().depth() > 0) {
Paragraph const & hook = pars[outerHook(par_offset, pars)];
- tmp->layout(hook.layout());
+ tmp->setLayout(hook.layout());
// not sure the line below is useful
tmp->setLabelWidthString(par.params().labelWidthString());
tmp->params().depth(hook.params().depth());
bool const isempty = (par.allowEmpty() && par.empty());
if (!isempty && (par.size() > pos || par.empty())) {
- tmp->layout(par.layout());
+ tmp->setLayout(par.layout());
tmp->params().align(par.params().align());
tmp->setLabelWidthString(par.params().labelWidthString());
par.params().clear();
// do not lose start of appendix marker (bug 4212)
par.params().startOfAppendix(soa);
- par.layout(bparams.textClass().defaultLayout());
+ par.setLayout(bparams.textClass().defaultLayout());
}
// layout stays the same with latex-environments
if (keep_layout) {
- par.layout(tmp->layout());
+ par.setLayout(tmp->layout());
par.setLabelWidthString(tmp->params().labelWidthString());
par.params().depth(tmp->params().depth());
}
FontInfo const font = getLabelFont();
FontMetrics const & fm = theFontMetrics(font);
- docstring const str = par_.getLabelstring();
+ docstring const str = par_.labelString();
if (!str.empty()) {
double x = x_;
layout->labeltype == LABEL_BIBLIO ||
layout->labeltype == LABEL_CENTERED_TOP_ENVIRONMENT)) {
FontInfo const font = getLabelFont();
- if (!par_.getLabelstring().empty()) {
- docstring const str = par_.getLabelstring();
+ docstring const str = par_.labelString();
+ if (!str.empty()) {
double spacing_val = 1.0;
if (!parparams.spacing().isDefault())
spacing_val = parparams.spacing().getValue();