]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetTOC.cpp
Minor corrections and elaborations
[lyx.git] / src / insets / InsetTOC.cpp
index a3739d74f51a4deb52de231c760e1c0b3cbd8b9e..0308392c0d3abaad4e474602032b4278c30d3447 100644 (file)
@@ -21,7 +21,6 @@
 #include "FuncRequest.h"
 #include "Language.h"
 #include "LaTeXFeatures.h"
-#include "OutputParams.h"
 #include "output_xhtml.h"
 #include "Paragraph.h"
 #include "ParagraphParameters.h"
@@ -29,6 +28,7 @@
 #include "TocBackend.h"
 
 #include "support/debug.h"
+#include "support/docstream.h"
 #include "support/gettext.h"
 #include "support/lassert.h"
 
@@ -128,11 +128,10 @@ int InsetTOC::plaintext(odocstringstream & os,
 }
 
 
-int InsetTOC::docbook(odocstream & os, OutputParams const &) const
+void InsetTOC::docbook(XMLStream &, OutputParams const &) const
 {
-       if (getCmdName() == "tableofcontents")
-               os << "<toc></toc>";
-       return 0;
+       // TOC are generated automatically by the DocBook processor.
+       return;
 }
 
 
@@ -159,18 +158,19 @@ void InsetTOC::makeTOCEntry(XMLStream & xs,
 void InsetTOC::makeTOCWithDepth(XMLStream & xs,
                Toc const & toc, OutputParams const & op) const
 {
-       Toc::const_iterator it = toc.begin();
-       Toc::const_iterator const en = toc.end();
        int lastdepth = 0;
-       for (; it != en; ++it) {
+       for (auto const & tocitem : toc) {
                // do not output entries that are not actually included in the output,
                // e.g., stuff in non-active branches or notes or whatever.
-               if (!it->isOutput())
+               if (!tocitem.isOutput())
+                       continue;
+
+               if (!tocitem.dit().paragraph().layout().htmlintoc())
                        continue;
 
                // First, we need to manage increases and decreases of depth
-               // If there's no depth to deal with, we artifically set it to 1.
-               int const depth = it->depth();
+               // If there's no depth to deal with, we artificially set it to 1.
+               int const depth = tocitem.depth();
 
                // Ignore stuff above the tocdepth
                if (depth > buffer().params().tocdepth)
@@ -206,7 +206,7 @@ void InsetTOC::makeTOCWithDepth(XMLStream & xs,
                }
 
                // Now output TOC info for this entry
-               Paragraph const & par = it->dit().innerParagraph();
+               Paragraph const & par = tocitem.dit().innerParagraph();
                makeTOCEntry(xs, par, op);
        }
        for (int i = lastdepth; i > 0; --i)
@@ -217,17 +217,18 @@ void InsetTOC::makeTOCWithDepth(XMLStream & xs,
 void InsetTOC::makeTOCNoDepth(XMLStream & xs,
                Toc const & toc, const OutputParams & op) const
 {
-       Toc::const_iterator it = toc.begin();
-       Toc::const_iterator const en = toc.end();
-       for (; it != en; ++it) {
+       for (auto const & tocitem : toc) {
                // do not output entries that are not actually included in the output,
                // e.g., stuff in non-active branches or notes or whatever.
-               if (!it->isOutput())
+               if (!tocitem.isOutput())
+                       continue;
+
+               if (!tocitem.dit().paragraph().layout().htmlintoc())
                        continue;
 
                xs << xml::StartTag("div", "class='lyxtoc-flat'") << xml::CR();
 
-               Paragraph const & par = it->dit().innerParagraph();
+               Paragraph const & par = tocitem.dit().innerParagraph();
                makeTOCEntry(xs, par, op);
 
                xs << xml::EndTag("div");