X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Finsets%2FInsetArgument.cpp;h=c4708c8d42f468be0222d07bd0249cc86942315f;hb=HEAD;hp=8382d9542f082e93407a48428b1a3fe7bec95279;hpb=ecf62a8f21e457936ed285d4fbcbed7348bb636b;p=lyx.git diff --git a/src/insets/InsetArgument.cpp b/src/insets/InsetArgument.cpp index 8382d9542f..c4708c8d42 100644 --- a/src/insets/InsetArgument.cpp +++ b/src/insets/InsetArgument.cpp @@ -18,10 +18,10 @@ #include "Cursor.h" #include "FuncStatus.h" #include "FuncRequest.h" +#include "InsetLayout.h" #include "InsetList.h" #include "Language.h" #include "Layout.h" -#include "Lexer.h" #include "ParIterator.h" #include "TexRow.h" #include "texstream.h" @@ -32,12 +32,14 @@ #include "support/debug.h" #include "support/docstream.h" #include "support/gettext.h" +#include "support/Lexer.h" #include "support/lstrings.h" using namespace std; namespace lyx { +using support::Lexer; InsetArgument::InsetArgument(Buffer * buf, string const & name) : InsetCollapsible(buf), name_(name), labelstring_(docstring()), @@ -62,31 +64,30 @@ void InsetArgument::read(Lexer & lex) } -void InsetArgument::updateBuffer(ParIterator const & it, UpdateType utype, bool const deleted) +void InsetArgument::init(Paragraph const & par) { - bool const insetlayout = !it.paragraph().layout().hasArgs(); + Inset const & ininset = par.inInset(); + bool const insetlayout = !par.layout().hasArgs(); Layout::LaTeXArgMap const args = insetlayout ? - it.inset().getLayout().args() : it.paragraph().layout().args(); + ininset.getLayout().args() : par.layout().args(); pass_thru_context_ = insetlayout ? - it.inset().getLayout().isPassThru() : it.paragraph().layout().pass_thru; + ininset.getLayout().isPassThru() : par.layout().pass_thru; // Record PassThru status in order to act on changes. bool const former_pass_thru = pass_thru_; // Handle pre 2.1 ArgInsets (lyx2lyx cannot classify them) // "999" is the conventional name given to those by lyx2lyx if (name_ == "999") { - int const req = insetlayout ? it.inset().getLayout().requiredArgs() - : it.paragraph().layout().requiredArgs(); - int const opts = insetlayout ? it.inset().getLayout().optArgs() - : it.paragraph().layout().optArgs(); + int const req = insetlayout ? ininset.getLayout().requiredArgs() + : par.layout().requiredArgs(); + int const opts = insetlayout ? ininset.getLayout().optArgs() + : par.layout().optArgs(); int nr = 0; int ours = 0; - InsetList::const_iterator parit = it.paragraph().insetList().begin(); - InsetList::const_iterator parend = it.paragraph().insetList().end(); - for (; parit != parend; ++parit) { - if (parit->inset->lyxCode() == ARG_CODE) { + for (InsetList::Element const & elt : par.insetList()) { + if (elt.inset->lyxCode() == ARG_CODE) { ++nr; - if (parit->inset == this) + if (elt.inset == this) ours = nr; } } @@ -126,13 +127,14 @@ void InsetArgument::updateBuffer(ParIterator const & it, UpdateType utype, bool docbooktagtype_ = (*lait).second.docbooktagtype; docbookattr_ = (*lait).second.docbookattr; docbookargumentbeforemaintag_ = (*lait).second.docbookargumentbeforemaintag; + docbookargumentaftermaintag_ = (*lait).second.docbookargumentaftermaintag; pass_thru_local_ = false; if (lait->second.is_toc_caption) { is_toc_caption_ = true; // empty if AddToToc is not set caption_of_toc_ = insetlayout - ? it.inset().getLayout().tocType() - : it.paragraph().layout().tocType(); + ? ininset.getLayout().tocType() + : par.layout().tocType(); } switch ((*lait).second.passthru) { @@ -155,13 +157,19 @@ void InsetArgument::updateBuffer(ParIterator const & it, UpdateType utype, bool if (former_pass_thru != pass_thru_) { // PassThru status changed. We might need to update // the language of the contents - Language const * l = insetlayout - ? it.inset().buffer().language() - : it.buffer()->language(); + // Language const * l = insetlayout + // ? it.inset().buffer().language() + // : it.buffer()->language(); + Language const * l = ininset.buffer().language(); fixParagraphLanguage(l); } setButtonLabel(); +} + +void InsetArgument::updateBuffer(ParIterator const & it, UpdateType utype, bool const deleted) +{ + init(it.paragraph()); InsetCollapsible::updateBuffer(it, utype, deleted); } @@ -272,7 +280,7 @@ bool InsetArgument::getStatus(Cursor & cur, FuncRequest const & cmd, string InsetArgument::contextMenuName() const { - if (decoration() == InsetLayout::CONGLOMERATE) + if (decoration() == InsetDecoration::CONGLOMERATE) return "context-argument-conglomerate"; else return "context-argument"; @@ -302,19 +310,21 @@ ColorCode InsetArgument::labelColor() const { } -InsetLayout::InsetDecoration InsetArgument::decoration() const +InsetDecoration InsetArgument::decoration() const { - InsetLayout::InsetDecoration dec = getLayout().decoration(); + InsetDecoration dec = getLayout().decoration(); if (!decoration_.empty()) dec = translateDecoration(decoration_); - return dec == InsetLayout::DEFAULT ? InsetLayout::CLASSIC : dec; + return dec == InsetDecoration::DEFAULT ? InsetDecoration::CLASSIC : dec; } void InsetArgument::docbook(XMLStream & xs, OutputParams const & rp) const { - // Ignore arguments that have already been output. + // Ignore arguments that have already been output or are planned to be output elsewhere. if (rp.docbook_prepended_arguments.find(this) != rp.docbook_prepended_arguments.end()) return; + if (rp.docbook_appended_arguments.find(this) != rp.docbook_appended_arguments.end()) + return; if (docbooktag_ != from_ascii("NONE") && docbooktag_ != from_ascii("IGNORE")) { // TODO: implement docbooktagtype_. @@ -347,7 +357,7 @@ void InsetArgument::latexArgument(otexstream & os, os << presetarg; if (!presetarg.empty() && !ts.str.empty()) os << ", "; - os << move(ts); + os << std::move(ts); if (add_braces) os << '}'; os << rdelim;