#include "encoding.h"
#include "language.h"
#include "lyxrc.h"
+#include "outputparams.h"
#include "paragraph.h"
#include "paragraph_funcs.h"
#include "ParagraphParameters.h"
}
-InsetOptArg * optArgInset(Paragraph const & par)
+int latexOptArgInsets(Buffer const & buf, Paragraph const & par,
+ ostream & os, OutputParams const & runparams, int number)
{
- // Find the entry.
+ int lines = 0;
+
InsetList::const_iterator it = par.insetlist.begin();
InsetList::const_iterator end = par.insetlist.end();
- for (; it != end; ++it) {
- InsetBase * ins = it->inset;
- if (ins->lyxCode() == InsetBase::OPTARG_CODE) {
- return static_cast<InsetOptArg *>(ins);
+ for (; it != end && number > 0 ; ++it) {
+ if (it->inset->lyxCode() == InsetBase::OPTARG_CODE) {
+ InsetOptArg * ins =
+ static_cast<InsetOptArg *>(it->inset);
+ lines += ins->latexOptional(buf, os, runparams);
+ --number;
}
}
- return 0;
+ return lines;
}
ParagraphList const & paragraphs,
ParagraphList::const_iterator pit,
ostream & os, TexRow & texrow,
- OutputParams const & runparams,
+ OutputParams const & runparams_in,
string const & everypar)
{
lyxerr[Debug::LATEX] << "TeXOnePar... " << &*pit << " '"
// In an an inset with unlimited length (all in one row),
// force layout to default
- if (!pit->forceDefaultParagraphs())
+ if (!pit->forceDefaultParagraphs())
style = pit->layout();
else
style = bparams.getLyXTextClass().defaultLayout();
+ OutputParams runparams = runparams_in;
+ runparams.moving_arg |= style->needprotect;
+
Language const * language = pit->getParLanguage(bparams);
Language const * doc_language = bparams.language;
Language const * previous_language =
os << '\n';
texrow.newline();
}
- }
+ }
switch (style->latextype) {
case LATEX_COMMAND:
os << '\\' << style->latexname();
// Separate handling of optional argument inset.
- if (style->optionalargs == 1) {
- InsetOptArg * it = optArgInset(*pit);
- if (it)
- it->latexOptional(buf, os, runparams);
+ if (style->optionalargs > 0) {
+ int ret = latexOptArgInsets(buf, *pit, os, runparams,
+ style->optionalargs);
+ while (ret > 0) {
+ texrow.newline();
+ --ret;
+ }
}
else
os << style->latexparam();