예제 #1
0
int InsetText::docbook(odocstream & os, OutputParams const & runparams) const
{
	ParagraphList::const_iterator const beg = paragraphs().begin();

	if (!undefined())
		sgml::openTag(os, getLayout().latexname(),
			      beg->getID(buffer(), runparams) + getLayout().latexparam());

	docbookParagraphs(text_, buffer(), os, runparams);

	if (!undefined())
		sgml::closeTag(os, getLayout().latexname());

	return 0;
}
예제 #2
0
ParagraphList::const_iterator makeEnvironment(
    Buffer const & buf,
    odocstream & os,
    OutputParams const & runparams,
    Text const & text,
    ParagraphList::const_iterator const & pbegin,
    ParagraphList::const_iterator const & pend)
{
    ParagraphList const & paragraphs = text.paragraphs();
    ParagraphList::const_iterator par = pbegin;

    Layout const & defaultstyle = buf.params().documentClass().defaultLayout();
    Layout const & bstyle = par->layout();
    string item_tag;

    // Opening outter tag
    sgml::openTag(buf, os, runparams, *pbegin);
    os << '\n';
    if (bstyle.latextype == LATEX_ENVIRONMENT && bstyle.pass_thru)
        os << "<![CDATA[";

    while (par != pend) {
        Layout const & style = par->layout();
        ParagraphList::const_iterator send;
        string id = par->getID(buf, runparams);
        string wrapper = "";
        pos_type sep = 0;

        // Opening inner tag
        switch (bstyle.latextype) {
        case LATEX_ENVIRONMENT:
            if (!bstyle.innertag().empty()) {
                sgml::openTag(os, bstyle.innertag(), id);
            }
            break;

        case LATEX_ITEM_ENVIRONMENT:
            if (!bstyle.labeltag().empty()) {
                sgml::openTag(os, bstyle.innertag(), id);
                sgml::openTag(os, bstyle.labeltag());
                sep = par->firstWordDocBook(os, runparams) + 1;
                sgml::closeTag(os, bstyle.labeltag());
            }
            wrapper = defaultstyle.latexname();
            // If a sub list (embedded list) appears next with a
            // different depth, then there is no need to open
            // another tag at the current depth.
            if(par->params().depth() == pbegin->params().depth()) {
                sgml::openTag(os, bstyle.itemtag());
            }
            break;
        default:
            break;
        }

        switch (style.latextype) {
        case LATEX_ENVIRONMENT:
        case LATEX_ITEM_ENVIRONMENT: {
            if (par->params().depth() == pbegin->params().depth()) {
                sgml::openTag(os, wrapper);
                par->simpleDocBookOnePar(buf, os, runparams,
                                         text.outerFont(distance(paragraphs.begin(), par)), sep);
                sgml::closeTag(os, wrapper);
                ++par;
            }
            else {
                send = searchEnvironment(par, pend);
                par = makeEnvironment(buf, os, runparams, text, par,send);
            }
            break;
        }
        case LATEX_PARAGRAPH:
            send = searchParagraph(par, pend);
            par = makeParagraph(buf, os, runparams, text, par,send);
            break;
        case LATEX_LIST_ENVIRONMENT:
        case LATEX_BIB_ENVIRONMENT:
        case LATEX_COMMAND:
            // FIXME This means that we are just skipping any paragraph that
            // isn't implemented above, and this includes lists.
            ++par;
            break;
        }

        // Closing inner tag
        switch (bstyle.latextype) {
        case LATEX_ENVIRONMENT:
            if (!bstyle.innertag().empty()) {
                sgml::closeTag(os, bstyle.innertag());
                os << '\n';
            }
            break;
        case LATEX_ITEM_ENVIRONMENT:
            // If a sub list (embedded list) appears next, then
            // there is no need to close the current tag.
            // par should have already been incremented to the next
            // element. So we can compare the depth of the next
            // element with pbegin.
            // We need to be careful, that we don't dereference par
            // when par == pend but at the same time that the
            // current tag is closed.
            if((par != pend && par->params().depth() == pbegin->params().depth()) || par == pend) {
                sgml::closeTag(os, bstyle.itemtag());
            }
            if (!bstyle.labeltag().empty())
                sgml::closeTag(os, bstyle.innertag());
            break;
        default:
            break;
        }
    }

    if (bstyle.latextype == LATEX_ENVIRONMENT && bstyle.pass_thru)
        os << "]]>";

    // Closing outter tag
    sgml::closeTag(os, *pbegin);

    return pend;
}