#include "insets/insetinclude.h"
#include "insets/insetbib.h"
#include "insets/insettext.h"
+#include "insets/insetoptarg.h"
#include "support/filetools.h"
#include "support/lstrings.h"
void Paragraph::write(Buffer const * buf, ostream & os,
BufferParams const & bparams,
- depth_type dth) const
+ depth_type & dth) const
{
// The beginning or end of a deeper (i.e. nested) area?
if (dth != params().depth()) {
return -1;
}
+namespace {
+
+InsetOptArg * optArgInset(Paragraph const & par)
+{
+ // Find the entry.
+ InsetList::iterator it = par.insetlist.begin();
+ InsetList::iterator end = par.insetlist.end();
+ for (; it != end; ++it) {
+ Inset * ins = it.getInset();
+ if (ins->lyxCode() == Inset::OPTARG_CODE) {
+ return static_cast<InsetOptArg *>(ins);
+ }
+ }
+ return 0;
+}
+
+} // end namespace
Paragraph * Paragraph::TeXOnePar(Buffer const * buf,
BufferParams const & bparams,
switch (style->latextype) {
case LATEX_COMMAND:
os << '\\'
- << style->latexname()
- << style->latexparam();
+ << style->latexname();
+
+ // Separate handling of optional argument inset.
+ if (style->optionalargs == 1) {
+ InsetOptArg * it = optArgInset(*this);
+ if (it != 0)
+ it->latexOptional(buf, os, false, false);
+ }
+ else
+ os << style->latexparam();
break;
case LATEX_ITEM_ENVIRONMENT:
if (bibkey) {