Some minor cleanup of new InsetArguments stuff that I did while

reading the patch....
This commit is contained in:
Richard Heck 2012-11-23 20:40:38 -05:00
parent 37d614636b
commit 1252c22fd3
7 changed files with 18 additions and 18 deletions

View File

@ -1461,7 +1461,7 @@ void Paragraph::Private::validate(LaTeXFeatures & features) const
// we have to provide all the optional arguments here, even though
// the last one is the only one we care about.
// Separate handling of optional argument inset.
if (layout_->latexargs().size() != 0)
if (!layout_->latexargs().empty())
latexArgInsets(*owner_, os, features.runparams(),
layout_->latexargs());
else

View File

@ -2531,7 +2531,7 @@ bool Text::getStatus(Cursor & cur, FuncRequest const & cmd,
if (lait != args.end()) {
enable = true;
InsetList::const_iterator it = cur.paragraph().insetList().begin();
InsetList::const_iterator end = cur.paragraph().insetList().end();
InsetList::const_iterator const end = cur.paragraph().insetList().end();
for (; it != end; ++it) {
if (it->inset->lyxCode() == ARG_CODE) {
InsetArgument const * ins =

View File

@ -59,12 +59,12 @@ void InsetArgument::updateBuffer(ParIterator const & it, UpdateType utype)
// Handle pre 2.1 ArgInsets (lyx2lyx cannot classify them)
if (name_ == "999") {
int req = insetlayout ? it.inset().getLayout().requiredArgs()
unsigned int const req = insetlayout ? it.inset().getLayout().numRequiredArgs()
: it.paragraph().layout().requiredArgs();
int opts = insetlayout ? it.inset().getLayout().optArgs()
unsigned int const opts = insetlayout ? it.inset().getLayout().numOptArgs()
: it.paragraph().layout().optArgs();
int nr = 0;
int ours = 0;
unsigned int nr = 0;
unsigned int ours = 0;
InsetList::const_iterator parit = it.paragraph().insetList().begin();
InsetList::const_iterator parend = it.paragraph().insetList().end();
for (; parit != parend; ++parit) {
@ -75,7 +75,7 @@ void InsetArgument::updateBuffer(ParIterator const & it, UpdateType utype)
}
}
bool done = false;
int realopts = 0;
unsigned int realopts = 0;
if (nr > req) {
// We have optional arguments
realopts = nr - req;

View File

@ -525,9 +525,9 @@ void InsetLayout::readArgument(Lexer & lex)
latexargs_[nr] = arg;
}
int InsetLayout::optArgs() const
unsigned int InsetLayout::numOptArgs() const
{
int nr = 0;
unsigned int nr = 0;
Layout::LaTeXArgMap::const_iterator it = latexargs_.begin();
for (; it != latexargs_.end(); ++it) {
if (!(*it).second.mandatory)
@ -537,9 +537,9 @@ int InsetLayout::optArgs() const
}
int InsetLayout::requiredArgs() const
unsigned int InsetLayout::numRequiredArgs() const
{
int nr = 0;
unsigned int nr = 0;
Layout::LaTeXArgMap::const_iterator it = latexargs_.begin();
for (; it != latexargs_.end(); ++it) {
if ((*it).second.mandatory)

View File

@ -84,9 +84,9 @@ public:
///
Layout::LaTeXArgMap latexargs() const { return latexargs_; }
///
int optArgs() const;
unsigned int numOptArgs() const;
///
int requiredArgs() const;
unsigned int numRequiredArgs() const;
///
docstring preamble() const { return preamble_; }
/// Get language dependent macro definitions needed for this inset

View File

@ -162,7 +162,7 @@ static TeXEnvironmentData prepareEnvironment(Buffer const & buf,
if (style.isEnvironment()) {
os << "\\begin{" << from_ascii(style.latexname()) << '}';
if (style.latexargs().size() != 0)
if (!style.latexargs().empty())
latexArgInsets(*pit, os, runparams, style.latexargs());
if (style.latextype == LATEX_LIST_ENVIRONMENT) {
os << '{'
@ -313,7 +313,7 @@ void TeXEnvironment(Buffer const & buf, Text const & text,
void latexArgInsets(Paragraph const & par, otexstream & os,
OutputParams const & runparams, Layout::LaTeXArgMap latexargs)
OutputParams const & runparams, Layout::LaTeXArgMap const & latexargs)
{
map<int, InsetArgument const *> ilist;
vector<string> required;
@ -332,7 +332,7 @@ void latexArgInsets(Paragraph const & par, otexstream & os,
Layout::LaTeXArgMap::const_iterator const lit =
latexargs.find(nr);
if (lit != latexargs.end()) {
Layout::latexarg arg = (*lit).second;
Layout::latexarg const & arg = (*lit).second;
if (!arg.requires.empty()) {
vector<string> req = getVectorFromString(arg.requires);
required.insert(required.end(), req.begin(), req.end());
@ -407,7 +407,7 @@ void parStartCommand(Paragraph const & par, otexstream & os,
os << '\\' << from_ascii(style.latexname());
// Separate handling of optional argument inset.
if (style.latexargs().size() != 0)
if (!style.latexargs().empty())
latexArgInsets(par, os, runparams, style.latexargs());
else
os << from_ascii(style.latexparam());

View File

@ -38,7 +38,7 @@ class Text;
/// must all come first.
void latexArgInsets(Paragraph const & par,
otexstream & os, OutputParams const & runparams,
Layout::LaTeXArgMap latexargs);
Layout::LaTeXArgMap const & latexargs);
/** Export \p paragraphs of buffer \p buf to LaTeX.
Don't use a temporary stringstream for \p os if the final output is