]> git.lyx.org Git - lyx.git/blobdiff - src/output_docbook.C
Change to use preffered calling of Boost.Function
[lyx.git] / src / output_docbook.C
index 69340132f006074af7c0836a4456281e18e3733a..de47d99b0f6d32ad4d133cccaabac94ab59b24ba 100644 (file)
@@ -64,18 +64,18 @@ void docbookParagraphs(Buffer const & buf,
 
        string item_tag;
 
-       ParagraphList::iterator par = const_cast<ParagraphList&>(paragraphs).begin();
-       ParagraphList::iterator pend = const_cast<ParagraphList&>(paragraphs).end();
+       ParagraphList::const_iterator par = paragraphs.begin();
+       ParagraphList::const_iterator pend = paragraphs.end();
+
+       Counters & counters = buf.params().getLyXTextClass().counters();
 
-    Counters & counters = buf.params().getLyXTextClass().counters();
-       
        for (; par != pend; ++par) {
 
                LyXLayout_ptr const & style = par->layout();
 
                // environment tag closing
                for (; depth > par->params().depth(); --depth) {
-                       sgml::closeEnvTags(os, false, environment_inner[depth], 
+                       sgml::closeEnvTags(os, false, environment_inner[depth],
                                item_tag, command_depth + depth);
                        sgml::closeTag(os, depth + command_depth, false, environment_stack[depth]);
                        environment_stack[depth].erase();
@@ -85,16 +85,18 @@ void docbookParagraphs(Buffer const & buf,
                if (depth == par->params().depth()
                   && environment_stack[depth] != style->latexname()
                   && !environment_stack[depth].empty()) {
-                               sgml::closeEnvTags(os, false, environment_inner[depth], 
+                               sgml::closeEnvTags(os, false, environment_inner[depth],
                                        item_tag, command_depth + depth);
                        sgml::closeTag(os, depth + command_depth, false, environment_stack[depth]);
 
                        environment_stack[depth].erase();
                        environment_inner[depth].erase();
                }
-               
-               string ls = "";
-               bool labelid = false;
+
+               string ls = par->getDocbookId();
+               if (!ls.empty())
+                       ls = " id = \"" + ls + "\"";
+
                // Write opening SGML tags.
                switch (style->latextype) {
                case LATEX_PARAGRAPH:
@@ -103,6 +105,7 @@ void docbookParagraphs(Buffer const & buf,
                                int i = counters.value("para");
                                ls = subst(style->latexparam(), "#", tostr(i));
                        }
+
                        sgml::openTag(os, depth + command_depth,
                                    false, style->latexname(), ls);
                        break;
@@ -111,11 +114,11 @@ void docbookParagraphs(Buffer const & buf,
                        if (depth != 0)
                                //error(ErrorItem(_("Error"), _("Wrong depth for LatexType Command."), par->id(), 0, par->size()));
                                ;
-                       
+
                        command_name = style->latexname();
 
                        cmd_depth = style->commanddepth;
-                       
+
                        if (command_flag) {
                                if (cmd_depth < command_base) {
                                        for (Paragraph::depth_type j = command_depth;
@@ -144,41 +147,29 @@ void docbookParagraphs(Buffer const & buf,
                        if (style->latexparam().find('#') != string::npos) {
                                counters.step(style->counter);
                        }
-                       // treat label as a special case for
-                       // more WYSIWYM handling.
-                       // This is a hack while paragraphs can't have
-                       // attributes, like id in this case.
-                       if (par->size() && par->isInset(0)) {
-                               InsetBase * inset = par->getInset(0);
-                               if (inset->lyxCode() == InsetOld::LABEL_CODE) {
-                                       command_name += " id=\"";
-                                       command_name += (static_cast<InsetCommand *>(inset))->getContents();
-                                       command_name += '"';
-                                       labelid = true;
-                               }
-                       }
-                       if (!labelid && !style->latexparam().empty()) {
+
+                       if (!style->latexparam().empty()) {
                                ls = style->latexparam();
                                if (ls.find('#') != string::npos) {
-                                       string el = expandLabel(buf.params().getLyXTextClass(), 
+                                       string el = expandLabel(buf.params().getLyXTextClass(),
                                                style, false);
                                        ls = subst(ls, "#", el);
-                               } 
+                               }
                        }
-                       
+
                        sgml::openTag(os, depth + command_depth, false, command_name, ls);
 
                        // Label around sectioning number:
                        if (!style->labeltag().empty()) {
-                               sgml::openTag(os, depth + 1 + command_depth, false, 
+                               sgml::openTag(os, depth + 1 + command_depth, false,
                                        style->labeltag());
                                os << expandLabel(buf.params().getLyXTextClass(), style, false);
-                               sgml::closeTag(os, depth + 1 + command_depth, false, 
+                               sgml::closeTag(os, depth + 1 + command_depth, false,
                                        style->labeltag());
                        }
 
                        // Inner tagged header text, e.g. <title> for sectioning:
-                       sgml::openTag(os, depth + 1 + command_depth, false, 
+                       sgml::openTag(os, depth + 1 + command_depth, false,
                                style->innertag());
                        break;
 
@@ -197,10 +188,10 @@ void docbookParagraphs(Buffer const & buf,
                                environment_stack[depth] = style->latexname();
                                environment_inner[depth] = "!-- --";
                                // outputs <environment_stack[depth] latexparam()>
-                               sgml::openTag(os, depth + command_depth, false, 
-                                               environment_stack[depth], style->latexparam());
+                               sgml::openTag(os, depth + command_depth, false,
+                                               environment_stack[depth], style->latexparam() + ls);
                        } else {
-                               sgml::closeEnvTags(os, false, environment_inner[depth], 
+                               sgml::closeEnvTags(os, false, environment_inner[depth],
                                        style->itemtag(), command_depth + depth);
                        }
 
@@ -209,7 +200,7 @@ void docbookParagraphs(Buffer const & buf,
                                        if (style->innertag() == "CDATA")
                                                os << "<![CDATA[";
                                        else
-                                               sgml::openTag(os, depth + command_depth, false, 
+                                               sgml::openTag(os, depth + command_depth, false,
                                                        style->innertag());
                                }
                                break;
@@ -223,18 +214,18 @@ void docbookParagraphs(Buffer const & buf,
                        break;
                default:
                        sgml::openTag(os, depth + command_depth,
-                                   false, style->latexname());
+                                   false, style->latexname(), ls);
                        break;
                }
 
                par->simpleDocBookOnePar(buf, os,
-                       outerFont(par - const_cast<ParagraphList&>(paragraphs).begin(), paragraphs),
-                       runparams, depth + 1 + command_depth, labelid);
+                       outerFont(par - paragraphs.begin(), paragraphs),
+                       runparams, depth + 1 + command_depth);
 
                // write closing SGML tags
                switch (style->latextype) {
                case LATEX_COMMAND:
-                       sgml::closeTag(os, depth + command_depth, false, 
+                       sgml::closeTag(os, depth + command_depth, false,
                                style->innertag());
                        break;
                case LATEX_ENVIRONMENT:
@@ -242,7 +233,7 @@ void docbookParagraphs(Buffer const & buf,
                                if (style->innertag() == "CDATA")
                                        os << "]]>";
                                else
-                                       sgml::closeTag(os, depth + command_depth, false, 
+                                       sgml::closeTag(os, depth + command_depth, false,
                                                style->innertag());
                        }
                        break;
@@ -261,7 +252,7 @@ void docbookParagraphs(Buffer const & buf,
        // Close open tags
        for (int d = depth; d >= 0; --d) {
                if (!environment_stack[depth].empty()) {
-                               sgml::closeEnvTags(os, false, environment_inner[depth], 
+                               sgml::closeEnvTags(os, false, environment_inner[depth],
                                        item_tag, command_depth + depth);
                }
        }
@@ -272,4 +263,3 @@ void docbookParagraphs(Buffer const & buf,
                        os << endl;
                }
 }
-