#include "ParameterStruct.h"
#include "gettext.h"
-#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()) {
// Write font changes
LyXFont font2 = getFontSettings(bparams, i);
if (font2 != font1) {
-#ifndef INHERIT_LANGUAGE
font2.lyxWriteChanges(font1, os);
-#else
- font2.lyxWriteChanges(font1, bparams.language, os);
-#endif
column = 0;
font1 = font2;
}
retfont = getFontSettings(bparams, pos - 1);
} else
retfont = LyXFont(LyXFont::ALL_INHERIT, getParLanguage(bparams));
-#ifdef INHERIT_LANGUAGE
- if (retfont.language() == inherit_language)
- retfont.setLanguage(bparams.language);
-#endif
return retfont;
}
layoutfont = lout->font;
LyXFont tmpfont = getFontSettings(bparams, pos);
-#ifndef INHERIT_LANGUAGE
tmpfont.realize(layoutfont);
-#else
- tmpfont.realize(layoutfont, bparams.language);
-#endif
return pimpl_->realizeFont(tmpfont, bparams);
}
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) {
Paragraph::getParLanguage(BufferParams const & bparams) const
{
if (!empty()) {
-#ifndef INHERIT_LANGUAGE
return getFirstFontSettings().language();
-#else
- Language const * lang = getFirstFontSettings().language();
-#ifdef WITH_WARNINGS
-#warning We should make this somewhat better, any ideas? (Jug)
-#endif
- if (lang == inherit_language || lang == ignore_language)
- lang = bparams.language;
- return lang;
-#endif
} else if (previous_)
return previous_->getParLanguage(bparams);
else
for (; cit != end; ++cit)
if (cit->font().language() != ignore_language &&
cit->font().language() != latex_language &&
-#ifdef INHERIT_LANGUAGE
- cit->font().language() != inherit_language &&
-#endif
cit->font().language() != doc_language)
return true;
return false;