diff options
Diffstat (limited to 'src/definition.cpp')
-rw-r--r-- | src/definition.cpp | 117 |
1 files changed, 69 insertions, 48 deletions
diff --git a/src/definition.cpp b/src/definition.cpp index 92baf0c..cbfad94 100644 --- a/src/definition.cpp +++ b/src/definition.cpp @@ -41,6 +41,7 @@ #include "namespacedef.h" #include "filedef.h" #include "dirdef.h" +#include "pagedef.h" #define START_MARKER 0x4445465B // DEF[ #define END_MARKER 0x4445465D // DEF] @@ -1613,72 +1614,92 @@ void Definition::writeNavigationPath(OutputList &ol) const } // TODO: move to htmlgen -void Definition::writeToc(OutputList &ol) +void Definition::writeToc(OutputList &ol, const LocalToc &localToc) { SectionDict *sectionDict = m_impl->sectionDict; if (sectionDict==0) return; - ol.pushGeneratorState(); - ol.disableAllBut(OutputGenerator::Html); - ol.writeString("<div class=\"toc\">"); - ol.writeString("<h3>"); - ol.writeString(theTranslator->trRTFTableOfContents()); - ol.writeString("</h3>\n"); - ol.writeString("<ul>"); - SDict<SectionInfo>::Iterator li(*sectionDict); - SectionInfo *si; - int level=1,l; - char cs[2]; - cs[1]='\0'; - bool inLi[5]={ FALSE, FALSE, FALSE, FALSE }; - for (li.toFirst();(si=li.current());++li) - { - if (si->type==SectionInfo::Section || - si->type==SectionInfo::Subsection || - si->type==SectionInfo::Subsubsection || - si->type==SectionInfo::Paragraph) + if (localToc.isHtmlEnabled()) + { + int maxLevel = localToc.htmlLevel(); + ol.pushGeneratorState(); + ol.disableAllBut(OutputGenerator::Html); + ol.writeString("<div class=\"toc\">"); + ol.writeString("<h3>"); + ol.writeString(theTranslator->trRTFTableOfContents()); + ol.writeString("</h3>\n"); + ol.writeString("<ul>"); + SDict<SectionInfo>::Iterator li(*sectionDict); + SectionInfo *si; + int level=1,l; + char cs[2]; + cs[1]='\0'; + bool inLi[5]={ FALSE, FALSE, FALSE, FALSE }; + for (li.toFirst();(si=li.current());++li) { - //printf(" level=%d title=%s\n",level,si->title.data()); - int nextLevel = (int)si->type; - if (nextLevel>level) + if (si->type==SectionInfo::Section || + si->type==SectionInfo::Subsection || + si->type==SectionInfo::Subsubsection || + si->type==SectionInfo::Paragraph) { - for (l=level;l<nextLevel;l++) + //printf(" level=%d title=%s\n",level,si->title.data()); + int nextLevel = (int)si->type; + if (nextLevel>level) { - ol.writeString("<ul>"); + for (l=level;l<nextLevel;l++) + { + if (l < maxLevel) ol.writeString("<ul>"); + } } - } - else if (nextLevel<level) - { - for (l=level;l>nextLevel;l--) + else if (nextLevel<level) { - if (inLi[l]) ol.writeString("</li>\n"); - inLi[l]=FALSE; - ol.writeString("</ul>\n"); + for (l=level;l>nextLevel;l--) + { + if (l <= maxLevel && inLi[l]) ol.writeString("</li>\n"); + inLi[l]=FALSE; + if (l <= maxLevel) ol.writeString("</ul>\n"); + } } + cs[0]='0'+nextLevel; + if (nextLevel <= maxLevel && inLi[nextLevel]) ol.writeString("</li>\n"); + QCString titleDoc = convertToHtml(si->title); + if (nextLevel <= maxLevel) ol.writeString("<li class=\"level"+QCString(cs)+"\"><a href=\"#"+si->label+"\">"+(si->title.isEmpty()?si->label:titleDoc)+"</a>"); + inLi[nextLevel]=TRUE; + level = nextLevel; } - cs[0]='0'+nextLevel; - if (inLi[nextLevel]) ol.writeString("</li>\n"); - QCString titleDoc = convertToHtml(si->title); - ol.writeString("<li class=\"level"+QCString(cs)+"\"><a href=\"#"+si->label+"\">"+(si->title.isEmpty()?si->label:titleDoc)+"</a>"); - inLi[nextLevel]=TRUE; - level = nextLevel; } - } - while (level>1) - { - if (inLi[level]) ol.writeString("</li>\n"); + while (level>1 && level <= maxLevel) + { + if (inLi[level]) ol.writeString("</li>\n"); + inLi[level]=FALSE; + ol.writeString("</ul>\n"); + level--; + } + if (level <= maxLevel && inLi[level]) ol.writeString("</li>\n"); inLi[level]=FALSE; ol.writeString("</ul>\n"); - level--; + ol.writeString("</div>\n"); + ol.popGeneratorState(); + } + + if (localToc.isLatexEnabled()) + { + ol.pushGeneratorState(); + ol.disableAllBut(OutputGenerator::Latex); + int maxLevel = localToc.latexLevel(); + + ol.writeString("\\etocsetnexttocdepth{"+QCString().setNum(maxLevel)+"}\n"); + + ol.writeString("\\localtableofcontents\n"); + ol.popGeneratorState(); } - if (inLi[level]) ol.writeString("</li>\n"); - inLi[level]=FALSE; - ol.writeString("</ul>\n"); - ol.writeString("</div>\n"); - ol.popGeneratorState(); } //---------------------------------------------------------------------------------------- +SectionDict * Definition::getSectionDict(void) +{ + return m_impl->sectionDict; +} QCString Definition::symbolName() const { |