]> git.lyx.org Git - lyx.git/blobdiff - src/output_docbook.C
Really fix start_of_appendix output
[lyx.git] / src / output_docbook.C
index 62822e35aad80fc640202f042f7cb025e6121660..f398c8b76fa0bfc02e2ee70bf41b7b83a4b970a0 100644 (file)
 #include "output_docbook.h"
 
 #include "buffer.h"
+#include "buffer_funcs.h"
 #include "bufferparams.h"
 #include "counters.h"
 #include "debug.h"
-#include "lyxtext.h"
 #include "paragraph.h"
 #include "paragraph_funcs.h"
+#include "ParagraphList_fwd.h"
 #include "ParagraphParameters.h"
 #include "sgml.h"
 
@@ -27,7 +28,7 @@
 
 #include "support/lstrings.h"
 #include "support/lyxlib.h"
-#include "support/tostr.h"
+#include "support/convert.h"
 #include "support/types.h"
 
 #ifdef HAVE_LOCALE
@@ -88,7 +89,7 @@ ParagraphList::const_iterator searchEnvironment(ParagraphList::const_iterator co
                if(p->params().depth() < par->params().depth())
                        return p;
 
-               if( style->latexname() != bstyle->latexname() and p->params().depth() == par->params().depth() )
+               if( style->latexname() != bstyle->latexname() && p->params().depth() == par->params().depth() )
                        return p;
        }
        return pend;
@@ -100,18 +101,19 @@ ParagraphList::const_iterator makeParagraph(Buffer const & buf,
                                            OutputParams const & runparams,
                                            ParagraphList const & paragraphs,
                                            ParagraphList::const_iterator const & pbegin,
-                                           ParagraphList::const_iterator const & pend) {
-       ParagraphList::const_iterator par = pbegin;
-       const int depth = 0;
-       for(; par != pend; ++par) {
-               LyXLayout_ptr const & style = par->layout();
-               string id = par->getDocbookId();
-               id = id.empty()? "": " id = \"" + id + "\"";
-
-               sgml::openTag(buf, os, depth, true, style->latexname(), id);
-               par->simpleDocBookOnePar(buf, os, runparams, outerFont(par - paragraphs.begin(), paragraphs));
-               sgml::closeTag(os, depth, true, style->latexname());
-               os << '\n';
+                                           ParagraphList::const_iterator const & pend)
+{
+       LyXLayout_ptr const & defaultstyle = buf.params().getLyXTextClass().defaultLayout();
+       for(ParagraphList::const_iterator par = pbegin; par != pend; ++par) {
+               if (par != pbegin)
+                       os << '\n';
+               if (par->layout() == defaultstyle && par->emptyTag()) {
+                       par->simpleDocBookOnePar(buf, os, runparams, outerFont(par - paragraphs.begin(), paragraphs));
+               } else {
+                       sgml::openTag(buf, os, runparams, *par);
+                       par->simpleDocBookOnePar(buf, os, runparams, outerFont(par - paragraphs.begin(), paragraphs));
+                       sgml::closeTag(os, *par);
+               }
        }
        return pend;
 }
@@ -126,43 +128,39 @@ ParagraphList::const_iterator makeEnvironment(Buffer const & buf,
        ParagraphList::const_iterator par = pbegin;
 
        LyXLayout_ptr const & defaultstyle = buf.params().getLyXTextClass().defaultLayout();
-       const int depth = 0;
-
        LyXLayout_ptr const & bstyle = par->layout();
        string item_tag;
-       
-       string id = par->getDocbookId();
-       string env_name = bstyle->latexname();
+
        // Opening outter tag
-       sgml::openTag(buf, os, depth, false, env_name, bstyle->latexparam() + id);
+       sgml::openTag(buf, os, runparams, *pbegin);
        os << '\n';
-       if (bstyle->latextype == LATEX_ENVIRONMENT and bstyle->innertag() == "CDATA")
+       if (bstyle->latextype == LATEX_ENVIRONMENT && bstyle->pass_thru)
                os << "<![CDATA[";
 
        while (par != pend) {
                LyXLayout_ptr const & style = par->layout();
-               string id = "";
                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() and bstyle->innertag() != "CDATA") {
-                               sgml::openTag(buf, os, depth, true, bstyle->innertag());
+                       if (!bstyle->innertag().empty()) {
+                               sgml::openTag(os, bstyle->innertag(), id);
                        }
                        break;
 
                case LATEX_ITEM_ENVIRONMENT:
                        if (!bstyle->labeltag().empty()) {
-                               sgml::openTag(buf, os, depth, true, bstyle->innertag());
-                               sgml::openTag(buf, os, depth, true, bstyle->labeltag());
+                               sgml::openTag(os, bstyle->innertag(), id);
+                               sgml::openTag(os, bstyle->labeltag());
                                sep = par->getFirstWord(buf, os, runparams) + 1;
-                               sgml::closeTag(os, depth, true, bstyle->labeltag());
+                               sgml::closeTag(os, bstyle->labeltag());
                        }
                        wrapper = defaultstyle->latexname();
-                       sgml::openTag(buf, os, depth, true, bstyle->itemtag());
+                       sgml::openTag(os, bstyle->itemtag());
                default:
                        break;
                }
@@ -171,9 +169,9 @@ ParagraphList::const_iterator makeEnvironment(Buffer const & buf,
                case LATEX_ENVIRONMENT:
                case LATEX_ITEM_ENVIRONMENT: {
                        if(par->params().depth() == pbegin->params().depth()) {
-                               sgml::openTag(buf, os, depth, true, wrapper, id);
+                               sgml::openTag(os, wrapper);
                                par->simpleDocBookOnePar(buf, os, runparams, outerFont(par - paragraphs.begin(), paragraphs), sep);
-                               sgml::closeTag(os, depth, true, wrapper);
+                               sgml::closeTag(os, wrapper);
                                ++par;
                        }
                        else {
@@ -193,26 +191,26 @@ ParagraphList::const_iterator makeEnvironment(Buffer const & buf,
                // Closing inner tag
                switch (bstyle->latextype) {
                case LATEX_ENVIRONMENT:
-                       if (!bstyle->innertag().empty() and bstyle->innertag() != "CDATA") {
-                               sgml::closeTag(os, depth, true, bstyle->innertag());
+                       if (!bstyle->innertag().empty()) {
+                               sgml::closeTag(os, bstyle->innertag());
                                os << '\n';
                        }
                        break;
                case LATEX_ITEM_ENVIRONMENT:
-                       sgml::closeTag(os, depth, true, bstyle->itemtag());
+                       sgml::closeTag(os, bstyle->itemtag());
                        if (!bstyle->labeltag().empty())
-                               sgml::closeTag(os, depth, true, bstyle->innertag());
+                               sgml::closeTag(os, bstyle->innertag());
                        break;
                default:
                        break;
                }
        }
 
-       if (bstyle->latextype == LATEX_ENVIRONMENT and bstyle->innertag() == "CDATA")
+       if (bstyle->latextype == LATEX_ENVIRONMENT && bstyle->pass_thru)
                os << "]]>";
 
        // Closing outter tag
-       sgml::closeTag(os, depth, false, env_name);
+       sgml::closeTag(os, *pbegin);
 
        return pend;
 }
@@ -225,48 +223,26 @@ ParagraphList::const_iterator makeCommand(Buffer const & buf,
                                          ParagraphList::const_iterator const & pbegin,
                                          ParagraphList::const_iterator const & pend)
 {
-       Paragraph::depth_type depth = 0; // paragraph depth
-
        ParagraphList::const_iterator par = pbegin;
-       Counters & counters = buf.params().getLyXTextClass().counters();
        LyXLayout_ptr const & bstyle = par->layout();
-       
-       string id = par->getDocbookId();
-       id = id.empty()? "" : " id = \"" + id + "\"";
-
-       if (bstyle->latexparam().find('#') != string::npos) {
-               counters.step(bstyle->counter);
-       }
-       
-       if (!bstyle->latexparam().empty()) {
-               id = bstyle->latexparam();
-               if (id.find('#') != string::npos) {
-                       string el = expandLabel(buf.params().getLyXTextClass(),
-                                               bstyle, false);
-                       id = subst(id, "#", el);
-               }
-       }
 
        //Open outter tag
-       sgml::openTag(buf, os, depth, false, bstyle->latexname(), id);
+       sgml::openTag(buf, os, runparams, *pbegin);
        os << '\n';
 
        // Label around sectioning number:
        if (!bstyle->labeltag().empty()) {
-               sgml::openTag(buf, os, depth, false, bstyle->labeltag());
+               sgml::openTag(os, bstyle->labeltag());
                os << expandLabel(buf.params().getLyXTextClass(), bstyle, false);
-               sgml::closeTag(os, depth, false, bstyle->labeltag());
+               sgml::closeTag(os, bstyle->labeltag());
        }
-       
-       // Opend inner tag
-       sgml::openTag(buf, os, depth, true, bstyle->innertag());
 
+       // Opend inner tag and  close inner tags
+       sgml::openTag(os, bstyle->innertag());
        par->simpleDocBookOnePar(buf, os, runparams,  outerFont(par - paragraphs.begin(), paragraphs));
-
-       // Close inner tags
-       sgml::closeTag(os, depth, true, bstyle->innertag());
+       sgml::closeTag(os, bstyle->innertag());
        os << '\n';
-       
+
        ++par;
        while (par != pend) {
                LyXLayout_ptr const & style = par->layout();
@@ -292,9 +268,8 @@ ParagraphList::const_iterator makeCommand(Buffer const & buf,
                        break;
                }
        }
-
        // Close outter tag
-       sgml::closeTag(os, depth, false, bstyle->latexname());
+       sgml::closeTag(os, *pbegin);
 
        return pend;
 }