namespace {
-class LayoutNamesEqual : public unary_function<Layout, bool> {
-public:
- LayoutNamesEqual(docstring const & name)
- : name_(name)
- {}
- bool operator()(Layout const & c) const
- {
- return c.name() == name_;
- }
-private:
- docstring name_;
-};
-
-
bool layout2layout(FileName const & filename, FileName const & tempfile,
int const format = LAYOUT_FORMAT)
{
lexrc.eatLine();
vector<string> const req
= getVectorFromString(lexrc.getString());
- requires_.insert(req.begin(), req.end());
+ required_.insert(req.begin(), req.end());
break;
}
// If we do not succeed, then it was not there, which means that
// the textclass did not provide the definitions of the standard
// insets. So we need to try to load them.
- int erased = provides_.erase("stdinsets");
+ size_type const erased = provides_.erase("stdinsets");
if (!erased) {
FileName tmp = libFileSearch("layouts", "stdinsets.inc");
floatlist_.newFloat(fl);
// each float has its own counter
counters_.newCounter(from_ascii(type), from_ascii(within),
- docstring(), docstring());
+ docstring(), docstring(),
+ bformat(_("%1$s (Float)"), _(name)));
// also define sub-float counters
docstring const subtype = "sub-" + from_ascii(type);
counters_.newCounter(subtype, from_ascii(type),
- "\\alph{" + subtype + "}", docstring());
+ "\\alph{" + subtype + "}", docstring(),
+ bformat(_("Sub-%1$s (Float)"), _(name)));
}
return getout;
}
bool TextClass::hasLayout(docstring const & n) const
{
docstring const name = n.empty() ? defaultLayoutName() : n;
-
- return find_if(layoutlist_.begin(), layoutlist_.end(),
- LayoutNamesEqual(name))
- != layoutlist_.end();
+ return getLayout(name) != nullptr;
}
{
LATTEST(!name.empty());
- const_iterator it =
- find_if(begin(), end(), LayoutNamesEqual(name));
-
- if (it == end()) {
+ Layout const * c = getLayout(name);
+ if (!c) {
LYXERR0("We failed to find the layout '" << name
<< "' in the layout list. You MUST investigate!");
for (auto const & lay : *this)
LASSERT(false, return dummy);
}
- return *it;
+ return *c;
}
LATTEST(!name.empty());
// Safe to continue, given what we do below.
- iterator it = find_if(begin(), end(), LayoutNamesEqual(name));
-
- if (it == end()) {
+ Layout * c = getLayout(name);
+ if (!c) {
LYXERR0("We failed to find the layout '" << to_utf8(name)
<< "' in the layout list. You MUST investigate!");
for (auto const & lay : *this)
LATTEST(false);
// we are here only in release mode
layoutlist_.push_back(createBasicLayout(name, true));
- it = find_if(begin(), end(), LayoutNamesEqual(name));
+ c = getLayout(name);
}
- return *it;
+ return *c;
}
LayoutList::iterator it =
remove_if(layoutlist_.begin(), layoutlist_.end(),
- LayoutNamesEqual(name));
+ [name](const Layout &c) { return c.name() == name; });
- LayoutList::iterator end = layoutlist_.end();
+ LayoutList::iterator const end = layoutlist_.end();
bool const ret = (it != end);
layoutlist_.erase(it, end);
return ret;
}
+Layout const * TextClass::getLayout(docstring const & name) const
+{
+ LayoutList::const_iterator cit =
+ find_if(begin(), end(),
+ [name](const Layout &c) { return c.name() == name; });
+ if (cit == layoutlist_.end())
+ return nullptr;
+
+ return &(*cit);
+}
+
+
+Layout * TextClass::getLayout(docstring const & name)
+{
+ LayoutList::iterator it =
+ find_if(layoutlist_.begin(), layoutlist_.end(),
+ [name](const Layout &c) { return c.name() == name; });
+ if (it == layoutlist_.end())
+ return nullptr;
+
+ return &(*it);
+}
+
+
bool DocumentClass::addLayoutIfNeeded(docstring const & n) const
{
if (hasLayout(n))