- 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
-{
- // 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 (!getLayout().latexname().empty()) {
- if (getLayout().latextype() == InsetLayout::COMMAND) {
- // FIXME UNICODE
- if (runparams.moving_arg)
- os << "\\protect";
- os << '\\' << from_utf8(getLayout().latexname());
- if (!getLayout().latexparam().empty())
- os << from_utf8(getLayout().latexparam());
- os << '{';
- } else if (getLayout().latextype() == InsetLayout::ENVIRONMENT) {
- os << "%\n\\begin{" << from_utf8(getLayout().latexname()) << "}\n";
- if (!getLayout().latexparam().empty())
- os << from_utf8(getLayout().latexparam());
- }
- }
- OutputParams rp = runparams;
- if (getLayout().isPassThru())
- rp.verbatim = true;
- if (getLayout().isNeedProtect())
- rp.moving_arg = true;
- int i = InsetText::latex(os, rp);
- if (!getLayout().latexname().empty()) {
- if (getLayout().latextype() == InsetLayout::COMMAND) {
- os << "}";
- } else if (getLayout().latextype() == InsetLayout::ENVIRONMENT) {
- os << "\n\\end{" << from_utf8(getLayout().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;
-}
-
-
-docstring InsetCollapsable::xhtml(odocstream & os, OutputParams const & runparams) const
-{
- InsetLayout const & il = getLayout();
- if (undefined())
- return InsetText::xhtml(os, runparams);
-
- bool const opened = html::openTag(os, il.htmltag(), il.htmlattr());
- if (!il.counter().empty()) {
- BufferParams const & bp = buffer().masterBuffer()->params();
- Counters & cntrs = bp.documentClass().counters();
- cntrs.step(il.counter());
- // FIXME: translate to paragraph language
- if (!il.htmllabel().empty())
- os << cntrs.counterLabel(from_utf8(il.htmllabel()), bp.language->code());
- }
- bool innertag_opened = false;
- if (!il.htmlinnertag().empty())
- innertag_opened = html::openTag(os, il.htmlinnertag(), il.htmlinnerattr());
- docstring deferred = InsetText::xhtml(os, runparams);
- if (innertag_opened)
- html::closeTag(os, il.htmlinnertag());
- if (opened)
- html::closeTag(os, il.htmltag());
- return deferred;
-}
-
-
-void InsetCollapsable::validate(LaTeXFeatures & features) const
-{
- features.useInsetLayout(getLayout());
- InsetText::validate(features);