mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 18:08:10 +00:00
Simplify before clean-up before following bugfix
This commit is contained in:
parent
c76cbead59
commit
1ac48c7cba
@ -2841,19 +2841,13 @@ bool Text::getStatus(Cursor & cur, FuncRequest const & cmd,
|
||||
for (; pit <= lastpit; ++pit) {
|
||||
if (pars_[pit].layout() != lay)
|
||||
break;
|
||||
InsetList::const_iterator it = pars_[pit].insetList().begin();
|
||||
InsetList::const_iterator end = pars_[pit].insetList().end();
|
||||
for (; it != end; ++it) {
|
||||
if (it->inset->lyxCode() == ARG_CODE) {
|
||||
InsetArgument const * ins =
|
||||
static_cast<InsetArgument const *>(it->inset);
|
||||
for (auto const & table : pars_[pit].insetList())
|
||||
if (InsetArgument const * ins = table.inset->asInsetArgument())
|
||||
if (ins->name() == arg) {
|
||||
// we have this already
|
||||
enable = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else
|
||||
enable = false;
|
||||
|
@ -22,7 +22,7 @@
|
||||
#include "Paragraph.h"
|
||||
#include "TextClass.h"
|
||||
|
||||
#include "insets/InsetText.h"
|
||||
#include "insets/InsetArgument.h"
|
||||
|
||||
#include "support/debug.h"
|
||||
#include "support/docstream.h"
|
||||
@ -181,18 +181,14 @@ bool TocBackend::updateItem(DocIterator const & dit_in)
|
||||
// FIXME: This is supposed to accomplish the same as the body of
|
||||
// InsetText::iterateForToc(), probably
|
||||
Paragraph & par = toc_item->dit().paragraph();
|
||||
InsetList::const_iterator it = par.insetList().begin();
|
||||
InsetList::const_iterator end = par.insetList().end();
|
||||
for (; it != end; ++it) {
|
||||
Inset & inset = *it->inset;
|
||||
if (inset.lyxCode() == ARG_CODE) {
|
||||
for (auto const & table : par.insetList())
|
||||
if (InsetArgument const * arg = table.inset->asInsetArgument()) {
|
||||
tocstring = par.labelString();
|
||||
if (!tocstring.empty())
|
||||
tocstring += ' ';
|
||||
inset.asInsetText()->text().forOutliner(tocstring,TOC_ENTRY_LENGTH);
|
||||
arg->text().forOutliner(tocstring,TOC_ENTRY_LENGTH);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int const toclevel = toc_item->dit().text()->
|
||||
getTocLevel(toc_item->dit().pit());
|
||||
|
@ -40,6 +40,7 @@ class Dimension;
|
||||
class DocIterator;
|
||||
class FuncRequest;
|
||||
class FuncStatus;
|
||||
class InsetArgument;
|
||||
class InsetCollapsable;
|
||||
class InsetCommand;
|
||||
class InsetIterator;
|
||||
@ -154,6 +155,8 @@ public:
|
||||
virtual InsetCommand * asInsetCommand() { return 0; }
|
||||
/// is this inset based on the InsetCommand class?
|
||||
virtual InsetCommand const * asInsetCommand() const { return 0; }
|
||||
/// is this inset based on the InsetArgument class?
|
||||
virtual InsetArgument const * asInsetArgument() const { return nullptr; }
|
||||
|
||||
/// the real dispatcher
|
||||
void dispatch(Cursor & cur, FuncRequest & cmd);
|
||||
|
@ -225,19 +225,13 @@ bool InsetArgument::getStatus(Cursor & cur, FuncRequest const & cmd,
|
||||
Layout::LaTeXArgMap::const_iterator const lait = args.find(type);
|
||||
if (lait != args.end()) {
|
||||
flag.setEnabled(true);
|
||||
InsetList::const_iterator it = cur.paragraph().insetList().begin();
|
||||
InsetList::const_iterator end = cur.paragraph().insetList().end();
|
||||
for (; it != end; ++it) {
|
||||
if (it->inset->lyxCode() == ARG_CODE) {
|
||||
InsetArgument const * ins =
|
||||
static_cast<InsetArgument const *>(it->inset);
|
||||
for (auto const & table : cur.paragraph().insetList())
|
||||
if (InsetArgument const * ins = table.inset->asInsetArgument())
|
||||
if (ins->name() == type) {
|
||||
// we have this already
|
||||
flag.setEnabled(false);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else
|
||||
flag.setEnabled(false);
|
||||
return true;
|
||||
|
@ -29,6 +29,9 @@ public:
|
||||
///
|
||||
InsetArgument(Buffer *, std::string const &);
|
||||
|
||||
///
|
||||
InsetArgument const * asInsetArgument() const { return this; }
|
||||
|
||||
/// Outputting the parameter of a LaTeX command
|
||||
void latexArgument(otexstream & os, OutputParams const & runparams_in,
|
||||
docstring const & ldelim, docstring const & rdelim,
|
||||
|
@ -371,22 +371,14 @@ bool InsetText::getStatus(Cursor & cur, FuncRequest const & cmd,
|
||||
Layout::LaTeXArgMap::const_iterator const lait = args.find(arg);
|
||||
if (lait != args.end()) {
|
||||
status.setEnabled(true);
|
||||
ParagraphList::const_iterator pit = paragraphs().begin();
|
||||
for (; pit != paragraphs().end(); ++pit) {
|
||||
InsetList::const_iterator it = pit->insetList().begin();
|
||||
InsetList::const_iterator end = pit->insetList().end();
|
||||
for (; it != end; ++it) {
|
||||
if (it->inset->lyxCode() == ARG_CODE) {
|
||||
InsetArgument const * ins =
|
||||
static_cast<InsetArgument const *>(it->inset);
|
||||
for (Paragraph const & par : paragraphs())
|
||||
for (auto const & table : par.insetList())
|
||||
if (InsetArgument const * ins = table.inset->asInsetArgument())
|
||||
if (ins->name() == arg) {
|
||||
// we have this already
|
||||
status.setEnabled(false);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else
|
||||
status.setEnabled(false);
|
||||
return true;
|
||||
@ -876,16 +868,12 @@ void InsetText::iterateForToc(DocIterator const & cdit, bool output_active,
|
||||
}
|
||||
|
||||
// if we find an optarg, we'll save it for use later.
|
||||
InsetText const * arginset = 0;
|
||||
InsetList::const_iterator it = par.insetList().begin();
|
||||
InsetList::const_iterator end = par.insetList().end();
|
||||
for (; it != end; ++it) {
|
||||
Inset & inset = *it->inset;
|
||||
dit.pos() = it->pos;
|
||||
//lyxerr << (void*)&inset << " code: " << inset.lyxCode() << std::endl;
|
||||
inset.addToToc(dit, doing_output, utype, backend);
|
||||
if (inset.lyxCode() == ARG_CODE)
|
||||
arginset = inset.asInsetText();
|
||||
InsetArgument const * arginset = nullptr;
|
||||
for (auto const & table : par.insetList()) {
|
||||
dit.pos() = table.pos;
|
||||
table.inset->addToToc(dit, doing_output, utype, backend);
|
||||
if (InsetArgument const * x = table.inset->asInsetArgument())
|
||||
arginset = x;
|
||||
}
|
||||
|
||||
// End custom AddToToc in paragraph layouts
|
||||
|
@ -534,9 +534,7 @@ void latexArgInsets(Paragraph const & par, otexstream & os,
|
||||
InsetList::const_iterator it = par.insetList().begin();
|
||||
InsetList::const_iterator end = par.insetList().end();
|
||||
for (; it != end; ++it) {
|
||||
if (it->inset->lyxCode() == ARG_CODE) {
|
||||
InsetArgument const * ins =
|
||||
static_cast<InsetArgument const *>(it->inset);
|
||||
if (InsetArgument const * ins = it->inset->asInsetArgument()) {
|
||||
if (ins->name().empty())
|
||||
LYXERR0("Error: Unnamed argument inset!");
|
||||
else {
|
||||
@ -618,6 +616,7 @@ void latexArgInsets(ParagraphList const & pars, ParagraphList::const_iterator pi
|
||||
getArgInsets(os, runparams, latexargs, ilist, required, prefix);
|
||||
}
|
||||
|
||||
|
||||
namespace {
|
||||
|
||||
// output the proper paragraph start according to latextype.
|
||||
|
Loading…
Reference in New Issue
Block a user