mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 10:00:33 +00:00
Introduce Layout::args() and simplify code
This commit is contained in:
parent
8db4faa160
commit
bec9c1325e
@ -950,6 +950,15 @@ void Layout::readArgument(Lexer & lex)
|
||||
}
|
||||
|
||||
|
||||
Layout::LaTeXArgMap Layout::args() const
|
||||
{
|
||||
LaTeXArgMap args = latexargs_;
|
||||
if (!itemargs_.empty())
|
||||
args.insert(itemargs_.begin(), itemargs_.end());
|
||||
return args;
|
||||
}
|
||||
|
||||
|
||||
int Layout::optArgs() const
|
||||
{
|
||||
int nr = 0;
|
||||
|
@ -105,6 +105,8 @@ public:
|
||||
///
|
||||
typedef std::map<std::string, latexarg> LaTeXArgMap;
|
||||
///
|
||||
LaTeXArgMap args() const;
|
||||
///
|
||||
LaTeXArgMap const & latexargs() const { return latexargs_; }
|
||||
///
|
||||
LaTeXArgMap const & itemargs() const { return itemargs_; }
|
||||
|
@ -1374,10 +1374,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
|
||||
if (change_layout)
|
||||
setLayout(cur, layout);
|
||||
|
||||
Layout::LaTeXArgMap args = tclass[layout].latexargs();
|
||||
Layout::LaTeXArgMap itemargs = tclass[layout].itemargs();
|
||||
if (!itemargs.empty())
|
||||
args.insert(itemargs.begin(), itemargs.end());
|
||||
Layout::LaTeXArgMap args = tclass[layout].args();
|
||||
Layout::LaTeXArgMap::const_iterator lait = args.begin();
|
||||
Layout::LaTeXArgMap::const_iterator const laend = args.end();
|
||||
for (; lait != laend; ++lait) {
|
||||
@ -2571,10 +2568,7 @@ bool Text::getStatus(Cursor & cur, FuncRequest const & cmd,
|
||||
break;
|
||||
}
|
||||
Layout const & lay = cur.paragraph().layout();
|
||||
Layout::LaTeXArgMap args = lay.latexargs();
|
||||
Layout::LaTeXArgMap itemargs = lay.itemargs();
|
||||
if (!itemargs.empty())
|
||||
args.insert(itemargs.begin(), itemargs.end());
|
||||
Layout::LaTeXArgMap args = lay.args();
|
||||
Layout::LaTeXArgMap::const_iterator const lait =
|
||||
args.find(arg);
|
||||
if (lait != args.end()) {
|
||||
|
@ -1554,16 +1554,9 @@ void MenuDefinition::expandArguments(BufferView const * bv, bool switcharg)
|
||||
return;
|
||||
|
||||
Inset const * inset = &bv->cursor().inset();
|
||||
Layout::LaTeXArgMap args;
|
||||
if (inset && bv->cursor().paragraph().layout().latexargs().empty()
|
||||
&& bv->cursor().paragraph().layout().itemargs().empty())
|
||||
Layout::LaTeXArgMap args = bv->cursor().paragraph().layout().args();
|
||||
if (inset && args.empty())
|
||||
args = inset->getLayout().latexargs();
|
||||
else {
|
||||
args = bv->cursor().paragraph().layout().latexargs();
|
||||
Layout::LaTeXArgMap itemargs = bv->cursor().paragraph().layout().itemargs();
|
||||
if (!itemargs.empty())
|
||||
args.insert(itemargs.begin(), itemargs.end());
|
||||
}
|
||||
if (args.empty() || (switcharg && args.size() == 1))
|
||||
return;
|
||||
Layout::LaTeXArgMap::const_iterator lait = args.begin();
|
||||
|
@ -57,18 +57,12 @@ void InsetArgument::read(Lexer & lex)
|
||||
|
||||
void InsetArgument::updateBuffer(ParIterator const & it, UpdateType utype)
|
||||
{
|
||||
Layout::LaTeXArgMap args;
|
||||
bool const insetlayout = &it.inset() && it.paragraph().layout().latexargs().empty()
|
||||
&& it.paragraph().layout().itemargs().empty();
|
||||
Layout::LaTeXArgMap args = it.paragraph().layout().args();
|
||||
pass_thru_ = it.paragraph().layout().pass_thru;
|
||||
bool const insetlayout = &it.inset() && args.empty();
|
||||
if (insetlayout) {
|
||||
args = it.inset().getLayout().latexargs();
|
||||
pass_thru_ = it.inset().getLayout().isPassThru();
|
||||
} else {
|
||||
args = it.paragraph().layout().latexargs();
|
||||
Layout::LaTeXArgMap itemargs = it.paragraph().layout().itemargs();
|
||||
if (!itemargs.empty())
|
||||
args.insert(itemargs.begin(), itemargs.end());
|
||||
pass_thru_ = it.paragraph().layout().pass_thru;
|
||||
}
|
||||
|
||||
// Handle pre 2.1 ArgInsets (lyx2lyx cannot classify them)
|
||||
|
@ -338,8 +338,7 @@ bool InsetText::getStatus(Cursor & cur, FuncRequest const & cmd,
|
||||
status.setEnabled(false);
|
||||
return true;
|
||||
}
|
||||
if (&buffer().inset() == this || !cur.paragraph().layout().latexargs().empty()
|
||||
|| !cur.paragraph().layout().itemargs().empty())
|
||||
if (&buffer().inset() == this || !cur.paragraph().layout().args().empty())
|
||||
return text_.getStatus(cur, cmd, status);
|
||||
|
||||
Layout::LaTeXArgMap args = getLayout().latexargs();
|
||||
|
Loading…
Reference in New Issue
Block a user