- if (!layout_)
- return InsetLayout::CLASSIC;
- InsetLayout::InsetDecoration const dec = layout_->decoration();
- switch (dec) {
- case InsetLayout::CLASSIC:
- case InsetLayout::MINIMALISTIC:
- case InsetLayout::CONGLOMERATE:
- return dec;
- case InsetLayout::DEFAULT:
- break;
- }
- if (lyxCode() == FLEX_CODE)
- return InsetLayout::CONGLOMERATE;
- return InsetLayout::CLASSIC;
-}
-
-
-int InsetCollapsable::latex(odocstream & os,
- OutputParams const & runparams) const
-{
- // FIXME: What should we do layout_ is 0?
- // 1) assert
- // 2) throw an error
- if (!layout_)
- return 0;
-
- // This implements the standard way of handling the LaTeX output of
- // a collapsable inset, either a command or an environment. Standard
- // collapsable insets should not redefine this, non-standard ones may
- // call this.
- if (!layout_->latexname().empty()) {
- if (layout_->latextype() == InsetLayout::COMMAND) {
- // FIXME UNICODE
- if (runparams.moving_arg)
- os << "\\protect";
- os << '\\' << from_utf8(layout_->latexname());
- if (!layout_->latexparam().empty())
- os << from_utf8(layout_->latexparam());
- os << '{';
- } else if (layout_->latextype() == InsetLayout::ENVIRONMENT) {
- os << "%\n\\begin{" << from_utf8(layout_->latexname()) << "}\n";
- if (!layout_->latexparam().empty())
- os << from_utf8(layout_->latexparam());
- }
- }
- OutputParams rp = runparams;
- if (layout_->isPassThru())
- rp.verbatim = true;
- if (layout_->isNeedProtect())
- rp.moving_arg = true;
- int i = InsetText::latex(os, rp);
- if (!layout_->latexname().empty()) {
- if (layout_->latextype() == InsetLayout::COMMAND) {
- os << "}";
- } else if (layout_->latextype() == InsetLayout::ENVIRONMENT) {
- os << "\n\\end{" << from_utf8(layout_->latexname()) << "}\n";
- i += 4;
- }
- }
- return i;
-}
-
-
-// FIXME It seems as if it ought to be possible to do this more simply,
-// maybe by calling InsetText::docbook() in the middle there.
-int InsetCollapsable::docbook(odocstream & os, OutputParams const & runparams) const
-{
- ParagraphList::const_iterator const beg = paragraphs().begin();
- ParagraphList::const_iterator par = paragraphs().begin();
- ParagraphList::const_iterator const end = paragraphs().end();
-
- if (!undefined())
- sgml::openTag(os, getLayout().latexname(),
- par->getID(buffer(), runparams) + getLayout().latexparam());
-
- for (; par != end; ++par) {
- par->simpleDocBookOnePar(buffer(), os, runparams,
- outerFont(distance(beg, par),
- paragraphs()));
- }
-
- if (!undefined())
- sgml::closeTag(os, getLayout().latexname());
-
- return 0;
-}
-
-
-void InsetCollapsable::validate(LaTeXFeatures & features) const
-{
- string const preamble = getLayout().preamble();
- if (!preamble.empty())
- features.addPreambleSnippet(preamble);
- features.require(getLayout().requires());
- InsetText::validate(features);