#include "encoding.h"
#include "language.h"
#include "lyxrc.h"
+#include "outputparams.h"
#include "paragraph.h"
#include "paragraph_funcs.h"
#include "ParagraphParameters.h"
#include "texrow.h"
#include "vspace.h"
+#include "insets/insetbibitem.h"
#include "insets/insetoptarg.h"
#include "support/lstrings.h"
-#ifdef HAVE_LOCALE
-#endif
-
using lyx::support::subst;
using std::endl;
using std::ostream;
using std::string;
-extern string bibitemWidest(Buffer const &);
-
namespace {
os, texrow, runparams);
}
}
- lyxerr[Debug::LATEX] << "TeXDeeper...done " << &*par << endl;
+ lyxerr[Debug::LATEX] << "TeXDeeper...done " << endl;
return par;
}
texrow.newline();
}
- lyxerr[Debug::LATEX] << "TeXEnvironment...done " << &*par << endl;
- return par; // ale970302
+ if (par != paragraphs.end() && lyxerr.debugging(Debug::LATEX))
+ lyxerr << "TeXEnvironment...done " << &*par << endl;
+ return par;
}
-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 << " '"
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 =
if (bparams.inputenc == "auto" &&
language->encoding() != previous_language->encoding()) {
os << "\\inputencoding{"
- << language->encoding()->LatexName()
+ << language->encoding()->latexName()
<< "}\n";
texrow.newline();
}
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();
os << everypar;
bool need_par = pit->simpleTeXOnePar(buf, bparams,
- outerFont(pit - paragraphs.begin(), paragraphs),
+ outerFont(std::distance(paragraphs.begin(), pit), paragraphs),
os, texrow, runparams);
// Make sure that \\par is done with the font of the last
// We do not need to use to change the font for the last paragraph
// or for a command.
LyXFont const outerfont =
- outerFont(pit - paragraphs.begin(),
-paragraphs);
+ outerFont(std::distance(paragraphs.begin(), pit),
+ paragraphs);
LyXFont const font =
(pit->empty()
}
}
- if (boost::next(pit) == const_cast<ParagraphList&>(paragraphs).end()
+ if (boost::next(pit) == paragraphs.end()
&& language->babel() != doc_language->babel()) {
// Since \selectlanguage write the language to the aux file,
// we need to reset the language at the end of footnote or
texrow.newline();
}
- lyxerr[Debug::LATEX] << "TeXOnePar...done " << &*boost::next(pit) << endl;
+ if (boost::next(pit) != paragraphs.end() &&
+ lyxerr.debugging(Debug::LATEX))
+ lyxerr << "TeXOnePar...done " << &*boost::next(pit) << endl;
return ++pit;
}
ParagraphList::const_iterator par = paragraphs.begin();
ParagraphList::const_iterator endpar = paragraphs.end();
+ BOOST_ASSERT(runparams.par_begin <= runparams.par_end);
+ // if only part of the paragraphs will be outputed
+ if (runparams.par_begin != runparams.par_end) {
+ par = boost::next(paragraphs.begin(), runparams.par_begin);
+ endpar = boost::next(paragraphs.begin(), runparams.par_end);
+ // runparams will be passed to nested paragraphs, so
+ // we have to reset the range parameters.
+ const_cast<OutputParams&>(runparams).par_begin = 0;
+ const_cast<OutputParams&>(runparams).par_end = 0;
+ }
+
// if only_body
while (par != endpar) {
+ ParagraphList::const_iterator lastpar = par;
// well we have to check if we are in an inset with unlimited
// length (all in one row) if that is true then we don't allow
// any special options in the paragraph and also we don't allow
if (layout->is_environment) {
par = TeXOnePar(buf, paragraphs, par, os, texrow,
- runparams, everypar);
+ runparams, everypar);
} else if (layout->isEnvironment() ||
!par->params().leftIndent().zero())
{
texrow, runparams);
} else {
par = TeXOnePar(buf, paragraphs, par, os, texrow,
- runparams, everypar);
+ runparams, everypar);
}
} else {
par = TeXOnePar(buf, paragraphs, par, os, texrow,
- runparams, everypar);
+ runparams, everypar);
}
+ if (std::distance(lastpar, par) >= std::distance(lastpar, endpar))
+ break;
}
// It might be that we only have a title in this document
if (was_title && !already_title) {